gpt4 book ai didi

c - Qemu: fatal: Lockup: cant escalate 3 to Hardfault (Current Priority -1) 错误-Core Dumped

转载 作者:太空狗 更新时间:2023-10-29 12:39:12 25 4
gpt4 key购买 nike

我正在尝试在 QEMU 上使用 cortex M4 处理器模拟 STM32F407XX Controller 。我写的 .ld 文件如下:

ENTRY(_Reset)

MEMORY
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K
PERIPHERALS(rw) : ORIGIN = 0x40000000, LENGTH = 128K
}

SECTIONS
{

.startup . : { stm32.o(.text) } >FLASH
.text : { *(.text) }
.data : { *(.data) } >RAM AT> FLASH
.bss : { *(.bss COMMON) } >RAM
. = ALIGN(4);
. = . + 0x400; /* required amount of stack */
stack_top = 0x20020000;
}

当我生成 .elf 文件并运行代码时,出现错误

Qemu: fatal: Lockup: cant escalate 3 to Hardfault (Current Priority -1) error.
Aborted (Core Dumped)

我感觉是内存问题。我究竟做错了什么?我已经按照STM32F407的引用手册要求分配了flash、RAM内存。

为什么首先会出现此错误?我该如何解决此错误?谢谢。

最佳答案

将 vector 表放在正确的位置解决了这个问题。我在上面的评论中遵循了@peter Maydell 的所有说明。我在这里添加它们。

You can turn on some of the debug logging options of QEMU with -d ('in_asm,int,exec,cpu,guest_errors,unimp' are probably a good set to start with), which will tell you what your guest code is doing. I would start by checking that your ELF file has a vector table in it at the place where QEMU expects to find it. Otherwise QEMU will hard fault immediately out of reset (which is what the hardware does).

The core dump is expected: QEMU goes into lockup, but we don't emulate lockup correctly (strictly speaking QEMU should just sit there doing nothing like the real hardware does), so we print a register dump and abort(). As I said in my previous comment, your problem is almost certainly that your binary doesn't have a vector table.

The main thing you must have in your vector table is the entries for the initial PC and stack pointer. The interrupt and exception entries are worth putting in but will only be needed if there is an interrupt or exception. If you put in debugging handlers for the other faults you'll at least know when you get a fault due to a bug in the rest of your program, though

关于c - Qemu: fatal: Lockup: cant escalate 3 to Hardfault (Current Priority -1) 错误-Core Dumped,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55220313/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com