MBD ToolBox : DataMemRead / DataMemWrite on flash

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

MBD ToolBox : DataMemRead / DataMemWrite on flash

1,897 Views
adrienpol
Contributor II

Hello,

I would like to store some data on the flash of my MPC5744p, and to be able to keep them after a reset.

I follow advises from this post : How to manage the memory using the simulink?  (method 2)

I modified "MPC5744P_FLASH.ld" :

MEMORY {
    word                :           org = 0x00FA0000, len = 0x0000001F
    int_flash           :           org = 0x00FA0020, len = 0x0020DFE0
    m_dflash            :           org = 0x011AE000, len = 0x00050000  
    vector_table        :           org = 0x011FE000, len = 0x00001000
    exception_handlers  :           org = 0x011FF000, len = 0x00001000
    int_sram            :           org = 0x40000000, len = 0x0005F800
    stack_ram           :           org = 0x4005F800, len = 0x00000800
    local_sram          :           org = 0x50800000, len = 0x00010000
}

SECTIONS
{
    .dflash : { KEEP (*(.dflash)) } > m_dflash  /* place .dflash section into dflsah memory*/
.

.

.

Point on it in the Matlab configuration, and checked modification in the generated ".map"

In Simulink I have a DataMemRead and a DataMemWrite block with this configuration :

pastedImage_3.png

To test, I configure the Write box to write the data from a CAN Signal, on trigger. And I read it on a second CAN signal. 

I generate the ".elf" with Simulink, and use S32 Design Studio to flash on the board.

It works until this point.

But I can't view my data on the "Memory" View of S32 :

pastedImage_4.png

And after a reset my read data is always "0xFF".

If someone has a clue... :smileywink:

Regards,
Adrien.

0 Kudos
Reply
3 Replies

1,393 Views
Daniel_Popa
NXP Employee
NXP Employee

Hi Adrien,

My 2 cents on this - i think it can only works with RAM addresses since for writing in flash we need special instructions.

constantinrazvan.chivu,

Can you please confirm?

Thank you!

Daniel

0 Kudos
Reply

1,393 Views
adrienpol
Contributor II

Hello,

Thanks you for your quick answer.

I would bet on the same answer. I will surely add an EEPROM for my device.

But just to understand, I found this Figure on the "MPC5744PRM.pdf"

pastedImage_1.png

With the MBD ToolBox blocks DataMem, we are using the yellow "link" ?

So to read/write in the Flash we would need an other block/function to be able to use the "Flash Memory Controller" ?

Thanks you,

Adrien.

0 Kudos
Reply

1,391 Views
constantinrazva
NXP Employee
NXP Employee

Hello adrienpol‌,

You and dumitru-daniel.popa are right - you will be needing another block to be able to use the flash memory controller to program(0)/erase(1) bits into flash.

And regarding the DataMem block, it does use the "yellow link" as described by you (the system RAM controller).

Unfortunately we do not have such a block for now, but you can import the example from the SDK for MPC5744x that comes with the S32 Design Studio - it shows how to use FLASH_DRV* functions to program and erase flash. You can find more documentation in    

 [Install Folder]\S32DS_Power_v2017.R1\S32DS\S32_SDK_MPC574xx_EAR_0.8.2\doc\Start_here.html

(Click on Modules -> Flash Memory and see all the functions the SDK provides)

Kind regards,

Razvan.