20.3.3 测试工程框架
工程框架配置修改完毕后,需要进行简单的测试,根据测试结果判断框架是否搭建成功。回到内核代码顶层目录,输入make ARCH=arm CROSS_COMPILE=arm-linux- menuconfig命令,出现内核设置图形界面。
在内核配置界面选择Load an Alternate Configuration File菜单,进入后输入“arch/arm/ configs/s3c2410_defconfig”命令,确定后会加载s3c2410默认的配置文件。加载默认配置文件的好处是已经经过验证,用户只需要在默认配置文件的基础上修改自己的配置,减轻了配置的工作量。
加载默认配置文件后,可以开始配置新增加的菜单。进入System Types菜单项,打开S3C24XX Implementations菜单,出现一个目标开发板的列表:
[ ] Simtec Electronics BAST (EB2410ITX)
[ ] IPAQ H1940
[ ] Acer N30
[ ] SMDK2410/A9M2410
[ ] SMDK2440
[ ] AESOP2440
[ ] QQ2440/mini2440
[ ] Thorcom VR1000
[ ] HP iPAQ rx3715
[ ] NexVision OTOM Board
[ ] NexVision NEXCODER 2440 Light Board
[ ] mini2440
列表最后一项是在20.3.1节中添加的mini2440菜单项。把光标移到mini2440菜单项使用回车选中。选择mini2440开发板完毕后,保存退出内核配置界面。在命令行输入“make ARCH=arm CROSS_COMPILE=arm-linux- bzImage”命令编译内核代码。请注意,此时编译内核代码可能会有好多的错误,并且不会编译通过,问题是虽然建立了目标板工程框架,但是在源代码文件中没有任何内容。下面是在笔者机器上报错的部分信息提示:
arch/arm/kernel/traps.c: In function '__bug':
arch/arm/kernel/traps.c:627: warning: 'noreturn' function does return
kernel/intermodule.c:179: warning: 'inter_module_register' is deprecated (declared at kernel/intermodule.c:38)
kernel/intermodule.c:180: warning: 'inter_module_unregister' is deprecated (declared at kernel/intermodule.c:79)
kernel/intermodule.c:182: warning: 'inter_module_put' is deprecated (declared at kernel/intermodule.c:160)
fs/yaffs2/yaffs_fs.c:198: warning: initialization from incompatible pointer type
fs/yaffs2/yaffs_fs.c:228: warning: initialization from incompatible pointer type
fs/yaffs2/yaffs_fs.c:229: warning: initialization from incompatible pointer type
fs/yaffs2/yaffs_fs.c: In function 'yaffs_proc_write':
fs/yaffs2/yaffs_fs.c:1865: warning: 'len' might be used uninitialized in this function
fs/yaffs2/yaffs_fs.c: At top level:
fs/yaffs2/yaffs_fs.c:1305: warning: 'yaffs_do_sync_fs' defined but not used
fs/yaffs2/yaffs_guts.c: In function 'yaffs_ObjectHasCachedWriteData':
fs/yaffs2/yaffs_guts.c:2997: warning: unused variable 'cache'
fs/yaffs2/yaffs_guts.c: In function 'yaffs_Scan':
fs/yaffs2/yaffs_guts.c:4490: warning: unused variable 'hl'
fs/yaffs2/yaffs_qsort.c:77:1: warning: "min" redefined
In file included from fs/yaffs2/yportenv.h:35,
from fs/yaffs2/yaffs_qsort.c:30:
include/linux/kernel.h:243:1: warning: this is the location of the previous definition
drivers/char/keyboard.c:1018:2: warning: #warning "Cannot generate rawmode keyboard for your architecture yet."
drivers/net/dm9000x.c: In function 'dmfe_probe':
drivers/net/dm9000x.c:288: warning: assignment makes integer from pointer without a cast
drivers/serial/serial_core.c:2427: warning: 'uart_register_port' is deprecated (declared at drivers/serial/serial_core.c:2348)
drivers/serial/serial_core.c:2428: warning: 'uart_unregister_port' is deprecated (declared at drivers/serial/serial_core.c:2405)
从报错信息看,主要集中在函数未定义和函数重定义两种错误。在编译的时候提示出错的函数名称需要关注,可能需要在新增的代码文件中重新定义或者调用。内核编译会出错退出,报错信息如下:
arm-linux-ld:arch/arm/kernel/vmlinux.lds:815: parse error
make: *** [.tmp_vmlinux1] Error 1
该信息提示解析arch/arm/kernel/vmlinux.lds文件第815行出错,出现该错误表示已经完成内核代码编译,在链接代码时产生问题,在后面章节会详细分析出错原因。
到目前为止,向内核新增的代码框架已经可以正常工作,第20.4节将介绍如何编写对应开发板的代码。