Announcement

Collapse
No announcement yet.

Announcement

Collapse
No announcement yet.

[TUTORIAL] Modifying the boot image

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

    [TUTORIAL] Modifying the boot image

    Here's a short tutorial on how to modify the boot image of an X7 in order to e.g. edit the Mali GPU related speed parameters. The process relies heavily on Finless Bob's prior work (http://freaktab.com/forum/developmen...8998#post28998).

    The following external tools are needed:The process is as follows. Note: I have simplified the commands by omitting long path names etc. Use your own judgement on how to apply in your own environment.


    Unpack the ROM image
    Code:
    $ imgrepackerrk wasser-3.0.6-minix-x7-rk3188.img

    Strip the 8 byte header from the extracted boot image
    Code:
    $ dd if=boot.img.krnl of=bootimg.cpio.gz skip=8 bs=1 count=20000000
    The result is a gzipped cpio archive file.


    Extract the cpio archive to a directory
    Code:
    $ mkdir newboot
    $ cd newboot
    $ gzip -dc ../bootimg.cpio.gz | cpio -iduvm
    Gzip will complain about trailing garbage. That's the footer, which can be ignored.


    Edit the files as needed.

    Note: I'm using the Mali patch as an example. Pay attention to the path to the module. It may vary between Android versions.

    Open file 'init.rk30board.rc' with a text editor, find the line containing the entry for the 'mali.ko' kernel module and edit it to look as follows:
    Code:
    insmod /system/lib/modules/mali.ko mali_dvfs=133,200,266,300,400,600,798 mali_init_clock=133

    Recreate the raw boot image file

    Boot images can not contain touched/modified files, so the dates of the edited files need to be reset. In the new Lollipop ROM there's a symbolic link inside the boot image which will trigger an error but it shouldn't cause any problems.
    Code:
    $ find . -exec touch -d "1970-01-01 01:00" {} \;
    Then just repack the files to a new gzipped cpio archive.
    Code:
    $ find . ! -name "." | sort | cpio -oa -H newc | gzip -n > ../newboot.cpio.gz
    $ cd ..

    Add CRC to the file to create the final image file

    Note: You need to have a version of the rkcrc utility which supports the -k parameter.
    Code:
    $ rkcrc -k newboot.cpio.gz newboot.img

    FINAL NOTE: Before attempting to flash the new boot image, you might want to do the following checks:
    1. Is the size of the new boot image file within ballpark of the unmodified one?
    2. Can it be taken apart with this process?
    Last edited by Molle; 08-25-2017, 05:10.
    NVidia Shield TV 2015 16 GB || Stock
    NVidia Shield TV 2017 16 GB || Stock
    Buy me a beer?

    #2
    Reserved.
    NVidia Shield TV 2015 16 GB || Stock
    NVidia Shield TV 2017 16 GB || Stock
    Buy me a beer?

    Comment


      #3
      Thanks a lot Molle.


      It took me a bloody day to find "rkutils", the linked website (linux-rockchip.info) seems to have trouble.

      Anyways, so far "bash for windows" has done quite a good job with the basic command, and i finally found a windows version of the rkcrc (really happy i didnt compile).. However, i am stuck at the "insmod" right after i extract the cpio package.

      Code:
      root@XXXX:/mnt/c/Users/XXXXXXX/Desktop/cpio# gzip -dc bootimg.cpio.gz | cpio -iduvm
      charger
      data
      default.prop
      dev
      drmboot.ko
      file_contexts
      fstab.rk30board.bootmode.emmc
      fstab.rk30board.bootmode.unknown
      init
      init.box.samba.rc
      init.connectivity.rc
      init.customer.rc
      init.environ.rc
      init.initd.rc
      init.rc
      init.rk30board.bootmode.emmc.rc
      init.rk30board.bootmode.unknown.rc
      init.rk30board.environment.rc
      init.rk30board.rc
      init.rk30board.usb.rc
      init.rockchip.rc
      init.su.rc
      init.trace.rc
      init.usb.rc
      init.zygote32.rc
      proc
      property_contexts
      res
      res/images
      res/images/charger
      res/images/charger/battery_0.png
      res/images/charger/battery_1.png
      res/images/charger/battery_2.png
      res/images/charger/battery_3.png
      res/images/charger/battery_4.png
      res/images/charger/battery_5.png
      res/images/charger/battery_charge.png
      res/images/charger/battery_fail.png
      res/images/charger/capacity_text_bottom.png
      res/images/charger/capacity_text_left.png
      res/images/charger/capacity_text_right.png
      res/images/charger/capacity_text_top.png
      rk30xxnand_ko.ko
      sbin
      sbin/adbd
      sbin/e2fsck
      sbin/healthd
      sbin/mkdosfs
      sbin/resize2fs
      sbin/sdtool
      sbin/ueventd
      sbin/watchdogd
      seapp_contexts
      selinux_version
      
      gzip: bootimg.cpio.gz: decompression OK, trailing garbage ignored
      sepolicy
      service_contexts
      sys
      system
      ueventd.rc
      ueventd.rk30board.rc
      4878 blocks
      so, whenever i input "insmod /system/lib/modules/mali.ko mali_dvfs=133,200,266,300,400,600,798 mali_init_clock=133", would get a

      Code:
      root@XXX:/mnt/c/Users/XXXX/Desktop/cpio# insmod /system/lib/modules/mali.ko mali_dvfs=133,2
      ali_init_clock=133
      insmod: ERROR: could not load module /system/lib/modules/mali.ko: No such file or directory
      obviously that was expected as i noticed before hand that those folders should be empty, as i extracted a 1.42mb package.

      Any clue what i am doing wrong? (Apart from using linux under windows).

      EDIT: forget it, didnt see that i should add the line to that specific file in the beginning.
      Last edited by Pluto; 05-20-2017, 17:15.

      Comment


        #4
        Originally posted by Pluto View Post
        i should add the line to that specific file in the beginning.
        There is an existing 'insmod' line for the Mali kernel module in 'init.rk30board.rc'. Just append the parameter part of my example line to that and you should be ok.
        NVidia Shield TV 2015 16 GB || Stock
        NVidia Shield TV 2017 16 GB || Stock
        Buy me a beer?

        Comment


          #5
          Yup, found out the hard way.

          Nevertheless, i've failed.

          Initially, gzip -dc together with cpio would'nt work well, and i noticed a few files being unreadable.

          gzip -d works, and i got a lot less issues without it, but cpio command wouldnt respond to it at all, the cpio file however could be extracted with 7zip on windows (this is where my doubts are).

          I edit the line on the .co file, did the time trick, repack and crc signing. All i get is the blue led in the front, no HDMI output at all.

          Comment


            #6
            Originally posted by Pluto View Post
            Code:
            root@XXXX:/mnt/c/Users/XXXXXXX/Desktop/cpio# gzip -dc bootimg.cpio.gz | cpio -iduvm
            Looking at the command you executed, it seems you extracted the files to the same directory where the gz file resided. If you didn't delete it afterwards, you probably packed it inside the new boot image. I have put some extra instructions to the original post on how to unpack the files to a separate directoty.
            NVidia Shield TV 2015 16 GB || Stock
            NVidia Shield TV 2017 16 GB || Stock
            Buy me a beer?

            Comment


              #7
              That is exactly where i usually mess up with such cases, paths.

              I just redid it, the image file differ slightly. I will flash in a couple of hours and report back.

              PS, what is the address for flashing a boot file in our usual tools?

              Comment

              Working...
              X