Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
161 changes: 161 additions & 0 deletions .github/workflows/test-pico2-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
name: Pico2 Build Validation

on:
push:
branches: [main, release/*]
Comment thread
psiddh marked this conversation as resolved.
paths:
Comment thread
psiddh marked this conversation as resolved.
Comment thread
psiddh marked this conversation as resolved.
- examples/raspberry_pi/pico2/**
- backends/cortex_m/**
Comment thread
psiddh marked this conversation as resolved.
schedule:
# Run daily at 3 AM UTC to catch upstream breakages
- cron: '0 3 * * *'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
Comment thread
psiddh marked this conversation as resolved.
Outdated
cancel-in-progress: true

jobs:
test-pico2-fp32-build:
name: test-pico2-fp32-build
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
permissions:
id-token: write
contents: read
with:
runner: linux.2xlarge.memory
docker-image: ci-image:executorch-ubuntu-22.04-arm-sdk
submodules: 'recursive'
ref: ${{ github.sha }}
Comment thread
psiddh marked this conversation as resolved.
Outdated
timeout: 60
Comment thread
psiddh marked this conversation as resolved.
Outdated
script: |
# Activate conda environment from the docker image
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
conda activate "${CONDA_ENV}"

source .ci/scripts/utils.sh
Comment thread
psiddh marked this conversation as resolved.
install_executorch "--use-pt-pinned-commit"

# Install ARM baremetal toolchain
.ci/scripts/setup-arm-baremetal-tools.sh
source examples/arm/arm-scratch/setup_path.sh

echo "=== Step 1: Export FP32 model ==="
cd examples/raspberry_pi/pico2
python export_mlp_mnist.py
test -f balanced_tiny_mlp_mnist.pte
echo "FP32 model exported: $(ls -la balanced_tiny_mlp_mnist.pte)"
cd -

echo "=== Step 2: Build FP32 firmware ==="
./examples/raspberry_pi/pico2/build_firmware_pico.sh --model=balanced_tiny_mlp_mnist.pte

echo "=== Step 3: Validate FP32 artifacts ==="
ELF_FILE=examples/raspberry_pi/pico2/build/executorch_pico.elf
UF2_FILE=examples/raspberry_pi/pico2/build/executorch_pico.uf2

test -f "${ELF_FILE}" || { echo "FAIL: .elf not found"; exit 1; }
test -f "${UF2_FILE}" || { echo "FAIL: .uf2 not found"; exit 1; }

echo "--- Section sizes ---"
arm-none-eabi-size -A "${ELF_FILE}"

echo "--- Section headers ---"
arm-none-eabi-objdump -h "${ELF_FILE}"

echo "--- Key symbols ---"
arm-none-eabi-nm --print-size --size-sort --radix=d "${ELF_FILE}" | tail -20

# Validate binary fits in Pico2 memory:
# .text in flash (4MB = 4194304 bytes)
# .bss + .data in SRAM (520KB = 532480 bytes)
TEXT_SIZE=$(arm-none-eabi-size -A "${ELF_FILE}" | awk '/.text/ {print $2}')
BSS_SIZE=$(arm-none-eabi-size -A "${ELF_FILE}" | awk '/.bss/ {print $2}')
DATA_SIZE=$(arm-none-eabi-size -A "${ELF_FILE}" | awk '/.data/ {print $2}')

echo "FP32 binary: .text=${TEXT_SIZE} .bss=${BSS_SIZE} .data=${DATA_SIZE}"

SRAM_USED=$((BSS_SIZE + DATA_SIZE))
if [ "${TEXT_SIZE}" -gt 4194304 ]; then
echo "FAIL: .text (${TEXT_SIZE}) exceeds 4MB flash"
exit 1
fi
if [ "${SRAM_USED}" -gt 532480 ]; then
echo "FAIL: .bss+.data (${SRAM_USED}) exceeds 520KB SRAM"
exit 1
fi
echo "PASS: FP32 firmware fits in Pico2 memory (SRAM: ${SRAM_USED}/532480, Flash: ${TEXT_SIZE}/4194304)"
Comment thread
psiddh marked this conversation as resolved.
Outdated

test-pico2-cmsis-build:
name: test-pico2-cmsis-nn-build
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
permissions:
id-token: write
contents: read
with:
runner: linux.2xlarge.memory
docker-image: ci-image:executorch-ubuntu-22.04-arm-sdk
submodules: 'recursive'
ref: ${{ github.sha }}
Comment thread
psiddh marked this conversation as resolved.
Outdated
timeout: 60
Comment thread
psiddh marked this conversation as resolved.
Outdated
script: |
# Activate conda environment from the docker image
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
conda activate "${CONDA_ENV}"

source .ci/scripts/utils.sh
Comment thread
psiddh marked this conversation as resolved.
install_executorch "--use-pt-pinned-commit"

# Install ARM baremetal toolchain
.ci/scripts/setup-arm-baremetal-tools.sh
source examples/arm/arm-scratch/setup_path.sh

echo "=== Step 1: Export INT8 CMSIS-NN model ==="
cd examples/raspberry_pi/pico2
python export_mlp_mnist_cmsis.py
test -f balanced_tiny_mlp_mnist_cmsis.pte
echo "INT8 model exported: $(ls -la balanced_tiny_mlp_mnist_cmsis.pte)"
cd -

echo "=== Step 2: Build CMSIS-NN firmware ==="
./examples/raspberry_pi/pico2/build_firmware_pico.sh --cmsis --model=balanced_tiny_mlp_mnist_cmsis.pte

echo "=== Step 3: Validate CMSIS-NN artifacts ==="
ELF_FILE=examples/raspberry_pi/pico2/build/executorch_pico.elf
UF2_FILE=examples/raspberry_pi/pico2/build/executorch_pico.uf2

test -f "${ELF_FILE}" || { echo "FAIL: .elf not found"; exit 1; }
test -f "${UF2_FILE}" || { echo "FAIL: .uf2 not found"; exit 1; }

echo "--- Section sizes ---"
arm-none-eabi-size -A "${ELF_FILE}"

echo "--- Section headers ---"
arm-none-eabi-objdump -h "${ELF_FILE}"

echo "--- Key symbols ---"
arm-none-eabi-nm --print-size --size-sort --radix=d "${ELF_FILE}" | tail -20

# Verify CMSIS-NN symbols are linked
if arm-none-eabi-nm "${ELF_FILE}" | grep -q "cmsis_nn\|arm_nn"; then
echo "PASS: CMSIS-NN symbols found in binary"
else
echo "WARNING: No CMSIS-NN symbols detected — verify cortex_m backend linked correctly"
Comment thread
psiddh marked this conversation as resolved.
Outdated
fi

# Validate binary fits in Pico2 memory
TEXT_SIZE=$(arm-none-eabi-size -A "${ELF_FILE}" | awk '/.text/ {print $2}')
BSS_SIZE=$(arm-none-eabi-size -A "${ELF_FILE}" | awk '/.bss/ {print $2}')
DATA_SIZE=$(arm-none-eabi-size -A "${ELF_FILE}" | awk '/.data/ {print $2}')

echo "CMSIS-NN binary: .text=${TEXT_SIZE} .bss=${BSS_SIZE} .data=${DATA_SIZE}"

SRAM_USED=$((BSS_SIZE + DATA_SIZE))
if [ "${TEXT_SIZE}" -gt 4194304 ]; then
echo "FAIL: .text (${TEXT_SIZE}) exceeds 4MB flash"
exit 1
fi
if [ "${SRAM_USED}" -gt 532480 ]; then
echo "FAIL: .bss+.data (${SRAM_USED}) exceeds 520KB SRAM"
exit 1
fi
echo "PASS: CMSIS-NN firmware fits in Pico2 memory (SRAM: ${SRAM_USED}/532480, Flash: ${TEXT_SIZE}/4194304)"
Loading