Skip to content

apps/demo: probe the syscall stack from the MPU violation test #5502

apps/demo: probe the syscall stack from the MPU violation test

apps/demo: probe the syscall stack from the MPU violation test #5502

name: Build Firmware
on:
push:
branches: [main]
pull_request:
branches: [main, '*-branch']
workflow_call:
jobs:
changes-firmware:
runs-on: ubuntu-24.04
permissions:
pull-requests: read
outputs:
should-build: ${{ github.event_name != 'pull_request' || steps.filter.outputs.src == 'true' }}
steps:
- uses: dorny/paths-filter@v4
if: github.event_name == 'pull_request'
id: filter
with:
filters: |
src:
- '.github/actions/**'
- '.github/workflows/build-firmware.yml'
- 'boards/**'
- 'platform/**'
- 'resources/**'
- 'sdk/**'
- 'src/**'
- 'stored_apps/**'
- 'tools/**'
- 'third_party/**'
- 'cmake/**'
- 'CMakeLists.txt'
- 'Kconfig'
build-firmware:
needs: changes-firmware
if: needs.changes-firmware.outputs.should-build == 'true'
runs-on: ubuntu-24.04
container:
image: ghcr.io/coredevices/pebbleos-docker:v7
strategy:
matrix:
board:
- asterix
- obelix@dvt
- obelix@pvt
- getafix@dvt
- getafix@dvt2
slot:
- 0
- 1
exclude:
- board: "asterix"
slot: 1
steps:
- name: Mark Github workspace as safe
run: git config --system --add safe.directory "${GITHUB_WORKSPACE}"
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
submodules: true
- name: Fetch tags
run: git fetch --tags --force
- name: Rebase onto target branch
uses: ./.github/actions/rebase
with:
submodules: true
- name: Install Python dependencies
run: |
pip install -U pip
pip install -r requirements.txt
- name: Get npm cache directory
id: npm-cache-dir
shell: bash
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
- name: Set artifact board name
id: artifact_board
run: echo "NAME=$(printf '%s' "$BOARD" | tr @ _)" >> "$GITHUB_OUTPUT"
env:
BOARD: ${{ matrix.board }}
- name: Set slot suffix
id: slot_suffix
run: |
NEEDS_SUFFIX="obelix_dvt obelix_pvt getafix_dvt getafix_dvt2"
if echo $NEEDS_SUFFIX | grep -wq "${{ steps.artifact_board.outputs.NAME }}"; then
echo "SLOT_SUFFIX=_slot${{ matrix.slot }}" >> "$GITHUB_OUTPUT"
else
echo "SLOT_SUFFIX=" >> "$GITHUB_OUTPUT"
fi
- name: Configure
run: pbl configure --board '${{ matrix.board }}' -DCONFIG_FIRMWARE_SLOT=${{ matrix.slot }} -DCONFIG_RELEASE=y
- name: Build
run: pbl build
- name: Bundle
run: pbl bundle
- name: Copy artifacts
env:
BOARD: ${{ steps.artifact_board.outputs.NAME }}
SLOT_SUFFIX: ${{ steps.slot_suffix.outputs.SLOT_SUFFIX }}
run: |
pbz=$(ls build/normal_${BOARD}_*.pbz)
version=$(basename "$pbz" | sed -E "s/^normal_${BOARD}_//; s/(_slot[01])?\.pbz$//")
mkdir artifacts
cp "$pbz" artifacts/
cp build/pebbleos.hex "artifacts/firmware_${BOARD}_${version}${SLOT_SUFFIX}.hex"
cp build/pebbleos.bin "artifacts/firmware_${BOARD}_${version}${SLOT_SUFFIX}.bin"
cp build/pebbleos.elf "artifacts/firmware_${BOARD}_${version}${SLOT_SUFFIX}.elf"
cp build/pebbleos_loghash_dict.json \
"artifacts/firmware_${BOARD}_${version}${SLOT_SUFFIX}_loghash_dict.json"
- name: Store
uses: actions/upload-artifact@v7
with:
name: firmware-${{ steps.artifact_board.outputs.NAME }}${{ steps.slot_suffix.outputs.SLOT_SUFFIX }}
path: artifacts
- name: Get Build ID
id: build_id
run: |
echo "BUILD_ID=$(readelf -n build/pebbleos.elf | sed -n -e 's/^.*Build ID: //p')" >> "$GITHUB_OUTPUT"
- name: Upload log hash dictionary
if: ${{ github.event_name != 'pull_request' && github.repository == 'coredevices/PebbleOS' }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.LOG_HASH_BUCKET_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.LOG_HASH_BUCKET_SECRET }}
AWS_DEFAULT_REGION: us-east-1
run: |
pip install awscli
aws s3 cp build/pebbleos_loghash_dict.json \
"s3://${{ vars.LOG_HASH_BUCKET_NAME }}/${{ steps.build_id.outputs.BUILD_ID }}-${{ github.sha }}-normal.json" \
--endpoint-url "${{ vars.LOG_HASH_BUCKET_ENDPOINT }}"
merge-firmware:
needs: build-firmware
runs-on: ubuntu-24.04
strategy:
matrix:
board:
- obelix_dvt
- obelix_pvt
- getafix_dvt
- getafix_dvt2
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Download artifacts
uses: actions/download-artifact@v8
with:
pattern: firmware-${{ matrix.board }}_slot*
- name: Merge slot-specific pbz files
env:
BOARD: ${{ matrix.board }}
run: |
# Version string is embedded in the bundle name (git describe), e.g.
# normal_obelix_pvt_v4.35.0-2-gdeadbee_slot0.pbz -> v4.35.0-2-gdeadbee.
version=$(ls firmware-${BOARD}_slot0/normal_${BOARD}_*_slot0.pbz | \
sed -E "s/^.*normal_${BOARD}_//; s/_slot0\.pbz$//")
if [ ! -f "firmware-${BOARD}_slot1/normal_${BOARD}_${version}_slot1.pbz" ]; then
echo "::error::${BOARD} slot1 bundle $(ls firmware-${BOARD}_slot1/*.pbz) does not match slot0 version ${version}"
exit 1
fi
mkdir merged
python3 tools/merge_pbz.py \
--slot0-pbz "firmware-${BOARD}_slot0/normal_${BOARD}_${version}_slot0.pbz" \
--slot1-pbz "firmware-${BOARD}_slot1/normal_${BOARD}_${version}_slot1.pbz" \
--output "merged/normal_${BOARD}_${version}.pbz"
cp "firmware-${BOARD}_slot0/firmware_${BOARD}_${version}_slot0_loghash_dict.json" \
"merged/firmware_${BOARD}_${version}_loghash_dict.json"
- name: Store
uses: actions/upload-artifact@v7
with:
name: firmware-${{ matrix.board }}
path: merged
build-firmware-status:
needs: [changes-firmware, build-firmware, merge-firmware]
if: always()
runs-on: ubuntu-24.04
steps:
- if: >-
needs.build-firmware.result == 'failure' ||
needs.build-firmware.result == 'cancelled' ||
needs.merge-firmware.result == 'failure' ||
needs.merge-firmware.result == 'cancelled'
run: exit 1