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

SDK • Re: Panic function

$
0
0
Okay I see

I'm getting an error just adding a header

Code:

fatal error: hardware/exception.h: No such file or directory   11 | #include "hardware/exception.h"
You need to include hardware_exception as one of your link libraries.
As far as the assemble code goes I'm out of my depth there, the comment explain what is going on but I'm not that versed enough to understand how to change it.
I think you can simplify stack_guard to:

Code:

void __attribute__((used,naked)) stack_trap(void)    {asm volatile(        "   push    {r0-r3}         \n\t"   // Save R0-R3 on original stack        "   mov     r0, sp          \n\t"   // Get stack pointer        "   adr     r1, 2f          \n\t"   // Address of data block        "   push    {r4-r7}         \n\t"   // Save R4-R7        "   mov     r4, r8          \n\t"   // Copy R8-R11 to R4-R7        "   mov     r5, r9          \n\t"        "   mov     r6, r10         \n\t"        "   mov     r7, r11         \n\t"        "   push    {r4-r7}         \n\t"   // Save R8-R11        "   mov     r4, r12         \n\t"   // Copy R12 to R4        "   mov     r5, lr          \n\t"   // Copy LR to R5        "   push    {r4-r5}         \n\t"   // Save them        "   ldm     r0!, {r4-r7}    \n\t"   // Retrieve R0-R3 from original stack        "   push    {r4-r7}         \n\t"   // Save them on the new stack        "   ldm     r0!, {r4-r7}    \n\t"   // Retrieve R0-R3 from exception frame        "   push    {r4-r7}         \n\t"   // Save them on the new stack        "   ldm     r0!, {r4-r7}    \n\t"   // Retrieve R12, LR, PC & PSP from exception frame        "   push    {r0,r4-r7}      \n\t"   // Save Original SP, R12, LR, PC & PSP to stack        "   mov     r0, sp          \n\t"   // R0 = Location of saved data        "   ldm     r1!, {r2-r4}    \n\t"   // Load next three words from data block        "   mov     r5, #0          \n\t"   // Create dummy exception frame        "   push    {r2-r3}         \n\t"   // PC = stack_report, PSP = Thread mode, Thumb        "   push    {r5}            \n\t"   // LR = 0        "   push    {r5}            \n\t"   // R12 = 0        "   push    {r5}            \n\t"   // R3 = 0        "   push    {r5}            \n\t"   // R2 = 0        "   push    {r5}            \n\t"   // R1 = 0        "   push    {r0}            \n\t"   // R0 = 0        "   bx      r4              \n\t"   // Exception return: Thread mode, main stack        "   .align  2               \n\t"        "2: .word   crash_report    \n\t"   // Address of crash_report routine        "   .word   0x1000000       \n\t"   // PSP = Thread mode, Thumb        "   .word   0xFFFFFFF9      \n\t"   // Exception return: Thread mode, main stack        );    }    

Statistics: Posted by Memotech Bill — Tue Jan 14, 2025 7:50 pm



Viewing all articles
Browse latest Browse all 4816

Trending Articles