#!/bin/bash # Build, sign, flash, wait for stub, attach GDB. set -e M=/home/fabiorafaelcoutada/portugalfuturista/universalisos/microkernel G=/home/fabiorafaelcoutada/.espressif/tools/xtensa-esp-elf-gdb/16.3_20250913/xtensa-esp-elf-gdb/bin/xtensa-esp32-elf-gdb MCUBOOT=/home/fabiorafaelcoutada/portugalfuturista/mcuboot UBOOT_TOOLS=/home/fabiorafaelcoutada/portugalfuturista/universalis-uboot/tools cd "$M" make TARGET=esp32 -j$(nproc) python3 "$UBOOT_TOOLS/mk_esp_mcuboot_image.py" build/esp32/universalisos.elf build/esp32/uos_esp.bin imgtool sign --key "$MCUBOOT/root-ec-p256.pem" --align 1 --version 1.0.0 \ --header-size 0x20 --pad-header --slot-size 0x180000 \ build/esp32/uos_esp.bin build/esp32/uos_esp_signed.bin esptool --chip esp32 --port /dev/ttyACM0 --baud 460800 write-flash \ 0x1000 "$MCUBOOT/build_esp32/mcuboot_esp32.bin" \ 0x20000 build/esp32/uos_esp_signed.bin # Wait for MCUboot + UOS break (no UART spam from UOS) sleep 6 # Drain residual MCUboot logs so GDB sees a clean stream stty -F /dev/ttyACM0 115200 raw -echo -ixon -ixoff 2>/dev/null || true timeout 1 cat /dev/ttyACM0 >/dev/null 2>&1 || true exec "$G" -n \ -ex "set confirm off" \ -ex "set remotetimeout 10" \ -ex "set architecture xtensa" \ -ex "file $M/build/esp32/universalisos.elf" \ -ex "target remote /dev/ttyACM0" \ -ex "p/x \$pc" \ -ex "p/x \$a1" \ -ex "info registers a0 a1 a2 pc ps" \ -ex "bt" \ -ex "x/8i \$pc"