Linux 上带有 Cortex-M4 的 qemu-arm
qemu-arm with Cortex-M4 on Linux
我正在使用 qemu-arm 和 ARM Workbench IDE 到 run/profile 一个用 armcc/armlink 构建的 ARM 二进制文件(一个 .axf 文件,程序用 C 编写)。这适用于 Cortex-A9 和 ARM926/ARM5TE。但是,无论我尝试过什么,当为 Cortex-M4 构建二进制文件时,它都不起作用。当 M4 选择为 CPU.
时,模拟器和 qemu-arm 都会挂起
我知道这个处理器需要一些额外的启动代码,但我可以找到任何关于如何获得它的综合教程 运行ning。有谁知道如何做到这一点?我有一个相当大的项目,只有一个主要功能,但如果一个“hello world”或一些带参数的简单程序 运行.
就已经很有帮助了
这是我在 Cortex-A9 上使用的命令行:
qemu-system-arm -machine versatileab -cpu cortex-a9 -nographic -monitor null -semihosting -append 'some program arguments' -kernel program.axf
我不知道如何用 versatilepb 做到这一点,它没有“正常工作”,但这确实有效:
flash.s
.thumb
.thumb_func
.global _start
_start:
stacktop: .word 0x20001000
.word reset
.word hang
.thumb_func
reset:
bl notmain
b hang
.thumb_func
hang: b .
.thumb_func
.globl PUT32
PUT32:
str r1,[r0]
bx lr
notmain.c
void PUT32 ( unsigned int, unsigned int );
#define UART0BASE 0x4000C000
int notmain ( void )
{
unsigned int rx;
for(rx=0;rx<8;rx++)
{
PUT32(UART0BASE+0x00,0x30+(rx&7));
}
return(0);
}
flash.ld
ENTRY(_start)
MEMORY
{
rom : ORIGIN = 0x00000000, LENGTH = 0x1000
ram : ORIGIN = 0x20000000, LENGTH = 0x1000
}
SECTIONS
{
.text : { *(.text*) } > rom
.rodata : { *(.rodata*) } > rom
.bss : { *(.bss*) } > ram
}
(我被告知入口点是拇指函数地址是关键 YMMV)
arm-none-eabi-as --warn --fatal-warnings -mcpu=cortex-m3 flash.s -o flash.o
arm-none-eabi-gcc -Wall -O2 -ffreestanding -mcpu=cortex-m3 -mthumb -c notmain.c -o notmain.o
arm-none-eabi-ld -nostdlib -nostartfiles -T flash.ld flash.o notmain.o -o notmain.elf
arm-none-eabi-objdump -D notmain.elf > notmain.list
arm-none-eabi-objcopy -O binary notmain.elf notmain.bin
检查向量table,等等
00000000 <_start>:
0: 20001000
4: 0000000d
8: 00000013
0000000c <reset>:
c: f000 f804 bl 18 <notmain>
10: e7ff b.n 12 <hang>
00000012 <hang>:
12: e7fe b.n 12 <hang>
看起来不错。
和运行它
qemu-system-arm -M lm3s811evb -m 8K -nographic -kernel notmain.bin
01234567
然后ctrl-a然后x退出
QEMU: Terminated
-cpu cortex-m4 工作正常。必须尝试找到 m3 和 m4 之间可能出现在像这样的 sim 中的不同之处,然后从那里开始。
在 Luminary Micro(不久前被 ti 收购)之后,我认为没有其他人会为一台机器付出努力。但是正如本站点至少一个问题中已经讨论的那样,您可以 运行 核心(reader 的练习)。
多用途pb
int notmain ( void )
{
unsigned int ra;
for(ra=0;;ra++)
{
ra&=7;
PUT32(0x101f1000,0x30+ra);
}
return(0);
}
qemu-system-arm -machine versatileab -cpu cortex-m4 -nographic -monitor null -kernel notmain.elf
qemu-system-arm: This board cannot be used with Cortex-M CPUs
您不能随意将不同的 CPU 类型插入 Arm 板型号。如果您尝试它,那么生成的系统可能会运气好,或者可能会崩溃,或者有奇怪的行为;在某些情况下,-cpu 选项将被忽略。这是因为 CPU 与板的集成很重要:中断控制器之类的东西是板的一部分,而不是 CPU,但并非所有 CPU 都适用于所有中断控制器。通常,QEMU 在检测和报告无效用户选项的错误方面不如它应有的好。
在这种情况下,您可能使用的是较旧的 QEMU:较新的 QEMU 将正确报告:
qemu-system-arm: This board cannot be used with Cortex-M CPUs
如果您尝试将“-machine versatilepb”与“-cpu cortex-m4”一起使用。年纪大的会崩溃或行为不端。
通常最好的办法是使用板子默认的 CPU 类型(即不指定 -cpu 选项),除了“virt”之外的每个板子类型木板。如果您想为 Cortex-M4 编写代码,您应该寻找具有 Cortex-M4 的板类型。 mps2-an386
可能是一个不错的选择。 (如果您的 QEMU 没有那种板类型,请升级到更新的板:无论如何,已经有很多您想要的 M-profile 仿真错误修复。)
我正在使用 qemu-arm 和 ARM Workbench IDE 到 run/profile 一个用 armcc/armlink 构建的 ARM 二进制文件(一个 .axf 文件,程序用 C 编写)。这适用于 Cortex-A9 和 ARM926/ARM5TE。但是,无论我尝试过什么,当为 Cortex-M4 构建二进制文件时,它都不起作用。当 M4 选择为 CPU.
时,模拟器和 qemu-arm 都会挂起我知道这个处理器需要一些额外的启动代码,但我可以找到任何关于如何获得它的综合教程 运行ning。有谁知道如何做到这一点?我有一个相当大的项目,只有一个主要功能,但如果一个“hello world”或一些带参数的简单程序 运行.
就已经很有帮助了这是我在 Cortex-A9 上使用的命令行:
qemu-system-arm -machine versatileab -cpu cortex-a9 -nographic -monitor null -semihosting -append 'some program arguments' -kernel program.axf
我不知道如何用 versatilepb 做到这一点,它没有“正常工作”,但这确实有效:
flash.s
.thumb
.thumb_func
.global _start
_start:
stacktop: .word 0x20001000
.word reset
.word hang
.thumb_func
reset:
bl notmain
b hang
.thumb_func
hang: b .
.thumb_func
.globl PUT32
PUT32:
str r1,[r0]
bx lr
notmain.c
void PUT32 ( unsigned int, unsigned int );
#define UART0BASE 0x4000C000
int notmain ( void )
{
unsigned int rx;
for(rx=0;rx<8;rx++)
{
PUT32(UART0BASE+0x00,0x30+(rx&7));
}
return(0);
}
flash.ld
ENTRY(_start)
MEMORY
{
rom : ORIGIN = 0x00000000, LENGTH = 0x1000
ram : ORIGIN = 0x20000000, LENGTH = 0x1000
}
SECTIONS
{
.text : { *(.text*) } > rom
.rodata : { *(.rodata*) } > rom
.bss : { *(.bss*) } > ram
}
(我被告知入口点是拇指函数地址是关键 YMMV)
arm-none-eabi-as --warn --fatal-warnings -mcpu=cortex-m3 flash.s -o flash.o
arm-none-eabi-gcc -Wall -O2 -ffreestanding -mcpu=cortex-m3 -mthumb -c notmain.c -o notmain.o
arm-none-eabi-ld -nostdlib -nostartfiles -T flash.ld flash.o notmain.o -o notmain.elf
arm-none-eabi-objdump -D notmain.elf > notmain.list
arm-none-eabi-objcopy -O binary notmain.elf notmain.bin
检查向量table,等等
00000000 <_start>:
0: 20001000
4: 0000000d
8: 00000013
0000000c <reset>:
c: f000 f804 bl 18 <notmain>
10: e7ff b.n 12 <hang>
00000012 <hang>:
12: e7fe b.n 12 <hang>
看起来不错。
和运行它
qemu-system-arm -M lm3s811evb -m 8K -nographic -kernel notmain.bin
01234567
然后ctrl-a然后x退出
QEMU: Terminated
-cpu cortex-m4 工作正常。必须尝试找到 m3 和 m4 之间可能出现在像这样的 sim 中的不同之处,然后从那里开始。
在 Luminary Micro(不久前被 ti 收购)之后,我认为没有其他人会为一台机器付出努力。但是正如本站点至少一个问题中已经讨论的那样,您可以 运行 核心(reader 的练习)。
多用途pb
int notmain ( void )
{
unsigned int ra;
for(ra=0;;ra++)
{
ra&=7;
PUT32(0x101f1000,0x30+ra);
}
return(0);
}
qemu-system-arm -machine versatileab -cpu cortex-m4 -nographic -monitor null -kernel notmain.elf
qemu-system-arm: This board cannot be used with Cortex-M CPUs
您不能随意将不同的 CPU 类型插入 Arm 板型号。如果您尝试它,那么生成的系统可能会运气好,或者可能会崩溃,或者有奇怪的行为;在某些情况下,-cpu 选项将被忽略。这是因为 CPU 与板的集成很重要:中断控制器之类的东西是板的一部分,而不是 CPU,但并非所有 CPU 都适用于所有中断控制器。通常,QEMU 在检测和报告无效用户选项的错误方面不如它应有的好。
在这种情况下,您可能使用的是较旧的 QEMU:较新的 QEMU 将正确报告:
qemu-system-arm: This board cannot be used with Cortex-M CPUs
如果您尝试将“-machine versatilepb”与“-cpu cortex-m4”一起使用。年纪大的会崩溃或行为不端。
通常最好的办法是使用板子默认的 CPU 类型(即不指定 -cpu 选项),除了“virt”之外的每个板子类型木板。如果您想为 Cortex-M4 编写代码,您应该寻找具有 Cortex-M4 的板类型。 mps2-an386
可能是一个不错的选择。 (如果您的 QEMU 没有那种板类型,请升级到更新的板:无论如何,已经有很多您想要的 M-profile 仿真错误修复。)