AddingADBRootToAnImage » History » Version 3
Denis 'GNUtoo' Carikli, 02/17/2020 11:53 PM
1 | 1 | Denis 'GNUtoo' Carikli | h1. AddingADB |
---|---|---|---|
2 | |||
3 | 3 | Denis 'GNUtoo' Carikli | First extract the boot.img from the zip |
4 | 1 | Denis 'GNUtoo' Carikli | <pre> |
5 | $ mkdir temp |
||
6 | $ cd temp |
||
7 | $ unzip ../replicant-6.0-0004-rc1-maguro.zip |
||
8 | $ file boot.img |
||
9 | boot.img: Android bootimg, kernel, ramdisk, page size: 2048, cmdline (androidboot.hardware=tuna) |
||
10 | </pre> |
||
11 | |||
12 | 3 | Denis 'GNUtoo' Carikli | Then extract the kernel, and initramfs from the boot.img. Also save the infos such as the load address, etc in boot.txt: |
13 | 1 | Denis 'GNUtoo' Carikli | <pre> |
14 | $ unbootimg --kernel kernel.img --ramdisk ramdisk.cpio.gz -i boot.img | tee boot.txt |
||
15 | total image size: 5619712 |
||
16 | kernel size: 4604340 |
||
17 | kernel load addr: 0x80008000 |
||
18 | ramdisk size: 1009915 |
||
19 | ramdisk load addr: 0x81000000 |
||
20 | 2nd boot size: 0 |
||
21 | 2nd boot load addr: 0x80f00000 |
||
22 | kernel tags addr: 0x80000100 |
||
23 | page size: 2048 |
||
24 | board: `' |
||
25 | cmdline: `androidboot.hardware=tuna' |
||
26 | id: 9b90141066f527ecd3909d2ab8e383ebd995fd40000 |
||
27 | </pre> |
||
28 | |||
29 | 3 | Denis 'GNUtoo' Carikli | Then uncompress the initramfs |
30 | 1 | Denis 'GNUtoo' Carikli | <pre> |
31 | $ gunzip ramdisk.cpio.gz |
||
32 | $ file ramdisk.cpio |
||
33 | ramdisk.cpio: ASCII cpio archive (SVR4 with no CRC) |
||
34 | </pre> |
||
35 | |||
36 | 3 | Denis 'GNUtoo' Carikli | Then edit the default.props, we use sed on the raw cpio image for simplicity (we don't have permissions and username to take care of this way): |
37 | 1 | Denis 'GNUtoo' Carikli | <pre> |
38 | 3 | Denis 'GNUtoo' Carikli | $ sed 's#ro.adb.secure=0# #' -i ramdisk.cpio |
39 | $ sed 's#ro.secure=1#ro.secure=0#' -i ramdisk.cpio |
||
40 | 1 | Denis 'GNUtoo' Carikli | $ sed 's#persist.sys.usb.config=none#persist.sys.usb.config=adb #' -i ramdisk.cpio |
41 | 2 | Denis 'GNUtoo' Carikli | </pre> |
42 | 1 | Denis 'GNUtoo' Carikli | |
43 | 3 | Denis 'GNUtoo' Carikli | Then recompress the initramfs |
44 | 1 | Denis 'GNUtoo' Carikli | <pre> |
45 | $ gzip ramdisk.cpio |
||
46 | 3 | Denis 'GNUtoo' Carikli | </pre> |
47 | |||
48 | We then recreate the image with the infos we saved in boot.txt. Note that the base is 0x80000000. The kernel has an offset and will be in 0x80008000: |
||
49 | <pre> |
||
50 | 1 | Denis 'GNUtoo' Carikli | $ mkbootimg --cmdline="androidboot.hardware=tuna" --kernel kernel.img --ramdisk ramdisk.cpio.gz --base 0x80000000 -o boot_new.img |
51 | </pre> |
||
52 | |||
53 | 3 | Denis 'GNUtoo' Carikli | Verify that we got all the arguments right: |
54 | 1 | Denis 'GNUtoo' Carikli | <pre> |
55 | $ unbootimg -i boot_new.img | tee boot_new.txt |
||
56 | $ diff -u boot.txt boot_new.txt |
||
57 | $ --- boot.txt 2020-02-18 00:39:59.890285634 +0100 |
||
58 | +++ boot_new.txt 2020-02-18 00:44:16.208897037 +0100 |
||
59 | @@ -1,7 +1,7 @@ |
||
60 | total image size: 5619712 |
||
61 | kernel size: 4604340 |
||
62 | kernel load addr: 0x80008000 |
||
63 | -ramdisk size: 1009915 |
||
64 | +ramdisk size: 1010280 |
||
65 | ramdisk load addr: 0x81000000 |
||
66 | 2nd boot size: 0 |
||
67 | 2nd boot load addr: 0x80f00000 |
||
68 | @@ -9,4 +9,4 @@ |
||
69 | page size: 2048 |
||
70 | board: `' |
||
71 | cmdline: `androidboot.hardware=tuna' |
||
72 | -id: 9b90141066f527ecd3909d2ab8e383ebd995fd40000 |
||
73 | +id: dd37b2ae1e50be62fe5c94b81b85aa56ffea17be000 |
||
74 | 3 | Denis 'GNUtoo' Carikli | </pre> |
75 | |||
76 | Reflash the image: |
||
77 | <pre> |
||
78 | heimdall flash --boot boot.img --recovery boot.img |
||
79 | 1 | Denis 'GNUtoo' Carikli | </pre> |