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.

MSP430I2041: if allocate original section in Flash and declaration variable in the section, we can not debug the program

Genius 3186 points

Part Number: MSP430I2041

Tool/software:

Hi,

My customer is developing MSP430i2041.

if allocate original section in Flash and declaration variable in the section useing #pragma DATA_SECTION(), they can not debug the program.

However, they can debug program that is only allocate Flash section in linker command file. (In the C file, comment out #pragma DATA_SECTION())

Do you have any idea for solve this?

Thanks,

GR

  • Where is the requested data_section located (according to the linker .cmd file)? What happens when they try to debug?

  • Hello Bruce,

    >Where is the requested data_section located (according to the linker .cmd file)?

    The section locate in Flash. it allocate by liker command file.

    >What happens when they try to debug?

    if run debug, it will not stop at breakpoint. it will not stop first breakpoint on main(). so it is not start main program.

    If test MSP430FR4xxx (FRAM series) in completely same program it does not have issue. So I believe this probrem is depends on Flash.

    Best Regards,

    GR

  • Can you upload the minum code which can recreate this problem?

  • Hello Eason,

    The minimum code is below.

    You can edit from any sample code.

    1. Linker command file

    MEMORY{
    
    -FLASH                   : origin = 0x8000, length = 0x7FDC
    +FLASH                   : origin = 0x8000, length = 0x6BDC
    +FLASH_DATA              : origin = 0xEBDC, length = 0x1400
    
    }
    
    SECTIONS{
    
    +.data_flash    : {} > FLASH_DATA 
    
    }

    2. main C code

    +#pragma DATA_SECTION(data_short, ".data_flash")
    +volatile short data_short[50][50] = {0};
    
    void main(void){
    
    +short sData = 1;
    +sData = data_short[1][2];
    

    Best Regards,

    GR

  • Can you try to use "const short data_short[50][50] = {0};"  to replace "volatile short data_short[50][50] = {0};"

    Besides, can you try this cmd file? 

    MEMORY{
    +FLASH : origin = 0x8000, length = 0x6000
    +FLASH_DATA : origin = 0xE000, length = 0x1400

    }

    SECTIONS{

    +.data_flash : {} > FLASH_DATA

    }

  • Hi Eason,

    Thanks for your suggestion.

    I will confirm to my customer for test in their enviorment.

    And I will get back.

    Best Regards,

    GR

  • Hi Eason,

    Besides, can you try this cmd file? 

    MEMORY{
    +FLASH : origin = 0x8000, length = 0x6000
    +FLASH_DATA : origin = 0xE000, length = 0x1400

    }

    SECTIONS{

    +.data_flash : {} > FLASH_DATA

    }

    They tried, but the issue was not solved.

    And we find that if the program load by CCS debug session, it get stucked the last for() loop on copy_decompress_lzss.c.

    Do you have any idea why is mcu stucked?

    Best Regards,

    GR

  • When I declared data_short as const (as Eason suggested), the linker didn't generate a copy table for it, so I expect C initialization wouldn't try to write into it.

    You might as well declare it const so the compiler can tell you if you accidentally try to write into it.

  • Hi Bruce,

    Thanks for your information.

    I will confirm them that is there or not another variable that in .data_flash section.

    Anyway, They can not start CCS debug in both (If use const and volatile for declaration ).

    So I believe this was not root of issue.

    Best Regards,

    GR

  • I create a simple example and don't see the problem:

    Please check the example: i20.zip

  • Hi Eason,

    Thanks for your information.

    My enviorment is same for you..

    I will confirm your project in their enviroments on customer side.
    Best Regards,

    GR

**Attention** This is a public forum