(嵌入式开发)移植最新版本3.4.2内核
一. 内核启动流程,据此配置内核(机器ID)
1.1 修改Makefile
1.2 选择默认配置 : make s3c2410_defconfig
1.3 make uImage
步骤1:
在UBOOT里:
set machid 16a // smdk2440 mach-smdk2440.c
或
set machid 7CF // mini2440 mach-mini2440.c
步骤2:
arch\arm\mach-s3c24xx\mach-smdk2440.c
s3c24xx_init_clocks(16934400);
改为
s3c24xx_init_clocks(12000000);
步骤3:
配置/编译: make s3c2410_defconfig 或 make mini2440_defconfig
make uImage
步骤4:
在uboot里:set bootargs console=ttySAC0,115200 .....
uboot的默认MACH ID:
gd->bd->bi_arch_number = MACH_TYPE_SMDK2410; // 193
如果s = getenv("machid");成功,则使用它
否则使用默认的
set machid 16a // smdk2440 mach-smdk2440.c
set machid 7CF // mini2440 mach-mini2440.c
nfs 32000000 192.168.1.123:/work/nfs_root/uImage_new
bootm 32000000
二. 修改分区, 制作新的文件系统
nfs 30000000 192.168.1.123:/work/nfs_root/fs_mini_mdev.yaffs2
nand erase.part rootfs
nand write.yaffs 30000000 260000 889bc0
nfs 30000000 192.168.1.123:/work/nfs_root/fs_mini_mdev.jffs2
nand erase.part rootfs
nand write.jffs2 30000000 260000 $filesize
set bootargs console=ttySAC0,115200 root=/dev/mtdblock3 rootfstype=jffs2
制作文件系统
1. 交叉编译busybox
安装:make install CONFIG_PREFIX=/work/nfs_root/fs_mini_mdev_new
2. 安装库
mkdir /work/nfs_root/fs_mini_mdev_new/lib
mkdir /work/nfs_root/fs_mini_mdev_new/usr/lib -p
cp /usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/armv4t/lib/*so* /work/nfs_root/fs_mini_mdev_new/lib -d
cp /usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/armv4t/usr/lib/*so* /work/nfs_root/fs_mini_mdev_new/usr/lib -d
3. 构建etc目录
4. 构建dev目录
5. 其他空目录
mkfs.jffs2 -n -s 2048 -e 128KiB -d fs_mini_mdev_new -o fs_mini_mdev_new.jffs2
烧写:
nfs 30000000 192.168.1.123:/work/nfs_root/fs_mini_mdev_new.jffs2
nand erase.part rootfs
nand write.jffs2 30000000 260000 $filesize
set bootargs console=ttySAC0,115200 root=/dev/mtdblock3 rootfstype=jffs2
nfs 32000000 192.168.1.123:/work/nfs_root/uImage_new
bootm 32000000
SIGILL illegal instruction
6. 重新配置内核支持EABI
set bootargs console=ttySAC0,115200 root=/dev/mtdblock3 rootfstype=jffs2
nfs 32000000 192.168.1.123:/work/nfs_root/uImage_eabi
bootm 32000000
三. 移植YAFFS文件系统
1. 获得源码
git clone git://www.aleph1.co.uk/yaffs2
2. 打补丁
cd yaffs-dir
./patch-ker.sh c m linux-tree 比如 ./patch-ker.sh c m /work/system/linux-3.4.2
3. 配置内核支持YAFFS
4. 编译、使用uImage
5. 制作、烧写yaffs映象
mkyaffs2image fs_mini_mdev_new fs_mini_mdev_new.yaffs2
uboot:
nfs 30000000 192.168.1.123:/work/nfs_root/fs_mini_mdev_new.yaffs2
nand erase.part rootfs
nand write.yaffs 30000000 260000 $filesize
6. 启动
set bootargs console=ttySAC0,115200 root=/dev/mtdblock3
nfs 32000000 192.168.1.123:/work/nfs_root/uImage_yaffs
bootm 32000000
7. 没成功,用替代法查找问题
7.1 UBOOT可能有问题:换上1.1.6的UBOOT
tftp 30000000 u-boot.bin
nand erase.part u-boot
nand write 30000000 u-boot
reset
nfs 30000000 192.168.1.123:/work/nfs_root/fs_mini_mdev_new.yaffs2
nand erase rootfs
nand write.yaffs 30000000 260000 $(filesize)
set bootargs console=ttySAC0,115200 root=/dev/mtdblock3
nfs 32000000 192.168.1.123:/work/nfs_root/uImage_yaffs
bootm 32000000
发现1.1.6的UBOOT没问题,所以就是我们移植的新UBOOT有BUG:
drivers\mtd\nand\Nand_util.c
if (!need_skip && !(flags & WITH_DROP_FFS)) {
改为
if (!need_skip && !(flags & WITH_DROP_FFS) && !(flags & WITH_YAFFS_OOB)) {
7.2 YAFFS映象可能有问题
制作了u-boot_new.bin, uImage_new, fs_mini_mdev_new.yaffs
重烧整个系统:
使用jtag工具烧u-boot_new.bin
或使用uboot来更新自己: tftp 30000000 u-boot_new.bin; nand erase.part u-boot; nand write 30000000 u-boot
启动uboot,用它来烧写内核、FS
tftp 30000000 uImage_new; nand erase.part kernel; nand write 30000000 kernel
tftp 30000000 fs_mini_mdev_new.yaffs2; nand erase.part rootfs; nand write.yaffs 30000000 260000 $filesize
设置参数
set 'nand read 30000000 kernel;bootm 30000000'
set bootargs console=ttySAC0,115200 root=/dev/mtdblock3
set machid 16a
save
使用内核补丁:
patch -p1 < ../linux-3.4.2_100ask.patch
cp config_ok .config
make uImage
1.1 修改Makefile
1.2 选择默认配置 : make s3c2410_defconfig
1.3 make uImage
步骤1:
在UBOOT里:
set machid 16a // smdk2440 mach-smdk2440.c
或
set machid 7CF // mini2440 mach-mini2440.c
步骤2:
arch\arm\mach-s3c24xx\mach-smdk2440.c
s3c24xx_init_clocks(16934400);
改为
s3c24xx_init_clocks(12000000);
步骤3:
配置/编译: make s3c2410_defconfig 或 make mini2440_defconfig
make uImage
步骤4:
在uboot里:set bootargs console=ttySAC0,115200 .....
uboot的默认MACH ID:
gd->bd->bi_arch_number = MACH_TYPE_SMDK2410; // 193
如果s = getenv("machid");成功,则使用它
否则使用默认的
set machid 16a // smdk2440 mach-smdk2440.c
set machid 7CF // mini2440 mach-mini2440.c
nfs 32000000 192.168.1.123:/work/nfs_root/uImage_new
bootm 32000000
二. 修改分区, 制作新的文件系统
nfs 30000000 192.168.1.123:/work/nfs_root/fs_mini_mdev.yaffs2
nand erase.part rootfs
nand write.yaffs 30000000 260000 889bc0
nfs 30000000 192.168.1.123:/work/nfs_root/fs_mini_mdev.jffs2
nand erase.part rootfs
nand write.jffs2 30000000 260000 $filesize
set bootargs console=ttySAC0,115200 root=/dev/mtdblock3 rootfstype=jffs2
制作文件系统
1. 交叉编译busybox
安装:make install CONFIG_PREFIX=/work/nfs_root/fs_mini_mdev_new
2. 安装库
mkdir /work/nfs_root/fs_mini_mdev_new/lib
mkdir /work/nfs_root/fs_mini_mdev_new/usr/lib -p
cp /usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/armv4t/lib/*so* /work/nfs_root/fs_mini_mdev_new/lib -d
cp /usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/armv4t/usr/lib/*so* /work/nfs_root/fs_mini_mdev_new/usr/lib -d
3. 构建etc目录
4. 构建dev目录
5. 其他空目录
mkfs.jffs2 -n -s 2048 -e 128KiB -d fs_mini_mdev_new -o fs_mini_mdev_new.jffs2
烧写:
nfs 30000000 192.168.1.123:/work/nfs_root/fs_mini_mdev_new.jffs2
nand erase.part rootfs
nand write.jffs2 30000000 260000 $filesize
set bootargs console=ttySAC0,115200 root=/dev/mtdblock3 rootfstype=jffs2
nfs 32000000 192.168.1.123:/work/nfs_root/uImage_new
bootm 32000000
SIGILL illegal instruction
6. 重新配置内核支持EABI
set bootargs console=ttySAC0,115200 root=/dev/mtdblock3 rootfstype=jffs2
nfs 32000000 192.168.1.123:/work/nfs_root/uImage_eabi
bootm 32000000
三. 移植YAFFS文件系统
1. 获得源码
git clone git://www.aleph1.co.uk/yaffs2
2. 打补丁
cd yaffs-dir
./patch-ker.sh c m linux-tree 比如 ./patch-ker.sh c m /work/system/linux-3.4.2
3. 配置内核支持YAFFS
4. 编译、使用uImage
5. 制作、烧写yaffs映象
mkyaffs2image fs_mini_mdev_new fs_mini_mdev_new.yaffs2
uboot:
nfs 30000000 192.168.1.123:/work/nfs_root/fs_mini_mdev_new.yaffs2
nand erase.part rootfs
nand write.yaffs 30000000 260000 $filesize
6. 启动
set bootargs console=ttySAC0,115200 root=/dev/mtdblock3
nfs 32000000 192.168.1.123:/work/nfs_root/uImage_yaffs
bootm 32000000
7. 没成功,用替代法查找问题
7.1 UBOOT可能有问题:换上1.1.6的UBOOT
tftp 30000000 u-boot.bin
nand erase.part u-boot
nand write 30000000 u-boot
reset
nfs 30000000 192.168.1.123:/work/nfs_root/fs_mini_mdev_new.yaffs2
nand erase rootfs
nand write.yaffs 30000000 260000 $(filesize)
set bootargs console=ttySAC0,115200 root=/dev/mtdblock3
nfs 32000000 192.168.1.123:/work/nfs_root/uImage_yaffs
bootm 32000000
发现1.1.6的UBOOT没问题,所以就是我们移植的新UBOOT有BUG:
drivers\mtd\nand\Nand_util.c
if (!need_skip && !(flags & WITH_DROP_FFS)) {
改为
if (!need_skip && !(flags & WITH_DROP_FFS) && !(flags & WITH_YAFFS_OOB)) {
7.2 YAFFS映象可能有问题
制作了u-boot_new.bin, uImage_new, fs_mini_mdev_new.yaffs
重烧整个系统:
使用jtag工具烧u-boot_new.bin
或使用uboot来更新自己: tftp 30000000 u-boot_new.bin; nand erase.part u-boot; nand write 30000000 u-boot
启动uboot,用它来烧写内核、FS
tftp 30000000 uImage_new; nand erase.part kernel; nand write 30000000 kernel
tftp 30000000 fs_mini_mdev_new.yaffs2; nand erase.part rootfs; nand write.yaffs 30000000 260000 $filesize
设置参数
set 'nand read 30000000 kernel;bootm 30000000'
set bootargs console=ttySAC0,115200 root=/dev/mtdblock3
set machid 16a
save
使用内核补丁:
patch -p1 < ../linux-3.4.2_100ask.patch
cp config_ok .config
make uImage