#!/bin/bash # SN-L00 Firmware Build Script # Used by CI and local development set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" BUILD_DIR="${SCRIPT_DIR}/build" # Check for Pico SDK if [ -z "$PICO_SDK_PATH" ]; then # Try common locations if [ -d "/usr/share/pico-sdk" ]; then export PICO_SDK_PATH="/usr/share/pico-sdk" elif [ -d "$HOME/pico-sdk" ]; then export PICO_SDK_PATH="$HOME/pico-sdk" elif [ -d "/opt/pico-sdk" ]; then export PICO_SDK_PATH="/opt/pico-sdk" else echo "ERROR: PICO_SDK_PATH not set and SDK not found in common locations" echo "Please set PICO_SDK_PATH or install pico-sdk" exit 1 fi fi echo "Using Pico SDK: $PICO_SDK_PATH" # Clean build if requested if [ "$1" = "clean" ]; then echo "Cleaning build directory..." rm -rf "$BUILD_DIR" fi # Create build directory mkdir -p "$BUILD_DIR" cd "$BUILD_DIR" # Configure echo "Configuring..." cmake .. -DCMAKE_BUILD_TYPE=Release # Build echo "Building..." make -j$(nproc) # Report results if [ -f "sn_l00.uf2" ]; then echo "" echo "Build successful!" echo "Output: $BUILD_DIR/sn_l00.uf2" ls -lh sn_l00.uf2 sn_l00.elf else echo "Build failed - no output file" exit 1 fi