Hi
I found after CSEC_DRV_Init() function called, Flash Drv functions don't work.
I tried csec_keyconfig_s32k144 example project.
And I add some flash drv code for test.
And I run this project in Debug_Flash mode.
when I run 'Flash_DRV_EraseSector()', this exception is occurred.
And when I run this project in Debug_RAM mode, it just works normally.
Plus when I don't excecute 'CSEC_DRV_Init', it also works normally.
I already tried 'CSEC_DRV_Deinit'. But same exception was occurred.
** Secure Boot is activated on my board. **
Thanks
Best Regards
Phillip
Solved! Go to Solution.
Hi Phillip,
the CSEc driver uses OSIF for timeouts. You can check the source code.
To disable Systick, you can use:
S32_SysTick->CSR = S32_SysTick_CSR_ENABLE(0u) | S32_SysTick_CSR_TICKINT(0u);
To disable/enable interrupts, you can use:
ENABLE_INTERRUPTS(); // or __asm("cpsie i");
DISABLE_INTERRUPTS(); // or __asm("cpsid i");
Regards,
Lukas
Hi Phillip,
the problem is that CSEC_DRV_Init() starts the OSIF / Systick. Erase operation takes relatively a lot of time, so OSIF / Systick interrupt is triggered during the erase. If you run the code from RAM, it is not problem. If you run the code from flash, it leads to read-while-write error because it is not possible to access the program flash during erase operation.
Solution is to disable interrupts by PRIMASK during the erase or disable OSIF / Systick.
Regards,
Lukas
Hi Lukas.
Thank you so much for your reply.
I have two more questions.
1. Does CSEC use OSIF? Why?
When I delete the "OSIF_TimeDelay(0U);" in "CSEC_DRV_Init", Flashing works well.
2. Can you please let me know how to disable interrupts by PRIMASK during the erase
or disable OSIF / Systick?
Thanks
Best Regards
Phillip
Hi Phillip,
the CSEc driver uses OSIF for timeouts. You can check the source code.
To disable Systick, you can use:
S32_SysTick->CSR = S32_SysTick_CSR_ENABLE(0u) | S32_SysTick_CSR_TICKINT(0u);
To disable/enable interrupts, you can use:
ENABLE_INTERRUPTS(); // or __asm("cpsie i");
DISABLE_INTERRUPTS(); // or __asm("cpsid i");
Regards,
Lukas