嵌入式linux系统由linux内核与根文件系统两部分构成,两者缺一不可。
制作嵌入式平台使用的linux内核,方法和制作pc平台的linux内核基本一致,下面使用对比的方式介绍如何制作用于OK6410开发板的内核。
1. 清除原有配置与中间文件
x86: make distclean
arm: make distclean
2. 配置内核
x86: make menuconfig 后面默认加了ARCH=i386
arm: make menuconfig ARCH=arm
解压linux-2.6.36.tar.gz :
tar zxvf linux-2.6.36.tar.gz
cd linux-2.6.36
make s3c6400_defconfig ARCH=arm
(在linux-2.6.36/arch/arm/configs/下面有很多开发板的默认配置文件,利用这个命令就可以在一些开发板的出厂配置文件基础上进行配置)
make menuconfig ARCH=arm
System Type -->
ARM system type --->
3. 编译内核
x86: make bzImage
arm: make uImage ARCH=arm CROSS_COMPILE=arm-linux-
===========================================================================================
arch/arm/mach-s3c64xx/built-in.o: In function `smdk6410_machine_init':
/forlinux/work/kernel/linux-2.6.36/arch/arm/mach-s3c64xx/mach-smdk6410.c:916: undefined reference to `s3c_ts_set_platdata'
arch/arm/mach-s3c64xx/built-in.o:(.init.data+0x288): undefined reference to `s3c_device_ts'
arch/arm/mach-s3c64xx/built-in.o:(.init.data+0x298): undefined reference to `s3c_device_tvenc'
arch/arm/mach-s3c64xx/built-in.o:(.init.data+0x29c): undefined reference to `s3c_device_tvscaler'
arch/arm/mach-s3c64xx/built-in.o:(.init.data+0x2a0): undefined reference to `s3c_device_vpp'
arch/arm/mach-s3c64xx/built-in.o:(.init.data+0x2a4): undefined reference to `s3c_device_mfc'
arch/arm/mach-s3c64xx/built-in.o:(.init.data+0x2a8): undefined reference to `s3c_device_rotator'
arch/arm/mach-s3c64xx/built-in.o:(.init.data+0x2ac): undefined reference to `s3c_device_jpeg'
arch/arm/mach-s3c64xx/built-in.o:(.init.data+0x2b0): undefined reference to `s3c_device_g2d'
arch/arm/mach-s3c64xx/built-in.o:(.init.data+0x2b4): undefined reference to `s3c_device_g3d'
make: *** [.tmp_vmlinux1] Error 1
[root@localhost linux-2.6.36]# make menuconfig ARCH=arm
scripts/kconfig/mconf arch/arm/Kconfig
*** End of Linux kernel configuration.
*** Execute 'make' to build the kernel or try 'make help'.
[root@localhost linux-2.6.36]#
============================================================================================
[root@localhost linux-2.6.36]# vim /forlinux/work/kernel/linux-2.6.36/arch/arm/mach-s3c64xx/mach-smdk6410.c
打开这个文件,将里面的这些都注释掉
// s3c_ts_set_platdata(&s3c_ts_platform);
// &s3c_device_ts,
//// &s3c_device_tvenc,
//// &s3c_device_tvscaler,
//// &s3c_device_vpp,
//// &s3c_device_mfc,
//// &s3c_device_rotator,
//// &s3c_device_jpeg,
//// &s3c_device_g2d,
//// &s3c_device_g3d,
然后编译:
为什么会出现如下的错误呢:
mkimage" command not found - U-Boot images will not be built
Image arch/arm/boot/uImage is ready
因为使用make uImage编译生成的内核能由uboot引导,编译时会用到mkimage工具,出现这种错误是因为编译器无法找到mkimage工具,该工具在uboot/tools目录下,以下两种方法可以解决问题:
方法一:在/etc/bashrc的末行加入以下语句:
export PATH:=$PATH:[uboot所在目录]/tools
方法二:将uboot/tools目录下的mkimage文件拷备到交叉编译环境的BIN目录:
cd [uboot所在目录]/tools
cp mkimage /usr/local/arm/3.4.1/bin
在红帽下测试:
如果在Ubuntu下编译内核uImage出现
"mkimage" command not found - U-Boot images will not be built问题
解决方法:
如果使用的是Ubuntu 9.10及以上版本,可以使用下面的命令安装mkimage:
#apt-get install uboot-mkimage 当然也可以按照上面拷贝工具的方法来解决。
安装完成后在编译内核make umage ARCH=arm CROSS_COMPILE=arm-linux-,就可以生成uImage文件