Gcc 使用-pflash命令执行裸机qemu执行

Gcc 使用-pflash命令执行裸机qemu执行,gcc,arm,qemu,Gcc,Arm,Qemu,我有一个网站,教你如何为versatilePB运行qemu 网站示例使用-kernel选项将二进制图像加载到0x10000中;我只是假设二进制文件在内部通过-kernel加载到0x10000中 这是命令qemu系统arm-M versatilepb-M 128M-kernel test.bin-serial stdio,源代码可以在以下位置找到- ld设置如下所示: ENTRY(_Reset) SECTIONS { . = 0x10000; .startup . : { startup.o(

我有一个网站,教你如何为versatilePB运行
qemu

网站示例使用
-kernel
选项将二进制图像加载到0x10000中;我只是假设二进制文件在内部通过
-kernel
加载到0x10000中

这是命令
qemu系统arm-M versatilepb-M 128M-kernel test.bin-serial stdio
,源代码可以在以下位置找到-

ld设置如下所示:

ENTRY(_Reset)
SECTIONS
{
 . = 0x10000;
 .startup . : { startup.o(.text) } 
 ...
}
.global _Reset
_Reset:
 LDR sp, =stack_top
 BL c_entry
 B . 
volatile unsigned int * const UART0DR = (unsigned int *)0x101f1000;

void print_uart0(const char *s) {
 while(*s != '\0') { /* Loop until end of string */
 *UART0DR = (unsigned int)(*s); /* Transmit char */
 s++; /* Next char */
 }
}

void c_entry() {
 print_uart0("Hello world!\n");
}
启动组件简单如下:

ENTRY(_Reset)
SECTIONS
{
 . = 0x10000;
 .startup . : { startup.o(.text) } 
 ...
}
.global _Reset
_Reset:
 LDR sp, =stack_top
 BL c_entry
 B . 
volatile unsigned int * const UART0DR = (unsigned int *)0x101f1000;

void print_uart0(const char *s) {
 while(*s != '\0') { /* Loop until end of string */
 *UART0DR = (unsigned int)(*s); /* Transmit char */
 s++; /* Next char */
 }
}

void c_entry() {
 print_uart0("Hello world!\n");
}
主c代码(c_条目)如下所示:

ENTRY(_Reset)
SECTIONS
{
 . = 0x10000;
 .startup . : { startup.o(.text) } 
 ...
}
.global _Reset
_Reset:
 LDR sp, =stack_top
 BL c_entry
 B . 
volatile unsigned int * const UART0DR = (unsigned int *)0x101f1000;

void print_uart0(const char *s) {
 while(*s != '\0') { /* Loop until end of string */
 *UART0DR = (unsigned int)(*s); /* Transmit char */
 s++; /* Next char */
 }
}

void c_entry() {
 print_uart0("Hello world!\n");
}
我需要修改代码,使其在启动时不使用
-kernel
,但使用
-pflash
进行模拟,就像从闪存驱动器读取二进制文件一样。这是我试图让它发挥作用的方法:

更改启动程序集和test.ld 我刚刚使用了我的例子的同一作者的另一个例子: 这是启动代码:

.section INTERRUPT_VECTOR, "x"
.global _Reset
_Reset:
  B Reset_Handler /* Reset */
  B . /* Undefined */
  B . /* SWI */
  B . /* Prefetch Abort */
  B . /* Data Abort */
  B . /* reserved */
  B . /* IRQ */
  B . /* FIQ */

Reset_Handler:
  LDR sp, =stack_top
  BL c_entry
  B .
这是test.ld

ENTRY(_Reset)
SECTIONS
{
 . = 0x0;
 .text : {
 startup.o (INTERRUPT_VECTOR)
 *(.text)
 }
 .data : { *(.data) }
 .bss : { *(.bss COMMON) }
 . = ALIGN(8);
 . = . + 0x1000; /* 4kB of stack memory */
 stack_top = .;
}
更新生成代码 在生成test.bin之后,我使用
dd
命令创建了一个flash二进制文件

arm-none-eabi-as -mcpu=arm926ej-s -g startup.s -o startup.o
arm-none-eabi-gcc -c -mcpu=arm926ej-s -g test.c -o test.o
arm-none-eabi-ld -T test.ld test.o startup.o -o test.elf
arm-none-eabi-objcopy -O binary test.elf test.bin
dd if=/dev/zero of=flash.bin bs=4096 count=4096
dd if=test.bin of=flash.bin bs=4096 conv=notrunc
qemu执行 已执行qemu以获取此错误消息

qemu-system-arm -M versatilepb -m 128M  -pflash flash.bin -nographic
>> failed to read the initial flash content
>> Initialization of device cfi.pflash01 failed
可能有什么问题?我上传了示例和示例代码

  • 不使用-pflash:

    • 似乎
      -M
      选项会影响其他选项。 我试着用
      -mconnex
      使用gumstix板,效果很好


      我注意到的另一件事是,使用
      -M versatilepb
      ,我必须使用
      -kernel
      来加载和运行程序

      太多的外部链接,这张罚单对读者来说毫无价值……你是如何生成flash.bin的?@hesham_EE:“更新构建代码”中的最后两行代码做到了这一点。