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.

怎么把.txt段拆分开放入不同的FLASH段里



由于代码过大,超出0X4000的大小, 原先把.TXT放在  FLASHF      : origin = 0x3E4000, length = 0x004000,导致CODE放不下, 我想把部分子程序放在FLASHE      : origin = 0x3E8000, length = 0x004000

我在CMD里新建了 text2               : > FLASHHE     PAGE = 0

然后又 #pragma CODE_SECTION(MODBUSslave_analyzeData, "text2");

这样做并没有解决问题, 编译后程序还是放在FLASHF的 .txt段里,

请问要怎么做才能把.TXT放不下的部分拆分后放入其他地方?

  • 如果使用不是内部的flash的话 需要有工程将部分数据烧写到flash中
    然后上电跳转去读
  • text : > FLASHHE|FLASHF PAGE = 0
    用个或(|)即可
  • 用了 |  还是不行啊, (末尾一竖是鼠标光标)

    还是只会分配到其中一个段里

  • 可以在定义FLASH的时候吧length加长,把两个合并成一个

  • 把CMD发上来看看
  • CMD文件如下,不方便编辑,只作了黄底处理

    MEMORY

    {
    PAGE 0: /* Program Memory */
    /* Memory (RAM/FLASH/OTP) blocks can be moved to PAGE1 for data allocation */

    /*ZONE0 : origin = 0x002000, length = 0x002000 */ /* XINTF zone 0 */
    /*ZONE1 : origin = 0x004000, length = 0x002000 */ /* XINTF zone 1 */
    /*IQTABLES : origin = 0x3FF000, length = 0x000b50*/
    RAML0 : origin = 0x008000, length = 0x002000 /* on-chip RAM block L0 */
    /*ZONE2 : origin = 0x080000, length = 0x080000*/ /* XINTF zone 2 */
    /*ZONE6 : origin = 0x100000, length = 0x080000*/ /* XINTF zone 6 */
    OTP : origin = 0x3D7800, length = 0x000800 /* on-chip OTP */
    /*FLASHJ : origin = 0x3D8000, length = 0x014000*/ /*my code*/
    FLASHJ : origin = 0x3D8000, length = 0x004000 /* on-chip FLASH */
    /* FLASHI : origin = 0x3DA000, length = 0x002000 /* on-chip FLASH */
    /*FLASHH : origin = 0x3DC000, length = 0x004000*/ /* on-chip FLASH */
    FLASHG : origin = 0x3E0000, length = 0x004000 /* on-chip FLASH */
    FLASHF : origin = 0x3E4000, length = 0x004000 /* on-chip FLASH */
    FLASHE : origin = 0x3E8000, length = 0x004000 /* on-chip FLASH */
    FLASHD : origin = 0x3EC000, length = 0x004000 /* on-chip FLASH */
    FLASHC : origin = 0x3F0000, length = 0x004000 /* on-chip FLASH */
    FLASHA : origin = 0x3F6000, length = 0x001F80 /* on-chip FLASH */
    CSM_RSVD : origin = 0x3F7F80, length = 0x000076 /* Part of FLASHA. Program with all 0x0000 when CSM is in use. */
    BEGIN : origin = 0x3F7FF6, length = 0x000002 /* Part of FLASHA. Used for "boot to Flash" bootloader mode. */
    CSM_PWL : origin = 0x3F7FF8, length = 0x000008 /* Part of FLASHA. CSM password locations in FLASHA */

    /* ZONE7 : origin = 0x3FC000, length = 0x003FC0 /* XINTF zone 7 available if MP/MCn=1 */
    /* ROM : origin = 0x3FF000, length = 0x000FC0 */ /* Boot ROM available if MP/MCn=0 */
    RESET : origin = 0x3FFFC0, length = 0x000002 /* part of boot ROM (MP/MCn=0) or XINTF zone 7 (MP/MCn=1) */
    VECTORS : origin = 0x3FFFC2, length = 0x00003E /* part of boot ROM (MP/MCn=0) or XINTF zone 7 (MP/MCn=1) */
    EXTCODE : origin = 0x100000, length = 0x020000 /*外部RAM512K*/

    PAGE 1 : /* Data Memory */
    /* Memory (RAM/FLASH/OTP) blocks can be moved to PAGE0 for program allocation */
    /* Registers remain on PAGE1 */

    RAMM0 : origin = 0x000000, length = 0x000800 /* on-chip RAM block M0 */
    /*RAMM1 : origin = 0x000400, length = 0x000400*/ /* on-chip RAM block M1 */
    /*RAML1 : origin = 0x009000, length = 0x001000 */ /* on-chip RAM block L1 */
    FLASHB : origin = 0x3F4000, length = 0x002000 /* on-chip FLASH */
    RAMH0 : origin = 0x3F8000, length = 0x002000 /* on-chip RAM block H0 */
    EXTDAT : origin = 0x120000, length = 0x020000 /*extern ram*/
    }

    /* Allocate sections to memory blocks.
    Note:
    codestart user defined section in DSP28_CodeStartBranch.asm used to redirect code
    execution when booting to flash
    ramfuncs user defined section to store functions that will be copied from Flash into RAM
    */

    SECTIONS
    {

    /* Allocate program areas: */
    .cinit : > FLASHA PAGE = 0
    .pinit : > FLASHA, PAGE = 0
    .text : > FLASHJ | FLASHG, PAGE = 0
    /*text2 : > FLASHH PAGE = 0*/
    codestart : > BEGIN PAGE = 0
    ramfuncs : LOAD = FLASHD,
    RUN = RAML0,
    LOAD_START(_RamfuncsLoadStart),
    LOAD_END(_RamfuncsLoadEnd),
    RUN_START(_RamfuncsRunStart),
    PAGE = 0
    /*经实测, 外部RAM速度不如优化后的内部FLASH*/
    /*ramcode : LOAD = FLASHJ,
    RUN = EXTCODE,
    LOAD_START(_RamcodeLoadStart),
    LOAD_END(_RamecodeLoadEnd),
    RUN_START(_RamcodeRunStart),
    PAGE = 0*/

    csmpasswds : > CSM_PWL PAGE = 0
    csm_rsvd : > CSM_RSVD PAGE = 0

    /* Allocate uninitalized data sections: */
    .stack : > RAMM0 PAGE = 1
    .res : > RAMH0 PAGE = 1/*my code*/
    .ebss : > RAMH0 PAGE = 1
    .tab : > RAMH0 PAGE = 1/*my code*/
    .esysmem : > RAMH0 PAGE = 1
    .cy : > RAMH0 PAGE = 1/*my code*/
    .vars : > RAMH0 PAGE = 1/*my code*/
    /*.crctab : > RAMH0 PAGE = 1*//*my code*/
    .crctab : > RAMM0 PAGE = 1

    /* Initalized sections go in Flash */
    /* For SDFlash to program these, they must be allocated to page 0 */
    .econst : > FLASHA PAGE = 0
    .switch : > FLASHA PAGE = 0

    /* Allocate IQ math areas: */
    /*IQmath : > FLASHC PAGE = 0 */ /* Math Code */
    /* IQmathTables : > ROM PAGE = 0, TYPE = NOLOAD */ /* Math Tables In ROM */
    /* IQmath : > RAML0, PAGE = 0*/
    /*IQmathTables : > IQTABLES, PAGE = 0, type = NOLOAD*/
    /*IQmathTablesRam : > RAMH0, PAGE = 1*/

    /* .reset is a standard section used by the compiler. It contains the */
    /* the address of the start of _c_int00 for C Code. /*
    /* When using the boot ROM this section and the CPU vector */
    /* table is not needed. Thus the default type is set here to */
    /* DSECT */
    .reset : > RESET, PAGE = 0, TYPE = DSECT
    vectors : > VECTORS PAGE = 0, TYPE = DSECT
    .adcsect : > FLASHJ PAGE = 0

    }

  • cmd看不出问题,另外.text也应该能放得进两个段里面

  • 我也看了TI的文档的,里面也没说什么特殊的,只要加个 |   就好了,

    问题是我这边编译就出错  .txt 长度是 0x4043, 一个FLASH长度是0x4000,加了或以后还是编译报错FLASH不够,非常纳闷。

    我当时就直接把FLASH合并了,问题是解决了,但不会拆分.txt  ,作为开发者就一直记挂着