PlatformIO, nRF52832 and MyBoardNRF5
I'm back with another problem...
I've started trying to get some nodes up and running, and I've hit a roadblock. I'm using PlatformIO as my IDE and my nodes are using Rigado BMD-300 modules, which are based on nRF52832 chips. I managed to get them to work in Arduino IDE a couple of years ago, using MyBoardNRF5, but I'm struggling to get them to work in PlatformIO.
I've managed to make a MyBoardNRF5.json file and put it in 'board' in my project folder and the files under variants in variants\MyBoardNRF5, but I'm struggling with where to put MyBoardNRF5.h/.cpp. I've tried to put them in 'variants\MyBoardNRF5', in include and in 'src', but it seems PlatformIO isn't picking them up, as I get an error message that the reference "g_ADigitalPinMap" is undefined, which happens in compat_pin_arduino.h. It also looks like I need to define MYBOARDNRF5 somewhere, so that the information from MyBoardNRF5.cpp is included if this file is loaded.
Anyone using PlatformIO with a nRF52832 chip, using MyBoardNRF5, have a small project they're willing to share so I can see how it is built up and where the various files should be put?
[env:MyBoardNRF5] platform = nordicnrf52 board = MyBoardNRF5 framework = arduino board_build.mcu = nrf52832 monitor_speed = 115200 monitor_port = COM10 upload_protocol = blackmagic build_flags = -I variants/MyBoardNRF5 lib_deps = mysensors/MySensors@^2.3.2 adafruit/Adafruit BME280 Library@^2.2.2
MyBoardNRF5.h/.cpp need to be in src
There is another folder where you have to place the board definitions. I think if you Google on MyBoardNRF5 platformio you will find what you need.
Also checkout this topic https://forum.mysensors.org/topic/9266/guide-nrf5-nrf51-nrf52-for-beginners
Googling "platformio myboardnrf5 nrf52832" gives this thread as the first hit...
I had already copied the variant.xxx files into the correct folder and MyBoardNRF5.h/cpp to src. Will they be automatically included during Build, or do I need to tell the compiler to include them somehow?
Another thing, when doing this in the Arduino IDE, it seems several compiler directives (?) are set when you select the board and processor, which seems to not happen in PlatformIO, like MYBOARDNRF5 and MY_ARDUINO_CORE_NRF5. Is this something I need to do somehow in platformio.ini or do I add them in main.cpp? I tried to do it in main.cpp, and then it complained about missing syscalls.h (from variant.h)
I had also seen the guide for beginners-thread previously, but it didn't get any clearer this time either.
This post might help:
If it doesn't, let me know and I will dig for the exact example
Thanks. I had looked at this previously. He was using nrf52_dk, not MyBoardNRF5. I don't know if that makes it easier or harder. I'm not a programmer, which is probably part of why I'm struggling to get this to work...
If you have a proper example to show, that would be great!
Maybe just ditch PlatformIO for the nodes and use Arduino IDE instead, but I would prefer to continue using PlatformIO.
@Stig all right I will have a look but I'm pretty sure I've used the same example, so that should work for you also
I've placed the test code here: https://github.com/rikki78/NRF5_test
I hope this helps you!
I see that you don't define MYBOARDNRF5 anywhere, unless that happens in any of the MySensors files. Doesn't this exclude more or less everything from MyBoardNRF.cpp?
Another thing, when I try to do upload (through PlatformIO), it comes up with 2 targets, but I can't see anywhere where I can specify the target to attach to. When I try to start arm-eabi-none-gdb manually, it fails with an internal error when I try to attach to a target manually.
The target is set in the platformio.ini file
upload_port = COM6
I'm not sure about the define your talking about, maybe that isn't needed and the pins are defined in the boards directory. What happens if you define this MYBOARDNRF5?
upload_port does not specify the target. It just selects if you'll use the gdb port or the uart port from the BMP. The target I'm talking about is what comes up when trying to do upload.
Configuring upload protocol... AVAILABLE: blackmagic, cmsis-dap, jlink, nrfjprog, nrfutil, stlink CURRENT: upload_protocol = blackmagic Looking for BlackMagic port... Auto-detected: COM2 Uploading .pio\build\MyBoardNRF5\firmware.hex Target voltage: 3.45V Available Targets: No. Att Driver 1 Nordic nRF52 M3/M4 2 Nordic nRF52 Access Port 0x000020d8 in transportProcessFIFO() () Loading section .text, size 0x895c lma 0x0 Loading section .ARM.exidx, size 0x8 lma 0x895c Loading section .data, size 0x23c lma 0x8964 Start address 0x32e0, load size 35744 Transfer rate: 42 KB/sec, 916 bytes/write. Section .text, range 0x0 -- 0x895c: matched. Section .ARM.exidx, range 0x895c -- 0x8964: matched. Section .data, range 0x8964 -- 0x8ba0: matched. Kill the program being debugged? (y or n) [answered Y; input not from terminal]
If I don't do
then PlatformIO complains about undefined reference to 'g_ADigitalPinMap', which is in compat_pin_mapping.h and is called from MyBoardNRF5.cpp when MYBOARDNRF5 is defined. But I see that your variant.h/.cpp is different than the ones coming with ArduinoHwNRF5, which I'm using. Maybe try your version instead and see what happens...