s32k144 CSEC_DRV_Init SDK function question

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

s32k144 CSEC_DRV_Init SDK function question

跳至解决方案
2,094 次查看
kmh48301
Contributor IV

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.

 

kmh48301_1-1629174933781.png

And I run this project in Debug_Flash mode.

when I run 'Flash_DRV_EraseSector()', this exception is occurred.

kmh48301_2-1629175084671.png

 

 

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

0 项奖励
回复
1 解答
2,067 次查看
lukaszadrapa
NXP TechSupport
NXP TechSupport

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

在原帖中查看解决方案

0 项奖励
回复
3 回复数
2,086 次查看
lukaszadrapa
NXP TechSupport
NXP TechSupport

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

0 项奖励
回复
2,080 次查看
kmh48301
Contributor IV

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

0 项奖励
回复
2,068 次查看
lukaszadrapa
NXP TechSupport
NXP TechSupport

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

0 项奖励
回复