I have a suspicion that this is related to the SoftDevice. I tried flashing example from the nrf52 SDK, and I got the same segfault address. Debugging a bit showed me that this occurs during BLE Stack (SoftDevice) initialization.
After I merged .hex file produced by ‘make’ command with SoftDevice .hex file from SDK, and flashed it, example started working. Maybe I need to write some kind of custom build command?
On the other hand, once I run load for merged .hex file, I could also load just make-produced .hex file (example code only) and it seems to work fine. Maybe I need to point platformIO to my softdevice hex, since it uses malformed or incompatible one?
I’m already using build_flags = -DNRF52_S132 in my platformio.ini - hackaBLE is based on nrf52832, which is s132 SoftDevice. SoftDevice that worked for me is from nRF52 SDK v15.3, s132_nrf52_6.1.1_softdevice.hex.
Does platformio produce code that isn’t yet merged with SoftDevice (or however it does that?), so I could try to merge it myself and upload it manually?
If it is a corrupted softdevice file, can you navigate to the path indicated by the code
So <home dir>/.platformio/packages/framework-arduinonrf52/cores/nRF5/SDK/components/softdevice/<softdevice>/hex/<hexfile> and then replace the hex file.
I tried putting in newer version of SoftDevice, but got the same issue as this guy:
It’s also seems like a relatively new issue? But also something is already in the package as a result of it. I tried changing URL to development version (platform = https://github.com/platformio/platform-nordicnrf52.git) in platformio.ini, but to no avail - I still get a segfault, although at a different address:
received signal SIGSEGV, Segmentation fault.
0x0001d27c in ?? ()
I also thought it may be a conflict between softdevices. So I went to gdb and ran
(gdb) target extended-remote /dev/ttyACM0
Remote debugging using /dev/ttyACM0
(gdb) monitor erase_mass
Target does not support this command.
(gdb) attach 1
Attaching to Remote target
warning: No executable has been specified and target does not support
determining executable automatically. Try using the "file" command.
0x0002b4a8 in ?? ()
(gdb) monitor erase_mass
erase..
(gdb) kill
Kill the program being debugged? (y or n) y
[Inferior 1 (Remote target) killed]
(gdb) run
Starting program:
warning: No executable has been specified and target does not support
determining executable automatically. Try using the "file" command.
Program received signal SIGSEGV, Segmentation fault.
0x00000000 in ?? ()
Which makes sense, I guess. But after I tried to upload code from platformio…
I still got a segfault at 0x00. So maybe issue is with flashing, somehow? What really bothered me is that gdb command for uploading is arm-none-eabi-gdb -nx --batch -ex "target extended-remote /dev/ttyACM0" -ex "monitor swdp_scan" -ex "attach 1" -ex load -ex compare-sections -ex kill /media/data/projects/BLE/BlinkyAdvert/.pio/build/hackaBLE/firmware.elf
I’m not sure how gdb processes this command line, but will this empy load command work? I’m not sure. At this point I’m honestly just saying ideas.