HOSTLD scripts/kconfig/conf # # configuration written to .config # 生成了一个.config文件。 vi .config # # Automatically generated file; DO NOT EDIT. # Linux/arm 3.4.2 Kernel Configuration # CONFIG_ARM=y CONFIG_HAVE_PWM=y CONFIG_SYS_SUPPORTS_APM_EMULATION=y CONFIG_GENERIC_GPIO=y CONFIG_ARCH_USES_GETTIMEOFFSET=y CONFIG_KTIME_SCALAR=y CONFIG_HAVE_PROC_CPU=y CONFIG_NO_IOPORT=y CONFIG_STACKTRACE_SUPPORT=y CONFIG_HAVE_LATENCYTOP_SUPPORT=y CONFIG_LOCKDEP_SUPPORT=y CONFIG_TRACE_IRQFLAGS_SUPPORT=y CONFIG_HARDIRQS_SW_RESEND=y CONFIG_GENERIC_IRQ_PROBE=y CONFIG_RWSEM_GENERIC_SPINLOCK=y CONFIG_ARCH_HAS_CPUFREQ=y CONFIG_ARCH_HAS_CPU_IDLE_WAIT=y CONFIG_GENERIC_HWEIGHT=y CONFIG_GENERIC_CALIBRATE_DELAY=y .config 文件里是前一个命令生成的一些配置项。
1.1将arch/arm/mach-s3c24xx/mach-smdk2440.c中的:s3c24xx_init_clocks(16934400); 修改为: s3c24xx_init_clocks(12000000); vi arch/arm/mach-s3c24xx/mach-smdk2440.c
2.现在试着make zImage 看看能不能支持开发板。 make zImage arch/arm/mm/tlb-v4wbi.S: Assembler messages: arch/arm/mm/tlb-v4wbi.S:64: Error: too many positional arguments 但出现了错误,编译没有通过。上网没有查到解决问题。 那试试换一下交叉编译连,是不是交叉编译连太老了? [root@localhost linux-3.4.2]# arm-linux-gcc -v Reading specs from /home/hyx/gcc-3.4.5-glibc-2.3.6/bin/../lib/gcc/arm-linux/3.4.5/specs Configured with: /work/tools/create_crosstools/crosstool-0.43/build/arm-linux/gcc-3.4.5-glibc-2.3.6/gcc-3.4.5/configure --target=arm-linux --host=i686-host_pc-linux-gnu --prefix=/work/tools/gcc-3.4.5-glibc-2.3.6 --with-float=soft --with-headers=/work/tools/gcc-3.4.5-glibc-2.3.6/arm-linux/include --with-local-prefix=/work/tools/gcc-3.4.5-glibc-2.3.6/arm-linux --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c,c++ --enable-shared --enable-c99 --enable-long-long Thread model: posix gcc version 3.4.5 这个是原来的交叉编译版本。 在韦东山的资料D:\韦东山Linux视频驱动第2期\韦东Linux视频第1第2期所有源码文档图片芯片手册(1)\韦东Linux视频第1第2期所有源码文档图片芯片手册\毕业班_文档_图片_源码_bin\中找到了arm-linux-gcc-4.3.2.tar.bz2交叉编译工具 并复制到E:\ARM6410实验资料hyx\6410实验源码包hyx后上传到虚拟机。
2.1 解压、编译、安装交叉编译连arm-linux-gcc-4.3.2.tar.bz2 tar -vxf arm-linux-gcc-4.3.2.tar.bz2 但这个是解压到了/home/hyx/usr/local/arm/4.3.2下 现在将其解压到根目录下 tar -xjf arm-linux-gcc-4.3.2.tar.bz2 -C / ps:查看现在命令的环境变量路径 [root@localhost hyx]# echo $PATH /usr/lib/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/home/hyx/gcc-3.4.5-glibc-2.3.6/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin 修改环境变量: 方法1:(强烈推荐) [root@localhost bin]# export PATH=/usr/local/arm/4.3.2/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin [root@localhost bin]# arm-linux-gcc -v 方法2: vi /etc/profile # Path manipulation if [ "$EUID" = "0" ]; then pathmunge /sbin pathmunge /usr/sbin pathmunge /usr/local/sbin pathmunge /home/hyx/usr/local/arm/4.3.2/bin/ fi wq 退出 source /etc/profile arm-linux-gcc -v 显示: Thread model: posix gcc version 4.3.2 (Sourcery G++ Lite 2008q3-72)
2.2 ok到此为止,交叉编译连准备好了。开始再次编译新内核3.4.2。 make zImage Kernel: arch/arm/boot/zImage is ready /home/hyx/u-boot-1.1.6/tools/mkimage -A arm -O linux -C none -a 0x30008000 -e 0x30008000 -d arch/arm/boot/zImage arch/arm/boot/uImage nfs 30000000 10.1.30.111:/home/hyx/linux-3.4.2-hyx/linux-3.4.2/arch/arm/boot/uImage OK2440_hyx_2.3#bootm ## Booting image at 30000000 ... Image Name: Created: 2014-07-29 9:16:01 UTC Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 2399720 Bytes = 2.3 MB Load Address: 30008000 Entry Point: 30008000 Verifying Checksum ... OK OK
Starting kernel ...
Uncompressing Linux... done, booting the kernel. undefined instruction pc : [<30192e0c>] lr : [<3010800c>] sp : 307f7aa8 ip : 4000001c fp : 00000020 r10: 305ac524 r9 : 41129200 r8 : 30000100 r7 : 0000016a r6 : 307f6a88 r5 : 00000000 r4 : 30108000 r3 : 0000016a r2 : c05bf540 r1 : 4000001c r0 : 0000016a Flags: nZCv IRQs on FIQs on Mode UK12_32 Resetting CPU ... 出现如上错误信息。 /**********************************************************/ 2014/7/30 9:40:13 参考 http://blog.csdn.net/liangkaiming/article/details/5986680 http://blog.csdn.net/subfate/article/details/6228730 修改: /home/hyx/u-boot-1.1.6/tools/mkimage -A arm -O linux -C none -a 0x30008000 -e 0x30008000 -d arch/arm/boot/zImage arch/arm/boot/uImage nfs 30000000 10.1.30.111:/home/hyx/linux-3.4.2-hyx/linux-3.4.2/arch/arm/boot/uImage bootm 最终还是不可以正常启动!!!反复查阅源代码还是找不到问题出现的地方!! 猜测是uboot版本太低的缘故,接下来准备移植较新的uboot版本。 uboot移植过程请查阅《2014-arm-u-boot-2012.04.01移植for2440.txt》。 /****************************************************************************/ 2014/8/6 16:15:39 u-boot-2012.04.01移植for2440已完成 接下来再看看打印信息: nfs 30000000 10.1.30.111:/home/hyx/linux-3.4.2-hyx/linux-3.4.2/arch/arm/boot/uImage Bytes transferred = 2399784 (249e28 hex) ok2440-hyx-uboot-v7.3# bootm ## Booting kernel from Legacy Image at 30000000 ... Image Name: Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 2399720 Bytes = 2.3 MiB Load Address: 30008000 Entry Point: 30008000 Verifying Checksum ... OK Loading Kernel Image ... OK OK
Starting kernel ...
Uncompressing Linux... done, booting the kernel. 这里是什么错误信息没有提示,但没有进入内核而是重新启动。 分析uboot引导内核流程: do_bootm boot_fn = boot_os[images.os.os]; static boot_os_fn *boot_os[] = { #ifdef CONFIG_BOOTM_LINUX [IH_OS_LINUX] = do_bootm_linux, do_bootm_linux boot_jump_linux unsigned long machid = gd->bd->bi_arch_number; s = getenv("machid"); r2 = gd->bd->bi_boot_params; kernel_entry(0, machid, r2); // void (*kernel_entry)(int zero, int arch, uint params); /****************************************************************************/ 2014/8/7 10:02:32 再重新试下载镜像 nfs 32000000 10.1.30.111:/home/hyx/linux-3.4.2-hyx/linux-3.4.2/arch/arm/boot/uImage bootm 32000000 结果还是不行!! 试重新制作uImag镜像:之前的镜像是用u-boot-1.1.6制作的。 cd /home/hyx/linux-3.4.2-hyx/linux-3.4.2/arch/arm/boot/ /home/hyx/u-boot-2012.04.01-hyx/u-boot-2012.04.01/tools/mkimage -A arm -O linux -C none -a 0x30108000 -e 0x30108000 -d arch/arm/boot/zImage arch/arm/boot/uImage 还是不行啊~~~~ 删除文件,重新重头开始编译。 1.0 解压tar xzvf linux-3.4.2.tar.gz -C ./linux-3.4.2-hyx/ chmod 777 linux-3.4.2/ -R 1.1 修改Makefile cd linux-3.4.2/ 修改:ARCH ?= $(SUBARCH) CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%) 为ARCH ?= arm CROSS_COMPILE ?= arm-linux- 1.2 选择默认配置 : make s3c2410_defconfig 1.3 修改时钟; arch\arm\mach-s3c24xx\mach-smdk2440.c s3c24xx_init_clocks(16934400); 改为 s3c24xx_init_clocks(12000000); 1.4 制作镜像: make zImage /home/hyx/u-boot-2012.04.01-hyx/u-boot-2012.04.01/tools/mkimage -A arm -O linux -C none -a 0x30108000 -e 0x30108000 -d arch/arm/boot/zImage arch/arm/boot/uImage cp arch/arm/boot/uImage arch/arm/boot/uImage-v1.0 1.5 nfs下载到开发板启动: nfs 32000000 10.1.30.111:/home/hyx/linux-3.4.2-hyx/linux-3.4.2/arch/arm/boot/uImage-v1.0 bootm 32000000 OK
2.1.5 构建etc目录、构建dev目录、其他空目录 拷贝已有的目录: cp ../fs_mini_hyx/etc ./ -rf [root@localhost etc]# cd .. [root@localhost fs_mini_mdev_new_hyx]# ls bin etc lib linuxrc sbin usr [root@localhost fs_mini_mdev_new_hyx]# mkdir dev [root@localhost fs_mini_mdev_new_hyx]# cd dev/ [root@localhost dev]# ls [root@localhost dev]# mknod console c 5 1 [root@localhost dev]# mknod null c 1 3 [root@localhost fs_mini_mdev_new_hyx]# mkdir proc mnt tmp sys root 2.1.6 1.移植YAFFS文件系统,www.aleph1.co.uk/yaffs2 文件存在路径:D:\韦东山Linux视频驱动第2期\韦东Linux视频第1第2期所有源码文档图片芯片手册(1) \韦东Linux视频第1第2期所有源码文档图片芯片手册\毕业班_文档_图片_源码_bin\毕业班第3课移植新内核_文档_图片_补丁_二进制程序 \用git下载的yaffs最新源码 yaffs2.tar.bz2 解压 tar xjvf yaffs2.tar.bz2 2. 打补丁
cd yaffs-dir ./patch-ker.sh c m /home/hyx/linux-3.4.2-hyx/linux-3.4.2
3. 配置内核支持YAFFS File systems ---> [*] Miscellaneous filesystems ---> <*> yaffs2 file system support 4. 编译 make zImage 出现错误: fs/yaffs2/yaffs_vfs.c:440: warning: initialization from incompatible pointer type fs/yaffs2/yaffs_vfs.c:445: warning: initialization from incompatible pointer type fs/yaffs2/yaffs_vfs.c:447: warning: initialization from incompatible pointer type fs/yaffs2/yaffs_vfs.c: In function 'yaffs_mtd_put_super': fs/yaffs2/yaffs_vfs.c:2514: error: 'struct mtd_info' has no member named 'sync' fs/yaffs2/yaffs_vfs.c:2515: error: 'struct mtd_info' has no member named 'sync' fs/yaffs2/yaffs_vfs.c: In function 'yaffs_internal_read_super': ........ ........ 通过建立其source insight工程查询代码: mtd->sync struct mtd_info *mtd void (*_sync) (struct mtd_info *mtd); mtd_info结构体里是带下划线的_ 后面的错误也是这样修改。 fs/yaffs2/yaffs_vfs.c:2967 root = d_make_root(inode); // d_alloc_root(inode); 编译: make zImage fs/yaffs2/yaffs_mtdif.c: In function 'nandmtd_erase_block': fs/yaffs2/yaffs_mtdif.c:42: error: 'struct mtd_info' has no member named 'erase' make[2]: *** [fs/yaffs2/yaffs_mtdif.o] Error 1 加下划线 编译: make zImage fs/yaffs2/yaffs_mtdif1.c: In function 'nandmtd1_write_chunk_tags': fs/yaffs2/yaffs_mtdif1.c:138: error: 'struct mtd_info' has no member named 'write_oob' fs/yaffs2/yaffs_mtdif1.c: In function 'nandmtd1_read_chunk_tags': fs/yaffs2/yaffs_mtdif1.c:200: error: 'struct mtd_info' has no member named 'read_oob' fs/yaffs2/yaffs_mtdif1.c:223: error: 'struct mtd_info' has no member named 'block_isbad' fs/yaffs2/yaffs_mtdif1.c: In function 'nandmtd1_mark_block_bad': fs/yaffs2/yaffs_mtdif1.c:291: error: 'struct mtd_info' has no member named 'block_markbad' fs/yaffs2/yaffs_mtdif1.c: In function 'nandmtd1_query_block': fs/yaffs2/yaffs_mtdif1.c:341: error: 'struct mtd_info' has no member named 'block_isbad' make[2]: *** [fs/yaffs2/yaffs_mtdif1.o] Error 1 加下划线 编译: make zImage 又出现如上错,同样修改方法。 /home/hyx/u-boot-2012.04.01-hyx/u-boot-2012.04.01/tools/mkimage -A arm -O linux -C none -a 0x30108000 -e 0x30108000 -d arch/arm/boot/zImage arch/arm/boot/uImage cp arch/arm/boot/uImage arch/arm/boot/uImage-v2.0 5. 制作、烧写yaffs映象 [root@localhost nfs_root_hyx]# mkyaffs2image fs_mini_mdev_new_hyx fs_mini_new.yaffs2 uboot: nfs 30000000 10.1.30.111:/home/hyx/nfs_root_hyx/fs_mini_new.yaffs2 nand erase.part rootfs nand write.yaffs 30000000 260000 $filesize
启动: nfs 32000000 10.1.30.111:/home/hyx/linux-3.4.2-hyx/linux-3.4.2/arch/arm/boot/uImage-v2.0 bootm 32000000 错误: yaffs: dev is 32505859 name is "mtdblock3" rw yaffs: passed flags "" VFS: Mounted root (yaffs filesystem) on device 31:3. Freeing init memory: 172K Kernel panic - not syncing: No init found. Try passing init= option to kernel. See Linux Documentation/init.txt for guidance. Backtrace: [] (dump_backtrace+0x0/0x10c) from [] (dump_stack+0x18/0x1c)
发现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)) {
编译
make distclean
make smdk2440-hyx_config
make
cp u-boot.bin u-boot-v7.4.bin
再次烧录yaffs文件
nfs 30000000 10.1.30.111:/home/hyx/nfs_root_hyx/fs_mini_new.yaffs2
nand erase.part rootfs
nand write.yaffs 30000000 260000 $filesize
烧uImage镜像试启动:
nfs 32000000 10.1.30.111:/home/hyx/linux-3.4.2-hyx/linux-3.4.2/arch/arm/boot/uImage-v2.0
bootm 32000000
错误:
yaffs: dev is 32505859 name is "mtdblock3" rw
yaffs: passed flags ""
VFS: Mounted root (yaffs filesystem) on device 31:3.
Freeing init memory: 172K
Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000004
Backtrace:
[] (dump_backtrace+0x0/0x10c) from [] (dump_stack+0x18/0x1c)
r6:c3819d60 r5:c05a6b14 r4:c05a6b14
[] (dump_stack+0x0/0x1c) from [] (panic+0x7c/0x1d0)
解决办法:重新配置内核支持EABI
make menuconfig
Kernel Features --->
[*] Use the ARM EABI to compile the kernel
[*] Allow old ABI binaries to run with this kernel (EXPERIMENTAL)
编译:
make zImage
/home/hyx/u-boot-2012.04.01-hyx/u-boot-2012.04.01/tools/mkimage -A arm -O linux -C none -a 0x30108000 -e 0x30108000 -d arch/arm/boot/zImage arch/arm/boot/uImage
cp arch/arm/boot/uImage arch/arm/boot/uImage-v2.1
烧uImage镜像试启动:
nfs 32000000 10.1.30.111:/home/hyx/linux-3.4.2-hyx/linux-3.4.2/arch/arm/boot/uImage-v2.1
bootm 32000000
启动成功!!!
drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
ALSA device list:
No soundcards found.
yaffs: dev is 32505859 name is "mtdblock3" rw
yaffs: passed flags ""
VFS: Mounted root (yaffs filesystem) on device 31:3.
Freeing init memory: 164K
试使用补丁:
[root@localhost linux-3.4.2]# patch -p1 <../linux-3.4.2-hyx-v1.0.diff
[root@localhost linux-3.4.2]# cp ../config-hyx-3.4.2 .config
make zImage
试烧打补丁后的uImage镜像试启动:
/home/hyx/u-boot-2012.04.01-hyx/u-boot-2012.04.01/tools/mkimage -A arm -O linux -C none -a 0x30108000 -e 0x30108000 -d arch/arm/boot/zImage arch/arm/boot/uImage
nfs 32000000 10.1.30.111:/home/hyx/linux-3.4.2/arch/arm/boot/uImage
bootm 32000000
启动成功!!!
4.移植网卡
修改:Mach-smdk2440.c (linux-3.4.2\arch\arm\mach-s3c24xx) 4283 2014/8/7
添加修改:
/*
* The DM9000 has no eeprom, and it's MAC address is set by
* the bootloader before starting the kernel.
*/
/* DM9000AEP 10/100 ethernet controller */