The above u-boot.bin has 1024KB padding at the head of file,for example first executable instruction is at the offset 1KB. If you want to generate a no-padding image, you need do below dd command in host.
$ dd if=./u-boot.bin of=./u-boot-no-padding.bin bs =1024 skip=1
Usually this no-padding uboot image is used in the SD card, for example, program this no-padding uboot image into 1KB offset of SD card so that we do not overwrite the MBR (including partition table) within first 512B on the SD card.
Note : Any image which must be loaded by uboot must have an unique image head, for example, some data must be added at the head of loaded image to tell uboot about the image (for example, it's a kernel, or ramfs , etc) and how to load the image (for example, load/execute address).
Therefor before you can load any image into RAM by uboot , you need a tool to add this information to generate a new image which can be recognized by uboot . Fortunately, this tool is delivered together with uboot . After you make uboot using the above steps, you can find the tool (mkimage ) under tools/.
Later the document will describe how to use mkimage to generate the image (for example kernel image, ramfs image) to be loaded by uboot .
Build Kernel Image
To run Android using NFS or from SD, build the kernel with the default configuration now as follows:
Assume you had already built uboot . mkimage was generated under myandroid//bootable/bootloader/uboot-imx/tools / and it's in your PATH
$ cd ~/myandroid/kernel_imx
$ echo $ARCH && echo $CROSS_COMPILE
Make sure you have those 2 environment variables set
$ make imx5_android_defconfig
Generate ".config " according to default config file under arch/arm/configs .
$ make uImage
You can generate zImage too by "make zImage ", use following command to generate uImage from zImage .
With a successful build in either of the above case, the generated kernel image is ~/myandroid/kernel_imx/arch/arm/boot/uImage .
Generate uImage to be loaded by u-boot
To generate uImage from the built zImage , generate a uImage based on the above zImage as follows:
$ cd myandroid/kernel_imx/arch/arm/boot
$ ~/myandroid/bootable/bootloader/uboot-imx/tools/mkimage -A arm -O linux -T kernel -C none -a 0x90008000 -e 0x90008000 -n "Android Linux Kernel" -d ./zImage ./uImage
During boot, when uboot try to load above "uImage ", it will know to load it (without image head added by mkimage tool) into 0x90008000 (specified by "-a"), and then jump to 0x90008000 (specified by "-e") to execute it. "-C none" means no compression when generating "uImage ". This is because the original zImage is already a compressed one.
Build Android image
After applying all i.MX patches and kernel image built out, build the Android image using following steps:
$ cd
~/myandroid
Command to build for i.MX51 BBG3 board is:
$ make PRODUCT-imx51_BBG-eng | tee build_imx51_BBG_android.log
"imx51_BBG" is the product names (see ~/myandroid/vendor/fsl/product
)
After build, check build_*_android.log
to make sure no build error.
For i.MX51 BBG build, the following outputs are generated as default under myandroid/out/target/product/imx51_BBG:
root / : root file system (including init, init.rc , etc). Mounted at /
system / : Android system binary/libraries. Mounted at /system
data / : Android data area. Mounted at /data
Above three folders can be used to create your Android file system for NFS mounting, i.e. root/ > / , system/ > /system , data/ > /data
recovery / : root file system when booting in "recovery" mode. Not directly used.
ramdisk.img : Ramdisk image generated from "root/". Not directly used.
system.img : EXT3 image generated from "system/". Can be programmed to "SYSTEM" partition on SD card with "dd "
userdata.img : EXT3 image generated from "data/".
recovery.img : EXT3 image generated from "recovery/". Can be programmed to "RECOVERY" partition on SD card with "dd "
Generate uRamdisk to be loaded by uboot
The following steps generate a RAMDISK image recognized by uboot :
Assume you had already built uboot . mkimage was generated under myandroid//bootable/bootloader/uboot-imx/tools /
$ cd myandroid/out/target/product/imx51_BBG
$ ~/myandroid/bootable/bootloader/uboot-imx/tools/mkimage - A arm -O linux -T ramdisk -C none -a 0x90308000 -n "Android Root Filesystem " -d ./ramdisk.img ./uramdisk.img
编译完成,我们可以逐步将img文件烧写到SD卡中.
上述过程简单,按步骤一步步进行即可,不抓图描述.
Program Bootloader into SD using dd
Insert the SD card/cardreader to the Linux PC (root privileges are needed for programming SD)