1 Linux kernel配置
1.1 dts
修改dts以支持ramdisk bootargs和ramdisk分区:
在memory项后通过chosen方式添加bootargs,添加内容如下:
/ {
model = "TI AM335x CORS";
compatible = "ti,am335x-evm", "ti,am33xx";
memory {
device_type = "memory";
reg = <0x80000000 0x8000000>; /* 128 MB */
};
chosen {
bootargs = "console=ttyO0,115200n8 root=/dev/ram0";
};
};
在nand@0,0 { 内增加一个ramdisk分区(我使用8M大小):
partition@8 {
label = "NAND.kernel";
reg = <0x00200000 0x00400000>;
};
partition@9 {
label = "NAND.file-system";
reg = <0x00600000 0x02800000>;
};
partition@10 {
label = "NAND.ramdisk";
reg = <0x02E00000 0x00800000>;
};
partition@11 {
label = "NAND.types";
reg = <0x03600000 0x04200000>;
};
};
最后重新编译dts:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- am335x-cors.dtb
1.2 Kernel
使用的dtb方式启动内核,故采取dtb的chosen方式传递bootargs给内核,需要修改内核config配置:
make ARCH=arm menuconfig
Boot options --->
按N键取消配置项
[ ] Use appended device tree blob to zImage (EXPERIMENTAL)
其次
a):General setup-->选择 Initial RAM filesystem and RAM disk...... 项
b):Device Drivers-->Block devices-->选择 RAM block device support 项
并检查Optimize for size是否被选中,如果没有则选中,此项优化内核大小,根据需要进行配置。
修改Default RAM disk size kbytes选项为(8192)
ramdisk是一种内存虚拟磁盘技术,实质上并不是一种文件系统,它使用的文件系统时ext2文件系统。所以要在make menuconfig ARCH=arm的时候进入File systems菜单,选上<*> Second extended fs support。以提供内核对ext2文件系统的支持。
最后重新编译内核:
./build.sh
最后copy:
cp arch/arm/boot/dts/am335x-cors.dtb ../../tftpboot/
cp arch/arm/boot/zImage ../../tftpboot/
2 Busybox编译
2.1 配置busybox
进入busybox目录执行#make menuconfig
进入Busybox Settings -> build Options ->不选中"Build busybox as a static binary“,即静态链接:
[ ] Build BusyBox as a static binary (no shared libs) │ │
│ │[ ] Build BusyBox as a position independent executable │ │
│ │[ ] Force NOMMU build │ │
│ │[*] Build shared libbusybox │ │
│ │[*] Produce a binary for each applet, linked against libbusybox │ │
│ │[*] Produce additional busybox binary linked against libbusybox │ │
│ │[*] Build with Large File Support (for accessing files > 2 GB) │ │
│ │(arm-linux-gnueabihf-) Cross Compiler prefix
Installation Options -> 选中"Don't use /usr",以免busybox不慎被安装到宿主机系统的相应目录下,破坏宿主机系统。Busybox Installation Prefix (