openthread_nrf52_arduino icon indicating copy to clipboard operation
openthread_nrf52_arduino copied to clipboard

[Feature] Support PlatformIO

Open soburi opened this issue 4 years ago • 4 comments

It maybe need to create new repository.

Even if so, this package's build system are complex to support PlatformIO. Simplify the build system (#4) to help to creating PlatformIO package.

soburi avatar Nov 12 '19 12:11 soburi

Hi @soburi I might be able to help with this - I have ported a different arduino emulation lib (for linux) to build and work properly in platformio as a 'first class - standard arduino' target. If I use your project I would be willing to do the glue needed and send in a PR.

Am I correct that this project isn't just a "openthread" project but also a "port of arduino to run on top of a nrf52 with soft device"? It seems like your soft device is already 7.0.2 which is new enough to work with new processor needs (nrf52833). Previously we were using ESP32s and NRF52840. For the nrf52 I've been using the adafruit-nrf52-arduino project, but that project is still using soft device 6.1.1 - so I either need to update that project or switch to a different arduino port. Would you recommend using your project in this application?

geeksville avatar Oct 18 '20 09:10 geeksville

HI @geeksville

Sorry for the delayed response. (I was a bit busy recently week.)

If I use your project I would be willing to do the glue needed and send in a PR.

Ok. Any PR is welcoming!

Am I correct that this project isn't just a "openthread" project but also a "port of arduino to run on top of a nrf52 with soft device"?

Yes. This project depends on Thread and Zigbee SDK and The SDK use SoftDevice. Thus, this project is worked on SoftDevice.

Would you recommend using your project in this application?

I think this project is not even matured.

There are a few things to keep in mind when using this project.

It basically uses code base original 'Adafruit_nRF52_Arduino'. The significant change is this project is using SoftDevice. It is make modifing to 'bluefruit.cpp' and 'Adafruit_TinyUSB_nRF.cpp'. And 'IPAddress' class is modified and depends on openthread's IPaddress representation. It may cause some problems. I think it is better to revert to original source if not use openthread.

soburi avatar Nov 03 '20 09:11 soburi

Thanks for your reply . alas - since I opened this I went and fixed my immediate root problem (updating nrf52 arduino to run with soft device 7.2) So I think I'll be staying with adafruit nrf52 for now (and I'll send them a PR)

geeksville avatar Nov 11 '20 04:11 geeksville

Hello all!

Ive made some hacky changes so this project can be built with platformio:

  • https://github.com/leojrfs/openthread_nrf52_arduino/commit/b42ed248b27a738209af47ea174eaf5aa00bb9b6, a single change to this repo, so we can use is as a "platform_packages" entry in platformio.ini
  • https://github.com/leojrfs/platform-nordicnrf52/commit/64bc4c71f833358f2ece2aa85986976472058c20 and https://github.com/platformio/builder-framework-arduino-nrf5/commit/08ccc03196db3c58fbd52ddd55b20ea406c927ae so that it can be built

So in theory should be easy to integrate with platformio.

I managed to build but after flashing it doesnt seem to go past the bootloader.

take the following example in src/main.app:

#include <Arduino.h>
// seems to need this header or else it errors out with undefined references
#include "Adafruit_TinyUSB.h"


void setup()
{
    pinMode(LED_BUILTIN, OUTPUT);
    pinMode(PIN_LED2, OUTPUT);
}

void loop()
{
    digitalWrite(LED_BUILTIN, HIGH);
    digitalWrite(PIN_LED2, LOW);
    delay(250);
    digitalWrite(LED_BUILTIN, LOW); 
    digitalWrite(PIN_LED2, HIGH);
    delay(250);
}

If one uses the original adafruit arduino core, this example works correctly:

  • content in platformio.ini:
[env:nrf52840_dk_adafruit]
platform = nordicnrf52
board = nrf52840_dk_adafruit
framework = arduino
upload_protocol = jlink
monitor_speed = 115200
monitor_port = /dev/tty.usbmodem32201
  • flash the bootloader from adafruit :
wget https://raw.githubusercontent.com/adafruit/Adafruit_nRF52_Arduino/master/bootloader/pca10056/pca10056_bootloader-0.6.2_s140_6.1.1.hex
nrfjprog --program pca10056_bootloader-0.6.2_s140_6.1.1.hex -f nrf52 --chiperase --reset
  • build and upload the example app from platformio:
platformio run -t upload

The same procedure for this core doesn't work, it seems to get stuck in the bootloader (with LED1 flashing):

  • content in platformio.ini:
[env:nrf52840_dk_adafruit]
platform = https://github.com/leojrfs/platform-nordicnrf52.git
board = nrf52840_dk_adafruit
framework = arduino
platform_packages =
  framework-arduinoadafruitnrf52 @ https://github.com/leojrfs/openthread_nrf52_arduino.git#master
upload_protocol = jlink
monitor_speed = 115200
monitor_port = /dev/tty.usbmodem32201
  • flash the bootloader from this repo :
wget https://raw.githubusercontent.com/soburi/openthread_nrf52_arduino/master/bootloader/pca10056/pca10056_bootloader-0.6.1_s140_7.0.1.hex
nrfjprog --program pca10056_bootloader-0.6.1_s140_7.0.1.hex -f nrf52 --chiperase --reset
  • build and upload the example app from platformio:
platformio run -t upload

any hints?

leojrfs avatar Feb 17 '22 14:02 leojrfs