我需要在手臂上运行helloworld。我启动:
$ arm-none-eabi-g++ -mthumb -mcpu=cortex-m3 -c test.cpp -o test
$ file test
test: ELF 32-bit LSB relocatable, ARM, EABI5 version 1 (SYSV), not stripped
$ qemu-arm test <br>
Error while loading test: Permission denied
qemu-system-arm -machine help
...
lm3s811evb Stellaris LM3S811EVB
...
从LM3S811数据表或查看QEMU ARM硬件上的Stellaris Backend的来源。UART0基础地址为0x4000c000,数据(RX和TX)寄存器为Offset 0x000。从经验来看,QEMU后端往往不会为TX缓冲区忙而打扰...
flash.s
.cpu cortex-m0
.thumb
.thumb_func
.global _start
_start:
.word 0x20001000
.word reset
.word hang
.word hang
.word hang
.word hang
.word hang
.thumb_func
reset:
bl notmain
b hang
.thumb_func
hang: b .
.thumb_func
.globl PUT32
PUT32:
str r1,[r0]
bx lr
uart01.c
void PUT32 ( unsigned int, unsigned int );
#define UART0BASE 0x4000C000
int notmain ( void )
{
unsigned int rx;
for(rx=0;rx<7;rx++)
{
PUT32(UART0BASE+0x00,0x30+rx);
}
return(0);
}
flash.ld
MEMORY
{
rom : ORIGIN = 0x00000000, LENGTH = 0x1000
ram : ORIGIN = 0x20000000, LENGTH = 0x1000
}
SECTIONS
{
.text : { *(.text*) } > rom
.rodata : { *(.rodata*) } > rom
.bss : { *(.bss*) } > ram
}
是的,Stellaris是您可以购买的第一个硅中的Cortex-M3,我指定了Cortex-M0。基本上可以防止Thumb2扩展或大多数。更多便携式,如果需要的话,可以很容易地更改它。
arm-none-eabi-as --warn -mcpu=cortex-m0 flash.s -o flash.o
arm-none-eabi-gcc -Wall -O2 -nostdlib -nostartfiles -ffreestanding -mcpu=cortex-m0 -mthumb -c uart01.c -o uart01.o
arm-none-eabi-ld -o uart01.elf -T flash.ld flash.o uart01.o
arm-none-eabi-objdump -D uart01.elf > uart01.list
arm-none-eabi-objcopy uart01.elf uart01.bin -O binary
然后
qemu-system-arm -M lm3s811evb -m 16K -nographic -kernel uart01.bin
,输出为
0123456
ctrl-a,然后按x退出qemu。或
qemu-system-arm -M lm3s811evb -m 16K -kernel uart01.bin
然后ctrl-alt-3(3不是F3),串行控制台随串行输出弹出。当您关闭该串行控制台QEMU关闭时。
我想记住有人告诉我Qemu Cortex-M3支持不太好。
正常的手臂芯应经过良好的测试,因为它们用于用于各种手臂目标板的交叉编译。不确定哪些内核的测试良好,但是如果您像手臂一样启动,但剩下的拇指可以做拇指的东西,用
启动.globl _start
_start:
b reset
b hang
b hang
b hang
reset:
mov sp,#0x20000
bl notmain
hang:
b hang
机器
versatilepb ARM Versatile/PB (ARM926EJ-S)
在0x101f1000处有其UART,所以
for(ra=0;;ra++)
{
ra&=7;
PUT32(0x101f1000,0x30+ra);
}
可以使用
构建您的应用ARM -NONE -AEBI -GCC -WALL -O2 -NOSTDLIB -NOSTARTFIELS -FFREESTANDING -MCPU = ARM7TDMI -MTHUMB -C UART01.C -O UART01.O
将您的链接脚本更改为所有基于RAM的。
MEMORY
{
ram : ORIGIN = 0x00000000, LENGTH = 32K
}
SECTIONS
{
.text : { *(.text*) } > ram
.bss : { *(.text*) } > ram
}
,然后
qemu-system-arm -M versatilepb -m 128M -nographic -kernel hello.bin
(嗯,这是在0x0000的加载,还是0x8000?,不应该太难找出)
您可以获得Cortex-M的拇指感觉(M0基本上不是M3,您可以找到ARMV7-A机器,您可能可以运行Thumb2构建的代码(仍然像ARM一样靴子,而不是Cortex-M))。例如
realview-pb-a8 ARM RealView Platform Baseboard for Cortex-A8
可能几乎可以按原样使用newlib,需要更改CRT0.S或如今所谓的任何东西,就像臂那样启动臂而不是皮层M。其余的可以使用ARMV7M构建,从理论上讲将起作用。
和或从Stellaris开始,只需对您的真正目标做出自己的HW支持,并在发现问题时修复Cortex-M3核心。