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

Soft Device + Application flash doesn't work with Eclipse

Hello all,

I struggle to program nrf52 on Eclipse, and it works fine with Keil. Let me explain :

With Keil :

-I first flash softdevice 5.0 manually with JFlash Lite

-I flash my code with Keil,

it works fine. I can flash a merged hex file and my code after that, it is okay, my code is running

With Eclipse :

My code compiles (the same code), but if I flash the same softdevice, and my code, my code is not running.

I checked my project ld file and .map file : all is okay (i.e : same parameters in Keil),  my code starts at 0x23000

I am running out of ideas... Any help?

Thank you!

Parents
  • UPDATE : I found out what is going on : I am using the default .ld file provided in an SDK example and the FLASH lenght was specifed to 5D000, wich is too much : I had data around 0x39000 which were corrupted. When I specify Keil parameter (0x15000), my code doesn't compile anymore! I am facing flash overflow! Now I know Keil was performing size optimisation I have to tell gcc to do. (because in Keil, the code compiles)

    I set the same Optimisation level as Keil (O2) but I don't know how to tell gcc to use microlib library.

    Could someone help please? 

  • For GCC optimization for space, use -Os

    For newlib nano, use linker parameter --specs=nano.specs

    It is better to use Eclipse native project than makefile project.  

  • Thank you for the advice. Unfortunately, with -Os : it still overflows by 276 bytes. I could increase FLASH lenght a little bit, but it will delay the issue : my code is going to be bigger. In Keil, it compiles fine with -O2, and I would like to have this results in Eclipse. nano.specs is already set. here is a piece of my Makefile, I think it could help :

    # Libraries common to all targets
    LIB_FILES += \

    # Optimization flags
    OPT = -O2 -g3
    # Uncomment the line below to enable link time optimization
    #OPT += -flto



    CPPFLAGS += BOARD_PCA10040
    CPPFLAGS += NRF52 NRF52832_XXAA
    CPPFLAGS += NRF52_PAN_74
    CPPFLAGS += NRF_SD_BLE_API_VERSION=5
    CPPFLAGS += S132
    CPPFLAGS += SOFTDEVICE_PRESENT
    CPPFLAGS += SWI_DISABLE0

    # C flags common to all targets
    CFLAGS += $(OPT)
    CFLAGS += -DBOARD_PCA10040
    CFLAGS += -DCONFIG_GPIO_AS_PINRESET
    CFLAGS += -DNRF52
    CFLAGS += -DNRF52832_XXAA
    CFLAGS += -DNRF52_PAN_74
    CFLAGS += -DNRF_SD_BLE_API_VERSION=5
    CFLAGS += -DS132
    CFLAGS += -DSOFTDEVICE_PRESENT
    CFLAGS += -DSWI_DISABLE0
    CFLAGS += -mcpu=cortex-m4
    CFLAGS += -mthumb -mabi=aapcs
    CFLAGS +=  -Wall
    CFLAGS += -Werror=implicit-function-declaration
    CFLAGS += -Wno-unused-function -Wno-comment -Wno-unused-variable
    CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
    CFLAG += -split_sections
    CFLAG += -apcs=interwork
    CFLAG += --cpu Cortex-M4.fp
    # keep every function in a separate section, this allows linker to discard unused ones
    CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
    CFLAGS += -fno-builtin -fshort-enums
    CFLAG += --library_type=microlib


    # C++ flags common to all targets
    CXXFLAGS += $(OPT)

    # Assembler flags common to all targets
    ASMFLAGS += -O2 -g3
    ASMFLAGS += -mcpu=cortex-m4
    ASMFLAGS += -mthumb -mabi=aapcs
    ASMFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
    ASMFLAGS += -DBOARD_PCA10040
    ASMFLAGS += -DCONFIG_GPIO_AS_PINRESET
    ASMFLAGS += -DNRF52
    ASMFLAGS += -DNRF52832_XXAA
    ASMFLAGS += -DNRF52_PAN_74
    ASMFLAGS += -DNRF_SD_BLE_API_VERSION=5
    ASMFLAGS += -DS132
    ASMFLAGS += -DSOFTDEVICE_PRESENT
    ASMFLAGS += -DSWI_DISABLE0
    ASMFLAGS += -D__MICROLIB

    # Linker flags
    LDFLAGS += $(OPT)
    LDFLAGS += -mthumb -mabi=aapcs -L $(TEMPLATE_PATH) -T$(LINKER_SCRIPT)
    LDFLAGS += -mcpu=cortex-m4
    LDFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
    LDFLAG += --library_type=microlib
    # let linker dump unused sections
    LDFLAGS += -Wl,--gc-sections
    # use newlib in nano version
    LDFLAGS += -specs=nano.specs -lc -lnosys -lm

    I tried to copy compiler command lines and asm command line from Keil.

    I tried to make gcc use microlib; but either I put the line or not, it doesn't change anything

    Thank you for support :)

Reply
  • Thank you for the advice. Unfortunately, with -Os : it still overflows by 276 bytes. I could increase FLASH lenght a little bit, but it will delay the issue : my code is going to be bigger. In Keil, it compiles fine with -O2, and I would like to have this results in Eclipse. nano.specs is already set. here is a piece of my Makefile, I think it could help :

    # Libraries common to all targets
    LIB_FILES += \

    # Optimization flags
    OPT = -O2 -g3
    # Uncomment the line below to enable link time optimization
    #OPT += -flto



    CPPFLAGS += BOARD_PCA10040
    CPPFLAGS += NRF52 NRF52832_XXAA
    CPPFLAGS += NRF52_PAN_74
    CPPFLAGS += NRF_SD_BLE_API_VERSION=5
    CPPFLAGS += S132
    CPPFLAGS += SOFTDEVICE_PRESENT
    CPPFLAGS += SWI_DISABLE0

    # C flags common to all targets
    CFLAGS += $(OPT)
    CFLAGS += -DBOARD_PCA10040
    CFLAGS += -DCONFIG_GPIO_AS_PINRESET
    CFLAGS += -DNRF52
    CFLAGS += -DNRF52832_XXAA
    CFLAGS += -DNRF52_PAN_74
    CFLAGS += -DNRF_SD_BLE_API_VERSION=5
    CFLAGS += -DS132
    CFLAGS += -DSOFTDEVICE_PRESENT
    CFLAGS += -DSWI_DISABLE0
    CFLAGS += -mcpu=cortex-m4
    CFLAGS += -mthumb -mabi=aapcs
    CFLAGS +=  -Wall
    CFLAGS += -Werror=implicit-function-declaration
    CFLAGS += -Wno-unused-function -Wno-comment -Wno-unused-variable
    CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
    CFLAG += -split_sections
    CFLAG += -apcs=interwork
    CFLAG += --cpu Cortex-M4.fp
    # keep every function in a separate section, this allows linker to discard unused ones
    CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
    CFLAGS += -fno-builtin -fshort-enums
    CFLAG += --library_type=microlib


    # C++ flags common to all targets
    CXXFLAGS += $(OPT)

    # Assembler flags common to all targets
    ASMFLAGS += -O2 -g3
    ASMFLAGS += -mcpu=cortex-m4
    ASMFLAGS += -mthumb -mabi=aapcs
    ASMFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
    ASMFLAGS += -DBOARD_PCA10040
    ASMFLAGS += -DCONFIG_GPIO_AS_PINRESET
    ASMFLAGS += -DNRF52
    ASMFLAGS += -DNRF52832_XXAA
    ASMFLAGS += -DNRF52_PAN_74
    ASMFLAGS += -DNRF_SD_BLE_API_VERSION=5
    ASMFLAGS += -DS132
    ASMFLAGS += -DSOFTDEVICE_PRESENT
    ASMFLAGS += -DSWI_DISABLE0
    ASMFLAGS += -D__MICROLIB

    # Linker flags
    LDFLAGS += $(OPT)
    LDFLAGS += -mthumb -mabi=aapcs -L $(TEMPLATE_PATH) -T$(LINKER_SCRIPT)
    LDFLAGS += -mcpu=cortex-m4
    LDFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
    LDFLAG += --library_type=microlib
    # let linker dump unused sections
    LDFLAGS += -Wl,--gc-sections
    # use newlib in nano version
    LDFLAGS += -specs=nano.specs -lc -lnosys -lm

    I tried to copy compiler command lines and asm command line from Keil.

    I tried to make gcc use microlib; but either I put the line or not, it doesn't change anything

    Thank you for support :)

Children
No Data
Related