Use FlexSPI while decrypted with OTFAD

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

Use FlexSPI while decrypted with OTFAD

1,633 Views
LeslieLee
Contributor III

Hello,

I am using RT1011 chip in my project, and there is a feature where user can store their own file in the external flash.

But there is a problem where the FlexSPI cannot be used when I want to use OTFAD to decrypt the program.

I think the program failed to continue when it goes into the function FLEXSPI_Init. When I used a while(1) loop before this function Jlink can connect to the running target. But when I try to put the while(1) loop after or the first line of the FLEXSPI_Init function, Jlink failed to connect the target.

As the program is in XIP mode, so all the code related to FlexSPI operation is allocated in the ITCM. Also like the previous post and application note state the frequency adjustment code should not be encrypted, all the clock code is also allocated in the ITCM.

I use the MCUXpresso linkscripts function to allocate the code in ITCM,

data.ldt:

 <#if memory.name=="SRAM_ITC">
*file_system.o(.text*)
*flash_program.o(.text*)
*fsl_flexspi.o(.text*)
*clock_config.o(.text*)
*fsl_clock.o(.text*)
*tusb_board.o(.text*)
*fsl_iomuxc.o(.text*)
</#if>

main_text.ldt:

 *(EXCLUDE_FILE(*flash_program.o *fsl_flexspi.o *file_system.o *clock_config.o *fsl_clock.o *tusb_board.o *fsl_iomuxc.o) .text*)

So is that we are not allowed to use FlexSPI to operate the external flash when we using OTFAD?

Or there is some special setting for FlexSPI in order to use OTFAD at the same time?

Thanks

0 Kudos
6 Replies

1,626 Views
mjbcswitzerland
Specialist V

Hi

OTFAD can be turned off and on on-the-fly so if you are running code in ITC you can temporarily disable the OTFAD in case is is still causing any restrictions.

Regards

Mark
[uTasker project developer for Kinetis and i.MX RT]
Contact me by personal message or on the uTasker web site to discuss professional training, solutions to problems or rapid product development requirements

For professionals searching for faster, problem-free Kinetis and i.MX RT 10xx developments the uTasker project holds the key: https://www.utasker.com/iMX/RT1010.html

 

0 Kudos

1,611 Views
LeslieLee
Contributor III

You mean clear the GE flag of OTFAD CR register to turn off OTFAD?

I tried to execute OTFAD->CR &= ~OTFAD_CR_GE(1U); to turn off OTFAD but after the execution the OTFAD CR register still have GE flag set, showing this operation is not valid.

May I know what is the proper operation for turning off OTFAD?

Also may I know exactly what FlexSPI operation will crash OTFAD? As I am using FreeRTOS in the mean time, I afraid the context switch kicks in when I turned off the OTFAD, so it is better for me to only turn off OTFAD on problematic FlexSPI operation.

Thanks for the help!

0 Kudos

1,608 Views
mjbcswitzerland
Specialist V

Hi

The GE bit can be used to enable and disable OTFAD operation.

During ITC operation to do things that can't be done when OTFAD is operating you will certainly have to disable interrupts so that context switches are blocked and generally to ensure no interrupt are taken that could try to run in QSPI.

Regards

Mark

0 Kudos

1,605 Views
LeslieLee
Contributor III

Hi

The problem now I faced is even I clear GE bit with that code, the GE bit still unchange.

And when I try to manually change the GE bit through the peripheral register window, also doesn't work.

So is there any setting need to be done before turn off the GE bit?

Thanks

0 Kudos

1,601 Views
LeslieLee
Contributor III

Okay I think I found the reason why I cant set GE to 0, it looks like the OTFAD_ENABLE fuse is burnt to 1, and GE or OTFAD_ENABLE value control the OTFAD activation, so I think I can't turn off OTFAD through code.

Is there another way to temporarily turn off OTFAD without operating GE bit?

0 Kudos

1,595 Views
mjbcswitzerland
Specialist V

Hi

The OTFAD has two areas that it can decrypt in. If the GE is fixed by eFuse you may still be able to disable the regions being used by changing its start and end addresses.
Eg set OTFAD_CTX0_RGD_W1 to be the same as OTFAD_CTX0_RGD_W0 so that the region has a size of 0.

I use the uTasker security concept which simplifies the standard method and adds more flexibility so don't need to set eFuses (with associated restrictions). Also the method is compatible on parts with OTFAD and BEE so doesn't need different methods (from the user's perspective) when changing between i.MX RT part). More details below.

Regards

Mark

 


- Boot loader concept including XiP on-the-fly decryption, clone protection or AES256 protected RAM execution.
-- Boot Loader concept flow chart: https://www.utasker.com/docs/iMX/Loader.pdf and usage reference https://www.utasker.com/docs/iMX/uTaskerLoader_TestDrive.pdf
-- Serial Loader features: https://www.utasker.com/docs/uTasker/uTaskerSerialLoader.pdf
-- Building the loader with MCUXpresso: https://www.utasker.com/docs/iMX/MCUXpresso.pdf (and video guide https://youtu.be/p_eUGo6GypY ) - the guide document explains how to use with any application (eg. SDK) and to enabling its operation with On-The-Fly decryption in 5 minutes
-- Building the loader with IAR: https://www.utasker.com/docs/iMX/IAR.pdf (and video guide https://youtu.be/XPCwVndP99s )
-- Building the loader with VisualStudio and GCC: https://www.utasker.com/docs/iMX/GCC.pdf (and video guide https://youtu.be/0UzLLSXABK8 )
Video Guide to encrypting NXP SDK examples to run from XiP memory using on-the-fly decryption and uploading with the µTasker loader: https://www.youtube.com/watch?v=5iT7KP691ls&list=PLWKlVb_MqDQEOCnsNOJO8gd3jDCwiyKKe&index=10
Video Guide to encrypting NXP SDK examples to run at optimal speed in internal RAM and uploading with the µTasker loader:
https://www.youtube.com/watch?v=fnfLQ-nbscI&list=PLWKlVb_MqDQEOCnsNOJO8gd3jDCwiyKKe&index=11
Video Guide for Embedded Artist OEM Module for i.MX RT 1062 showing precise secured application operation analysis: https://youtu.be/o7hQbOqhJoc

0 Kudos