浅析如何配置下载的2.6.30.4内核实现arm交叉编译出ep9312标准开发板内核zImage
1.下载解压linux-2.6.30.4.tar.bz2
luther@gliethttp:/luther/works$ wget
luther@gliethttp:/luther/works$ tar jxvf linux-2.6.30.4.tar.bz2
2.修改Makefile,使其支持arm编译
luther@gliethttp:/luther/works/linux-2.6.30.4$ vim Makefile
修改SUBARCH和CROSS_COMPILE
第173行 SUBARCH := arm
第194行 CROSS_COMPILE ?= arm-none-eabi-
也可以不用修改,直接使用下面方式make传递上面2个变量值
luther@gliethttp:/luther/works/linux-2.6.30.4$ make SUBARCH=arm CROSS_COMPILE=arm-linux- ep93xx_defconfig
3.编译相应arm处理器芯片对应的标准开发板默认配置
arch/arm/configs下为所有能够使用上的arm处理器标准开发板对应的config配置信息.
luther@gliethttp:/luther/works/linux-2.6.30.4$ ll arch/arm/configs/ep93xx_defconfig
-rw-r--r-- 1 luther luther 26K 2009-07-31 06:34 arch/arm/configs/ep93xx_defconfig
luther@gliethttp:/luther/works/linux-2.6.30.4$ make ep93xx_defconfig
这样将在当前目录生成一个.config文件,这个文件就是即将执行make编译的zImage内核所有配置信息文件.
以后使用make menuconfig作的所有改动,也都直接回写到.config文件中[luther.gliethttp]
luther@gliethttp:/luther/works/linux-2.6.30.4$ ll .config
-rw-r--r-- 1 luther luther 36K 2009-08-03 11:12 .config
luther@gliethttp:/luther/works/linux-2.6.30.4$ make menuconfig
"System Type" ==> "Cirrus EP93xx Implementation Options" ==>
只选中"Support for MaverickCrunch"和Support Cirrus Logic EDB9312"
保存退出.
如果不执行make menuconfig去掉其他开发板的支持,那么默认编译的是
"System Type" ==> "Cirrus EP93xx Implementation Options" ==>
中的第1个开发板配置"Support ADS Sphere",所以反汇编之后得到的machine_desc的.nr为723,而不是
ep9312对应的451,#define MACH_TYPE_EDB9312 451
c0008344: c001bdb0 strgth fp, [r1], -r0
c0008348: c0008348 andgt r8, r0, r8, asr #6
c000834c: c001bdb0 strgth fp, [r1], -r0
c0008350: c001bf50 andgt fp, r1, r0, asr pc
c0008354 <__lookup_machine_type>:
c0008354: e24f3014 sub r3, pc, #20 ; 0x14 // 从当前pc回数20个字节,即
c0008358: e8930070 ldmia r3, {r4, r5, r6} // 所以r4等于c0008348
c000835c: e0433004 sub r3, r3, r4 // r5 = c001bdb0
c0008360: e0855003 add r5, r5, r3 // r6 = c001bf50
c0008364: e0866003 add r6, r6, r3
c0008368: e5953000 ldr r3, [r5] // 所以取出虚拟地址c001bdb0数据
c001bdb0 <__arch_info_begin>:
c001bdb0: 000002d3 ldreqd r0, [r0], -r3 // 0x2d3等于723,所以这里可以看出错了,
c001bdb4: 80800000 addhi r0, r0, r0
c001bdb8: 00003fb4 streqh r3, [r0], -r4
c001bdbc: c02d7f20 eorgt r7, sp, r0, lsr #30
c001bdc0: 00000100 andeq r0, r0, r0, lsl #2
经过上面make menuconfig之后,再来看看反汇编.
反汇编可以得到machine_desc的.nr
c0008344: c001ba18 andgt fp, r1, r8, lsl sl
c0008348: c0008348 andgt r8, r0, r8, asr #6
c000834c: c001ba18 andgt fp, r1, r8, lsl sl
c0008350: c001ba4c andgt fp, r1, ip, asr #20
c0008354 <__lookup_machine_type>:
c0008354: e24f3014 sub r3, pc, #20 ; 0x14 // 从当前pc回数20个字节,即
c0008358: e8930070 ldmia r3, {r4, r5, r6} // r4 = c0008348, r5 = c001ba18, r6 = c001ba4c
c000835c: e0433004 sub r3, r3, r4
c0008360: e0855003 add r5, r5, r3
c0008364: e0866003 add r6, r6, r3
c0008368: e5953000 ldr r3, [r5] // 所以取出虚拟地址c001ba18数据
c001ba18 <__arch_info_begin>:
c001ba18: 000001c3 andeq r0, r0, r3, asr #3 // 0x1c3 = 451,所以等于MACH_TYPE_EDB9312
c001ba1c: 80800000 addhi r0, r0, r0
c001ba20: 00003fb4 streqh r3, [r0], -r4
c001ba24: c02d6cd0 ldrgtd r6, [sp], -r0
c001ba28: 00000100 andeq r0, r0, r0, lsl #2
4.开始编译内核
luther@gliethttp:/luther/works/linux-2.6.30.4$ make -j4 clean
luther@gliethttp:/luther/works/linux-2.6.30.4$ make -j4 zImage
luther@gliethttp:/luther/works/linux-2.6.30.4$ ll arch/arm/boot/zImage
-rwxr-xr-x 1 luther luther 1.6M 2009-08-03 11:17 arch/arm/boot/zImage
5.编译modules模块
luther@gliethttp:/luther/works/linux-2.6.30.4$ make -j4 modules
6.将编译出来的所有modules释放到指定目录
luther@gliethttp:/luther/works/linux-2.6.30.4$ make -j4 modules_install INSTALL_MOD_PATH=/vobs/gliethttp
luther@gliethttp:/luther/works/linux-2.6.30.4$ tree /vobs/gliethttp
/vobs/gliethttp
`-- lib
`-- modules
`-- 2.6.30.4
|-- build -> /luther/works/linux-2.6.30.4
|-- kernel
| `-- drivers
| `-- scsi
| `-- scsi_wait_scan.ko
|-- modules.alias
|-- modules.ccwmap
|-- modules.dep
|-- modules.ieee1394map
|-- modules.inputmap
|-- modules.isapnpmap
|-- modules.ofmap
|-- modules.order
|-- modules.pcimap
|-- modules.seriomap
|-- modules.symbols
|-- modules.usbmap
`-- source -> /luther/works/linux-2.6.30.4
8 directories, 13 files
luther@gliethttp:/luther/works/linux-2.6.30.4$
当然也可以直接make -j4一次性编译出所有内容.
可以配置脚本make之后直接将zImage拷贝到tftp目录,
luther@gliethttp:/vobs/works/linux-2.6.30.4$ vim arch/arm/boot/Makefile
$(obj)/zImage: $(obj)/compressed/vmlinux FORCE
$(call if_changed,objcopy)
@echo ' Kernel: $@ is ready'
@cp $(obj)/zImage /vobs/tftp-dir // 追加该行,将自动将zImage拷贝到/vobs/tftp-dir下
然后redboot直接loade -v -r -b 0x800000 zImage 即可下载,然后exec -r 0x800000 -s 0x600000运行kernel
make V=1 zImage 加入V=1可以将编译log打印很全,
也可以直接使用make CROSS_COMPILE=arm-none-eabi-来提供CROSS_COMPILE交叉编译器变量给Makefile.[luther.gliethttp]
PS: 编译2.6内核需要arm-none-eabi-gcc 4.3.3版本或者arm-linux-gcc 3.4.1版本
3.3.2用于编译busybox,所以需要严格按照相应版本编译相应软件,否则会提示如下错误:
arch/arm/kernel/crunch-bits.S: Assembler messages:
arch/arm/kernel/crunch-bits.S:140: Error: Maverick MVFX register expected -- `cfmv32sc mvdx0,dspsc'
arch/arm/kernel/crunch-bits.S:149: Error: Maverick MVFX register expected -- `cfmvsc32 dspsc,mvdx0'
make[1]: *** [arch/arm/kernel/crunch-bits.o] Error 1
阅读(1341) | 评论(0) | 转发(0) |