ARM926EJ-Sid的交叉编译

时间:2013-10-09 01:01:22

标签: gcc arm cross-compiling

我的最终目标是为我的NAS编译rtorrent,这是一台Synology DS107 +。为了熟悉交叉编译,我想编译一个helloworld。对我来说这已经成了一个新手的障碍。

执行程序会导致分段错误。我使用gcc-arm-none-eabi在Ubuntu x84_64上编译它。

为目标编译程序需要哪些工具?我还咨询了"Cross compile from linux to ARM-ELF (ARM926EJ-S/MT7108)"并需要workaround,因为gcc抱怨没有声明_exit。

以下是更详细的信息:

的/ proc内/ cpuinfo

Processor   : ARM926EJ-Sid(wb) rev 0 (v5l)
BogoMIPS    : 499.71
Features    : swp half thumb fastmult vfp edsp 
CPU implementer : 0x41
CPU architecture: 5TEJ
CPU variant : 0x0
CPU part    : 0x926
CPU revision    : 0
Cache type  : write-back
Cache clean : cp15 c7 ops
Cache lockdown  : format C
Cache format    : Harvard
I size      : 32768
I assoc     : 1
I line length   : 32
I sets      : 1024
D size      : 32768
D assoc     : 4
D line length   : 32
D sets      : 256

Hardware    : MV-88fxx81
Revision    : 0000
Serial      : 0000000000000000

uname -a

Linux DiskStation 2.6.15 #1637 Sat May 4 05:59:19 CST 2013
armv5tejl GNU/Linux synology_88f5281_107+

dmesg (来自头部的片段似乎对我有用)

Linux version 2.6.15 (root@build2) (gcc version 3.4.3 (CSL 2005Q1B) (Marvell 2006Q3))
#1637 Sat May 4 05:59:19 CST 2013
CPU: ARM926EJ-Sid(wb) [41069260] revision 0 (ARMv5TEJ)
Machine: MV-88fxx81
...
Synology Hareware Version: DS107v20
Memory policy: ECC disabled, Data cache writeback
...
CPU0: D VIVT write-back cache
CPU0: I cache: 32768 bytes, associativity 1, 32 byte lines, 1024 sets
CPU0: D cache: 32768 bytes, associativity 4, 32 byte lines, 256 sets

readelf -h busybox (从设备中取出)

ELF Header:
Magic:   7f 45 4c 46 01 01 01 61 00 00 00 00 00 00 00 00 
Class:                             ELF32
Data:                              2's complement, little endian
Version:                           1 (current)
OS/ABI:                            ARM
ABI Version:                       0
Type:                              EXEC (Executable file)
Machine:                           ARM
Version:                           0x1
Entry point address:               0x8de0
Start of program headers:          52 (bytes into file)
Start of section headers:          1319468 (bytes into file)
Flags:                             0x602, has entry point, GNU EABI, software FP, VFP
Size of this header:               52 (bytes)
Size of program headers:           32 (bytes)
Number of program headers:         3
Size of section headers:           40 (bytes)
Number of section headers:         20
Section header string table index: 19

编辑:命令行

我使用了选项-march=armv5te -mtune=arm926ej-s -mno-long-calls -msoft-float -static。我还尝试通过 mcpu 取消 march oder替换 mtune 。如果没有 static ,则说找不到。还尝试了-mfpu=vfp和Debian软件包的armel二进制文件。例如 busybox-static 在我的HTC Desire S(armv7l)上正常运行,也会导致段错误。

使用:

  • arm-linux-gnueabi-gcc→细分错误
  • arm-none-eabi-gcc→分段错误(或非法指令,但很少,无法判断何时)
  • 尚未尝试过CodeBench。

我尝试的代码是:

# include <stdlib.h>

void _exit (int x) { while (1) {} } // only needed for arm-none-eabi-gcc

int main (int argc, char* argv[]) {
    return 47;
}

0 个答案:

没有答案