This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

setting DEBUG flag in eclipse

I am trying to track down a fatal error and want to use the Error module as documented below, to get the line number and file name.

Using eclipse, where should DEBUG be set. So far I have tried sdk_config.h file with the following addition:

#ifndef DEBUG 

#define DEBUG 1

#endif

However this is only giving me the PC and I am not getting through to app_error_save_and_stop where the line number and filename should be determined. Is this the correct way to set the DEBUG flag?

If the DEBUG flag is set:

When app_error_fault_handler is invoked, the error info (for example the function parameters: error code, line number, and file name) are copied to global memory, interrupts are disabled, and the application enters an infinite loop.

Parents
  • Hi,

    You should define DEBUG in the makefile. I.e. CFLAGS += -DDEBUG

    You should also add the -g3 flag and remove compiler optimization (to get expected debug results). I.e. CFLAGS += -Wall -Werror -O0 -g3.

  • Unfortunately I am not seeing the expected behaviour. Despite implementing all of the above with the addition of adding app_error_weak.c to the makefile to ensure it is recompiled. I can see -DDEBUG applied to the compilation of app_error_weak.c in the build log.

    However I am not hitting the expected line:

    It has just occurred to me that I am using segger RTT which could be effecting the behaviour of NRF_LOG_FINAL_FLUSH()

    Also Eclipse isn't alway honest when comes to highlighting.

    So I have access to the PC, I guess I need to manually go through the map file to determine where things are failing?

  • Is the code going into app_error_save_and_stop() ?

    If you have access the the PC, and you have the .elf file, you could use arm-none-eabi-addr2line to find where it is failing also.

    // Example, pc=0x01BEEF

    $ arm-none-eabi-addr2line 0x01BEEF -e app_beacon.elf

    C:\folder\SDK\src\main.c:34

  • I am not getting into app_error_save_and_stop() and don't have an elf file, however was under the impression that a hex file is actually contained the elf data.

    Unfortunately arm-none-eabi-addr2line doesn't appear to like my hex file, (it is the file I flash onto the board) I get the following:

    /Users/venerly/nordic/gcc-arm-none-eabi-7-2017-q4-major/bin/arm-none-eabi-addr2line 200516 -e nrf52832_xxaa.hex

    which outputs:

    ??:0

Reply
  • I am not getting into app_error_save_and_stop() and don't have an elf file, however was under the impression that a hex file is actually contained the elf data.

    Unfortunately arm-none-eabi-addr2line doesn't appear to like my hex file, (it is the file I flash onto the board) I get the following:

    /Users/venerly/nordic/gcc-arm-none-eabi-7-2017-q4-major/bin/arm-none-eabi-addr2line 200516 -e nrf52832_xxaa.hex

    which outputs:

    ??:0

Children
Related