@BearWithBeard said in GUIDE - NRF5 / NRF51 / NRF52 for beginners:
I just got my first NRF5 running. I'll note how I got it working in case any of you guys still have troubles:
Setup
- OS: Windows 10
- Programmer: STM32 Blue Pill with the Black Magic Probe firmware
- NRF5: EByte E73-TBB dev board with a E73-2G4M0S1B (NRF52832)
- Environment: PlatformIO
Instructions
Load the Black Magic Probe firmware with stlink
as the probe host onto Blue Pill. You can follow this guide.
Connect your new BMP to the NRF52 module:
BMP |
NRF52 |
Serial Port |
3V3 |
3V3 |
|
GND |
GND |
|
A5 |
SWDCLK |
GDB Server |
B14 |
SWDIO |
GBD Server |
A2 |
TX |
UART |
A3 |
RX |
UART |
Note: A2 and A3 are not required for programming. This is how you'd wire up the BMP for "classic" serial debugging. You can use the BMP both for programming and serial communication - no need for a second FTDI module.
Using the GNU Arm Embedded Toolchain, run arm-none-eabi-gdb
in a console and enter the following commands to unlock the NRF52:
target extended-remote BMP_GDB_SERVER_PORT
mon swdp_scan
attach N // N = number of "Nordic nRF52 Access Port" if there are several
mon erase_mass
detach
From the two serial ports the BMP provides, you want to use the GDB Server for BMP_GDB_SERVER_PORT
above. If Windows only provides generic names for both ("USB Serial Device" or something), the one with the lower number should (usually) be the right choice. If not, try the other one.
Windows users also must prefix the port with \\.\
if the number is double-digit, e.g. \\.\COM13
.
Now you can start uploading sketches the usual way. Here's my minimal PlatformIO config:
[env:nrf52_dk]
platform = nordicnrf52
board = nrf52_dk
board_build.variant = generic
framework = arduino
upload_protocol = blackmagic
lib_deps =
548 ; MySensors
And a minimal test sketch for MySensors:
#include <Arduino.h>
#define LED 17
#define MY_RADIO_RF24
#define MY_RADIO_NRF5_ESB
#define MY_NODE_ID 182
#define SKETCH_NAME "NRF52 Test"
#define SKETCH_VERSION "0.1"
#include <MySensors.h>
#define CHILD_ID 1
MyMessage msg(CHILD_ID, V_VAR1);
void presentation()
{
sendSketchInfo(SKETCH_NAME, SKETCH_VERSION);
present(CHILD_ID, S_CUSTOM);
}
void setup()
{
pinMode(LED, OUTPUT);
}
void loop()
{
static uint8_t num;
send(msg.set(num));
++num;
digitalWrite(LED, HIGH);
wait(5000);
digitalWrite(LED, LOW);
wait(5000);
}
Works like a charm so far! Now, if you please excuse me, I have a whole new microprocessor family to explore. Fun times!
For the life of me i cant figure out if im making the BlackMagic properly. I'm moving the boot0 jumper to 1, flashing the 8kb maple (usb flash) DFU file using the st-link application on windows.
I move the jumper back to 0, and connect using the micro usb, and i can flash code normally using arudino IDE using the STM32duino bootloader (and if i do so, i see the device communication on a new COM port).
From there i cant get anything from these guides to work. the windows STM "flash demonstrator" app doesnt recognize the device, and i dont have a linux machine available at the moment for the dfu-util (and Ubuntu shell on windows wont recognize the usb device). When i try to flash the blackmagic.bin starting at 0x08002000 using the ST-link software it shows it succeeded, but when i return the jumper to 0 and reset the device, this is what i get:
The 2 new COM ports appear (COM12,COM13), but i cant seem to flash anything successfully.
I've installed the GNU arm toolchain for windows and tried "target extended-remote \.\COM13" (12 just gets stuck on nothing), and i get: