🛠 Premier sketch sur le cœur M4 : le blink qui se flash par ADB
Objectives
Program the Arduino side of the X8: you are programming the Cortex-M4 of the STM32H747XI (up to 240 MHz) from the Arduino IDE, while the Cortex-M7 of the same SoC runs the "normally invisible" bridge firmware that exposes the MCU peripherals to Linux. The main difference from a classic board: the sketch is uploaded via ADB (upload.tool=adb, VID 0x2341 / PID 0x0061, application slot 0x08100000–0x08200000), not via standard serial. You will install the core, flash a blink, and understand the roles of the three embedded systems on the board.
Hardware
- 1 × Arduino Portenta X8 + USB-C data cable (USB 3.0 port preferred)
- Arduino IDE 1.8.10+, Arduino IDE 2.x, or arduino-cli
- Board Manager: core “Arduino Mbed OS Portenta Boards”, then board “Arduino Portenta X8” (
arduino:mbed_portenta:portenta_x8) - The board must be visible to
adb devicesbefore any upload (see the getting started tutorial)
Full Code
// blink_m4.ino — coeur Cortex-M4 du STM32H747XI de la Portenta X8
// Carte : "Arduino Portenta X8" (arduino:mbed_portenta:portenta_x8)
// L'upload passe par ADB, pas par un port serie classique.
#include "SerialRPC.h" // optionnel : monitor serie proxyfie vers Linux
int compteur = 0;
void setup {
Serial.begin(115200); // visible cote Linux via le service m4-proxy
while (!Serial) {}
pinMode(LED_BUILTIN, OUTPUT);
Serial.println("Portenta X8 - sketch M4 en vie");
}
void loop {
digitalWrite(LED_BUILTIN, HIGH);
delay(500);
digitalWrite(LED_BUILTIN, LOW);
delay(500);
Serial.print("tick ");
Serial.println(compteur++);
}
Expected Verification
In the IDE, the upload displays progress via adb, then the sketch starts: the LED blinks at 1 Hz. The Serial of this sketch is not a classic USB serial port — it is proxied to Linux by the m4-proxy service (the RPC tutorial will teach you how to read it from a container). Keep an eye on the board: if the upload fails, adb devices must already respond before touching the code.
Common Errors
- Upload fails even though the code compiles: ADB upload requires the board to be seen by adb — under Linux, udev permissions are needed for VID
0x2341; historically, adb has also broken on arm64 hosts (ArduinoCore-mbed issue #492, closed). - Selecting “Portenta H7” instead of “Portenta X8”: same core family, different target — the X8 has a different bootloader/upload tool (adb).
- Waiting for the classic IDE serial monitor: on the X8, the M4 console goes through SerialRPC/m4-proxy on the Linux side; the standard USB serial monitor is not the documented path.
- Confusing the cores: the M4 is YOUR Arduino core; the M7 of the same SoC runs Arduino’s bridge firmware (do not flash it with the IDE — it is updated via a dedicated procedure, see the firmware tutorial).
- Compilation errors in online examples such as
QSPIFBlockDevice not foundorWiFiAccessPoint does not name a type: known rot from old examples (ArduinoCore-mbed issues #529 open / #884 closed) — start from the examples in the installed core, not from 2022 blogs. - >
Other tutorials for this board
- Premiers pas : comprendre le monstre à 9 cœurs et entrer dans Linux via ADB
- Docker dès la sortie de l'emballage : premier conteneur sur le Linux embarqué
- Pont Linux ↔ Arduino : appeler des fonctions du sketch M4 depuis Python (RPC)
- Mettre la X8 en réseau : Wi-Fi du Murata 1DX et Gigabit Ethernet sur porteuse
- Nœud IoT de datalogging : capteurs sur le M4, stockage et transport en conteneur
- Le firmware caché : mettre à jour le bridge STM32H7 M7 qui expose les périphériques à Linux
Code examples for this board
etat-systeme.shBashgpio-libgpiod.shBashpython-gpio.pyPythondocker-hello.shBashflasher-core-arduino.shBashwifi-nmcli.shBash