在 TI cc26xx 中保留闪存 space
Reserve flash memory space in TI cc26xx
我目前正在尝试在链接器文件中保留闪存的一个扇区,以将一些数据保存到其中(使用 driverlib API)。我首先将脚本写入特定的内存地址,然后我 运行 我的应用程序读取保存的数据。
不幸的是,每当我刷机时,数据都会丢失。因此,我试图更改链接器文件并保留一些 space 但我不确定我是否正确地进行了操作。我将不胜感激任何帮助或提示。
MEMORY
{
/* Flash Size 128 KB minus the CCA area below (88 bytes) */
/* OLD: FLASH (RX) : ORIGIN = 0x00000000, LENGTH = 0x0001FFA8 */
FLASH (RX) : ORIGIN = 0x00000000, LENGTH = 0x0001FF88
/*
* Custom reserved memory space with size of 32 bytes
*/
CNVM (RX) : ORIGIN = 0x0001FF88, LENGTH = 32
/*
* Customer Configuration Area and Bootloader Backdoor configuration
* in flash, up to 88 bytes
*/
FLASH_CCFG (RX) : ORIGIN = 0x0001FFA8, LENGTH = 88
/* RAM Size 20KB */
SRAM (RWX) : ORIGIN = 0x20000000, LENGTH = 0x00005000
/* Application can use GPRAM region as RAM if cache is disabled in CCFG */
GPRAM (RWX) : ORIGIN = 0x11000000, LENGTH = 0x00002000
}
/*. Highest address of the stack. Used in startup file .*/
_estack = ORIGIN(SRAM) + LENGTH(SRAM); /* End of SRAM */
/*. Generate a link error if heap and stack don’t fit into RAM .*/
_Min_Heap_Size = 0;
_Min_Stack_Size = 0x100;
SECTIONS
{
.text :
{
_text = .;
KEEP(*(.vectors))
*(.text*)
*(.rodata*)
_etext = .;
} > FLASH = 0
.text:
{
*(.rodata*)
} > CNVM
.data :
{
_data = .;
*(vtable)
*(.data*)
_edata = .;
} > SRAM AT > FLASH
.ARM.exidx :
{
*(.ARM.exidx*)
} > FLASH
.bss :
{
_bss = .;
*(.bss*)
*(COMMON)
_ebss = .;
} > SRAM
.ccfg :
{
KEEP(*(.ccfg))
} > FLASH_CCFG
/* User_heap_stack section, used to check that there is enough RAM left */
._user_heap_stack :
{
. = ALIGN(4);
. = . + _Min_Heap_Size;
. = . + _Min_Stack_Size;
. = ALIGN(4);
} > SRAM
.gpram :
{
} > GPRAM
}
在我的案例中,使用链接器方法没有提供所需的结果。我最终做的是在闪烁 sensortag 之前编辑从我的代码生成的二进制文件。
在 linux 上使用 hexdump 命令如下 hexdump generated_binary_file.bin
可以注意到每一行都包含起始内存地址(对于特定范围的地址),然后是写入该范围的数据。
因此,使用一个小的 python 脚本,可以更改特定行中的值并生成自己的修改后的二进制文件,该文件稍后将被闪存到 sensortag。内存地址内容可以使用您包含在初始代码中(在 bin 生成和编辑之前)的特定功能来读取,例如 memcpy()
。
我目前正在尝试在链接器文件中保留闪存的一个扇区,以将一些数据保存到其中(使用 driverlib API)。我首先将脚本写入特定的内存地址,然后我 运行 我的应用程序读取保存的数据。
不幸的是,每当我刷机时,数据都会丢失。因此,我试图更改链接器文件并保留一些 space 但我不确定我是否正确地进行了操作。我将不胜感激任何帮助或提示。
MEMORY
{
/* Flash Size 128 KB minus the CCA area below (88 bytes) */
/* OLD: FLASH (RX) : ORIGIN = 0x00000000, LENGTH = 0x0001FFA8 */
FLASH (RX) : ORIGIN = 0x00000000, LENGTH = 0x0001FF88
/*
* Custom reserved memory space with size of 32 bytes
*/
CNVM (RX) : ORIGIN = 0x0001FF88, LENGTH = 32
/*
* Customer Configuration Area and Bootloader Backdoor configuration
* in flash, up to 88 bytes
*/
FLASH_CCFG (RX) : ORIGIN = 0x0001FFA8, LENGTH = 88
/* RAM Size 20KB */
SRAM (RWX) : ORIGIN = 0x20000000, LENGTH = 0x00005000
/* Application can use GPRAM region as RAM if cache is disabled in CCFG */
GPRAM (RWX) : ORIGIN = 0x11000000, LENGTH = 0x00002000
}
/*. Highest address of the stack. Used in startup file .*/
_estack = ORIGIN(SRAM) + LENGTH(SRAM); /* End of SRAM */
/*. Generate a link error if heap and stack don’t fit into RAM .*/
_Min_Heap_Size = 0;
_Min_Stack_Size = 0x100;
SECTIONS
{
.text :
{
_text = .;
KEEP(*(.vectors))
*(.text*)
*(.rodata*)
_etext = .;
} > FLASH = 0
.text:
{
*(.rodata*)
} > CNVM
.data :
{
_data = .;
*(vtable)
*(.data*)
_edata = .;
} > SRAM AT > FLASH
.ARM.exidx :
{
*(.ARM.exidx*)
} > FLASH
.bss :
{
_bss = .;
*(.bss*)
*(COMMON)
_ebss = .;
} > SRAM
.ccfg :
{
KEEP(*(.ccfg))
} > FLASH_CCFG
/* User_heap_stack section, used to check that there is enough RAM left */
._user_heap_stack :
{
. = ALIGN(4);
. = . + _Min_Heap_Size;
. = . + _Min_Stack_Size;
. = ALIGN(4);
} > SRAM
.gpram :
{
} > GPRAM
}
在我的案例中,使用链接器方法没有提供所需的结果。我最终做的是在闪烁 sensortag 之前编辑从我的代码生成的二进制文件。
在 linux 上使用 hexdump 命令如下 hexdump generated_binary_file.bin
可以注意到每一行都包含起始内存地址(对于特定范围的地址),然后是写入该范围的数据。
因此,使用一个小的 python 脚本,可以更改特定行中的值并生成自己的修改后的二进制文件,该文件稍后将被闪存到 sensortag。内存地址内容可以使用您包含在初始代码中(在 bin 生成和编辑之前)的特定功能来读取,例如 memcpy()
。