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.

Problems when debug Contiki with CCS6

I got some ideas from this post: 

Ki-Soo Lee said:
Hi Mark,
The CCS debugger supports debugging of GCC ELF images. You can simply start a project-less debug session and load your GCC ELF executable to debug/run it:

processors.wiki.ti.com/.../Debug_Handbook_for_CCS

Thanks
ki

However, things do not go well finally. 

Hi Mark,

When I am debugging Contiki with CCS, the program stops before "while(1){......}", no matter how many times I press the "step over" or some other buttons. 

When I move "while(1){......}" to somewhere else, it happened again. Do you have some ideas of it? Thanks.

/yanqiu

  • Yanqiu,

    By looking at the disassembly and the source code, it seems there is a missing correlation between the while(1) and the code actually running on the target: the opcode at address 0x176 is branching to itself, which matches the behavior of an infinite loop but it is not running the code inside of it. This is usually caused by optimization turned on in your project - you can test this by disabling it (if it is turned on).

    Also, from your screenshot I can't see the rest of the code inside the while(1) loop, but from what I see the code does not execute any meaningful operation - it defines a static variable and just increments it, but it is not used anywhere else. If that is the case, the compiler can suppress this code to save memory - especially if optimization is in effect.

    Therefore I would double-check the settings of your project and make sure there is code inside the loop that actually uses the local variable defined.

    Hope this helps,
    Rafael
  • Thanks for your response. The code is here:github.com/.../contiki-main.c
    I add the above "while(1)" for debug. Originally the program stopped before the official codes
    " while(1) {
    uint8_t r;
    do {
    r = process_run();
    watchdog_periodic();
    } while(r > 0);

    /* Drop to some low power mode */
    lpm_drop();
    }"
    This while loop is the main loop of the whole program.

    What kind of optimization could it be? I am using arm-none-eabi-gcc.

    Some gcc parameters is here: 

    program folder: 

    platform folder: 

    Thanks very much!