#!/bin/bash # Quick Build and Flash Script PROJECT_DIR="/Users/indianaholmessr/Desktop/iamDEV/c5 project/ESP32-C5-Toolkit" cd "$PROJECT_DIR" echo "========================================" echo "ESP32-C5 Toolkit - Quick Build & Flash" echo "========================================" echo "" # Check if ESP-IDF is sourced if [ -z "$IDF_PATH" ]; then echo "⚠️ ESP-IDF not sourced!" echo "" echo "Please run this first:" echo " source ~/esp/esp-idf/export.sh" echo "" echo "Then run this script again, or:" echo " cd \"$PROJECT_DIR\"" echo " idf.py --preview set-target esp32c5" echo " idf.py build" echo " idf.py -p /dev/cu.usbserial-* flash monitor" exit 1 fi echo "✓ ESP-IDF found: $IDF_PATH" echo "" # Set target echo "Setting target to ESP32-C5..." idf.py --preview set-target esp32c5 # Build echo "" echo "Building firmware..." idf.py build if [ $? -eq 0 ]; then echo "" echo "✓✓✓ BUILD SUCCESSFUL! ✓✓✓" echo "" # Try to find USB port USB_PORT=$(ls /dev/cu.usb* /dev/cu.SLAB* 2>/dev/null | head -1) if [ -n "$USB_PORT" ]; then echo "Found USB port: $USB_PORT" echo "" echo "Flashing and starting monitor..." echo "Press Ctrl+] to exit monitor" echo "" idf.py -p "$USB_PORT" flash monitor else echo "USB port not found automatically." echo "" echo "To flash manually, run:" echo " idf.py -p /dev/cu.YOUR_PORT flash monitor" echo "" echo "Available ports:" ls /dev/cu.* 2>/dev/null | grep -E "(usb|SLAB)" || echo " (none found)" fi else echo "" echo "❌ BUILD FAILED!" exit 1 fi