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.

CMD中的.switch段



我在程序中使用了switch语句,也在F2833x-nonBOIS-flash CMD文件中对.switch段做了分配空间和运行起始地址的操作,但是在编译中提示warning: load address of uninitialized section .switch ignored。在.map文件中查看.switch段,发现被看做未初始化段,并且长度为0.请问这是为什么?该怎样修改?谢谢

  • tanson,

    F2833x-nonBOIS-flash CMD文件是对所有寄存器的映射,你要对.switch段进行分配的话,应该在F2335.cmd这个文件里面定义啊,而且要非配在page 0中。

    /* 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

    Eric

  • 不好意思,刚才的CMD文件发错了,请您查阅本次回复

    我现在想把程序烧写进flash里面,上电后全部搬移到RAM中运行,所需要的CMD文件不就是FLASH的吗?还需要F2335.cmd这个文件吗?

    .switch : LOAD = FLASHA, PAGE = 0 /* can be ROM */ 
    RUN = RAM_L0L1L2L3, PAGE = 0 /* must be CSM secured RAM */
    LOAD_START(_switch_loadstart),
    RUN_START(_switch_runstart),
    SIZE(_switch_size)

    这是我在F2833x-nonBOIS-flash CMD中对switch段的操作。

    另外附上CMD文件,您帮我看看这样为flash-API分配段可不可以?

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

    ZONE0 : origin = 0x004000, length = 0x001000 /* XINTF zone 0 */
    RAM_L0L1L2L3: origin = 0x008000, length = 0x004000 /* on-chip RAM */
    OTP : origin = 0x380400, length = 0x000400 /* on-chip OTP */
    ZONE6 : origin = 0x100000, length = 0x100000 /* XINTF zone 6 */
    ZONE7A : origin = 0x200000, length = 0x00FC00 /* XINTF zone 7 - program space */
    FLASHH : origin = 0x300000, length = 0x008000 /* on-chip FLASH */
    FLASHG : origin = 0x308000, length = 0x008000 /* on-chip FLASH */
    FLASHF : origin = 0x310000, length = 0x008000 /* on-chip FLASH */
    FLASHE : origin = 0x318000, length = 0x008000 /* on-chip FLASH */
    FLASHD : origin = 0x320000, length = 0x008000 /* on-chip FLASH */
    FLASHC : origin = 0x328000, length = 0x008000 /* on-chip FLASH */
    FLASHA : origin = 0x338000, length = 0x007F80 /* on-chip FLASH */
    CSM_RSVD : origin = 0x33FF80, length = 0x000076 /* Part of FLASHA. Program with all 0x0000 when CSM is in use. */
    BEGIN_FLASH : origin = 0x33FFF6, length = 0x000002 /* Part of FLASHA. Used for "boot to Flash" bootloader mode. */
    CSM_PWL : origin = 0x33FFF8, length = 0x000008 /* Part of FLASHA. CSM password locations in FLASHA */
    ADC_CAL : origin = 0x380080, length = 0x000009 /* Part of TI OTP */
    IQTABLES : origin = 0x3FE000, length = 0x000b50 /* IQ Math Tables in Boot ROM */
    IQTABLES2 : origin = 0x3FEB50, length = 0x00008c /* IQ Math Tables in Boot ROM */
    FPUTABLES : origin = 0x3FEBDC, length = 0x0006A0 /* FPU Tables in Boot ROM */
    ROM : origin = 0x3FF27C, length = 0x000D44 /* Boot ROM */
    RESET : origin = 0x3FFFC0, length = 0x000002 /* part of boot ROM */
    VECTORS : origin = 0x3FFFC2, length = 0x00003E /* part of boot ROM */


    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 = 0x000400 /* on-chip RAM block M0 */
    BOOT_RSVD : origin = 0x000400, length = 0x000080 /* Part of M1, BOOT rom will use this for stack */
    RAMM1 : origin = 0x000480, length = 0x000380 /* on-chip RAM block M1 */
    RAML4 : origin = 0x00C000, length = 0x001000 /* on-chip RAM block L4 */
    RAML5 : origin = 0x00D000, length = 0x001000 /* on-chip RAM block L5 */
    RAML6 : origin = 0x00E000, length = 0x001000 /* on-chip RAM block L6 */
    RAML7 : origin = 0x00F000, length = 0x001000 /* on-chip RAM block L7 */
    ZONE7B : origin = 0x20FC00, length = 0x000400 /* XINTF zone 7 - data space */
    FLASHB : origin = 0x330000, length = 0x008000 /* on-chip FLASH */
    }

    SECTIONS
    {

    Flash28_API:
    {
    -lFlash28335_API_V210.lib(.econst)
    -lFlash28335_API_V210.lib(.text)
    } LOAD = FLASHD,
    RUN = RAM_L0L1L2L3,
    LOAD_START(_Flash28_API_LoadStart),
    LOAD_END(_Flash28_API_LoadEnd),
    RUN_START(_Flash28_API_RunStart),
    PAGE = 0

    /*** Code Security Password Locations ***/
    csmpasswds : > CSM_PWL PAGE = 0
    csm_rsvd : > CSM_RSVD PAGE = 0

    /*** User Defined Sections ***/
    codestart : > BEGIN_FLASH, PAGE = 0 /* Used by file CodeStartBranch.asm */
    wddisable : > FLASHA, PAGE = 0
    copysections : > FLASHA, PAGE = 0

    /* Allocate IQ math areas: */
    IQmath : > FLASHC PAGE = 0 /* Math Code */
    IQmathTables : > IQTABLES, PAGE = 0, TYPE = NOLOAD
    IQmathTables2 : > IQTABLES2, PAGE = 0, TYPE = NOLOAD
    FPUmathTables : > FPUTABLES, PAGE = 0, TYPE = NOLOAD

    /* Allocate DMA-accessible RAM sections: */
    DMARAML4 : > RAML4, PAGE = 1
    DMARAML5 : > RAML5, PAGE = 1
    DMARAML6 : > RAML6, PAGE = 1
    DMARAML7 : > RAML7, PAGE = 1

    /* Allocate 0x400 of XINTF Zone 7 to storing data */
    ZONE7DATA : > ZONE7B, PAGE = 1

    /* Allocate ADC_cal function (pre-programmed by factory into TI reserved memory) */
    .adc_cal : load = ADC_CAL, PAGE = 0, TYPE = NOLOAD

    /* .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

    /*** Uninitialized Sections ***/
    .stack : > RAMM0 PAGE = 1
    .ebss : > RAMM1 PAGE = 1
    .esysmem : > RAMM1 PAGE = 1

    /*** Initialized Sections ***/
    .cinit : LOAD = FLASHA, PAGE = 0 /* can be ROM */
    RUN = RAM_L0L1L2L3, PAGE = 0 /* must be CSM secured RAM */
    LOAD_START(_cinit_loadstart),
    RUN_START(_cinit_runstart),
    SIZE(_cinit_size)

    .const : LOAD = FLASHA, PAGE = 0 /* can be ROM */
    RUN = RAM_L0L1L2L3, PAGE = 0 /* must be CSM secured RAM */
    LOAD_START(_const_loadstart),
    RUN_START(_const_runstart),
    SIZE(_const_size)

    .econst : LOAD = FLASHA, PAGE = 0 /* can be ROM */
    RUN = RAM_L0L1L2L3, PAGE = 0 /* must be CSM secured RAM */
    LOAD_START(_econst_loadstart),
    RUN_START(_econst_runstart),
    SIZE(_econst_size)

    .pinit : LOAD = FLASHA, PAGE = 0 /* can be ROM */
    RUN = RAM_L0L1L2L3, PAGE = 0 /* must be CSM secured RAM */
    LOAD_START(_pinit_loadstart),
    RUN_START(_pinit_runstart),
    SIZE(_pinit_size)

    .switch : LOAD = FLASHA, PAGE = 0 /* can be ROM */
    RUN = RAM_L0L1L2L3, PAGE = 0 /* must be CSM secured RAM */
    LOAD_START(_switch_loadstart),
    RUN_START(_switch_runstart),
    SIZE(_switch_size)

    .text : LOAD = FLASHA, PAGE = 0 /* can be ROM */
    RUN = RAM_L0L1L2L3, PAGE = 0 /* must be CSM secured RAM */
    LOAD_START(_text_loadstart),
    RUN_START(_text_runstart),
    SIZE(_text_size)
    }

    thanks Eric

  • tanson,

    TI是默认是在non bios .cmd定义寄存器的存储映射,而在F2833x.cmd中分配flash,RAM空间,当然你把两者融合在一起做成一个cmd也是没问题的,只要相对应的地址不要出错就可以。

    你把所有的代码和数据放在FLASHA扇区,空间要确保够用。

    另外建议你对那些load在flash,run在RAM的段用下面的语法定义

    ramfuncs           

    : LOAD = FLASHD,                         

    RUN = RAMM0,                         

    LOAD_START(_RamfuncsLoadStart),                         

    LOAD_SIZE(_RamfuncsLoadSize),                         

    RUN_START(_RamfuncsRunStart),                         

    PAGE = 0

    Eric

     

  • Tthanks Eric

    我将CMD空间重新做了分配,将EDC三个区合并代替A区,但是编译后还是有warning: load address of uninitialized section .switch ignored。这个警告,.map中.switch段还是没分配到空间。

    >> warning: load address of uninitialized section .const ignored
    >> warning: load address of uninitialized section .switch ignored

    而且每次都是这两个警告,第一个我还能理解,因为使用的large memory 所以const段不使用,就不必分配空间了,可是程序中明明使用了switch语句,.switch却没有空间,这点我一直很迷惑,这个switch有什么特别的地方要注意吗?


  • tanson,

    我认为这是因为.switch段里面并没有内容,所以就被编译器忽略了。你确定.switch段里面有数据吗?可以把load,run等代码都去掉,直接用.switch   :> FlashA,然后在memory map中看这个段有没有数据。

    Eric

  • Eric

    我按照你说的实验了一下,.switch    0    00318000    00000000     UNINITIALIZED 确实.switch里没有东西,并且标示为未初始化段,为什么会这样?我在程序中使用了switch语句,应该会有数据啊。

    另外我还做了一个实验把switch语句中的内容用if语句改写,程序烧写后能正常运行,在switch里却不行,对此您有什么建议?谢谢

  • 不知道你的问题解决了没有。我在spraau8这个文件的最后一段看到,说是 不是所有的内容都需要放在RAM中运行,只需要把.text从FLASH拷贝到ram即可。我准备按照这个方法试一试。

  • 可是.text段里面不就是所有的程序吗?所有的程序代码编译后不是都放在.text里面吗。