Modifying mbed_app.json

I need to modify mbed_app.json to enable the WiFi/BLE stacks on the M4 core of my Portenta H7.

I’ve been instructed to add:

"components_add": [
          "QSPIF",
          "WHD",
          "4343W_FS",
          "CYW43XXX"
],

to the mbed_app.json for the Portenta H7_M4 core. I can find the file at ~/.platformio/packages/framework-arduino-mbed/variants/PORTENTA_H7_M4, but changing it does not seem to rebuild the mbed core.

How can I apply these modifications to the .json file?

See GitHub - arduino/ArduinoCore-mbed.

Thanks for the response Max

Unfortunately I can’t get the mbed to arduino script working.
At first, I was getting this error after running ./mbed-os-to-arduino -a -g PORTENTA_H7_M4:PORTENTA_H7_M4

./mbed-os-to-arduino: line 335: declare: -A: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]

Which I managed to at least bypass by changing the line to declare -a (which isn’t identical, but seems close in meaning)

Once I did that, the build completes successfully, but the script wants to put the built files in /variants/0/ instead of /variants/PORTENTA_H7_M4 like expected:

Generating defines..../mbed-os-to-arduino: line 148: /Users/trylaarsdam/.platformio/packages/framework-arduino-mbed/variants/0/defines.txt: No such file or directory

For reference, I’m on MacOS 13.2.1

Turns out that the script just isn’t compatible with MacOS. Ran it on linux and the script appeared to work, but I’m getting these errors when compiling with the new version: (these are from the Arduino IDE, figured I’d try that first since that’s what the guide was talking about before moving on to PIO)

In file included from /Users/trylaarsdam/Documents/Arduino/hardware/arduino-git/mbed/cores/arduino/Arduino.h:26:0,
from /private/var/folders/7t/mjzq3kd54hldx9vr39qygscc0000gn/T/arduino/sketches/37A9C64A51AF387F6D851B0F3EBCB060/sketch/portenta-m4-wifi.ino.cpp:1:
/Users/trylaarsdam/Documents/Arduino/hardware/arduino-git/mbed/variants/PORTENTA_H7_M7/pinmode_arduino.h:30:10: fatal error: api/Common.h: No such file or directory
#include “api/Common.h”
^~~~~~~~~~~~~~
compilation terminated.

And the same error for the M4:
In file included from /Users/trylaarsdam/Documents/Arduino/hardware/arduino-git/mbed/cores/arduino/Arduino.h:26:0,
from /private/var/folders/7t/mjzq3kd54hldx9vr39qygscc0000gn/T/arduino/sketches/37A9C64A51AF387F6D851B0F3EBCB060/sketch/portenta-m4-wifi.ino.cpp:1:
/Users/trylaarsdam/Documents/Arduino/hardware/arduino-git/mbed/variants/PORTENTA_H7_M4/pinmode_arduino.h:30:10: fatal error: api/Common.h: No such file or directory
#include “api/Common.h”
^~~~~~~~~~~~~~
compilation terminated.

These files do exist and I can see them in finder, but it doesn’t look like the compiler can see them.

The ArduinoCore APIs are not in the repo (this also confused me in the past). You have to get clone GitHub - arduino/ArduinoCore-API: Hardware independent layer of the Arduino cores defining the official API and copy the api folder of that into /Users/trylaarsdam/Documents/Arduino/hardware/arduino-git/mbed/cores/arduino.

1 Like

Ah - I had seen a GH issue about that same issue but it didn’t specify where it was supposed to go so I just cloned Arduino-API into arduino-git/mbed

Once I moved it to /mbed/cores/arduino/ I can compile now. Thanks!