恩智浦的技术人员你们好
我在开发S32K144芯片的过程中遇到了一个问题
我想将一些变量放入我自定义的ROM字段 我不清楚该怎么在程序中实现
我在S32K144_64_flash.ld中定义了存储字段
并且在SECTIONS 中定义了CALC_RAM
#define CALC_RAM_ATTRIBUTE __attribute__((section(".CALC_RAM")))
CALC_RAM_ATTRIBUTE const uint8_t my_flash_array[] = {0x01, 0x02, 0x03, 0x04};
CALC_RAM_ATTRIBUTE const uint8_t my_flash_brray[] = {0x01, 0x02, 0x03, 0x04};
CALC_RAM_ATTRIBUTE const uint8_t my_flash_crray[] = {0x01, 0x02, 0x03, 0x04};
通过以上代码我已经将我的数组放入了CALC_RAM自定义字段
我的问题是 这样的操作方式比较繁琐 在新定义的 数组前 都需要加入CALC_RAM_ATTRIBUTE 这个宏定义
有没有更便捷的方法将 一段数据批量放入 我自定义的字段CALC_RAM ?
期待您的回复
万分感谢!
嗨@Ni_ ,
你通常有三种选择:
方案一。
修改时保留这些属性。
方案二。
将所有内容放入一个专用的源文件中,例如:
/* cal_data.c */
#include
const uint8_t table1[] = { 0x01, 0x02, 0x03, 0x04 };
const uint8_t table2[] = { 0x10, 0x20, 0x30, 0x40 };
const uint8_t table3[] = { 0xAA, 0xBB, 0xCC, 0xDD };
然后在链接器文件中:
MEMORY
{
int_flash_interrupts : ORIGIN = 0x00000000, LENGTH = 0x00000400
int_flash_config : ORIGIN = 0x00000400, LENGTH = 0x00000010
int_flash : ORIGIN = 0x00000410, LENGTH = 0x0007BBF0
calib_flash : ORIGIN = 0x0007C000, LENGTH = 0x00004000
int_sram_results : ORIGIN = 0x1FFF8000, LENGTH = 0x00000100
int_sram : ORIGIN = 0x1FFF8100, LENGTH = 0x0000DF00
int_sram_stack_c0 : ORIGIN = 0x20006000, LENGTH = 0x00001000
ram_rsvd2 : ORIGIN = 0x20007000, LENGTH = 0
}
.flash_config :
{
KEEP(*(.flash_config))
} > int_flash_config
.calib_flash :
{
. = ALIGN(4);
__calib_flash_start = .;
KEEP(*cal_data.o(.rodata*))
. = ALIGN(4);
__calib_flash_end = .;
} > calib_flash
.flash :
{
. = ALIGN(4);
*(.startup)
. = ALIGN(4);
*(.systeminit)
. = ALIGN(4);
*(.text.startup)
. = ALIGN(4);
在 .map 中文件:
选项 3.
使用 pragma/macros 部分。
有些编译器支持它,但 GCC 不支持。
此致,
丹尼尔
Any support, information, and technology (“Materials”) provided by NXP are provided AS IS, without any warranty express or implied, and NXP disclaims all direct and indirect liability and damages in connection with the Material to the maximum extent permitted by the applicable law.
NXP accepts no liability for any assistance with applications or product design. Materials may only be used in connection with NXP products. Any feedback provided to NXP regarding the Materials may be used by NXP without restriction.