platformio / platform-nordicnrf51

Nordic nRF51: development platform for PlatformIO
https://registry.platformio.org/platforms/platformio/nordicnrf51
Apache License 2.0
20 stars 25 forks source link

nrf51822 : support for mbed framework broken #26

Closed stefaandesmet2003 closed 5 years ago

stefaandesmet2003 commented 5 years ago

Hi, I have 2 issues : 1) trying to build&upload the nrf51 examples, I run into the following problem. Build is successful, but the build script's last step is to merge 'firmware.hex' and 'userfirmware.hex', but firmware.hex doesn't exist in the build directory. This gives an error on the upload step (see output log below). I can't figure out where 'firmware.hex' is supposed to come from. userfirmware.hex is built from firmware.elf; I can upload this file to the target with openocd, and it works correctly, but it requires the correct nordic SoftDevice to be already present in flash. 2) all the nrf51822.ld files in framework-mbed offset the user app in flash & ram, using offsets for a nordic SoftDevice, even when building with mbed BLE, like the mbed-ble-thermometer example. This causes the device to run out of RAM ( issue #18 ), and wastes ~90k of flash space on a double BLE stack. Is there a way to configure a build with or without nordic softdevice? Thanks for your help, Stefaan

[build step - end]

Compiling .pioenvs/nrf51_mkit/src/main.o
Generating LD script .pioenvs/nrf51_mkit/NRF51822.ld.link_script.ld
Linking .pioenvs/nrf51_mkit/firmware.elf
Checking size .pioenvs/nrf51_mkit/firmware.elf
Building .pioenvs/nrf51_mkit/userfirmware.hex
Memory Usage -> http://bit.ly/pio-memory-usage
DATA:    [=         ]   5.9% (used 960 bytes from 16384 bytes)
PROGRAM: [=         ]   9.4% (used 12340 bytes from 131072 bytes)
merge_firmwares([".pioenvs/nrf51_mkit/firmware.hex"], [".pioenvs/nrf51_mkit/userfirmware.hex"])

[upload step ->error ]

Uploading .pioenvs/nrf51_mkit/firmware.hex
GNU MCU Eclipse 64-bits Open On-Chip Debugger 0.10.0+dev-00392-gbe9ef0b0 (2018-01-12-14:56)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
0x4000
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 1000 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : clock speed 950 kHz
Info : STLINK v2 JTAG v27 API v2 SWIM v6 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 3.227369
Info : nrf51.cpu: hardware has 4 breakpoints, 2 watchpoints
Info : Listening on port 3333 for gdb connections
target halted due to debug-request, current mode: Thread
xPSR: 0xc1000000 pc: 0x000006d0 msp: 0x000007c0
** Programming Started **
auto erase enabled
Error: couldn't open .pioenvs/nrf51_mkit/firmware.hex
embedded:startup.tcl:476: Error: ** Programming Failed **
in procedure 'program'
in procedure 'program_error' called at file "embedded:startup.tcl", line 532
at file "embedded:startup.tcl", line 476
*** [upload] Error 1

I'm using the platformio extension in vscode on ubuntu, with github latest platform-nordicnrf51 (which pulls framework-mbed version 5.51104.190214)

valeros commented 5 years ago

Hi @stefaandesmet2003 ! Thanks for reporting! Indeed, there was a problem with merging firmware and the softdevice binary. It should be fixed in the latest framework package. Would be great if you could test it with your board.