AddingADBRootToAnImage » History » Version 8
Denis 'GNUtoo' Carikli, 02/18/2020 12:07 AM
1 | 8 | Denis 'GNUtoo' Carikli | h1. AddingADBRootToAnImage |
---|---|---|---|
2 | 1 | Denis 'GNUtoo' Carikli | |
3 | 6 | Denis 'GNUtoo' Carikli | In this tutorial we'll add adb root support to an existing Replicant release. |
4 | |||
5 | This is valid for the following configuration: |
||
6 | * *Image*: replicant-6.0-0004-rc1-maguro.zip |
||
7 | * *Device*: Galaxy Nexus (GT-I9250) |
||
8 | |||
9 | You'll need to adapt it slightly for other devices. |
||
10 | |||
11 | 3 | Denis 'GNUtoo' Carikli | First extract the boot.img from the zip |
12 | 1 | Denis 'GNUtoo' Carikli | <pre> |
13 | $ mkdir temp |
||
14 | $ cd temp |
||
15 | $ unzip ../replicant-6.0-0004-rc1-maguro.zip |
||
16 | $ file boot.img |
||
17 | boot.img: Android bootimg, kernel, ramdisk, page size: 2048, cmdline (androidboot.hardware=tuna) |
||
18 | </pre> |
||
19 | |||
20 | 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: |
21 | 1 | Denis 'GNUtoo' Carikli | <pre> |
22 | $ unbootimg --kernel kernel.img --ramdisk ramdisk.cpio.gz -i boot.img | tee boot.txt |
||
23 | total image size: 5619712 |
||
24 | kernel size: 4604340 |
||
25 | kernel load addr: 0x80008000 |
||
26 | ramdisk size: 1009915 |
||
27 | ramdisk load addr: 0x81000000 |
||
28 | 2nd boot size: 0 |
||
29 | 2nd boot load addr: 0x80f00000 |
||
30 | kernel tags addr: 0x80000100 |
||
31 | page size: 2048 |
||
32 | board: `' |
||
33 | cmdline: `androidboot.hardware=tuna' |
||
34 | id: 9b90141066f527ecd3909d2ab8e383ebd995fd40000 |
||
35 | </pre> |
||
36 | |||
37 | 3 | Denis 'GNUtoo' Carikli | Then uncompress the initramfs |
38 | 1 | Denis 'GNUtoo' Carikli | <pre> |
39 | $ gunzip ramdisk.cpio.gz |
||
40 | $ file ramdisk.cpio |
||
41 | ramdisk.cpio: ASCII cpio archive (SVR4 with no CRC) |
||
42 | </pre> |
||
43 | |||
44 | 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): |
45 | 1 | Denis 'GNUtoo' Carikli | <pre> |
46 | 4 | Denis 'GNUtoo' Carikli | $ sed 's#ro.adb.secure=1# #' -i ramdisk.cpio |
47 | 3 | Denis 'GNUtoo' Carikli | $ sed 's#ro.secure=1#ro.secure=0#' -i ramdisk.cpio |
48 | 1 | Denis 'GNUtoo' Carikli | $ sed 's#persist.sys.usb.config=none#persist.sys.usb.config=adb #' -i ramdisk.cpio |
49 | 2 | Denis 'GNUtoo' Carikli | </pre> |
50 | 1 | Denis 'GNUtoo' Carikli | |
51 | 3 | Denis 'GNUtoo' Carikli | Then recompress the initramfs |
52 | 1 | Denis 'GNUtoo' Carikli | <pre> |
53 | $ gzip ramdisk.cpio |
||
54 | 3 | Denis 'GNUtoo' Carikli | </pre> |
55 | |||
56 | 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: |
||
57 | <pre> |
||
58 | 1 | Denis 'GNUtoo' Carikli | $ mkbootimg --cmdline="androidboot.hardware=tuna" --kernel kernel.img --ramdisk ramdisk.cpio.gz --base 0x80000000 -o boot_new.img |
59 | </pre> |
||
60 | |||
61 | 3 | Denis 'GNUtoo' Carikli | Verify that we got all the arguments right: |
62 | 1 | Denis 'GNUtoo' Carikli | <pre> |
63 | $ unbootimg -i boot_new.img | tee boot_new.txt |
||
64 | $ diff -u boot.txt boot_new.txt |
||
65 | $ --- boot.txt 2020-02-18 00:39:59.890285634 +0100 |
||
66 | +++ boot_new.txt 2020-02-18 00:44:16.208897037 +0100 |
||
67 | @@ -1,7 +1,7 @@ |
||
68 | total image size: 5619712 |
||
69 | kernel size: 4604340 |
||
70 | kernel load addr: 0x80008000 |
||
71 | -ramdisk size: 1009915 |
||
72 | +ramdisk size: 1010280 |
||
73 | ramdisk load addr: 0x81000000 |
||
74 | 2nd boot size: 0 |
||
75 | 2nd boot load addr: 0x80f00000 |
||
76 | @@ -9,4 +9,4 @@ |
||
77 | page size: 2048 |
||
78 | board: `' |
||
79 | cmdline: `androidboot.hardware=tuna' |
||
80 | -id: 9b90141066f527ecd3909d2ab8e383ebd995fd40000 |
||
81 | +id: dd37b2ae1e50be62fe5c94b81b85aa56ffea17be000 |
||
82 | 3 | Denis 'GNUtoo' Carikli | </pre> |
83 | |||
84 | 7 | Denis 'GNUtoo' Carikli | You can then reflash the boot.img image. |
85 | |||
86 | Don't forget to adjust the heimdall arguments for your device. |
||
87 | |||
88 | If in doubt, it's better to consult the Replicant installation instructions that have the good heimdall arguments, as wrong arguments can completely break your device, making it too complicated to repair (you'd have to un-solder and re-solder resistors that are hardly visible). |
||
89 | 3 | Denis 'GNUtoo' Carikli | <pre> |
90 | heimdall flash --boot boot.img --recovery boot.img |
||
91 | 1 | Denis 'GNUtoo' Carikli | </pre> |
92 | 5 | Denis 'GNUtoo' Carikli | |
93 | Then you can use adb: |
||
94 | <pre> |
||
95 | $ adb logcat -b main |
||
96 | </pre> |