Resever SRAM custom session for msg for S32K14x

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

Resever SRAM custom session for msg for S32K14x

274 Views
chandan_uv
Contributor III

Hello, I want to reserve 256 bytes of SRM portion for custom msg between bootloader and application. I have modified .sct file as attached. Please let me know if there is any issue. Also I will run below code, please let me know if anything wrong.

 

 

 

extern uint32_t Image$$EXE_REGION_RAM_BOOTLOADER_MSG$$Base[];
const uint32_t secret_key= 0xACD3F90B;

//__attribute__((optimize("O0")))

// Disable optimization for this function
#pragma clang optimize off
void  write_dummy_msg_in_ram(void) {
	volatile uint8_t *volatile BOOTLOADER_MSG_ADDRESS = (volatile uint8_t *)Image$$EXE_REGION_RAM_BOOTLOADER_MSG$$Base; 
	uint8_t len = 0;
	//memcpy((uint8_t *)BOOTLOADER_MSG_ADDRESS,(uint8_t *) secret_key, 4); 
	//len = 4;
	BOOTLOADER_MSG_ADDRESS[len++] =  0x10;
	BOOTLOADER_MSG_ADDRESS[len++] =  0x12;
	BOOTLOADER_MSG_ADDRESS[len++] =  0x14;
	BOOTLOADER_MSG_ADDRESS[len++] =  0x16;
	BOOTLOADER_MSG_ADDRESS[len++] =  0x18;
	BOOTLOADER_MSG_ADDRESS[len++] =  0x20;
}

 

 

 

#define REGION_CODE_SRAM_L_START (REGION_RAM_INTERRUPT_VECTOR_START + REGION_RAM_INTERRUPT_VECTOR_SIZE)
#define REGION_CODE_SRAM_L_SIZE 0x00008000

#define REGION_BOOTLOADER_MSG_STRT (REGION_CODE_SRAM_L_START + REGION_CODE_SRAM_L_SIZE)
#define REGION_BOOTLOADER_MSG_SIZE 0x100

#define REGION_DATA_SRAM_L_START (REGION_BOOTLOADER_MSG_STRT + REGION_BOOTLOADER_MSG_SIZE)
#define REGION_DATA_SRAM_L_SIZE 0x00007B00

 

Also during compilation, I get below error. Any way to handle it.

C:\Users\CHANDA~1\AppData\Local\Temp\pa4d8-3(21): warning: L6312W: Empty Execution region description for region EXE_REGION_RAM_BOOTLOADER_MSG

0 Kudos
5 Replies

241 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi @chandan_uv 

this is a question rather for Keil/Arm community. We do not support their tools.

From MCU's point of view, the SRAM content is retained during reset. If you follow the procedure mentioned in the "31.3.4 SRAM retention: power modes and resets" in the RM rev. 14.1:
https://www.nxp.com/webapp/Download?colCode=S32K1XXRM
This procedure is used for preventing memory corruption during reset assertion.
If you enable RAM retention you should check the bits in CHIPCTL register and write 1 to them to allow accesses to SRAM immediately after reset. Otherwise, you will not have access to SRAM. That means this should be done already in startup files before RAM initialization. Also the SRAM initialization of that SRAM segment should be done only if those bits are '1' to not lose the content.

Regards,
Lukas

0 Kudos

203 Views
chandan_uv
Contributor III

@lukaszadrapa , Thanks for reply, my question was more related to SRAM data retention post reset as per MCU. As a created a different block of SRAM for msg between application <-> bootloader, It shouldn't get corrupted by initialization in startup code.

 

chandan_uv_0-1713764502634.png

I read the SRAM retention session, RCM_SRIE DELAY its alreay set to default 10LPO cycle. I have confusion.

* In interrupt post reset, should I set the SRAMU_RETEN and SRAML_RETEN to 0 or it happened automatically?

* If I have to do it, can you please tell the interrupt function which will be generated.

Tags (1)
0 Kudos

192 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

The description of the sequence says:

"4. After exiting reset, read SRAMU_RETEN and SRAML_RETEN in the Chip Control
register (CHIPCTL) and write 1 to them to allow accesses to SRAM."

So, this is not done automatically, it's up to user to write the bits.
No interrupt is triggered after reset. As I already wrote, you are supposed to do that in your startup code before first RAM access.

Regards,
Lukas

0 Kudos

185 Views
chandan_uv
Contributor III

okay @lukaszadrapa , One doubt In my current code I am not setting/resetting the SRAMU_RETEN  and SRAML_RETEN but still post reset data stored in my custom SRAM session is always same, none bytes are changing. any idea ?

 

chandan_uv_0-1713864332946.png

 

0 Kudos

161 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Even if SRAMU_RETEN and SRAML_RETEN are not used, the RAM content is retained. Usage of SRAMU_RETEN and SRAML_RETEN just ensures that the RAM won't be corrupted due to possible write access terminated by reset (and only that word would be corrupted, not whole RAM).
Next point which I already mentioned is that the RAM must be initialized due to ECC:

lukaszadrapa_0-1713942402694.png

There's always code like this in startup files which writes whole RAM at the beginning:

lukaszadrapa_1-1713942413908.png

 

So, this also needs to be changed based on content of SRAMU_RETEN and SRAML_RETEN or based on source of reset to not overwrite a data you need to keep over resets.

Regards,
Lukas

0 Kudos