用initramfs方式构建根文件系统
步骤:
0) set enveniment
a) $ export PATH=$PATH:/usr/local/arm/arm-2009q3/bin
1) make busybox.
a) $ cd busybox-1.20.2
b) $ make menuconfig
Busybox Settings
--> Build Options
[*] select build busybox as a static binary
(arm-none-linux-gnueabi-) Cross Compiler Prefix
c) $ make
d) $ make install
e) $ cd ..
2) create necessary directory and files
a) $ mkdir rootfs && cd rootfs
b) $ mkdir -p etc/init.d proc sys dev
c) $ sudo cp -a /dev/{null,zero,console} dev/
d) $ cp -rf ../busybox-1.20.2/_install/* ./
e) $ rm -f linuxrc && ln -s bin/busybox init
f) edit etc/fstab, add followings:
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
g) edit etc/inittab
::sysinit:/etc/init.d/rcS
console::respawn:-/bin/sh
::ctrlaltdel:/sbin/reboot
::shutdown:/bin/umount -a -r
h) edit etc/init.d/rcS
#!/bin/sh
mount -a
i) $ chmod +x etc/init.d/rcS
j) $ cd ..
3) create rootfs image.
a) $ dd if=/dev/zero of=rootfs.img bs=1k count=8192
b) $ sudo mke2fs -F -v -m0 rootfs.img
c) $ sudo mount -o loop rootfs.img /mnt/tmp/
mount: mount point /mnt/tmp/ does not exist 解决办法:sudo mount -o loop rootfs.img /mnt/
d) $ sudo cp rootfs/* /mnt/tmp/ -rf替换为 sudo cp rootfs/* /mnt/ -rf
e) $ sudo umount /mnt/tmp/替换为 sudo umount /mnt/
f) $ gzip -9 rootfs.img
g) $ fastboot flash ramdisk rootfs.img.gz
4) modify bootloader
a) 由于要加入rootfs,kernel size指定时要超过编译后的大小
diff --git a/TC4_uboot/include/movi.h b/TC4_uboot/include/movi.h
index dc8906d..b62fb2d 100644
--- a/TC4_uboot/include/movi.h
+++ b/TC4_uboot/include/movi.h
/* partition information */
#define PART_SIZE_UBOOT (480 * 1024)
+//[yeez_jinwei] 2012-10-17 中kernel+rootfs -> zImage size: 5.3M
-#define PART_SIZE_KERNEL (4 * 1024 * 1024)
+//#define PART_SIZE_KERNEL (4 * 1024 * 1024)
+#define PART_SIZE_KERNEL (8 * 1024 * 1024)
#define PART_SIZE_ROOTFS (2 * 1024 * 1024)// 2M
5) modify kernel
a) modify kernel config
Kernel Setting
General setup --->
[*] Initial RAM filesystem and RAM disk (initramfs/initrd) support
(rootfs)Initramfs source file(s)或者vi arch/arm/configs/m8012_defconfig 修改CONFIG_INITRAMFS_SOURCE="rootfs"
[CONFIC_CMDLINE=console=ttySCA0 xxx即可]
6) 编译内核
$(KERNEL_ROOT)/build_kernel.sh new
步骤:
0) set enveniment
a) $ export PATH=$PATH:/usr/local/arm/arm-2009q3/bin
1) make busybox.
a) $ cd busybox-1.20.2
b) $ make menuconfig
Busybox Settings
--> Build Options
[*] select build busybox as a static binary
(arm-none-linux-gnueabi-) Cross Compiler Prefix
c) $ make
d) $ make install
e) $ cd ..
2) create necessary directory and files
a) $ mkdir rootfs && cd rootfs
b) $ mkdir -p etc/init.d proc sys dev
c) $ sudo cp -a /dev/{null,zero,console} dev/
d) $ cp -rf ../busybox-1.20.2/_install/* ./
e) $ rm -f linuxrc && ln -s bin/busybox init
f) edit etc/fstab, add followings:
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
g) edit etc/inittab
::sysinit:/etc/init.d/rcS
console::respawn:-/bin/sh
::ctrlaltdel:/sbin/reboot
::shutdown:/bin/umount -a -r
h) edit etc/init.d/rcS
#!/bin/sh
mount -a
i) $ chmod +x etc/init.d/rcS
j) $ cd ..
3) create rootfs image.
a) $ dd if=/dev/zero of=rootfs.img bs=1k count=8192
b) $ sudo mke2fs -F -v -m0 rootfs.img
c) $ sudo mount -o loop rootfs.img /mnt/tmp/
mount: mount point /mnt/tmp/ does not exist 解决办法:sudo mount -o loop rootfs.img /mnt/
d) $ sudo cp rootfs/* /mnt/tmp/ -rf替换为 sudo cp rootfs/* /mnt/ -rf
e) $ sudo umount /mnt/tmp/替换为 sudo umount /mnt/
f) $ gzip -9 rootfs.img
g) $ fastboot flash ramdisk rootfs.img.gz
4) modify bootloader
a) 由于要加入rootfs,kernel size指定时要超过编译后的大小
diff --git a/TC4_uboot/include/movi.h b/TC4_uboot/include/movi.h
index dc8906d..b62fb2d 100644
--- a/TC4_uboot/include/movi.h
+++ b/TC4_uboot/include/movi.h
/* partition information */
#define PART_SIZE_UBOOT (480 * 1024)
+//[yeez_jinwei] 2012-10-17 中kernel+rootfs -> zImage size: 5.3M
-#define PART_SIZE_KERNEL (4 * 1024 * 1024)
+//#define PART_SIZE_KERNEL (4 * 1024 * 1024)
+#define PART_SIZE_KERNEL (8 * 1024 * 1024)
#define PART_SIZE_ROOTFS (2 * 1024 * 1024)// 2M
5) modify kernel
a) modify kernel config
Kernel Setting
General setup --->
[*] Initial RAM filesystem and RAM disk (initramfs/initrd) support
(rootfs)Initramfs source file(s)或者vi arch/arm/configs/m8012_defconfig 修改CONFIG_INITRAMFS_SOURCE="rootfs"
[CONFIC_CMDLINE=console=ttySCA0 xxx即可]
6) 编译内核
$(KERNEL_ROOT)/build_kernel.sh new
1114

被折叠的 条评论
为什么被折叠?



