Update framework-arduino-nrf52-mbedos 1.3.0 to 1.3.2

Hi. I am working on a project with an Arduino Nano 33 BLE. When I compile the project, PlatformIO uses the version 1.3.0 of the arduino-mbedos, while in the Arduino IDE board manager I can get the versions 1.3.1 and 1.3.2. How can I tell PlatformIO to use a newer version than 1.3.0? Thank you in advance.

1 Like

Have you tried

platform_packages = 
   framework-arduino-nrf52-mbedos@https://github.com/arduino/ArduinoCore-mbed.git#1.3.2

in the platformio.ini first? (docs).

Otherwise update requests as an issue to the platform at Issues Ā· platformio/platform-nordicnrf52 Ā· GitHub please.

1 Like

Thank you for your reply. With that change in platformio.ini, it seems that Platformio tries to download and install the correct 1.3.2 version of arduino-mbedos, but unfortunately in the end it gives me the following error:

Installing git+https://github.com/arduino/ArduinoCore-mbed.git#1.3.2
git version 2.29.2.windows.2
Cloning into ā€˜C:\Users\xxxxxx.platformio.cache\tmp\pkg-installing-rxfn24hoā€™ā€¦
remote: Enumerating objects: 4257, done.
remote: Counting objects: 100% (4257/4257), done.
remote: Compressing objects: 100% (3130/3130), done.
remote: Total 4257 (delta 1077), reused 3022 (delta 884), pack-reused 0
Receiving objects: 100% (4257/4257), 95.00 MiB | 11.99 MiB/s, done.
Resolving deltas: 100% (1077/1077), done.
Updating files: 100% (4240/4240), done.
Error: Could not find one of ā€˜package.jsonā€™ manifest files in the package

Any advice how to fix that? I have been able to find a not very elegant way to make Platformio uses the version 1.3.2 by overriding the files FROM:
C:\Users\xxxxxx\AppData\Local\Arduino15\packages\arduino\hardware\mbed\1.3.2
TO:
C:\Users\xxxxxx.platformio\packages\framework-arduino-nrf52-mbedos\

I have noticed the first folder does not contains the files ā€œ.piopmā€ and ā€œpackage.jsonā€

Iā€™ve forked the repo and added the package.json with the updated version info.

Can you try it with

platform_packages = 
   framework-arduino-nrf52-mbedos@https://github.com/maxgerhardt/ArduinoCore-mbed.git#1.3.2

?

1 Like

You are my hero. That definitely worked!! Now I am getting a compilation error, but I was able to successfully install the framework-arduino-nrf52-mbedos version1.3.2. Including the missing files in the fork will probably also solve the compilation error.

Tool Manager: Installing git+https://github.com/maxgerhardt/ArduinoCore-mbed.git#1.3.2
git version 2.30.0.windows.2
Cloning into 'C:\Users\xxxxx\.platformio\.cache\tmp\pkg-installing-uy19n7c1'...
remote: Enumerating objects: 4267, done.
remote: Counting objects: 100% (4267/4267), done.
remote: Compressing objects: 100% (3140/3140), done.
remote: Total 4267 (delta 1083), reused 3022 (delta 884), pack-reused 0
Receiving objects: 100% (4267/4267), 94.99 MiB | 10.44 MiB/s, done.
Resolving deltas: 100% (1083/1083), done.
Updating files: 100% (4248/4248), done.
Tool Manager: framework-arduino-nrf52-mbedos @ 1.3.2+sha.fb246c0 has been installed!
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/nordicnrf52/nano33ble.html
PLATFORM: Nordic nRF52 (7.0.0) > Arduino Nano 33 BLE
HARDWARE: NRF52840 64MHz, 256KB RAM, 960KB Flash
DEBUG: Current (blackmagic) External (blackmagic, cmsis-dap, jlink)
PACKAGES:
 - framework-arduino-nrf52-mbedos 1.3.2+sha.fb246c0
 - tool-sreccat 1.164.0 (1.64)

..................
..................
C:\users\xxxxx\.platformio\packages\framework-arduino-nrf52-mbedos\variants\ARDUINO_NANO33BLE/pinmode_arduino.h:23:10: fatal error: api/Common.h: No such file or directory
1 Like

My bad, I should test out stuff before I post it :smiley:

It is indeed weird though how the arduino-nrf52-mbedos repo does not include the API folder. The content for that is at GitHub - arduino/ArduinoCore-API: Hardware independent layer of the Arduino cores defining the official API as noted in https://github.com/platformio/platform-nordicnrf52/issues/53#issuecomment-536727405 and is only last-minute included in the package that gets downloaded by the Arduino IDE.

So I just pulled up the Arduino IDE, let it install the core in the 1.3.2 version and grabbed the api folder from there and added it in the branch.

Please delete the folder C:\users\xxxxx\.platformio\packages\framework-arduino-nrf52-mbedos\ and C:\users\xxxxx\.platformio\.cache to force PlatformIO to redownload the framework package. After a rebuild then, it should work.

Iā€™ve tested it this time and Iā€™m getting

Processing nano33ble (platform: nordicnrf52; board: nano33ble; framework: arduino)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Tool Manager: Installing git+https://github.com/maxgerhardt/ArduinoCore-mbed.git#1.3.2
git version 2.29.2.windows.2
Cloning into 'C:\Users\Max\.platformio\.cache\tmp\pkg-installing-8pa0g19m'...
remote: Enumerating objects: 4311, done.
remote: Counting objects: 100% (4311/4311), done.
remote: Compressing objects: 100% (3169/3169), done.
remote: Total 4311 (delta 1103), reused 3057 (delta 898), pack-reused 0
Receiving objects: 100% (4311/4311), 95.03 MiB | 4.74 MiB/s, done.
Resolving deltas: 100% (1103/1103), done.
Updating files: 100% (4288/4288), done.
Tool Manager: framework-arduino-nrf52-mbedos @ 1.3.2+sha.e69d97a has been installed!
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/nordicnrf52/nano33ble.html
PLATFORM: Nordic nRF52 (7.0.0) > Arduino Nano 33 BLE
HARDWARE: NRF52840 64MHz, 256KB RAM, 960KB Flash
DEBUG: Current (blackmagic) External (blackmagic, cmsis-dap, jlink)
PACKAGES:
 - framework-arduino-nrf52-mbedos 1.3.2+sha.e69d97a
 - tool-sreccat 1.164.0 (1.64)
 - toolchain-gccarmnoneeabi 1.80201.190214 (8.2.1)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 26 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio\build\nano33ble\src\main.cpp.o
Compiling .pio\build\nano33ble\FrameworkArduinoVariant\variant.cpp.o
Compiling .pio\build\nano33ble\FrameworkArduino\Interrupts.cpp.o
Compiling .pio\build\nano33ble\FrameworkArduino\Serial.cpp.o
Compiling .pio\build\nano33ble\FrameworkArduino\Tone.cpp.o
Compiling .pio\build\nano33ble\FrameworkArduino\USB\PluggableUSBDevice.cpp.o
Compiling .pio\build\nano33ble\FrameworkArduino\USB\USBCDC.cpp.o
Compiling .pio\build\nano33ble\FrameworkArduino\USB\USBSerial.cpp.o
Compiling .pio\build\nano33ble\FrameworkArduino\WMath.cpp.o
Compiling .pio\build\nano33ble\FrameworkArduino\abi.cpp.o
Compiling .pio\build\nano33ble\FrameworkArduino\api\Common.cpp.o
Compiling .pio\build\nano33ble\FrameworkArduino\api\IPAddress.cpp.o
Compiling .pio\build\nano33ble\FrameworkArduino\api\PluggableUSB.cpp.o
Compiling .pio\build\nano33ble\FrameworkArduino\api\Print.cpp.o
Compiling .pio\build\nano33ble\FrameworkArduino\api\Stream.cpp.o
Compiling .pio\build\nano33ble\FrameworkArduino\api\String.cpp.o
Compiling .pio\build\nano33ble\FrameworkArduino\itoa.c.o
Compiling .pio\build\nano33ble\FrameworkArduino\main.cpp.o
Compiling .pio\build\nano33ble\FrameworkArduino\mbed\platform\cxxsupport\mstd_mutex.cpp.o
Compiling .pio\build\nano33ble\FrameworkArduino\pinToIndex.cpp.o
Compiling .pio\build\nano33ble\FrameworkArduino\wiring.cpp.o
Compiling .pio\build\nano33ble\FrameworkArduino\wiring_analog.cpp.o
Compiling .pio\build\nano33ble\FrameworkArduino\wiring_digital.cpp.o
Compiling .pio\build\nano33ble\FrameworkArduino\wiring_pulse.cpp.o
Compiling .pio\build\nano33ble\FrameworkArduino\wiring_shift.cpp.o
Archiving .pio\build\nano33ble\libFrameworkArduinoVariant.a
Indexing .pio\build\nano33ble\libFrameworkArduinoVariant.a
Archiving .pio\build\nano33ble\libFrameworkArduino.a
Indexing .pio\build\nano33ble\libFrameworkArduino.a
Linking .pio\build\nano33ble\firmware.elf
Checking size .pio\build\nano33ble\firmware.elf
Building .pio\build\nano33ble\firmware.bin
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [==        ]  16.3% (used 42608 bytes from 262144 bytes)
Flash: [=         ]   7.8% (used 76964 bytes from 983040 bytes)
=================== [SUCCESS] Took 61.75 seconds ===================

:slight_smile:

2 Likes
Output:
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/nordicnrf52/nano33ble.html
PLATFORM: Nordic nRF52 (7.0.0) > Arduino Nano 33 BLE
HARDWARE: NRF52840 64MHz, 256KB RAM, 960KB Flash
DEBUG: Current (blackmagic) External (blackmagic, cmsis-dap, jlink)
PACKAGES:
 - framework-arduino-nrf52-mbedos 1.3.2+sha.e69d97a
 - tool-sreccat 1.164.0 (1.64)
 - toolchain-gccarmnoneeabi 1.80201.190214 (8.2.1)
Converting AMR_UC_Suspension.ino
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 28 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <ArduinoBLE> 1.2.0
|-- <SparkFun External EEPROM Arduino Library> 1.0.5
|   |-- <Wire>
Building in release mode
....................
....................
Linking .pio\build\nano33ble\firmware.elf
Building .pio\build\nano33ble\firmware.bin
Checking size .pio\build\nano33ble\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [===       ]  27.7% (used 72664 bytes from 262144 bytes)
Flash: [===       ]  33.7% (used 331668 bytes from 983040 bytes)
========================================================================== [SUCCESS] Took 46.81 seconds ==========================================================================

Compiled successfully. Thanks again maxgerhardt for fixing my problem and for teaching me a few things about Platformio and Git Repos usages. :pray:

Great to hear!

This is also tracked in Arduino MBed framework needs update (for Nano 33 BLE, etc.) Ā· Issue #111 Ā· platformio/platform-nordicnrf52 Ā· GitHub (and was also cross-tracked in a few other issues before), so hopefully soon in the next version, the package update will land and you can just normally update the Nordic-NRF52 platform then (PIO Home ā†’ Platform ā†’ Updates) when it releases.

1 Like

@maxgerhardt Updating to your branch definitely brought me to the latest, however there seems now to be a conflict with Arduinoā€™s USBSerial and mbedā€™s USBSerial.

Iā€™m attempting to use the SerialUSB from arduinoā€™s library, but it does not appear on my MacOS ā€“ is it best for me to open a new topic for this?

Can you quickly share the platformio.ini and source code that works in the Arduino IDE but fails here in PlatformIO?

Here is my arduino sketch, uploaded from the Web IDE:

void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.println("Hello World!");
  delay(1);        
}

Now as similar as I can do with mbed directly, on platformio.

#include <Arduino.h>

int main() {
    Serial.begin(9600);

    for(;;) {
        Serial.println("Hello World");
        delay(1);
    }

}

With the Arduino upload the serial device can be found, connected to, and prints as expected. However with the mbed/platformio upload the board cannot be found as a serial device at all (if I switch over to the bootloader I can find it as a serial device).

Why overwrite the main() function? This way the USB initialization functions wonā€™t get called.

Can you test the exact sketch

#include <Arduino.h>

void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.println("Hello World!");
  delay(1);        
}

on PlatformIO with

[env:nano33ble]
platform = nordicnrf52
board = nano33ble
framework = arduino
platform_packages = 
   framework-arduino-nrf52-mbedos@https://github.com/maxgerhardt/ArduinoCore-mbed.git#1.3.2

?

Okay, if I do it that way it does work (unsurprisingly). I was unaware of the initialization code that was present in main.

I am overriding main as Iā€™m really aiming to just use mbed APIs. Previously I was using USBSerial from mbed directly ā€“ however it appears something has changed and now that class is excluded from Arduino when I try to use it. The header for mbed and arduino are the same so the Arduino one is what is included. I tried changing the header file but I cannot get the compiler to resolve to the mbedā€™s USBSerial.

This unblocks me though, I can initialize what I need from Arduino for Serial and use that ā€“ though I would be interested in using the mbed USBSerial as a learning exercise.

Thanks so much :slight_smile:

Quick Edit:

USBSerial in mbed: Mbed OS Reference | USBSerial.h Source File

the guard conflicts with: ArduinoCore-mbed/PluggableUSBSerial.h at master Ā· arduino/ArduinoCore-mbed Ā· GitHub

I assume this is intentional, but I guess this becomes an Arduino question now, not a platformio one :slight_smile:

Aah, but now I understand what you want to do.

Can you try this piece of code?

#include "mbed/mbed.h"
#include <drivers/USBSerial.h>

USBSerial usbSerial;

int main(void) {
  while (1) {
    usbSerial.printf("Konnichiwa from mbed-os USBSerial!\r\n");
    thread_sleep_for(1000);
  }
  return 0;
}

The two classes eem to have the same name but theyā€™re in different namespaces.

Also take a look at the mbed.h file ā€“ they do a little trickery here that actually always includes Arduino.h and then the real mbed/mbed.h.

1 Like

Ah that is some trickery! Thank you for pointing that out. I did notice the difference in namespaces, and would get ambiguity errors, but I didnā€™t know the syntax for resolving the mbed one (the header does the trick for sure).

This really helps, now I can use my previous code and be completely free from the Arduino libraries and use the Nano 33 BLE as a purely mbed board (which is cool). Now you may ask why I bought an Arduino board to begin with ā€“ to which I have no answer.

It is cool though that hobbiests can start with an Arduino board here, and later move lower-level and more advanced with mbed and have a path to good tooling.

1 Like

The linked issue has been resolved and you can use the normal platformio.ini

[env:nano33ble]
platform = nordicnrf52
board = nano33ble
framework = arduino

and delete the C:\Users\<user>\.platformio\packages\framework-arduino-nrf52-mbedos folder, then on the next ā€œBuildā€, it will download the latest version that has now been uploaded into the official PlatformIO repositories.

Processing nano33ble (platform: nordicnrf52; board: nano33ble; framework: arduino)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Tool Manager: Installing platformio/framework-arduino-nrf52-mbedos @ ~1.3.0
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Tool Manager: framework-arduino-nrf52-mbedos @ 1.3.2 has been installed!
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/nordicnrf52/nano33ble.html
PLATFORM: Nordic nRF52 (7.0.0) > Arduino Nano 33 BLE
HARDWARE: NRF52840 64MHz, 256KB RAM, 960KB Flash
DEBUG: Current (blackmagic) External (blackmagic, cmsis-dap, jlink)
PACKAGES:
 - framework-arduino-nrf52-mbedos 1.3.2
 - tool-sreccat 1.164.0 (1.64)
 - toolchain-gccarmnoneeabi 1.80201.190214 (8.2.1)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
..
RAM:   [==        ]  16.7% (used 43744 bytes from 262144 bytes)
Flash: [=         ]   8.2% (used 80768 bytes from 983040 bytes)
======================= [SUCCESS] Took 61.83 seconds ===================

So, this issue is now official solved and does not require my repackaged version anymore.

Trying to update to latest master from arduino like so:

platform_packages =
framework-arduino-nrf52-mbedos@https://github.com/arduino/ArduinoCore-mbed.git

yields an error:

Error: Could not find one of 'package.json' manifest files in the package

Is this a discrepancy between what you did and the latest in the master branch @maxgerhardt?

Wonā€™t work because of two reasons:

  • the repo needs to have a package.json describing that itā€™s the PlatformIO package framework-arduino-mbed
  • this repo is special because it does not contain all the files. See ā€œapiā€ folder in the packed arduino release

and the folder content at ArduinoCore-mbed/cores/arduino at main Ā· arduino/ArduinoCore-mbed Ā· GitHub. That is also mentioned in their README.

See Commits Ā· maxgerhardt/ArduinoCore-mbed Ā· GitHub for how I did it ā€“ a fork followed by adding the package.json with the right version number and a manual re-add of the api folder gives a repo that one can then refer to in platform_pacakges.

PS: Thereā€™s also a PR Enable mbed-os support for Nano 33 BLE by maxgerhardt Ā· Pull Request #113 Ā· platformio/platform-nordicnrf52 Ā· GitHub open but itā€™s WIP with some questions unanswered.

This makes sense, yesterday I forked and added a package.json ā€“ interestingly didnā€™t need to add back in the api folder. Curious if this is related to them upgrading to mbed 6.8 for some reason.

But is it there in the repo? Without this, Arduino sketches should not be able to compile o_O. Do produced firmwares from this work?