and tried simple blink to upload w/ STlink v2 in Platformio:
#include <Arduino.h>
void setup()
{
// initialize LED digital pin as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
void loop()
{
// turn the LED on (HIGH is the voltage level)
digitalWrite(LED_BUILTIN, HIGH);
// wait for a second
delay(100);
// turn the LED off by making the voltage LOW
digitalWrite(LED_BUILTIN, LOW);
// wait for a second
delay(100);
}
> Executing task in folder nrf-blink: C:\Users\max\.platformio\penv\Scripts\platformio.exe run --target upload <
Processing nrf52_dk (platform: nordicnrf52; board: nrf52_dk; framework: arduino)
----------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: [..]
PLATFORM: Nordic nRF52 (4.4.1) > Nordic nRF52-DK
HARDWARE: NRF52832 64MHz, 64KB RAM, 512KB Flash
DEBUG: Current (jlink) On-board (cmsis-dap, jlink) External (blackmagic, stlink)
PACKAGES:
- framework-arduinonordicnrf5 1.600.190830 (6.0)
- tool-bossac-nordicnrf52 1.10866.191129 (1.8.66)
- tool-jlink 1.65200.0 (6.52.0)
- tool-openocd 2.1000.200630 (10.0)
- tool-sreccat 1.164.0 (1.64)
- toolchain-gccarmnoneeabi 1.70201.0 (7.2.1)
LDF: Library Dependency Finder -> ..
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 2 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Checking size .pio\build\nrf52_dk\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [ ] 0.2% (used 140 bytes from 65536 bytes)
Flash: [ ] 0.5% (used 2536 bytes from 524288 bytes)
Configuring upload protocol...
AVAILABLE: blackmagic, cmsis-dap, jlink, mbed, nrfjprog, stlink
CURRENT: upload_protocol = stlink
Uploading .pio\build\nrf52_dk\firmware.hex
xPack OpenOCD, x86_64 Open On-Chip Debugger 0.10.0+dev-00378-ge5be992df (2020-06-26-09:29)
Licensed under GNU GPL v2
For bug reports, read
debug_level: 1
0x4000
nRF52 device has a CTRL-AP dedicated to recover the device from AP lock.
A high level adapter (like a ST-Link) you are currently using cannot access
the CTRL-AP so 'nrf52_recover' command will not work.
Do not enable UICR APPROTECT.
Error: timed out while waiting for target halted
embedded:startup.tcl:521: Error: ** Unable to reset target **
in procedure 'program'
in procedure 'program_error' called at file "embedded:startup.tcl", line 558
at file "embedded:startup.tcl", line 521
*** [upload] Error 1
============================================================ [FAILED] Took 2.21 seconds ============================================================
The terminal process "C:\Users\max\.platformio\penv\Scripts\platformio.exe 'run', '--target', 'upload'" terminated with exit code: 1.
Terminal will be reused by tasks, press any key to close it.
You can use the one that PlatformIO uses itself: It is installed in C:\Users\<User>\.platformio\packages\tool-openocd. Just cd in there with a terminal use the bin\openocd.exe binary and the scripts folder for the configs.
xPack OpenOCD, x86_64 Open On-Chip Debugger 0.10.0+dev-00378-ge5be992df (2020-06-26-09:29)
Licensed under GNU GPL v2
For bug reports, read OpenOCD: Bug Reporting
Info : auto-selecting first available session transport “dapdirect_swd”. To override use ‘transport select ’.
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : STLINK V2J37S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.180196
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_dap_op_connect(connect)
Info : SWD DPIDR 0x2ba01477
Error: Could not find MEM-AP to control the core
Info : starting gdb server for nrf52.cpu on 3333
Info : Listening on port 3333 for gdb connections
According to provideed links from Nordic devzone, now I must somehow connect to this gdb server and run command:
>dap apreg 1 0x04 0x01
Yes, my next question, how I can connect to this GDB server )
I’m not 100% sure of the top of my head, but at the end of the openocd invocation you can just chain additional commands using -c "my command" switches. So try with -c "dap apreg 1 0x04 0x01" -c "shutdown" at the end? (might need a init; halt; command too?)
The commands available through -c might be different from the what’s available on the telnet server though. As you can see in
openocd is accepting telnet connections on (localhost) port 4444. So just open another cmd window and use telnet 127.0.0.1 4444 to connect to it. help and other commands are your friends once connected.
If you don’t have telnet available on your machine, using ncat with ncat 127.0.0.1 4444.
I’m afraid this is a STLink or OpenOCD related problem then. You might get better help by opening a new topic on the nRF forums (or OpenOCD - Open On-Chip Debugger / Tickets).
But, given the board link you’ve given, it shows that it has a Micro-USB port and with a USB-Serial chip. Isn’t the chip supposed to be programmable through that? Is there no documentation available on how to program it with e.g. Arduino over the serial port? Maybe the UART bootloader on this chip allows erasing very simply, with something like nrfutil?
Fun side note: An STLink can be converted to a JLink by changing its firmware. element14 Community. So a cheap 5€ STLink clone might actually become a full JLink with better capabilities. Then, upload_protocol = nrfjprog might also be directly usable?
Hm weird design decision by the board makers. Do they just preload the board with some AT firmware for bluetooth connectivity and that’s supposed to be unchangeable then?
Thanks for the feedback, we hope you get around the access port lock on your specific chip so that PlatformIO can be used normally
Max
i using the NRF52 Bluefruit with ST-LINK V2 and openocd
i can burn successfully
it´s a ble application
the problem is that not merging the SOFTDEVICE with my APP.
Then i can´t execute BLE application.
To make work, i have to BURN the SOFTDEVICE out the box
Can you help me ?
Sorry the post was cut off due to a bad connection probably, I meant, this looks like a builder script issue in PlatformIO, please open an issue at Issues · platformio/platform-nordicnrf52 · GitHub.