which contains a call to the SDK which runs from RAM and accesses the Flash which also holds my code.
If I comment out the call to flash_get_unique_id then there is no issue. If I include this line then core 0 signal handler is called with 0xFFFFFFFD and this always seems to happen in the passive idle task.
I have been wondering if the taskENTER_CRITICAL is enough to disable interrupts on both cores and prevent unwanted access to the Flash during my call to read the unique id. I am not sure how these things are related but for cause and effect.
I have also been looking into the configuration and note my config contains
Are you able to call this function without FreeRTOS? May be try calling it from main. Also, can you try to find which fault is triggering and the faulting instruction. This page has some useful details about finding the faulting instruction - Debugging and diagnosing hard faults on ARM Cortex-M CPUs.
I can see your query I give you my best, please see below and follow information…
The taskENTER_CRITICAL() and taskEXIT_CRITICAL() macros are designed to create critical sections by disabling interrupts. However, in an SMP (Symmetric Multi-Processing) system, these macros may not suffice for synchronizing both cores, especially if the FreeRTOS port you’re using does not utilize the configMAX_SYSCALL_INTERRUPT_PRIORITY configuration constant.
The flash_get_unique_id function, which accesses the flash memory, could be causing a hard fault if it’s being called while the flash memory is being accessed or modified by another process or core. This is because the RP2040’s flash memory, where the code resides, cannot be accessed for reading while being written to or erased.
You could consider:
Ensure that the flash_get_unique_id function is not being called from an interrupt service routine (ISR) or that it’s not interrupting any flash operation.
Verify that the configMAX_SYSCALL_INTERRUPT_PRIORITY is set appropriately for your system, which could help in managing interrupt priorities correctly.
Consider using taskENTER_CRITICAL_FROM_ISR() and taskEXIT_CRITICAL_FROM_ISR() if you’re dealing with ISRs.
Review the SMP-specific APIs and configuration options provided by FreeRTOS for multi-core systems.
Check if there’s a need to map certain functions to SRAM to avoid executing from flash during flash operations, as indicated by issues faced in similar environments.