I\'m trying to build a gcc cross compiler on Mac OS X, the target is arm-elf-eabi.
This is what I\'ve done so far:
This is the way how I make the cross compilation on Mac OS X, and execute the qemu to check if it works.
Just follow this instruction - https://github.com/jsnyder/arm-eabi-toolchain
mkdir /opt/arm # and make it writable
PREFIX=/opt/arm PROCS=8 CC=clang make install-cross
PREFIX=/opt/arm PROCS=8 CC=clang make cross-gdb
Check if all the binary files are available.
.text
entry: b start
arr: .byte 1, 2, 3, 4, 5, 6
eoa:
.align
start:
ldr r0, =eoa
ldr r1, =arr
mov r3, #0
loop:
ldrb r2, [r1], #1
add r3, r2, r3
cmp r1, r0
bne loop
stop: b stop
dd if=/dev/zero of=flash.bin bs=4096 count=4096
arm-none-eabi-as --gstabs+ -o add.o add.S
arm-none-eabi-ld -Ttext=0x0 -o add.elf add.o
arm-none-eabi-objcopy -O binary add.elf add.bin
dd if=add.bin of=flash.bin bs=4096 conv=notrunc
Start the qemu
qemu-system-arm -M connex -pflash flash.bin -gdb tcp::1234 -S
Execute the debugger
arm-none-eabi-gdb add.elf
Inside the debugger start the connection
target remote :1234
You can use n to execute the line one by one.
(gdb) target remote :1234
Remote debugging using :1234
entry () at add.S:2
2 entry: b start
(gdb) n
7 ldr r0, =eoa
(gdb) n
8 ldr r1, =arr
(gdb) n
9 mov r3, #0
(gdb) n
11 ldrb r2, [r1], #1
(gdb) n
12 add r3, r2, r3
(gdb) n
13 cmp r1, r0
(gdb) n
14 bne loop
(gdb) n
11 ldrb r2, [r1], #1
(gdb) n
12 add r3, r2, r3
--gstabs+ is the flag to use