2403221_en-US

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

2403221_en-US

2403221_en-US

How to allocate a memory address in S32K144 to store independent variables?

Hello to the technical staff of NXP!

I encountered a problem during the development of the S32K144 chip.

Ni__0-1786350352171.png

Using the address description above as an example, I want to allocate a separate address to store some global variables.
1. It can perform functions such as saving, erasing, and rewriting even when power is
off. 2. Furthermore, it must be able to participate in logical operations during program execution.
3. After compiling and generating the srec file, I'm unsure how to extract the data from this address
range. I'm unsure which address segment is appropriate for placing these variables, and what
the correct programming syntax for address allocation is. How should I modify the .ld file in the Linker_files folder within the project?
Are there any reference materials available
for learning? I still have questions about developing with the S32K144 chip.
Regarding flash allocation in the .ld file within the Linker_files folder, what is the correct syntax and why is it written this way? I'd
like to obtain this knowledge. Could you provide an official, clear, and correct syntax specification and internal logic explanation for my learning?


I sincerely look forward to your reply.
Thank you so much!

Re: S32K144如何开辟一段内存地址 实现独立变量的存储

Hi@ Ni_

Please be sure to use your company's email account to ask questions next time. We will not prioritize general email accounts such as QQ, 163, and Gmail.

Let me answer your first question first:

Taking the link file provided by the RTM version as an example, the link file actually tells how to implement the division of independent address space for custom data storage.

A closer look at "m_data_2" reveals that it first defines the address space range within the MEMORY.

(Here you can allocate the memory yourself. For example, you can further divide m_text into more other custom spaces. Note the actual address and range.)

/* Specify the memory areas */
MEMORY
{
  /* Flash */
  m_interrupts          (RX)  : ORIGIN = 0x00000000, LENGTH = 0x00000400
  m_flash_config        (RX)  : ORIGIN = 0x00000400, LENGTH = 0x00000010
  m_text                (RX)  : ORIGIN = 0x00000410, LENGTH = 0x0007FBF0

  /* SRAM_L */
  m_data                (RW)  : ORIGIN = 0x1FFF8000, LENGTH = 0x00008000

  /* SRAM_U */
  m_data_2              (RW)  : ORIGIN = 0x20000000, LENGTH = 0x00007000
}

Secondly, define ".customSection" in SECTIONS, which belongs to m_data_2.

  /* Custom Section Block that can be used to place data at absolute address. */
  /* Use __attribute__((section (".customSection"))) to place data here. */
  .customSectionBlock  ORIGIN(m_data_2) :
  {
    __customSection_start__ = .;
    KEEP(*(.customSection))  /* Keep section even if not referenced. */
    __customSection_end__ = .;
  } > m_data_2

Finally, when using "customSection", you can define variables in the program:

__attribute__((section (".customSection"))unsigned int i = 0;

The variable "i" will be placed in "customSection". You can check whether the address of the variable "i" is correct by using the compiled xx.map file.


Your second question is about saving data when power is off. You can achieve this entirely using the S32K1's EEPROM. Please refer to the article at this link.

https://mp.weixin.qq.com/s?__biz=MzI0MDk0ODcxMw==&mid=2247486584&idx=1&sn=3b8651b928edd19c642b17838a...


タグ(1)
評価なし
バージョン履歴
最終更新日:
木曜日
更新者: