The `ArduinoIoTCloud-Basic` sample fails to build for Portenta H7

It really is all about the ignored libraries, PlatformIO has troubles identifying them correctly.

The way I look at it, is to look in the .pio/libdeps folder and try to identify libraries that don’t belong there:
grafik

The board, being a Portenta M7, is not a “MKR” (Maker) board like the MKR WiFI 1010, so everything starting with MKR is wrong. There should also not be any WiFi library in libdeps, because only the WiFi library from the framework is supposed to be taken, as listed here, so WiFi101 and WiFiNINA are wrong. RTCZero is equally wrong, since that’s for an Arduino Zero (Atmel SAMD21G18), not a Portenta (STM32H7…). It’s also not an ESP32, so Arduino_ESP32_OTA goes out.

Applying all that by using

[env:portenta_h7_m7]
platform = ststm32
board = portenta_h7_m7
framework = arduino
lib_ldf_mode = deep+
lib_deps =
   arduino-libraries/ArduinoIoTCloud@^1.13.0
lib_ignore =
   WiFiNINA
   WiFi101
   MKRNB
   MKRGSM
   Arduino_ESP32_OTA
   RTCZero

makes the example compile.

Linking .pio\build\portenta_h7_m7\firmware.elf
Checking size .pio\build\portenta_h7_m7\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [==        ]  17.8% (used 93128 bytes from 523624 bytes)
Flash: [=======   ]  69.6% (used 547680 bytes from 786432 bytes)
Building .pio\build\portenta_h7_m7\firmware.bin
====================[SUCCESS] Took 216.23 seconds ====================

There is a setting that should have been able to simplify all this, that is, ignoring at least libraries meant for a different architectures like SAMD and ESP32, that is lib_compat_mode = strict. That is however so strict that even the ArduinoIoT library gets filtered out as “nonmatching” (which seems like a bug in PIO because the library.properties does have mbed_portenta in it).

In any case, that should build now. The only thing to watch out for is that for a Portenta H7, it defines all these connectivity methods

grafik

You probably want to properly choose whether it should use WiFi, Ethernet, GSM, NB-IoT or whatever. As far as I can see it in thingProperties.h, it will prefer Ethernet if available

you might have to adapt so that it’s hardcoded to the WiFi path, while defining SSID and password, of course.

2 Likes