🛠 Programmer les deux cœurs M7 et M4 du GIGA R1 et les faire communiquer
Objectives
Leverage the unique feature of the GIGA R1 in the Arduino range: program the Cortex-M7 (up to 480 MHz) and the Cortex-M4 (up to 240 MHz) of the STM32H747XI separately, for example using Arduino/C++ on the M7 and MicroPython on the M4, then make them communicate via RPC. This is the ideal approach for isolating a real-time interface from an application layer.
Hardware
- 1 Arduino GIGA R1 WiFi board
- 2 USB-C cables or a hub (one port per core on the PC side, depending on the core used)
- Arduino IDE 2.x with "Arduino Mbed OS Giga Boards" and the Arduino Create / MicroPython extension
- Basic knowledge of the serial console
Complete Code
// GIGA R1 WiFi — coeur M7 (Arduino) : horloge maitre qui pousse le temps vers le M4
// Cote M4 : un script MicroPython recoit les messages via le canal RPC embarque.
#include <Arduino.h>
#include "RPC.h"
void setup {
Serial.begin(115200); // console USB du M7
RPC.begin; // canal inter-cceurs M7 <-> M4
Serial.println("M7 pret, envoi vers le M4");
}
void loop {
RPC.printf("tick %lu\n", millis); // message vers le coeur secondaire
delay(1000);
String msg = RPC.readStringUntil('\n'); // reponse eventuelle du M4
if (msg.length) Serial.print("M4> ");
Serial.print(msg);
}
On the M4 side (MicroPython, after uploading the MicroPython firmware to the secondary core):
# M4 MicroPython — lecture du canal RPC
import time
try:
import rpc
canal = rpc.RPC
while True:
msg = canal.read
if msg:
print("M7>", msg)
time.sleep_ms(50)
except Exception as e:
print("RPC indisponible:", e)
Expected Verification
The M7 console displays "M7 ready" and then starts sending regular messages; the M4 console (or the MicroPython monitor) receives lines such as "tick 1000", "tick 2000", etc. Both cores run in parallel: a busy while True loop on the M4 does not interrupt the heartbeat of the M7.
Common Errors
- Believing that a single sketch runs both cores: each core has its own firmware and its own upload process; official documentation explicitly describes separate Arduino + MicroPython setups linked by RPC.
- Missing or incompatible RPC library for the core version: update "Arduino Mbed OS Giga Boards"; the exact API on the MicroPython side varies with versions.
- Improperly sized shared memory: the M7 has 192 KB of TCM RAM and up to 864 KB of user SRAM; inter-core sharing consumes RAM; avoid large buffers.
- Confusion with the Zephyr core: the new ArduinoCore-zephyr core uses an LLEXT loader at 0x08040000 and a dynamic loading model different from the Mbed model.
Other tutorials for this board
Code examples for this board
clignotante.inoArduinobouton.inoArduinorespiration.inoArduinoanalogique.inoArduinodac-onde.inoArduinooled-i2c.inoArduino