Announcement

Collapse
No announcement yet.

Announcement

Collapse
No announcement yet.

AmlImagePacker - Create a IMG file from the level1 folder without the Customization Tool

Collapse
This is a sticky topic.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    AmlImagePacker - Create a IMG file from the level1 folder without the Customization Tool

    For a project I needed to be able to script something to edit files of the system partition of a ROM and pack a burnable IMG file. As the Amlogic Customization Tool doesn't have any CLI, I couldn't use it in my script.

    I looked at how the CT worked to pack the level1 files into an IMG, and I saw that, after creating the PARTITION files, all it did was call some functions in the AmlImagePack DLL file. So I reproduced this behaviour in a tiny tool called AmlImagePacker. It's the exact opposite of this tool.

    You can see the source code and download it here : https://github.com/natinusala/AmlImagePacker

    It's very simple to use : put it in the Customization Tool folder, with the ROM and the DLL, and run it. It will automagically pack your level1 files in a burnable IMG file.

    It doesn't update the level1 PARTITION files from the changes made in level2 BUT :

    You can combine this tool with Aml_make_ext4fs.exe and create a script which updates the system partition from the files in the level2 folder and create a burnable IMG (it's very quick). With this, you just have to edit the files of the system folder and run your script without ever opening the CT to have a burnable image. Read the README file of the repository to see how.

    #2
    Good work m8, keep it going

    Comment


      #3
      Nice! With Amlogic getting stricter with sharing updates to the Customization Tool, I have a hunch we're going to be needing to do more heavy lifting on our end. Thanks for getting the ball rolling!

      Comment


        #4
        The ultimate goal would be to have a 100% open source Customization Tool clone, with a CLI and without the need of any Amlogic code/DLL (and the ability to load a previously unpacked ROM without unpacking it again). It would not be very hard to do, since we already know the format of most files and data, but it would certainly take a long time to have something as powerful as the current CT.

        Comment


          #5
          Well everything needs to start somewhere

          Comment


            #6
            Nice work keep it up....
            Many devices now mk902ii/Shield/Mk68 /Ugoos/neox5/minix5 (yes they still work lol) mk80 no it doesnt work lol.

            Comment


              #7
              What you have is already very useful for build automation. Any chance there's a Linux version coming?

              Comment


                #8
                For that I would need to manually pack the image instead of using the DLL. I guess I could reverse the unpacking procedure but it will not be enough, I will need to do some extra research and reverse engineering.

                ​​​​​In the meantime you could try to use Wine, I don't see why it wouldn't work (the only requirement is to have a system which uses the ECX register for __thiscall).

                Comment


                  #9
                  Originally posted by Magendanz View Post
                  What you have is already very useful for build automation. Any chance there's a Linux version coming?
                  For linux you could grab Khadas Vim SDK.
                  There are all tools needed to pack the rom.


                  How to use example:
                  Code:
                  /home/lewy/Desktop/Nugat_Amlogic/Pack_Img/aml_image_v2_packer -r /home/lewy/Desktop/Nugat_Amlogic/Pack_Img/upgrade/aml_upgrade_package.conf /home/lewy/Desktop/Nugat_Amlogic/Pack_Img/upgrade/ /home/lewy/Desktop/Nugat_Amlogic/Pack_Img/Your_Rom_Name.img
                  All needed files like boot.img, dtb.img, etc. need to be in upgrade folder.
                  Also the system.img needs to be in sprase format.
                  you could do it with:
                  Code:
                  img2simg system.img system_sprase.img
                  Get img2simg with apt-get.

                  Tool:
                  Diese Website steht zum Verkauf! freak-tab.de ist die beste Quelle für alle Informationen die Sie suchen. Von allgemeinen Themen bis hin zu speziellen Sachverhalten, finden Sie auf freak-tab.de alles. Wir hoffen, dass Sie hier das Gesuchte finden!


                  Cnfig File:
                  Diese Website steht zum Verkauf! freak-tab.de ist die beste Quelle für alle Informationen die Sie suchen. Von allgemeinen Themen bis hin zu speziellen Sachverhalten, finden Sie auf freak-tab.de alles. Wir hoffen, dass Sie hier das Gesuchte finden!





                  Hope that helps someone
                  Everything is possible if we work together!
                  ApkFreak

                  Comment


                  • Guest's Avatar
                    Guest commented
                    Editing a comment
                    Nice! I hadn't known about the aml_image_v2_packer tool.

                  #10
                  Yes they did update it in nougat, i have in my build box where i compile the khadas stuff.
                  i totally forgot about it...!

                  Comment


                    #11
                    I didn't know about that ! This is exactly what the function in the DLL does (config file, level1 folder and output image), I bet the code behind is exactly the same. Well that kinda makes my tool useless, unless you are stuck on Windows for some reason

                    Comment


                      #12
                      Not useless at all as there are those that would prefer to use Windows to do as much as is possible in that environment.
                      R-TV BOX S10, Beebox N3150, Chuwi Hibox, Nvidia Shield, A95X Max

                      Comment


                        #13
                        The DLL has a lot of methods, could there be another usage of it ? (I removed overloads, the class constructors/destructors and image open/close methods)


                        Code:
                        CAmlImagePack::AmlImg_check(char const *)                                                        
                        CAmlImagePack::AmlImg_get_backup_itemId(void *,int *)                                    
                        CAmlImagePack::AmlImg_get_errmsg(void)                                                      
                        CAmlImagePack::AmlImg_get_item_count(void *,char const *)                                
                        CAmlImagePack::AmlImg_get_item_size(void *)                                               
                        CAmlImagePack::AmlImg_get_item_type(void *)                                              
                        CAmlImagePack::AmlImg_get_next_item(void *,uint,char *,char *)                            
                        CAmlImagePack::AmlImg_get_size(void *)                                                      
                        CAmlImagePack::AmlImg_is_backup_item(void *)                                            
                        CAmlImagePack::AmlImg_is_verify_item(void *)                                             
                        CAmlImagePack::AmlImg_item_seek(void *,void *,__int64,uint)                               
                        CAmlImagePack::AmlImg_open_item(void *,char const *,char const *)                           
                        CAmlImagePack::AmlImg_pack(char const *,char const *,char const *,int)                        
                        CAmlImagePack::AmlImg_pack_create_mapItem(char const *,char const *,char const *,int,int) 
                        CAmlImagePack::AmlImg_read_item_data(void *,void *,void *,uint)                           
                        CAmlImagePack::AmlImg_unpack(char const *,char const *)                                   
                        CAmlImagePack::AmlImg_unpack_addSecure(char const *,char const *,int)                     
                        CAmlImagePack::AmlImg_unpack_filetype(char const *,char const *,char const *)                   
                        CAmlImagePack::AmlImg_unpack_maintype(char const *,char const *,char const *)             
                        CAmlImagePack::calc_img_crc(_iobuf *,long)                                                
                        CAmlImagePack::crc32(uint,uchar *,uint)                                                   
                        CAmlImagePack::init_crc_table(void)

                        Comment


                          #14
                          Any idea what i'm missing

                          1) Unpack Stock image with customisation tool, make changes to system (That i know work because of script install prior to this)
                          2) from root of customisation tool, in cmd -> Aml_make_ext4fs.exe -l 2048m -s -a system ./tmp/level1/system.PARTITION ./tmp/level2/system/
                          3) run Amlimagepacker.exe from root of customisation tool as admin
                          4) result is burn image that looks ok but wont boot.. just hangs on splash screen ?

                          Comment


                            #15
                            Repack your ROM by using the Customization Tool and check the logs for the Aml_make_ext4fs command, the -l argument may differ depending on your target Android device.

                            Can the Customization Tool depack the ROM created by my tool ? Does it look valid to you ?

                            Comment

                            Working...
                            X