🛠 Mise à jour OTA par bascule de banque sur le STM32H743ZI : 2 Mo de flash double banque

STM32H7 Nucleo-144 (flagship: NUCLEO-H743ZI) · avance · Schéma : IMG-stm32h7-nucleo-avance-2-stm32h743zi-dual-bank-ota.svg — flash 2 Mo du STM32H743ZI divisée en banque 1 (firmware actif) et banque 2 (image en cours d'écriture), flèche de bascule de banque (bank swap) et petit bloc « backup SRAM 4 Ko » avec le jumper SB156, flat vector style, étiquettes en français, fond blanc.

What you will build

The STM32H743ZI's 2 MB flash is dual-bank — the board sheet calls out bank-swap OTA updates as a headline feature. This tutorial designs the update scheme: run from bank 1, download a new image into bank 2, verify, swap, and keep a rollback path — plus the 4 KB backup SRAM (with its SB156 test jumper) as the place to keep the boot decision across power loss.

Architecture

Step 1 — Flash the staging bank

/* Erase + program the new image into bank 2 (HAL, STM32H7). */
FLASH_EraseInitTypeDef er = {
  .TypeErase    = FLASH_TYPEERASE_SECTORS,
  .Banks        = FLASH_BANK_2,
  .Sector       = 0,
  .NbSectors    = 9,          /* cover the image area - size for YOUR layout */
  .VoltageRange = FLASH_VOLTAGE_RANGE_3
};
uint32_t sec_err;
HAL_FLASHEx_Erase(&er, &sec_err);

/* Program in 256-bit (32-byte) flash words as required by the H7 family. */
HAL_FLASH_Program(FLASH_TYPEPROGRAM_FLASHWORD, bank2_dst, (uint32_t)chunk, chunk_len);

Step 2 — Verify, then swap

  1. Hash or CRC the written bank 2 content and compare against the manifest sent with the image.
  2. Arm the swap: write the boot flag into backup SRAM *before* touching bank configuration, so a power cut mid-update leaves a defined state.
  3. Reconfigure the bank mapping (option bytes / bank swap) so bank 2 becomes the execution base, then reset.

Step 3 — Rollback policy

On boot: if the backup-SRAM "image good" flag is absent after N attempts, swap back to the previous bank. Because both banks hold complete images, rollback is a remap, not a reflash.

Expected result

You can push a new firmware over your transport (the LwIP tutorial's Ethernet is the obvious carrier), watch the board reboot into the new image, and pull the plug mid-transfer without bricking: the old bank stays bootable until the swap is armed.

Common pitfalls

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials