s32k144 CSEC_DRV_Init SDK function question

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

s32k144 CSEC_DRV_Init SDK function question

Jump to solution
1,115 Views
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 Kudos
1 Solution
1,088 Views
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

View solution in original post

0 Kudos
3 Replies
1,107 Views
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 Kudos
1,101 Views
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 Kudos
1,089 Views
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 Kudos