i.MX RT Toolbox: subsystem executed from TCM RAM

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

i.MX RT Toolbox: subsystem executed from TCM RAM

Jump to solution
1,759 Views
Maciek
Contributor V

Hi,

is there a way to assign a time/performance critical subsystem (like IRQ handler) to be copied to and executed from TCM RAM on i.MX RT1064 (and not from the internal SPI Flash) ?

Thanks

Maciek

0 Kudos
1 Solution
1,705 Views
nxa11767
NXP Employee
NXP Employee

Hi @Maciek ,

1. Yes, for subsystem, you need to mark the subsystem to be treated as atomic and the function packaging option will be enabled in the Code Generation tab, and you can specify there the user defined signature and use that signature in the model header.

2. Yes, for IRQ handler you can take a look in startup_mimxrt1064.c for the IRQ handlers signatures.

I was mentioning that I am looking for another approach and I have another option. The subsystems, in Code generation tab have the below options:

nxa11767_0-1621844356298.png

The problem here is how to add a custom section in that drop down. And I came across something that is called custom storage class designer in simulink.  (https://www.mathworks.com/help/ecoder/ug/design-custom-storage-classes-and-memory-sections.html)

Default the storage classes and memory sections for a model are loaded from a package called Simulink. Type cscdesigner and will open the below window:

nxa11767_2-1621844735738.png

The Simulink package is read only, so you cannot add new memory sections, but you can create your own package. The steps I did:

 -  duplicate the Simulink dataclass package ( found it here for my matlab instalation c:\Program Files\MATLAB\R2020b\toolbox\simulink\simdemos\dataclasses).

 - rename duplicate to  +MyDataClasses (find it attached), that I placed it in the toolbox root directory and added to the matlab path)

- in command window, type cscdesigner('MyDataClasses'), and I have my custom package loaded.

- next i could add a new memory section

nxa11767_3-1621845205151.png

nxa11767_4-1621845301682.png

 

Then, you need to specify to the model to load the storage classes and memory section from this custom package. This is done from Embedded Coder app, Code Interface, Embedded Coder Dictionary:

nxa11767_5-1621845497644.png

I used Manage Package (Refresh to se my custom one in the drop down) - I did an Unload of the Simulink package and then Load of the MyDataClasses.

After doing all the above steps, I could see in the memory section dropdown of the subsystems my added memory section:

nxa11767_6-1621845671589.png

The option will be available for any subsystems (including the function call ones).

Hope this helps.

Best regards,

Alexandra

 

 

 

 

View solution in original post

4 Replies
1,740 Views
nxa11767
NXP Employee
NXP Employee

Hi @Maciek ,

There is a support in simulink coder to place variables and functions but using pragmas: https://www.mathworks.com/help/ecoder/ug/control-data-and-function-placement-in-memory-by-inserting-... but for ARM GCC you need to use __attribute__section.

But even with the above steps, I could not place the function system call of the IRQ handler block in a specific section(but I will continue to investigate in this direction also) so I tried something with custom code block that did the trick:

I used a Model Header custom code block with the next info:

nxa11767_0-1621517447702.png

I declared the interrupt handler specifying the attribute__section option and is placing the the handler function to be run from address 0x0 (ITC start address). The custom code will be added in the .h file of the model generated by simulink.

 The name of the section got it from the linker file: MIMXRT1064xxxxA.ld.

nxa11767_1-1621498839970.png

I hope this helps.

Best regards,

Alexandra

0 Kudos
1,730 Views
Maciek
Contributor V

Thanks @nxa11767 ,

to clarify:

1) in case of any subsystem (not IRQ handler) we only need to define it's name and signature in 'function packaging' and use these in 'Model Header' block (the same as you did)

2) in case of any IRQ Handler - we need to check the name and signature of the IRQ Handler in SDK and use these in 'Model Header' block (the same as you did)

Am I right ?

Thanks

Maciek

0 Kudos
1,706 Views
nxa11767
NXP Employee
NXP Employee

Hi @Maciek ,

1. Yes, for subsystem, you need to mark the subsystem to be treated as atomic and the function packaging option will be enabled in the Code Generation tab, and you can specify there the user defined signature and use that signature in the model header.

2. Yes, for IRQ handler you can take a look in startup_mimxrt1064.c for the IRQ handlers signatures.

I was mentioning that I am looking for another approach and I have another option. The subsystems, in Code generation tab have the below options:

nxa11767_0-1621844356298.png

The problem here is how to add a custom section in that drop down. And I came across something that is called custom storage class designer in simulink.  (https://www.mathworks.com/help/ecoder/ug/design-custom-storage-classes-and-memory-sections.html)

Default the storage classes and memory sections for a model are loaded from a package called Simulink. Type cscdesigner and will open the below window:

nxa11767_2-1621844735738.png

The Simulink package is read only, so you cannot add new memory sections, but you can create your own package. The steps I did:

 -  duplicate the Simulink dataclass package ( found it here for my matlab instalation c:\Program Files\MATLAB\R2020b\toolbox\simulink\simdemos\dataclasses).

 - rename duplicate to  +MyDataClasses (find it attached), that I placed it in the toolbox root directory and added to the matlab path)

- in command window, type cscdesigner('MyDataClasses'), and I have my custom package loaded.

- next i could add a new memory section

nxa11767_3-1621845205151.png

nxa11767_4-1621845301682.png

 

Then, you need to specify to the model to load the storage classes and memory section from this custom package. This is done from Embedded Coder app, Code Interface, Embedded Coder Dictionary:

nxa11767_5-1621845497644.png

I used Manage Package (Refresh to se my custom one in the drop down) - I did an Unload of the Simulink package and then Load of the MyDataClasses.

After doing all the above steps, I could see in the memory section dropdown of the subsystems my added memory section:

nxa11767_6-1621845671589.png

The option will be available for any subsystems (including the function call ones).

Hope this helps.

Best regards,

Alexandra

 

 

 

 

1,689 Views
Maciek
Contributor V

Thanks @nxa11767 for detailed description!

We will check the solution with custom storage classes. It is much better/cleaner than using function names/signatures.

Regards

Maciek

0 Kudos