This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] CODECOMPOSER:如何使用 TI CLANG 编译器定义闪存区域中的常量数据

Guru**** 1133960 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/tools/code-composer-studio-group/ccs/f/code-composer-studio-forum/1341163/codecomposer-how-to-define-the-constant-data-in-flash-region-with-ti-clang-complier

器件型号:CODECOMPOSER

大家好、

我目前发现、当我使用 cmd 文件来定义闪存区域中的数据时、它不会自动初始化。 您可以帮助找到一些权变措施吗?

详细信息、请参阅以下内容:

CMD 文件设置:

SECTIONS
{
    .intvecs:   > 0x00000000

    .ROMDATA: palign(8) {} > FLASH_BOOT
    .text   : palign(8) {} > FLASH
    .const  : palign(8) {} > FLASH | FLASH_BOOT
    .cinit  : palign(8) {} > FLASH
    .pinit  : palign(8) {} > FLASH
    .rodata : palign(8) {} > FLASH

...
}

变量设置:

__attribute__((used)) __attribute__((section (".ROMDATA"))) unsigned int dataFlash_3 = 3;
__attribute__((used)) __attribute__((section (".ROMDATA"))) unsigned int dataFlash_4 = 4;

然后、我在映射文件中发现、它显示未初始化:

.ROMDATA   0    00002010    00000008     UNINITIALIZED
                  00002010    00000004     adc12_14bit_resolution.o (.ROMDATA)
                  00002014    00000004     adc12_14bit_resolution.o (.ROMDATA)

以下是闪存区域:

是否有任何方法可以在自定义段中定义初始化数据?

我使用以下方法、它可以临时使用、但需要自定义每个变量的地址才能使用、这有点麻烦:

__attribute__((used)) __attribute__((location(0x2000))) const unsigned int dataFlash[2] = {100,200};

__attribute__((used)) __attribute__((persistent, location(0x2008))) unsigned int dataFlash_1 = 1;
__attribute__((used)) __attribute__((persistent, location(0x200C))) unsigned int dataFlash_2 = 2;

B.R.

萨尔

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    大家好、

    我找到了权变措施。

    使用 const 声明该变量可以解决该问题。

    __attribute__((used)) __attribute__((section (".ROMDATA"))) const unsigned int dataFlash_3 = 3;

    B.R.

    萨尔