S32K144 FLASH allocates custom fields to store the data that the program wants to write. Hello to NXP's technical staff I encountered a problem during the development of the S32K144 chip. I want to put some variables into my custom ROM fields, but I'm not sure how to do it in the program. I defined the storage fields in S32K144_64_flash.ld And CALC_RAM is defined in SECTIONS. #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}; The code above has placed my array into a custom field in CALC_RAM. My question is that this method is rather cumbersome. Since the macro CALC_RAM_ATTRIBUTE needs to be added before every newly defined array, is there a more convenient way to batch-store a piece of data into my custom field CALC_RAM? Looking forward to your reply Thank you so much! Re: S32K144 FLASH分配自定义字段 将程序中想要写入的数据放入自定义字段 Hi @Ni_,
You generally have three options:
OPTION 1.
Keep the attributes as you do it.
OPTION 2.
Put everything into a dedicated source file, for example:
/* 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 };
Then in the linker file:
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);
In the .map file:
OPTION 3.
Use a section pragma/macros.
Some compiler support it, not GCC though.
Regards,
Daniel
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.
查看全文