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
}
Parents
  • Hi, tried the .hex you attached and it's not running on my end either. Also looked at your .map file and it appears to be linked correctly assuming your SDK version is 8.x.x or later. Did you do any modifications to the makefile itself?

    Please compare your Makefile with the one I attached to this tutorial ->blinky s110

    Edit 10.11

    Ran the exact same code in SDK 10.0.0 without any problems, only changed the pin number to LED_1 to test it with my DK kit. Attached the .hex I compiled below which should toggle pin 19. Remember to load s110 v8.0.0. as well. Please try this one and see if it makes any difference.

    attachment:

  • ah, sorry, thought you used the DK kit. The xxAA chip variant has 16K of RAM as opposed to 32K on xxAC (chip overview). The linker in Keil places the call stack on top of the application, whereas the GNU linker in our SDK places the stack pointer in top of RAM (0x20008000). Change this line in the .ld from RAM (rwx) : ORIGIN = 0x20002000, LENGTH = 0x6000 to RAM (rwx) : ORIGIN = 0x20002000, LENGTH = 0x2000

Reply Children
No Data
Related