MBDT flash / nvm write freezes program S32K3xx

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

MBDT flash / nvm write freezes program S32K3xx

1,594 Views
BillDuley
Contributor III

Problem: When I attempt to write to flash region of chip, program seems to freeze.

I can leverage the memory example for RAM addresses, both read and write (0x20400000-0x20444000). No problem.

If I change the DataMemWrite Address to a value within the FLASH region (0x00400000 - 0x007E0000), the program compiles and flashes to the board. When my program attempts the write operation, FreeMaster indicates the program has locked up (counters freeze).

(Do I need to leverage the MCAL FLS driver to utilize flash regions of memory?)

Attached is my code attempt - MBDT toolbox version 1.2.2 (in a related post, I'm leveraging a patch that accommodates memory writes in subsystems). Also included in the zip is the FreeMaster project.

Are there guides or examples for MBDT and flash / NVM utilization?

Tags (1)
1 Reply

1,359 Views
FlorinCiuca
NXP Employee
NXP Employee
The reason the current model is not working is related to the manner in which the Flash memory should be manipulated. A direct memory manipulation using the Data Write MBDT block causes the MCU to enter into a fault state, hence the access has to be done via the dedicated driver.
 
For this we have created a demo application demonstrating how to access the Flash Memory. Please see the attached archive containing the model and a readme file.
 
The steps for enabling this support can be summarized as it follows:
1. Configuration of the Fls driver inside the .mex file:
Inside Fls peripheral, the following configuration options are relevant for this example:
a. Fls Physical Sector: selectable from the drop-down list, this option specifies in which Flash Sector will the operations be performed(16 Data Flash sectors and 512 Code Flash(128 for each of the 4 Code Flash areas) sectors are available). More information about memory zones, sizes, and number of sectors can be found in Flash block configuration table inside the Reference Manual.
b. Fls Page Size: this option specifies the size of a page within the previously configured sector. For internal flash, page size is 8 bytes
c. Fls Sector Size: this option specifies the size of the configured sector. For S32K344 MCU, all internal sectors have a 8kb size.
d. Fls Sector Start Address: this option specifies the address offset of the sector, beginning with the start address of the memory area.(e.g.: if 2 sectors with size of 8192 bytes are configured, the first will have Start Address 0 and the second will have Start Address 8192)
e. Fls Hardware Channel: this option specifies if the configured sector is located within the Internal or External Flash memory
2. Initialization of the Fls component inside the Board Initialization GUI
3. Implementation of the application
- Since Fls is not supported inside MBDT for S32K3 v1.2.0 in terms of Simulink blocks and configuration, we have used the Simulink custom code functionalities to call specific Fls driver APIs as you could see in the attached model. For more information about Simulink custom code functionalities, you could check this article: https://community.nxp.com/t5/NXP-Model-Based-Design-Tools/How-to-use-your-own-C-code-in-our-Toolbox-...
- We have used the Fls_Read, Fls_Write and Fls_Erase to demonstrate basic operations of accessing the Data Flash section of the S32K344.
 
For more details, please consult the associated readme file, providing details on how to run the application.
 
One other note that we would like to make is that the current address that you are using inside your application corresponds to the Code Flash section. Could you share with us why/if you need to write data to that specific section?

 

0 Kudos
Reply