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

Loading S310 in nRF51422 + blinky program not working.

Hi Nordic-Team,

I've spent a while trying to figure this out but I couldn't. I need your help.

I want to load the S310 softdevice to the nRF51422 chip + the blinky example. Once I have that working I can move on to programming my BLE/ANT application. Loading the blinky at address 0 works without any problem.

Before I moved to the PCA10007 board, I tried the same steps with the nRF51822 USB dongle S110 and that works. I could load the S110 and the BLE UART example.


Edit: On the same chip. Same steps as below. The softdevice S110 + blinky works.

loadbin _build/ble_app_uart_s110.bin 00016000 (address for S110)

I can even add the code below and see "Yes" printed in my com.

sd_softdevice_is_enabled(&enabled);
if (enabled == NRF_SUCCESS)
  simple_uart_putstring((const uint8_t*)"Yes ");
else
  simple_uart_putstring((const uint8_t*)"No ");

All logs and things I tried:

Board is PCA10007, REV 3.0.0 Chip is NRF51422 QFAAE0 1347AA

ARM GCC version:

arm-none-eabi-gcc --version
arm-none-eabi-gcc (4.8.2-14ubuntu1+6) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Compile output:

"/usr/bin/arm-none-eabi-gcc" -mcpu=cortex-m0 -mthumb -mabi=aapcs -DNRF51 -DBOARD_PCA10003 -DNRF51422_QFAA_E0 --std=gnu99 -mfloat-abi=soft -DDEBUG -g3 -O0 -Iincludes -I"../" -I"SDK/Include" -I"SDK/Include/gcc" -I"SDK/Include/ext_sensors" -I"SDK/Include/app_common" -I"SDK/Include/sd_common" -I"SDK/Include/s310" -I"SDK/Include/ble" -I"SDK/Include/ble/ble_services" -I"SDK/Include/ble/device_manager" -M main_blinky.c -MF "_build/main_blinky.d" -MT _build/main_blinky.o

"/usr/bin/arm-none-eabi-gcc" -mcpu=cortex-m0 -mthumb -mabi=aapcs -DNRF51 -DBOARD_PCA10003 -DNRF51422_QFAA_E0 --std=gnu99 -mfloat-abi=soft -DDEBUG -g3 -O0 -Iincludes -I"../" -I"SDK/Include" -I"SDK/Include/gcc" -I"SDK/Include/ext_sensors" -I"SDK/Include/app_common" -I"SDK/Include/sd_common" -I"SDK/Include/s310" -I"SDK/Include/ble" -I"SDK/Include/ble/ble_services" -I"SDK/Include/ble/device_manager" -c -o _build/main_blinky.o main_blinky.c

"/usr/bin/arm-none-eabi-gcc" -Xlinker -Map=_build/blinky_xxaa.map -mcpu=cortex-m0 -mthumb -mabi=aapcs -L SDK//Source//templates/gcc/ -Tgcc_nrf51_blank_xxaa.ld  _build/main_blinky.o _build/nrf_delay.o _build/system_nrf51.o _build/gcc_startup_nrf51.o  -o _build/blinky_xxaa.out

"/usr/bin/arm-none-eabi-objcopy" -O binary _build/blinky_xxaa.out _build/blinky_xxaa.bin

"/usr/bin/arm-none-eabi-objcopy" -O ihex _build/blinky_xxaa.out _build/blinky_xxaa.hex

JLink output:

JLinkExe -device nrf51422 -if swd -speed 100

SEGGER J-Link Commander V4.85d ('?' for help)
Compiled May 19 2014 17:57:41
Info: Device "NRF51422_XXAA" selected (257 KB flash, 16 KB RAM).
DLL version V4.85d, compiled May 19 2014 17:57:39
Firmware: J-Link Lite-Cortex-M V8 compiled Aug 29 2012 15:24:23
Hardware: V8.00
S/N: ********* 
Feature(s): GDB 
VTarget = 3.274V
Info: Found SWD-DP with ID 0x0BB11477
Info: Found Cortex-M0 r0p0, Little endian.
Info: FPUnit: 4 code (BP) slots and 0 literal slots
Found 1 JTAG device, Total IRLen = 4:
Cortex-M0 identified.
Target interface speed: 100 kHz

erase-all cmd:

w4 4001e504 2
w4 4001e50c 1
sleep 100
r
exit

state after cmd:

J-Link>h
PC = FFFFFFFE, CycleCnt = 00000000
R0 = FFFFFFFF, R1 = FFFFFFFF, R2 = FFFFFFFF, R3 = FFFFFFFF
R4 = FFFFFFFF, R5 = FFFFFFFF, R6 = FFFFFFFF, R7 = FFFFFFFF
R8 = FFFFFFFF, R9 = FFFFFFFF, R10= FFFFFFFF, R11= FFFFFFFF
R12= FFFFFFFF
SP(R13)= FFFFFFD8, MSP= FFFFFFD8, PSP= FFFFFFFC, R14(LR) = FFFFFFF9
XPSR = C1000003: APSR = NZcvq, EPSR = 01000000, IPSR = 003 (HardFault)
CFBP = 00000000, CONTROL = 00, FAULTMASK = 00, BASEPRI = 00, PRIMASK = 00

Blinky at address 0. Works without any problem.

load command:

r
loadbin _build/blinky_xxaa.bin 0
r
g
exit

state after cmd:

J-Link>h
PC = 0000041E, CycleCnt = 00000000
R0 = 000003E7, R1 = 00040000, R2 = 50000000, R3 = 00000167
R4 = 00000000, R5 = 00000000, R6 = FFFFFFFF, R7 = 20003FD8
R8 = FFFFFFFF, R9 = FFFFFFFF, R10= 1FFF4000, R11= 00000000
R12= FFFFFFFF
SP(R13)= 20003FD8, MSP= 20003FD8, PSP= FFFFFFFC, R14(LR) = 00000461
XPSR = 21000000: APSR = nzCvq, EPSR = 01000000, IPSR = 000 (NoException)
CFBP = 00000000, CONTROL = 00, FAULTMASK = 00, BASEPRI = 00, PRIMASK = 00

Loading S310 softdevice


Splitting .hex in two. ihex to binary ends up in a 250MB file. Same as it was with the S110 before 7.x.x.

"/usr/bin/arm-none-eabi-objcopy" -Iihex -Obinary --remove-section .sec3 s310/s310_nrf51422_1.0.0_softdevice.hex s310_nrf51422_1.0.0_softdevice_mainpart.bin
"/usr/bin/arm-none-eabi-objcopy" -Iihex -Obinary --remove-section .sec1 --remove-section .sec2 s310/s310_nrf51422_1.0.0_softdevice.hex s310_nrf51422_1.0.0_softdevice_uicr.bin

load cmd:

w4 4001e504 1
loadbin "s310_nrf51422_1.0.0_softdevice_mainpart.bin" 0
loadbin "s310_nrf51422_1.0.0_softdevice_uicr.bin" 0x10001000
r
g
exit

state after cmd:

J-Link>h
PC = 000194DE, CycleCnt = 00000000
R0 = FFFFFFFF, R1 = FFFFFFFF, R2 = FFFFFFFF, R3 = 00020000
R4 = FFFFFFFF, R5 = FFFFFFFF, R6 = FFFFFFFF, R7 = FFFFFFFF
R8 = FFFFFFFF, R9 = FFFFFFFF, R10= FFFFFFFF, R11= FFFFFFFF
R12= FFFFFFFF
SP(R13)= 200021B0, MSP= 200021B0, PSP= FFFFFFFC, R14(LR) = FFFFFFFF
XPSR = 61000000: APSR = nZCvq, EPSR = 01000000, IPSR = 000 (NoException)
CFBP = 00000000, CONTROL = 00, FAULTMASK = 00, BASEPRI = 00, PRIMASK = 00
J-Link>s
000194DE:  00 00              MOV     R0, R0
J-Link>s
000194E0:  00 00              MOV     R0, R0
J-Link>s
000194E2:  00 00              MOV     R0, R0
J-Link>s
000194E4:  00 00              MOV     R0, R0
J-Link>s
000194E6:  00 00              MOV     R0, R0
J-Link>s
000194E8:  00 00              MOV     R0, R0

load cmd for blinky at address 0x00020000

The address is defined in gcc_nrf51_s310_xxaa.ld FLASH (rx) : ORIGIN = 0x00020000, LENGTH = 0x20000

r
loadbin _build/blinky_xxaa.bin 20000
(also tried with _build/blinky_xxaa.hex)
r
g
exit

state after blinky.bin loaded:

HardFault

J-Link>h

WARNING: T-bit of XPSR is 0 but should be 1. Changed to 1.
PC = FFFFFFFE, CycleCnt = 00000000
R0 = 2000001C, R1 = 0000004A, R2 = DEADBEEF, R3 = 000005F7
R4 = 4000052C, R5 = FFFFFFFF, R6 = FFFFFFFF, R7 = FFFFFFFF
R8 = FFFFFFFF, R9 = FFFFFFFF, R10= FFFFFFFF, R11= FFFFFFFF
R12= FFFFFFFF
SP(R13)= 20003FE8, MSP= 20003FE8, PSP= FFFFFFFC, R14(LR) = FFFFFFF9
XPSR = 21000003: APSR = nzCvq, EPSR = 01000000, **IPSR = 003 (HardFault)**
CFBP = 00000000, CONTROL = 00, FAULTMASK = 00, BASEPRI = 00, PRIMASK = 00

state after blinky.hex loaded:

No HardFault but the LEDs aren't blinking.

J-Link>h
PC = 000194DE, CycleCnt = 00000000
R0 = FFFFFFFF, R1 = FFFFFFFF, R2 = FFFFFFFF, R3 = 00020000
R4 = FFFFFFFF, R5 = FFFFFFFF, R6 = FFFFFFFF, R7 = FFFFFFFF
R8 = FFFFFFFF, R9 = FFFFFFFF, R10= FFFFFFFF, R11= FFFFFFFF
R12= FFFFFFFF
SP(R13)= 200021B0, MSP= 200021B0, PSP= FFFFFFFC, R14(LR) = FFFFFFFF
XPSR = 61000000: APSR = nZCvq, EPSR = 01000000, IPSR = 000 (NoException)
CFBP = 00000000, CONTROL = 00, FAULTMASK = 00, BASEPRI = 00, PRIMASK = 00
J-Link>s
000194DE:  00 00              MOV     R0, R0
J-Link>s
000194E0:  00 00              MOV     R0, R0
J-Link>s
000194E2:  00 00              MOV     R0, R0

Now if I try to load blinky back to address 0 it doesn't work. I need to erase all and load again for the LEDs to start blinking again.


With Python Mergehex


I also tried with python mergehex.

python /usr/local/bin/hexmerge.py s310/s310_nrf51422_1.0.0_softdevice.hex _build/blinky_xxaa.hex:0x20000: -o s310_blinky.hex

state is same as before when loading blinky.hex at 0x20000, but the LEDs don't blink.

J-Link>h
PC = 000194DE, CycleCnt = 00000000
R0 = FFFFFFFF, R1 = FFFFFFFF, R2 = FFFFFFFF, R3 = 00020000
R4 = FFFFFFFF, R5 = FFFFFFFF, R6 = FFFFFFFF, R7 = FFFFFFFF
R8 = FFFFFFFF, R9 = FFFFFFFF, R10= FFFFFFFF, R11= FFFFFFFF
R12= FFFFFFFF
SP(R13)= 200021B0, MSP= 200021B0, PSP= FFFFFFFC, R14(LR) = FFFFFFFF
XPSR = 61000000: APSR = nZCvq, EPSR = 01000000, **IPSR = 000 (NoException)**
CFBP = 00000000, CONTROL = 00, FAULTMASK = 00, BASEPRI = 00, PRIMASK = 00
J-Link>s
000194DE:  FD E7              B       #-0x06
J-Link>s
000194DC:  20 BF              WFE
J-Link>s
000194DE:  FD E7              B       #-0x06
J-Link>s
000194DC:  20 BF              WFE
J-Link>s
000194DE:  FD E7              B       #-0x06
J-Link>s
000194DC:  20 BF              WFE
J-Link>s
000194DE:  FD E7              B       #-0x06
J-Link>s
000194DC:  20 BF              WFE
J-Link>s
000194DE:  FD E7              B       #-0x06
J-Link>s
000194DC:  20 BF              WFE
  • To add to the above. I went to Windows and tried with the nrfjprog.exe. Couldn't make it work either.

    Programming the softdevice and the program throws the error:
    ERROR: Merge not possible due to conflict in files.

    D:\nrf>nrfjprog -e --programs s310_nrf51422_1.0.0_softdevice.hex --program blinky_gcc_xxaa.hex --reset
    Applying system reset.
    Disabling flash write and erase protection mechanism.
    Erasing all flash (code region 0, code region 1 and UICR).
    Applying system reset.
    Enabling flash write and erase protection mechanism.
    Parsing hex file(s).
    ERROR: Merge not possible due to conflict in files.
    

    This part works. LEDs start blinking.

    D:\nrf>nrfjprog --program blinky_gcc_xxaa.hex
    Parsing hex file(s).
    Checking that there is no data to be written in region 0.
    Checking that there are no UICR conflicts.
    Disabling flash write and erase protection mechanism.
    Checking that the area to download is erased, and erasing if necessary.
    Programming.
    Enabling flash write and erase protection mechanism.
    
    D:\nrf>nrfjprog --reset
    Applying system reset.
    
Related