Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4890

SDK • Re: Panic function

$
0
0
Could I ask should the system be running after the hard fault? The display is up and showing information however system isn't in usable a reset is required to get things going. I'm not expecting to recover from a hard fault I just want to be sure what I see is what I should see.
I guess that depends upon what is causing the hard fault. On PicoBB, it is usually a stack overrun or unaligned memory access. In those cases PicoBB recovers and keeps on running.

It is possible I introduced an error in simplifying stack_trap. For debugging it might be worth setting a break on your version of crash_report and find out what happens when that routine returns (and therefore where core 0 is locking up).

Also, set a break point on stack_trap, note what the register values are on entry, then continue into crash_report and check that it is displaying the correct values. A break on stack_trap is also good for identifying the cause of a hard fault. Do a back trace as soon as the break occurs, and that will usually identify the cause.
Now that I have these two amazing features I need to make the report a little meaningful at least for me. I'm not looking to solve why my code is currently going into a hard fault but I'd like when I generate the report to flag values that may be out of range. To that end I just want to know should the PSP be pointing to a RAM or Flash address? I see it right now pointing to 0x49100200 I'm guessing that is the problem. The PC should also point to either a RAM or Flash address? what about LR? I'm good friends with SP my memory manager keeps an eye that address doesn't get too low.

Basically if there are expected ranges for values I want to colour them when they are not what they should be so it's quick to see where the problem may be.
The expected address ranges are documented in section 2.2 of the RP2040 datasheet:
ROM0x00000000
XIP0x10000000
SRAM0x20000000
APB Peripherals0x40000000
AHB-Lite Peripherals0x50000000
IOPORT Registers0xd0000000
Cortex-M0+ internal registers0xe0000000
See the datasheet for more detailed ranges.

Edit: As an aside, for your application stack_trap should probably be renamed fault_trap.

Statistics: Posted by Memotech Bill — Wed Jan 15, 2025 7:46 am



Viewing all articles
Browse latest Browse all 4890

Trending Articles