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

SDK • Re: Panic function

$
0
0
Yes I need to do a renaming and tidy for sure.

I'm not sure why the code I've got generates faults like crazy, I'm thinking it's most likely because it's test code and not an actual project.

I'm using the RP2350 I looked through the memory portion of the data sheet. I seem to remember there was a memory map graphic somewhere? Right now I'm just trying to understand what each register is and what it's for. I am not afraid to admit I'm not sure what they are all for.

Good to know that it maybe possible to recover from a hard fault. I'm going to have the code drop to a fault screen and reset to continue will be required. Panics are not common on my projects it's nice to know I can catch them now as well and carry on.

My suspicion is that there is unaligned memory going on. There was a warning from tinyUSB code

Code:

 /pico-sdk/lib/tinyusb/src/osal/osal_pico.h:120:25: warning: taking address of packed member of 'struct <anonymous>' may result in an unaligned pointer value [-Waddress-of-packed-member]  120 |   critical_section_init(&qdef->critsec);
To fix thewarnings like this(from pico-sdk/lib/tinyusb/src/osal/osal_pico.h):

Code:

pico-sdk/lib/tinyusb/src/osal/osal_pico.h:147:25: warning: taking address of packed member of 'struct <anonymous>' may result in an unaligned pointer value [-Waddress-of-packed-member]  147 |   critical_section_exit(&qhdl->critsec);      |                         ^~~~~~~~~~~~~~
I added an aligned attribute to a struct real quick
Lines 105-108 of pico-sdk/lib/tinyusb/src/osal/osal_pico.h

Code:

typedef struct {  tu_fifo_t ff;  struct critical_section critsec; // osal_queue may be used in IRQs, so need critical section} __attribute__((aligned(4))) osal_queue_def_t;  // Align to 4 bytes__attribute__((aligned(4)))
was added... hopefully it doesn't break funcionality
I've made this change as well

Statistics: Posted by DarkElvenAngel — Wed Jan 15, 2025 11:41 pm



Viewing all articles
Browse latest Browse all 4151

Trending Articles