Announcement

Collapse
No announcement yet.

Announcement

Collapse
No announcement yet.

aml_upgrade_package.img extract

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    aml_upgrade_package.img extract

    Thought this might be useful for someone, I whipped it up tonight so I don't have to use Windows to extract the files anymore.

    Code:
    #include <errno.h>
    #include <inttypes.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <arpa/inet.h>
    
    uint32_t convert(uint8_t *test, uint64_t loc) {
      return ntohl((test[loc] << 24) | (test[loc+1] << 16) | (test[loc+2] << 8) | test[loc+3]);
    }
    
    void main(void) {
      FILE *fileptr;
      uint8_t *buffer;
      long filelen;
    
      FILE *f;
      char *filename;
      uint64_t record;
      uint64_t record_loc;
      uint64_t file_loc;
      uint64_t file_size;
    
      fileptr = fopen("aml_upgrade_package.img", "rb");
      fseek(fileptr, 0, SEEK_END);
      filelen = ftell(fileptr);
      rewind(fileptr);
    
      buffer = (uint8_t *)malloc((filelen+1)*sizeof(uint8_t));
      fread(buffer, filelen, 1, fileptr);
      fclose(fileptr);
    
      for (record = 0; record < (uint8_t)buffer[0x18]; record = record + 1){
        record_loc = 0x40 + (record * 0x240);
    
        filename = (malloc(32));
        sprintf(filename,"%s.%s",(char *)&buffer[record_loc+0x120], (char *)&buffer[record_loc+0x20]);
    
        file_loc = convert(buffer,record_loc+0x10);
        file_size = convert(buffer,record_loc+0x18);
    
        f = fopen(filename, "wb");
        if (f == NULL) {
         printf("ERROR: could not open output\n");
         printf("the error was: %s\n",strerror(errno));
         free(filename);
         continue;
        }
        fwrite(&(buffer[file_loc]), sizeof(uint8_t), (size_t)file_size, f);
        fclose(f);
        free(filename);
      }
      free(buffer);
    }

    #2
    Building a new image is a bit more complicated so I'm going to wait until after I port CM13 before bothering with it.

    Comment


      #3
      Nice script calc



      Here you all can find a full documentation on how to use/compile this c script with linux.

      And I think this script should moved by one of the mods to the sub forum Knowledge & Tutorials.
      Because here it fades completely next to the seal attraction (ROM).

      Notice: Moved topic at your request. Left one week redirect. -RISCy Dude
      Last edited by RISCy Dude; 03-26-2017, 04:36. Reason: "Moved topic" notice.
      My contributions to the community
      [ ROMs ] Z4 RK3368 - android TV (ATV) | MXQ PRO 4K - p201 - android TV (ATV) | Yundo Y1 S912 - android TV (ATV) not yet released
      [ Tutorials ] Bootup logo Amlogic S912 devices | Redefine any Keyboard, Gamepad, Remote Control

      Comment


        #4
        Originally posted by calc View Post
        Thought this might be useful for someone, I whipped it up tonight so I don't have to use Windows to extract the files anymore.
        Nice tool!!

        What is the license of this code? GPL? BSD? or other?

        I ask this because I would like to add it as a package for openSUSE (or inside an existing package). With your nickname/name and link to this page of course! Or a link to a git tree if you have one.

        Comment


          #5
          calc//-Greetings. I have downloaded a R.-TV BOX img.on a formatted USB drive 4GB capacity. My box is H 96 PRO+ S 912 amlogic 8core-- 3Gb DDR 4 + 32GB storage.Will you please explain the procedure of how to install this image 7.1.2 onto my box..

          Comment

          Working...
          X