Files
CelloEffects/gcc/flash.sh
thomasandClaude Sonnet 5.5 66bb319423 CubeMX: SPI4 + SDMMC1/FatFs + I2S6, audio BSP et debug VS Code (Linux)
Regeneration CubeMX (Appli) preparant le driver ST67W611M1 et la carte SD :
- SPI4 (PE12/13/14, CS PF8) + DMA GPDMA1 canaux 4/5, SPI_RDY (PD12/EXTI12),
  CHIP_EN (PD13) et BOOT (PD15) pour la X-NUCLEO-67W61M1 sur l'Arduino
- SDMMC1 + FatFs (appels d'init non generes dans main, IRQ SDMMC1 prio 14),
  PM14 en open-drain ; I2S6_CK sur PA5 pour liberer PC12 (SDMMC1_CK)
- HAL UART retire ; USE_BSP_COM_FEATURE=0
- Audio preserve : ADF 4/16/24, prio IRQ 2, DMA canal 0 en priorite haute,
  GPDMA1_Channel2_IRQHandler deplace dans audio_irq.c (hors fichiers generes),
  BSP_MX_I2S6_Init (renommage dans le BSP pour eviter le conflit avec CubeMX)
- Middlewares/ST/ST67W6X_Network_Driver, FatFs et sources HAL SPI/SD ajoutes
  (driver ST67 pas encore integre au build)

Build et debug sous Linux :
- gcc/toolchain-env.sh, gdbserver.sh, arm-gdb.sh : outils de STM32CubeIDE par
  glob ; flash.sh les retrouve ; ruby_compat.rb pour Ruby >= 3.2 (TouchGFX)
- makefile_appli : sources SD/SPI/FatFs/audio_irq ; chmod +x des .out TouchGFX
- Objets de build (*.o, *.d, *.su) retires de l'index (deja dans .gitignore)
- AGENTS.md : toolchain Linux, configs VS Code (cppdbg et ST stlinkgdbtarget),
  pieges de l'extension ST (.settings/ide.store.json, preRunCommands reset)

Verifie sur carte : audio OK, debug Appli/Boot OK.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-23 22:49:06 +02:00

92 lines
3.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# Flash / probe helper for the STM32H7S78-DK dual-boot project (macOS/Linux).
#
# Usage: gcc/flash.sh <boot|appli|all|probe|reset|verify>
#
# boot Flash Boot (internal flash 0x08000000)
# appli Flash Appli (external OSPI flash 0x70000000, needs the external loader)
# all Flash Boot then Appli (required order)
# probe Connect to the board and print device info (no write)
# reset Hardware reset of the board
# verify Dump 4 KB of internal and external flash to /tmp for inspection
#
# The STM32H7RS core sits behind access port 1 and the running firmware can
# prevent a hot-plug connection, so every command uses "ap=1 mode=UR".
#
# STM32_Programmer_CLI is looked up in: $STM32_PROGRAMMER_CLI, $PATH,
# the standalone STM32CubeProgrammer app, then the STM32CubeIDE plugin.
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
BOOT_HEX="$ROOT/Boot/TouchGFX/build/bin/target.hex"
APPLI_HEX="$ROOT/Appli/TouchGFX/build/bin/target.hex"
LOADER="$ROOT/gcc/MX66UW1G45G_STM32H7S78-DK.stldr"
# Linux : outils de STM32CubeIDE installe dans ~/st (ST_PROGRAMMER_BIN, ST_GDBSERVER, PATH)
[[ -f "$ROOT/gcc/toolchain-env.sh" ]] && source "$ROOT/gcc/toolchain-env.sh"
find_cli() {
if [[ -n "${STM32_PROGRAMMER_CLI:-}" && -x "$STM32_PROGRAMMER_CLI" ]]; then
echo "$STM32_PROGRAMMER_CLI"; return
fi
if command -v STM32_Programmer_CLI >/dev/null 2>&1; then
command -v STM32_Programmer_CLI; return
fi
if [[ -x "${ST_PROGRAMMER_BIN:-}/STM32_Programmer_CLI" ]]; then
echo "$ST_PROGRAMMER_BIN/STM32_Programmer_CLI"; return
fi
local candidates=(
"/Applications/STMicroelectronics/programmer/STM32CubeProgrammer.app/Contents/MacOs/bin/STM32_Programmer_CLI"
"/Applications/STMicroelectronics/STM32Cube/STM32CubeProgrammer/STM32CubeProgrammer.app/Contents/MacOs/bin/STM32_Programmer_CLI"
"/opt/st/stm32cubeclt/STM32CubeProgrammer/bin/STM32_Programmer_CLI"
)
# STM32CubeIDE bundles its own copy; the plugin folder name changes with each update
local ide
for ide in /Applications/STMicroelectronics/STM32CubeIDE.app/Contents/Eclipse/plugins/com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.*/tools/bin/STM32_Programmer_CLI; do
candidates+=("$ide")
done
local c
for c in "${candidates[@]}"; do
[[ -x "$c" ]] && { echo "$c"; return; }
done
echo "error: STM32_Programmer_CLI not found (set STM32_PROGRAMMER_CLI)" >&2
exit 1
}
require() {
[[ -f "$1" ]] || { echo "error: $1 not found - build first (make -C gcc)" >&2; exit 1; }
}
CLI="$(find_cli)"
CONNECT=(-c port=SWD ap=1 mode=UR)
flash_boot() {
require "$BOOT_HEX"
echo ">>> Flashing Boot: $BOOT_HEX"
"$CLI" "${CONNECT[@]}" -d "$BOOT_HEX" -v -hardRst
}
flash_appli() {
require "$APPLI_HEX"
require "$LOADER"
echo ">>> Flashing Appli: $APPLI_HEX (external loader)"
"$CLI" "${CONNECT[@]}" -el "$LOADER" -d "$APPLI_HEX" -hardRst
}
case "${1:-}" in
boot) flash_boot ;;
appli) flash_appli ;;
all) flash_boot; flash_appli ;;
probe) "$CLI" -l st; "$CLI" "${CONNECT[@]}" ;;
reset) "$CLI" "${CONNECT[@]}" -hardRst ;;
verify)
"$CLI" "${CONNECT[@]}" -u 0x08000000 0x1000 /tmp/read_int.bin
"$CLI" "${CONNECT[@]}" -el "$LOADER" -u 0x70000000 0x1000 /tmp/read_ext.bin
;;
*)
sed -n '4,12p' "$0" | sed 's/^# \{0,1\}//'
exit 1
;;
esac