How to make a update.img booting from Nand or other media
Contents |
Requirement
a marsboard RK3066 or marsboard PX2 a desktop/laptop running Linux(64bit preferred) a micro usb cable, one side plugged in to the OTG port of marsboard, the other side plugged in to the usb port on desktop/laptop
Prepare the build environment
Install the packages for the compiler
Install packages for building kernel if you don't have them on your host.
sudo apt-get install build-essential lzop libncurses5-dev libssl-dev
Install the toolchain
Download ARM toolchain if you don't have Android 4.2.2/4.4.2 SDK on your host.
if your host is 64bit
git clone -b kitkat-release --depth 1 https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6
Or
download the zip file here http://www.haoyuelectronics.com/service/RK3066/tools/linux/x86_64_arm-eabi-4.6.zip
if your host is 32bit
git clone -b jb-release --depth 1 https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6
Or
download the zip file here hhttp://www.haoyuelectronics.com/service/RK3066/tools/linux/x86_32_arm-eabi-4.6.zip
you can use any toolchain if you are sure it works, or you can fix any error introduced by toolchain.
Get the source code
wget http://www.haoyuelectronics.com/service/RK3066/Images/linux-3.0.36-source-code/marsboard-linux-rockchip.tar.gz
Build the kernel
cd marsboard-linux-rockchip
if you want to use HDMI display, you can use this linux config
make ARCH=arm marsboard_rk3066_px2_hdmi_defconfig
if you want to use LCD display, the marsboard RK3006 & PX2 support two types of LCD module, HY070CTP-A (800x480) or HY070CTP-HD (1024x600).
make ARCH=arm marsboard_rk3066_px2_hy070ctp_a_defconfig
make ARCH=arm marsboard_rk3066_px2_hy070ctp_hd_defconfig
Compile the kernel
make ARCH=arm CROSS_COMPILE=`pwd`/arm-eabi-4.6/bin/arm-eabi- kernel.img -j8
The kernel will be at kernel.img (image for kernel partition) and arch/arm/boot/Image (raw binary)
if you want LZO compressed kernel, specify zkernel.img
make ARCH=arm CROSS_COMPILE=`pwd`/arm-eabi-4.6/bin/arm-eabi- zkernel.img -j8
The kernel will be at kernel.img (image for kernel partition) and arch/arm/boot/zImage (compressed binary)
Generate the image
Generate the initramfs
cd .. wget http://www.haoyuelectronics.com/service/RK3066/Images/linux-3.0.36-source-code/initrd.tar.gz make -C initrd
Generate the boot.img
Install mkbootimg
git clone https://github.com/neo-technologies/rockchip-mkbootimg.git cd rockchip-mkbootimg make sudo make install cd ..
Make boot.img
mkbootimg --kernel marsboard-linux-rockchip/arch/arm/boot/Image --ramdisk initrd.img -o boot.img
Done. Now we have the boot.img (image for boot/recovery partition) for marsboard.
Pack to update.img
git clone https://github.com/powermcu/rockchip-pack-tools
copy boot.img to rockchip-pack-tools
mv boot.img /path/rockchip-pack-tools/linux/linux-boot.img
copy rootfs.img to rockchip-pack-tools
mv rootfs.img /path/rockchip-pack-tools/linux/linux-rootfs.img
Generate the image
./mkupdate.sh # Pack the image
then you get a updata.img, how to upload it? use Linux Upgrade Tool.
Boot from Media
Modify the parameter
The linux rootfs maybe in the different partition or media(nand or uSD card or USB disk), so you need to tell the kernel which is the right rootfs to mount. So change the root= command line in your parameter to the rootfs you want to mount. The examples are:
root=/dev/mtdblock2 # rootfs in the nand partition block2 root=/dev/mmcblk0p1 # rootfs in the uSD card first partition root=/dev/sda1 # rootfs in the U disk or the USB hard drive first partition root=LABEL=linuxroot # rootfs in the partition with label "linuxroot", can be in uSD, U disk or USB hard drive.
Boot from nand
cd /path/rockchip-pack-tools
vi parameter
CMDLINE:console=ttyFIQ0,115200 console=tty2 root=/dev/mtdblock2 init=/sbin/init initrd=0x62000000,0x00800000 mtdparts=rk29xxnand:0x00002000@0x00000000(parameter),0x00010000@0x00002000(boot),-@0x00012000(rootfs)
Boot from sd card
cd /path/rockchip-pack-tools
vi parameter
CMDLINE:console=ttyFIQ0,115200 console=tty2 root=LABEL=linuxroot init=/sbin/init initrd=0x62000000,0x00800000 mtdparts=rk29xxnand:0x00002000@0x00000000(parameter),0x00010000@0x00002000(boot),-@0x00012000(rootfs)
Next step
Now you refer flash the image to flash the generated boot.img to "boot" partition parameter to "parameter" partition of your marsboard. And download a prebuilt rootfs or make your own rootfs. You will get linux system boot into ramdisk and then switch root to real rootfs.
blog comments powered by Disqus