feat: wireless firmware updates via direct-XIP dual-slot boot #356
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Badgemagic Firmware build | |
| on: | |
| push: | |
| pull_request: | |
| branches: [master] | |
| env: | |
| MRS_TOOLCHAIN: MRS_Toolchain_Linux_x64_V1.92 | |
| USBC_4KEY_BUILD_DIR: usb-c-4key | |
| USBC_2KEY_BUILD_DIR: usb-c-2key | |
| MICROB_4KEY_BUILD_DIR: micro-b-4key | |
| MICROB_2KEY_BUILD_DIR: micro-b-2key | |
| BIN_TYPES: '{.bin,.elf}' | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # fetch tags for versioning | |
| - name: Cache toolchain | |
| id: cache-toolchain | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.MRS_TOOLCHAIN }} | |
| key: ${{ env.MRS_TOOLCHAIN }}-cache | |
| - if: ${{ steps.cache-toolchain.outputs.cache-hit != 'true' }} | |
| name: Download toolchain | |
| run: | | |
| wget https://github.com/ch32-riscv-ug/MounRiver_Studio_Community_miror/releases/download/1.92-toolchain/${{ env.MRS_TOOLCHAIN }}.tar.xz | |
| tar -xvf ${{ env.MRS_TOOLCHAIN }}.tar.xz | |
| - name: Build firmware | |
| run: | | |
| export PREFIX=${{ env.MRS_TOOLCHAIN }}/RISC-V_Embedded_GCC/bin/riscv-none-embed- | |
| BUILD_DIR=${{ env.USBC_4KEY_BUILD_DIR }}/slotA HARDWARE_REV3=1 KEY_COUNT=4 SLOT=A make -j$(nproc) | |
| BUILD_DIR=${{ env.USBC_4KEY_BUILD_DIR }}/slotB HARDWARE_REV3=1 KEY_COUNT=4 SLOT=B make -j$(nproc) | |
| BUILD_DIR=${{ env.USBC_2KEY_BUILD_DIR }}/slotA KEY_COUNT=2 SLOT=A make -j$(nproc) | |
| BUILD_DIR=${{ env.USBC_2KEY_BUILD_DIR }}/slotB KEY_COUNT=2 SLOT=B make -j$(nproc) | |
| BUILD_DIR=${{ env.MICROB_4KEY_BUILD_DIR }}/slotA HARDWARE_REV1=1 KEY_COUNT=4 SLOT=A make -j$(nproc) | |
| BUILD_DIR=${{ env.MICROB_4KEY_BUILD_DIR }}/slotB HARDWARE_REV1=1 KEY_COUNT=4 SLOT=B make -j$(nproc) | |
| BUILD_DIR=${{ env.MICROB_2KEY_BUILD_DIR }}/slotA HARDWARE_REV1=1 KEY_COUNT=2 SLOT=A make -j$(nproc) | |
| BUILD_DIR=${{ env.MICROB_2KEY_BUILD_DIR }}/slotB HARDWARE_REV1=1 KEY_COUNT=2 SLOT=B make -j$(nproc) | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: badgemagic-firmware | |
| path: | | |
| ${{ env.USBC_4KEY_BUILD_DIR }}/slotA/badgemagic-* | |
| ${{ env.USBC_4KEY_BUILD_DIR }}/slotB/badgemagic-* | |
| ${{ env.USBC_2KEY_BUILD_DIR }}/slotA/badgemagic-* | |
| ${{ env.USBC_2KEY_BUILD_DIR }}/slotB/badgemagic-* | |
| ${{ env.MICROB_4KEY_BUILD_DIR }}/slotA/badgemagic-* | |
| ${{ env.MICROB_4KEY_BUILD_DIR }}/slotB/badgemagic-* | |
| ${{ env.MICROB_2KEY_BUILD_DIR }}/slotA/badgemagic-* | |
| ${{ env.MICROB_2KEY_BUILD_DIR }}/slotB/badgemagic-* | |
| # Skip upload APK for pull requests & only allow binaries build from master | |
| - if: ${{ github.event_name != 'pull_request' && github.ref_name == 'master' }} | |
| name: Upload firmware binaries to bin branch | |
| run: | | |
| git config --global user.name "${{ github.workflow }}" | |
| git config --global user.email "gh-actions@${{ github.repository_owner }}" | |
| git checkout --orphan bin | |
| git reset | |
| git add ${{ env.USBC_4KEY_BUILD_DIR }}/slotA/badgemagic-*${{ env.BIN_TYPES }} | |
| git add ${{ env.USBC_4KEY_BUILD_DIR }}/slotB/badgemagic-*${{ env.BIN_TYPES }} | |
| git add ${{ env.USBC_2KEY_BUILD_DIR }}/slotA/badgemagic-*${{ env.BIN_TYPES }} | |
| git add ${{ env.USBC_2KEY_BUILD_DIR }}/slotB/badgemagic-*${{ env.BIN_TYPES }} | |
| git add ${{ env.MICROB_4KEY_BUILD_DIR }}/slotA/badgemagic-*${{ env.BIN_TYPES }} | |
| git add ${{ env.MICROB_4KEY_BUILD_DIR }}/slotB/badgemagic-*${{ env.BIN_TYPES }} | |
| git add ${{ env.MICROB_2KEY_BUILD_DIR }}/slotA/badgemagic-*${{ env.BIN_TYPES }} | |
| git add ${{ env.MICROB_2KEY_BUILD_DIR }}/slotB/badgemagic-*${{ env.BIN_TYPES }} | |
| git commit -am "[Auto] Update firmware binaries from ${{ github.ref_name }} ($(date +%Y-%m-%d.%H:%M:%S))" | |
| git push --force origin bin |