Hi @danielmartynek
Thank you for the support. The issue is resolved now and the erase operation is working as expected.
I have a few follow-up questions regarding cache usage on S32K3:
- Is there any way to perform flash erase and write operations without using the cache module? Or is cache handling mandatory for reliable operation on this platform?
- If cache must be used, what precautions should be taken while performing flash operations (erase/write)?
- Are there specific steps required before and after flash operations (e.g., cache clean/invalidate)?
- Any recommended sequence from NXP?
- Also, could you please share the pros and cons of enabling cache in such use cases?
Additionally, I have a bootloader and application setup, and I am using the following API to jump from bootloader to application. If cache cannot be excluded, I would like to confirm whether my jump implementation is correct or if any cache-related handling needs to be added.
void JumpToApplication(void)
{
uint32 appStack = *(uint32 *)(APP_STARTADDR);
uint32 func = *(uint32 volatile *)(APP_STARTADDR + 0xC);
func = *(uint32 volatile *)(((uint32)func) + 0x4);
/* Disable all interrupts */
DisableAllInterrupts();
/* Set application's vector table using SCB register */
S32_SCB->VTOR = APP_STARTADDR;
/* Set MSP & PSP */
__asm volatile ("msr msp, %0" :: "r"(appStack));
__asm volatile ("msr psp, %0" :: "r"(appStack));
func = ((((uint32)func) & 0xFFFFFFFEU) | 1U);
(*(void (*)(void))func)();
while (1);
}
static void DisableAllInterrupts(void)
{
for (int i = DMATCD0_IRQn; i <= SoC_IRQn; i++)
{
IntCtrl_Ip_DisableIrq((IRQn_Type)i);
IntCtrl_Ip_ClearPending((IRQn_Type)i);
}
S32_SysTick->CSRr = 0U;
}
Please let me know if any additional steps (especially related to cache, MPU, or barriers) are required before jumping to the application.
Thanks,
Yusup