🛠 Débogage pas à pas : CMSIS-DAP et Arduino Debug Launcher

Arduino UNO R4 WiFi · avance · Schéma : IMG-uno-r4-wifi-avance-2-ur4wifi-debug-cmsis-dap.svg — UNO R4 WiFi avec deux ports USB-C annotés (HIC/débogueur à gauche, USB natif du RA4M1 à droite), écran d'IDE avec point d'arrêt rouge sur une ligne, pile d'appels et variables affichées.

Objectives

Move beyond Serial.print for debugging: the R4 is the first UNO with an embedded hardware debugger. The embedded USB bridge (HIC) exposes a CMSIS-DAP interface connected to the RA4M1's SWD, and the official Arduino Debug Launcher extension (VS Code / PlatformIO or IDE 2.x) enables breakpoints, stepping, and inspection of variables and memory — exactly like on STM32.

Hardware

Procedure

  1. Install the Arduino Debug Launcher extension and the proposed debugging component (OpenOCD/CMSIS-DAP managed by the extension).
  2. Open the sketch, place a breakpoint on a line in loop.
  3. Launch "Start Debugging": the board is flashed and then stopped at the breakpoint.
  4. Explore: local variables, global variables, call stack, Cortex-M4 registers, memory; step through with step-over/step-into (F10/F11).
// Croquis de test : le bug classique du débordement d'index.
int mesures[8];
int n = 0;

void setup { Serial.begin(115200); }

void loop {
  mesures[n] = analogRead(A0);   // point d'arrêt ici : surveillez n
  n++;
  if (n > 8) n = 0;              // bug volontaire : devrait etre n >= 8
  delay(200);
}

Expected Verification

Execution freezes at the breakpoint; the Variables window shows n increasing. By monitoring the array, you see the out-of-bounds write when n == 8 — the kind of bug invisible with Serial.print. Resume (F5), modify the condition, reflash, and recheck: this is the complete debugging loop.

Common Errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials