3,860
edits
m (Lakrits moved page FirefoxOS/Performance/Modifying boot.img to Firefox OS/Performance/Modifying boot.img: The official spelling of "Firefox OS" leaves a space between the two parts of the name. It's easier to find a page if the spelling of its...) |
|||
(7 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
==Modifying boot.img== | ==Modifying boot.img== | ||
This page is meant to illustrate the general steps necessary to make changes to the ramdisk in the boot partition of the | This page is meant to illustrate the general steps necessary to make changes to the ramdisk in the boot partition of the Flame. This may be desired for a number of reasons such as making changes to the init rc scripts or the init program itself, without changing the kernel. | ||
Ideally, the build system would build the kernel and ramdisk, and then create a boot.img which one could then flash. In this case, it's simply a matter of making whatever changes are necessary (and of course init would be automatically included as well). On the flame however, it was not quite so easy. | Ideally, the build system would build the kernel and ramdisk, and then create a boot.img which one could then flash. In this case, it's simply a matter of making whatever changes are necessary (and of course init would be automatically included as well). On the flame however, it was not quite so easy. | ||
Line 11: | Line 11: | ||
adb pull /dev/block/platform/msm_sdcc.1/by-name/boot . | adb pull /dev/block/platform/msm_sdcc.1/by-name/boot . | ||
</pre> | </pre> | ||
Where the file specified above is a friendly symlink to <code>|/dev/block/mmcblk0p7|</code>. For certain other devices (such as the hamachi) the partitions lived under <code>|/dev/mtd/|</code> and the mappings could be found by executing <code>|cat /proc/mtd|</code> on the device. | Where the file specified above is a friendly symlink to <code>|/dev/block/mmcblk0p7|</code>. | ||
====Hamachi Quirks==== | |||
For certain other devices (such as the hamachi) the partitions lived under <code>|/dev/mtd/|</code> and the mappings could be found by executing <code>|cat /proc/mtd|</code> on the device, which would emit something like the following, indicating the partition mappings: | |||
<pre> | |||
dev: size erasesize name | |||
mtd0: 00600000 00020000 "boot" | |||
mtd1: 0c800000 00020000 "system" | |||
mtd2: 02800000 00020000 "cache" | |||
mtd3: 00400000 00020000 "misc" | |||
[...] | |||
mtd20: 01b00000 00020000 "FOTA" | |||
mtd21: 00120000 00020000 "APPSBL" | |||
mtd22: 023c0000 00020000 "APPS" | |||
</pre> | |||
<!--mtd4: 00200000 00020000 "watchdog" | |||
mtd5: 0a100000 00020000 "userdata" | |||
mtd6: 00400000 00020000 "persist" | |||
mtd7: 00a00000 00020000 "recovery" | |||
mtd8: 00100000 00020000 "custpack" | |||
mtd9: 00100000 00020000 "tracability" | |||
mtd10: 00100000 00020000 "tuningpara" | |||
mtd11: 00140000 00020000 "MIBIB" | |||
mtd12: 00040000 00020000 "QCSBL" | |||
mtd13: 000a0000 00020000 "OEMSBL1" | |||
mtd14: 000a0000 00020000 "OEMSBL2" | |||
mtd15: 01a80000 00020000 "AMSS" | |||
mtd16: 017c0000 00020000 "EFS2" | |||
mtd17: 00040000 00020000 "STUDYPARA" | |||
mtd18: 00040000 00020000 "SECRO" | |||
mtd19: 00040000 00020000 "FOTAFLAG"--> | |||
From this we see that mtd0 is the boot partition and hence to retrieve it we would run | |||
<pre> | |||
adb pull /dev/mtd/mtd0 | |||
</pre> | |||
====Alternatively==== | ====Alternatively==== | ||
Line 44: | Line 78: | ||
So now that we have all three parts we continue on to making modifications. We will keep the kernel and device tree around unchanged for rebuilding the boot.img. The ramdisk on the other hand, we will unpack into a directory, make changes to, and repackage. This is where files such as '''init''' and '''init.rc''' (and various other *.rc's) live. | So now that we have all three parts we continue on to making modifications. We will keep the kernel and device tree around unchanged for rebuilding the boot.img. The ramdisk on the other hand, we will unpack into a directory, make changes to, and repackage. This is where files such as '''init''' and '''init.rc''' (and various other *.rc's) live. | ||
Firstly, unpack the ramdisk into a directory: | Firstly, to unpack the ramdisk into a directory: | ||
<pre> | <pre> | ||
mkdir initramfs_dir | mkdir initramfs_dir | ||
Line 51: | Line 85: | ||
</pre> | </pre> | ||
Make the desired changes | Make the desired changes, such as replacing init and modifying init.rc (both of which live in the root of the directory), and then repackage: | ||
<pre> | <pre> | ||
Line 59: | Line 93: | ||
One can make the <code>mkbootfs</code> tool by invoking <code>|./build.sh mkbootfs|</code> from the FirefoxOS source tree; | One can make the <code>mkbootfs</code> tool by invoking <code>|./build.sh mkbootfs|</code> from the FirefoxOS source tree; | ||
Now with the command we got from the <code>unmkbootimg</code> utility, we can reconstruct the | Now with the command we got from the <code>unmkbootimg</code> utility, we can reconstruct the boot.img with the newly generated ramdisk, such that it retains the same settings and kernel parameters. As well, if the original boot.img contained a device tree, make sure to add <code>|--dt $DTBLOBNAME|</code> to the end of the command. The utility <code>mkbootimg</code> can be built in the FirefoxOS source tree by invoking <code>|./build.sh mkbootimg|</code> and the resulting binary is found in <code>|$SRC_TOP/out/host/$HOST_NAME/bin/|</code> | ||
Once the new boot partition has been constructed, simply flash with fastboot or whichever tool is necessary for your device, e.g.: | |||
<pre> | |||
fastboot flash boot new_boot.img | |||
</pre> | |||
Note that with <code>fastboot</code> one can also specify to boot once using an image, as opposed to flashing it unto the device. You might want to do this first to make sure everything went well...: | |||
<pre> | |||
fastboot boot new_boot.img | |||
</pre> |
edits