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

GCC : Blinky project generated HEX file not working ?!

Hi,

I am trying to use GCC with Eclipse as explained in this tutorial, and after spending hours trying to figure it out, I am completely lost and ask for advices and help.

I have started with the most simple project : the blinky project without softdevice. After setting up the project in Eclipse, the compilation works fine, and I am able to load it into the chip, run and even use the debugger in step-by-step mode. That prove my toolchain is well configured.

But, I am not able to do the same with the blinky project "using" the softdevice. The project compile and generate a HEX file which is not working?! I tried to flash it using "target" as explained in the tutorial and push it directly using nRFGo Studio, the code is not working. Compilation has been done using optimization -O0 and -g3 to test the debugger without luck or -O3neither.

The two simples projects described above work perfectly with Keil. Unfortunately, our project code size exceeds the maximum allowed with the free version of Keil (32Kb), it is why I am trying to deal with GCC.

The only differences between these two projects are the memory space due to the softdevice. Any ideas?

Here is the debug window: you can see that the address trying to be resolved is 0xfffffffe

image description

Here is the CDT Build Console result :

15:54:26 **** Incremental Build of configuration Default for project armgcc ****
make all 
rm -rf _build
make[1]: entrant dans le répertoire « C:/Nordic/SDK/examples/peripheral/blinky/pca10028/s110/armgcc »
rm -rf _build/*.o
make[1]: quittant le répertoire « C:/Nordic/SDK/examples/peripheral/blinky/pca10028/s110/armgcc »
make[1]: entrant dans le répertoire « C:/Nordic/SDK/examples/peripheral/blinky/pca10028/s110/armgcc »
echo  makefile
makefile
mkdir _build
Compiling file: system_nrf51.c
Compiling file: main.c
Compiling file: nrf_delay.c
Compiling file: gcc_startup_nrf51.s
Linking target: nrf51422_xxac.out
make[2]: entrant dans le répertoire « C:/Nordic/SDK/examples/peripheral/blinky/pca10028/s110/armgcc »
Preparing: nrf51422_xxac.bin
Preparing: nrf51422_xxac.hex

   text	   data	    bss	    dec	    hex	filename
   1100	     96	      0	   1196	    4ac	_build/nrf51422_xxac.out

make[2]: quittant le répertoire « C:/Nordic/SDK/examples/peripheral/blinky/pca10028/s110/armgcc »
make[1]: quittant le répertoire « C:/Nordic/SDK/examples/peripheral/blinky/pca10028/s110/armgcc »

15:54:28 Build Finished (took 2s.928ms)

Here is the linker script (not modfied) :

/* Linker script to configure memory regions. */

SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)

MEMORY
{
  FLASH (rx) : ORIGIN = 0x18000, LENGTH = 0x28000
  RAM (rwx) :  ORIGIN = 0x20002000, LENGTH = 0x6000
}

INCLUDE "gcc_nrf51_common.ld"

The makefile has not been modified except for adding debug data with -O0 -g3.

I also attach the resulting nrf51422_xxac.map.map file.

UPDATE

I provide 2 .hex files of the same project compiled with Keil and GCC, both without oprimization -O0. Is there someone to know why the Hex provided by Keil is working and the other not? To test it, I use nRFGo Studio to push the .hex into the chip.

It should be a simple flash address problem isn't it?

nrf51422_xxac_gcc.hex

nrf51422_xxac_keil.hex

SOLUTION

My chip is XXAA using 16kb of RAM instead of 32kb for XXAC. Change .ld file from

MEMORY
{
  FLASH (rx) : ORIGIN = 0x18000, LENGTH = 0x28000
  RAM (rwx) :  ORIGIN = 0x20002000, LENGTH = 0x6000
}

to

MEMORY
{
  FLASH (rx) : ORIGIN = 0x18000, LENGTH = 0x28000
  RAM (rwx) :  ORIGIN = 0x20002000, LENGTH = 0x2000
}
Related