How to Force Specific Memory Area for Specific Variables in S32DS (RAM, Flash, Data Flash)

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

How to Force Specific Memory Area for Specific Variables in S32DS (RAM, Flash, Data Flash)

62 次查看
karmegancjk
Contributor III

Hi,

I am working with the S32K358 and using S32 Design Studio (S32DS) as my IDE. I would like to reserve specific memory regions for certain variables and ensure that these allocations are not affected by the compiler or linker during build time—especially when new variables or arrays are introduced later in the project.

My Requirements

1. Dedicated RAM Section

I need to allocate a specific section of RAM exclusively for my own variables. These variables should be placed at fixed memory locations and must not be moved or overwritten by the compiler/linker during future software builds or updates.

2. Dedicated Flash / Data Flash Section (EEPROM-like usage)

I want to reserve areas in Flash or Data Flash for persistent data storage. For example:

  • Application_Valid_Flag

  • Bootloader_Valid_Flag

  • Arrays or structures containing configuration or runtime state data

These variables should be stored at fixed memory addresses and should remain unaffected by firmware reprogramming or section relocations—functioning similarly to EEPROM.

My Questions

  1. How can I configure the project settings in S32DS to reserve and assign specific memory addresses for variables (RAM, Flash, or Data Flash)?

  2. How do I declare variables in code so they are placed into these custom-defined memory sections?

  3. If S32DS or the compiler does not provide direct settings for this, how can I manually modify the linker script to define and reserve these specific memory areas?

Thanks and Regards,

Karmegan C

标记 (4)
0 项奖励
回复
1 回复

13 次查看
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @karmegancjk,

It depends on the compiler. For example, GCC does not support placing a variable directly at a specific address. Instead, GCC requires you to place variables in named sections, and then use the linker script to assign those sections to specific memory addresses.

Have a look at any RTD example, the linker file already defines multiple memory sections. You can create new sections by referencing these existing ones and extending them as needed.

For example, Placing a Variable in int_sram_no_cacheable:

#pragma GCC section bss ".mcal_bss_no_cacheable"
uint8_t variable;
#pragma GCC section bss

 

Here is an example that uses ITCM and DTCM and the linker file is modified because of that.

https://community.nxp.com/t5/S32K-Knowledge-Base/Example-Siul2-Port-Ip-Example-S32K344-ITCM-DTCM-S32...

 

Regards,

Daniel

 

 

0 项奖励
回复