编译linux-3.6内核:
安装交叉编译工具:arm-linux-gnueabi-gcc
下载并解压linux-3.6源码
清楚源码中的无用的编译文件:makeclean清除除了config之外的所有编译出来的文档,makemrproper将配置的config也一并清除掉
配置内核(选择编译的版本):makemenuconfig ARCH=arm
编译内核:make-j4 ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-
谨慎使用make clean命令
错误总结:
q1:
drivers/i2c/busses/i2c-piix4.c:551:9:error: implicit declaration of function ‘kzalloc’[-Werror=implicit-function-declaration]
adap =kzalloc(sizeof(*adap), GFP_KERNEL);
^
drivers/i2c/busses/i2c-piix4.c:551:7:warning: assignment makes pointer from integer without a cast[-Wint-conversion]
adap =kzalloc(sizeof(*adap), GFP_KERNEL);
^
drivers/i2c/busses/i2c-piix4.c:561:11:warning: assignment makes pointer from integer without a cast[-Wint-conversion]
adapdata =kzalloc(sizeof(*adapdata), GFP_KERNEL);
^
drivers/i2c/busses/i2c-piix4.c:563:3:error: implicit declaration of function ‘kfree’[-Werror=implicit-function-declaration]
kfree(adap);
^
cc1: some warningsbeing treated as errors
make[3]: ***[drivers/i2c/busses/i2c-piix4.o] Error 1
make[2]: ***[drivers/i2c/busses] Error 2
make[1]: ***[drivers/i2c] Error 2
make[1]: *** Waitingfor unfinished jobs....
make: *** [drivers]Error 2
解决办法:找到出现错误的源文件drivers/i2c/busses/i2c-piix4.c,在头文件中添加一个#include
q2:
lib/mpi/generic_mpih-mul1.o:In function `mpihelp_add_1':
/home/mrk/Projects/linux-3.6/lib/mpi/mpi-inline.h:39:multiple definition of `mpihelp_add_1'
lib/mpi/generic_mpih-lshift.o:/home/mrk/Projects/linux-3.6/lib/mpi/mpi-inline.h:39:first defined here
/home/mrk/Projects/linux-3.6/lib/mpi/mpi-inline.h:110:multiple definition of `mpihelp_sub'
lib/mpi/generic_mpih-lshift.o:/home/mrk/Projects/linux-3.6/lib/mpi/mpi-inline.h:110:first defined here
make[2]: ***[lib/mpi/mpi.o] Error 1
make[1]: ***[lib/mpi] Error 2
make: *** [lib]Error 2
解决办法:
引起原因是由于GNU90和C99不兼容的问题,解决办法:将/mpi/mpi-inline.h头文件中extentinline替换成staticinline
q3
drivers/scsi/osd/osd_initiator.c:In function ‘build_test’:
drivers/scsi/osd/osd_initiator.c:68:2:error: size of unnamed array is negative
BUILD_BUG_ON(sizeof(struct osdv2_cdb) != OSD_TOTAL_CDB_LEN);
^
drivers/scsi/osd/osd_initiator.c:69:2:error: size of unnamed array is negative
BUILD_BUG_ON(sizeof(struct osdv1_cdb) != OSDv1_TOTAL_CDB_LEN);
^
make[3]: ***[drivers/scsi/osd/osd_initiator.o] Error 1
make[2]: ***[drivers/scsi/osd] Error 2
make[2]: *** Waitingfor unfinished jobs.…
解决办法:
将drivers/scsi/osd/osd_initiator.c:中68、69注释掉(方法待定,不确定是否以后会不会遇到问题)
后来历经周折终于编译通过了,特此声明:以上的问题都不是问题,如果您也遇到了以上的问题,那么就说明是您的内核版本,交叉编译工具版本,和主机内核版本之间不兼容。
后来我选择则ubuntu-14.04(内核版本3.13.8)作为主机,编译的内核版本linux-3.13.8,交叉编译工具的版本是4.8,顺利完成编译:
您顶多会遇到上边这个问题,那是因为uboot中制作uimage的工具没有找到,
安装一下再次编译:
编译完成: