Skip to content
Merged
1 change: 0 additions & 1 deletion .github/workflows/check_help_text.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ jobs:
uses: actions/checkout@v4

- name: Install dependencies (Linux)
if: runner.os == 'Linux'
run: sudo apt install cmake ninja-build python3 build-essential libusb-1.0-0-dev

- name: Checkout Pico SDK
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/check_precompiled.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash

# Pass updated files in $updated_files environment variable
Comment thread
lurch marked this conversation as resolved.

# enc_bootloader
echo "$updated_files" | grep -q "^enc_bootloader/.*\.elf$"
enc_bootloader_elf_not_updated=$?
Comment thread
lurch marked this conversation as resolved.
Outdated
if [ $enc_bootloader_elf_not_updated -eq 1 ]; then
echo "Checking enc_bootloader files for modifications as ELFs have not been updated"
for file in enc_bootloader/*; do
if [[ "$file" == "enc_bootloader/CMakeLists.txt" || "$file" == "enc_bootloader/BUILD.bazel" ]]; then
continue
fi
if echo "$updated_files" | grep -q "$file"; then
Comment thread
lurch marked this conversation as resolved.
Outdated
echo "File $file is in the PR but enc_bootloader ELFs have not been updated"
exit 1
fi
done
fi

# picoboot_flash_id
echo "$updated_files" | grep -q "^picoboot_flash_id/.*\.bin$"
flash_id_bin_not_updated=$?
if [ $flash_id_bin_not_updated -eq 1 ]; then
echo "Checking picoboot_flash_id files for modifications as BINs have not been updated"
for file in picoboot_flash_id/*; do
if [[ "$file" == "picoboot_flash_id/CMakeLists.txt" || "$file" == "picoboot_flash_id/BUILD.bazel" ]]; then
continue
fi
if echo "$updated_files" | grep -q "$file"; then
echo "File $file is in the PR but flash_id BINs have not been updated"
Comment thread
lurch marked this conversation as resolved.
exit 1
fi
done
fi

# xip_ram_perms
echo "$updated_files" | grep -q "^xip_ram_perms/.*\.elf$"
xip_ram_perms_elf_not_updated=$?
if [ $xip_ram_perms_elf_not_updated -eq 1 ]; then
echo "Checking xip_ram_perms files for modifications as ELFs have not been updated"
for file in xip_ram_perms/*; do
if [[ "$file" == "xip_ram_perms/CMakeLists.txt" || "$file" == "xip_ram_perms/BUILD.bazel" ]]; then
continue
fi
if echo "$updated_files" | grep -q "$file"; then
echo "File $file is in the PR but xip_ram_perms ELFs have not been updated"
Comment thread
lurch marked this conversation as resolved.
exit 1
fi
done
fi
52 changes: 52 additions & 0 deletions .github/workflows/check_precompiled.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Check Precompiled Binaries

on:
pull_request:
paths:
- 'enc_bootloader/**'
- 'picoboot_flash_id/**'
- 'xip_ram_perms/**'

jobs:
check-precompiled:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install dependencies (Linux)
run: sudo apt install cmake ninja-build python3 build-essential gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib libusb-1.0-0-dev

- name: Checkout Pico SDK
uses: actions/checkout@v4
with:
repository: raspberrypi/pico-sdk
ref: develop
path: pico-sdk
submodules: 'true'

- name: Build and Install
run: |
cmake -S . -B build -G "Ninja" -D PICO_SDK_PATH="${{ github.workspace }}/pico-sdk" -D USE_PRECOMPILED=FALSE
cmake --build build
sudo cmake --install build

- name: Check precompiled binaries have been updated
run: |
updated_files=$(curl -s -u "${{ github.repository_owner }}":"${{ github.token }}" -H "Accept: application/vnd.github.v3+json" "${{ github.event.pull_request._links.self.href }}/files")
updated_files=$(jq -r '.[] | .filename' <<<"$updated_files")

export updated_files
echo "Updated files: $updated_files"
./.github/workflows/check_precompiled.sh

- name: Upload new precompiled binaries
if: always()
uses: actions/upload-artifact@v4
with:
name: precompiled-binaries
path: |
enc_bootloader/enc_bootloader.elf
enc_bootloader/enc_bootloader_mbedtls.elf
picoboot_flash_id/flash_id.bin
xip_ram_perms/xip_ram_perms.elf
14 changes: 10 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ if (NOT DEFINED USE_PRECOMPILED)
set(USE_PRECOMPILED true)
endif()

if (USE_PRECOMPILED)
set(EXTERNAL_PROJECT_INSTALL_COMMAND "")
else()
set(EXTERNAL_PROJECT_INSTALL_COMMAND ${CMAKE_COMMAND} --install .)
Comment thread
will-v-pi marked this conversation as resolved.
Outdated
endif()

# compile enc_bootloader.elf
ExternalProject_Add(enc_bootloader
PREFIX enc_bootloader
Expand All @@ -74,7 +80,7 @@ ExternalProject_Add(enc_bootloader
"-DUSE_MBEDTLS=0"
"-DPICO_DEBUG_INFO_IN_RELEASE=OFF"
BUILD_ALWAYS 1 # todo remove this
INSTALL_COMMAND ""
INSTALL_COMMAND "${EXTERNAL_PROJECT_INSTALL_COMMAND}"
)

set(ENC_BOOTLOADER_ELF ${CMAKE_BINARY_DIR}/enc_bootloader/enc_bootloader.elf)
Expand All @@ -91,7 +97,7 @@ if (TARGET mbedtls)
"-DUSE_MBEDTLS=1"
"-DPICO_DEBUG_INFO_IN_RELEASE=OFF"
BUILD_ALWAYS 1 # todo remove this
INSTALL_COMMAND ""
INSTALL_COMMAND "${EXTERNAL_PROJECT_INSTALL_COMMAND}"
)

set(ENC_BOOTLOADER_MBEDTLS_ELF ${CMAKE_BINARY_DIR}/enc_bootloader_mbedtls/enc_bootloader.elf)
Expand All @@ -109,7 +115,7 @@ if (NOT PICOTOOL_NO_LIBUSB)
"-DUSE_PRECOMPILED:BOOL=${USE_PRECOMPILED}"
"-DPICO_DEBUG_INFO_IN_RELEASE=OFF"
BUILD_ALWAYS 1 # todo remove this
INSTALL_COMMAND ""
INSTALL_COMMAND "${EXTERNAL_PROJECT_INSTALL_COMMAND}"
)

set(XIP_RAM_PERMS_ELF ${CMAKE_BINARY_DIR}/xip_ram_perms/xip_ram_perms.elf)
Expand All @@ -125,7 +131,7 @@ if (NOT PICOTOOL_NO_LIBUSB)
"-DUSE_PRECOMPILED:BOOL=${USE_PRECOMPILED}"
"-DPICO_DEBUG_INFO_IN_RELEASE=OFF"
BUILD_ALWAYS 1 # todo remove this
INSTALL_COMMAND ""
INSTALL_COMMAND "${EXTERNAL_PROJECT_INSTALL_COMMAND}"
)

set(FLASH_ID_BIN ${CMAKE_BINARY_DIR}/picoboot_flash_id/flash_id.bin)
Expand Down
6 changes: 6 additions & 0 deletions enc_bootloader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ if (NOT USE_PRECOMPILED)

pico_set_binary_type(enc_bootloader no_flash)
pico_add_dis_output(enc_bootloader)

if (USE_MBEDTLS)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/enc_bootloader.elf DESTINATION ${CMAKE_CURRENT_LIST_DIR} RENAME enc_bootloader_mbedtls.elf)
else()
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/enc_bootloader.elf DESTINATION ${CMAKE_CURRENT_LIST_DIR})
endif()
else()
project(enc_bootloader C CXX ASM)
message("Using precompiled enc_bootloader.elf")
Expand Down
Empty file modified enc_bootloader/enc_bootloader.elf
100755 → 100644
Empty file.
Binary file modified enc_bootloader/enc_bootloader_mbedtls.elf
Comment thread
lurch marked this conversation as resolved.
Binary file not shown.
2 changes: 2 additions & 0 deletions picoboot_flash_id/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ if (NOT USE_PRECOMPILED)
target_link_options(flash_id PRIVATE -nostartfiles -nodefaultlibs -Ttext=0)
pico_add_bin_output(flash_id)
pico_add_dis_output(flash_id)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/flash_id.bin DESTINATION ${CMAKE_CURRENT_LIST_DIR})
else()
project(flash_id C CXX ASM)
message("Using precompiled flash_id.bin")
Expand Down
Empty file modified picoboot_flash_id/flash_id.bin
100755 → 100644
Empty file.
2 changes: 2 additions & 0 deletions xip_ram_perms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ if (NOT USE_PRECOMPILED)
string(REPLACE "RAM(rwx) : ORIGIN = 0x20000000, LENGTH = 512k" "RAM(rwx) : ORIGIN = 0x13ffc000, LENGTH = 16k" LINKER_SCRIPT "${LINKER_SCRIPT}")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/memmap_xip_ram.ld "${LINKER_SCRIPT}")
pico_set_linker_script(xip_ram_perms ${CMAKE_CURRENT_BINARY_DIR}/memmap_xip_ram.ld)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/xip_ram_perms.elf DESTINATION ${CMAKE_CURRENT_LIST_DIR})
else()
project(xip_ram_perms C CXX ASM)
message("Using precompiled xip_ram_perms.elf")
Expand Down
Binary file modified xip_ram_perms/xip_ram_perms.elf
100755 → 100644
Binary file not shown.