Hi guys,
I want to partition the FLASH of my s32k144 evaluation board, in order to activate the EEE functionality. I want a configuration with all the FlexNVM used as E-Flash.
I have some questions on the "flash_partitioning_s32k144" example provided with the SDK.
Proceeding in order, the program makes the following steps:
Before launching the program partition command the FlexNVM and D-flash IFR must be in an erased state. It is recommended that a new device is partitioned as the first step in factory programming.
Here, I've a question about the terminology used. As I understand from AN11983, the s32k1xx devices have the P-Flash memory and the FlexNVM memory. The FlexNVM memory can be configured as D-Flash, E-Flash or a combiantion of both. So, when the document says "FlexNVM and D-Flash IFR must be in an erased state", do you need to erase only the FlexNVM memory? (2) (IFR = nonvolatile Information Register found in each flash block, separate from the main memory array)
uint8_t unsecure_key[FTFx_PHRASE_SIZE] = {0xFFu, 0xFFu, 0xFFu, 0xFFu, 0xFEu, 0xFFu, 0xFFu, 0xFFu};
.......
address = 0x408u;
size = FTFx_PHRASE_SIZE;
ret = FLASH_DRV_Program(&flashSSDConfig, address, size, unsecure_key);
If I understood, you can protect your Flash from external accesses via debug, by programming the FSEC[SEC] field. When this security is enabled, you can only launch mass erase operations and have no access to memory locations.
Here, we're writing the "Program flash protection bytes", i.e., the P-Flash Protection Registers (FPROT 0-3).
These registers define which P-Flash regions are protected from program and erase operations. Such regions can't be programmed/erased. So we put all FPROT bits at 1 (0xFFu), so we are not protecting any P-Flash region (1 = no protect, 0 = protect).
uint8_t sourceBuffer[BUFFER_SIZE] = { .... }; // BUFFER_SIZE = 0x100u
........
address = flashSSDConfig.EERAMBase;
size = sizeof(uint32_t);
ret = FLASH_DRV_EEEWrite(&flashSSDConfig, address, size, sourceBuffer);
Why does it pass the size of an uint32_t? (5) Maybe it is writing the first 32 bit of the sourceBuffer in the EEPROM.
Moreover, I would ask some other questions:
- how EEE erasing is performed?(6)
- the code configured the whole FlexNVM as EEPROM backup. With this configuration, is it true that the system does not have any D-Flash available? (7)
- in the code documentation there is written:
The FlexNVM memory is partitioned to EEPROM use and is blocked for some erase commands (Erase Sector and Erase Block). As a consequence, loading the program to flash memory may fail on some debuggers. Please perform a mass erase operation on Flash to remove this partitioning after running the example to be able to update your application on target.
I didn't understand if it is the use of the Emulated EEPROM to make impossible to erase the FlexNVM memory, or it is because of some inner/hide setting in the code. (8)
How do I perform a mass erase operation with s32k144 and s32 design studio? Can you describe me the precise steps to do that, without risking to brick my board as happened for other people, like here? (9)
Thank you all in advance,
bye.
Hi,
To your questions:
1.
It's on users' responsibility on such a cache system to invalidate the cache when the original memory contents were modified. Once the P-flash or D-flash modifications were completed, users can enable the prefetch buffers again.
2.
D-Flash IFR has to be erased. The Program Partition command erases the contents of the FlexNVM memory (Section 36.5.11.14 RM rev.7).
3.
Just place the function that launches the Program Partition command into RAM and wait there until the command is complete.
4.
Erased Flash cells are read as “1” and programmed as “0” and the Margin level is basically the threshold of the reading. Some of the cells might be weakly programmed or erased. To check if the Flash has been erased or programmed properly, the Margin level can be adjusted. So, a read with 1s Margin will be more sensitive to weakly erased cells and 0s Margin to weakly programmed cells. You can refer, for instance, to AN3419 System Integrity Techniques for the S12XE, Chapter 3.
5.
In this case, it writes the EEPROM data in 32-bit steps.
Function FLASH_DRV_WaitEEWriteToFinish in flash_driver.c
6.
It works like FlexRAM.
7.
Yes
8.
Yes, when the data flash is targeted, DEPART must be set for no EEPROM (see FlexNVM partition code) else the Erase Flash Block command aborts setting the FSTAT[ACCERR] bit (Section 36.5.11.5).
9.
Can you please post the question on S32 Design Studio community?
Regards,
Daniel
I want to share with you how I thought to use the Flash memory such that you can warn me about some wrong configurations (if you want).
Before to start my application, I have to partition the flash memory in order to have the E-Flash (i.e., the emulated EEPROM). In order to do that I should use a different program similar to the one provided with the SDK and described in my first comment.
Once the partitioning is done, I can launch my actual application:
At this point, even if I disconnect the board from my PC the data in the E-Flash should remain. Is it right? Or is the data removed due to the "reset" signal raised when the USB cable is disconnected?
The problem with these steps is that when I launch the first program, the one partitioning the Flash, it may happen that, as I mantioned before:
The FlexNVM memory is partitioned to EEPROM use and is blocked for some erase commands (Erase Sector and Erase Block). As a consequence, loading the program to flash memory may fail on some debuggers. Please perform a mass erase operation on Flash to remove this partitioning after running the example to be able to update your application on target.
Thus, the second program, my actual application, could not be able to run on the partitioned Flash and I would be forced to mass erase the Flash removing again the partitions. How can I solve this problem?
Thank you!
As I thought, it is happened that after the launch of the partition program, I'm not be able anymore to flash my own application. I do not understand how can I use the emulated EEPROM in this case (When I try to flash the application, the program ends in the reset handler)
Hi,
Have you seen this thread:
https://community.nxp.com/docs/DOC-340114
In the debugger, there is an option to preserve the partitioning and a memory range.
Regards,
Daniel
Is there someone that can help me please? I would be very grateful. Thanks again.