From 9ae1962e1bff7188c7991860258d68c231c89a87 Mon Sep 17 00:00:00 2001 From: William Vinnicombe Date: Fri, 30 Aug 2024 17:42:13 +0100 Subject: [PATCH 01/14] Add build & test workflow --- .github/workflows/choco_packages.config | 8 +++ .github/workflows/test.yml | 68 +++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 .github/workflows/choco_packages.config create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/choco_packages.config b/.github/workflows/choco_packages.config new file mode 100644 index 0000000..e466fab --- /dev/null +++ b/.github/workflows/choco_packages.config @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..14d3215 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,68 @@ +on: + push: + pull_request: + +jobs: + build: + name: Build & Test + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + generator: ["Ninja", "Unix Makefiles"] + mbedtls: [true, false] + libusb: [true, false] + compile: [true, false] + exclude: + - os: 'windows-latest' + generator: "Unix Makefiles" + - libusb: false + compile: false + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install dependencies (Windows) + if: runner.os == 'Windows' + run: | + choco install -y .github/workflows/choco_packages.config + wget https://github.com/libusb/libusb/releases/download/v1.0.27/libusb-1.0.27.7z -O libusb.7z + 7z x libusb.7z -olibusb + - name: Set LIBUSB_ROOT (Windows) + if: runner.os == 'Windows' + shell: bash + run: echo "LIBUSB_ROOT=$(pwd)/libusb" >> "$GITHUB_ENV" + + - name: Install dependencies (macOS) + if: runner.os == 'macOS' + run: | + brew install cmake libusb pkg-config ninja wget + brew install --cask gcc-arm-embedded + + - name: Install dependencies (Linux) + if: runner.os == 'Linux' + run: sudo apt install cmake python3 build-essential gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib libusb-1.0.0-dev + - name: Checkout + uses: actions/checkout@v4 + with: + repository: raspberrypi/pico-sdk + ref: develop + path: pico-sdk + submodules: ${{ matrix.mbedtls }} + + - name: Build and Install + run: | + cmake -S . -B build -G "${{ matrix.generator }}" -D PICO_SDK_PATH=./pico-sdk ${{ matrix.libusb && '-D PICOTOOL_NO_LIBUSB=1' || '' }} ${{ matrix.compile && '-D USE_PRECOMPILED=false' || '' }} + cmake --build . + cmake --install . + + - name: Test + run: | + picotool help + wget https://datasheets.raspberrypi.com/soft/blink.uf2 -O blink.uf2 + wget https://datasheets.raspberrypi.com/soft/hello_world.uf2 -O hello_world.uf2 + wget https://datasheets.raspberrypi.com/soft/flash_nuke.uf2 -O flash_nuke.uf2 + picotool info -a blink.uf2 + picotool info -a hello_world.uf2 + picotool info -a flash_nuke.uf2 From b93d01666f8f465d624844594b71082d4fb25662 Mon Sep 17 00:00:00 2001 From: William Vinnicombe Date: Fri, 30 Aug 2024 17:54:27 +0100 Subject: [PATCH 02/14] Fix libusb package, pico-sdk path, and wget on windows --- .github/workflows/choco_packages.config | 1 + .github/workflows/test.yml | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/choco_packages.config b/.github/workflows/choco_packages.config index e466fab..d07b4ce 100644 --- a/.github/workflows/choco_packages.config +++ b/.github/workflows/choco_packages.config @@ -5,4 +5,5 @@ + diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 14d3215..0960e58 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -42,7 +42,7 @@ jobs: - name: Install dependencies (Linux) if: runner.os == 'Linux' - run: sudo apt install cmake python3 build-essential gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib libusb-1.0.0-dev + run: sudo apt install cmake python3 build-essential gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib libusb-1.0-0-dev - name: Checkout uses: actions/checkout@v4 with: @@ -53,7 +53,7 @@ jobs: - name: Build and Install run: | - cmake -S . -B build -G "${{ matrix.generator }}" -D PICO_SDK_PATH=./pico-sdk ${{ matrix.libusb && '-D PICOTOOL_NO_LIBUSB=1' || '' }} ${{ matrix.compile && '-D USE_PRECOMPILED=false' || '' }} + cmake -S . -B build -G "${{ matrix.generator }}" -D PICO_SDK_PATH="${{ github.workspace }}/pico-sdk" ${{ matrix.libusb && '-D PICOTOOL_NO_LIBUSB=1' || '' }} ${{ matrix.compile && '-D USE_PRECOMPILED=false' || '' }} cmake --build . cmake --install . From e010257475161f60fb3f283be801fdb667d4e924 Mon Sep 17 00:00:00 2001 From: William Vinnicombe Date: Fri, 30 Aug 2024 17:59:38 +0100 Subject: [PATCH 03/14] Install ninja on linux, and fix cmake build paths --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0960e58..61338f6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -42,7 +42,7 @@ jobs: - name: Install dependencies (Linux) if: runner.os == 'Linux' - run: sudo apt install cmake python3 build-essential gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib libusb-1.0-0-dev + 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 uses: actions/checkout@v4 with: @@ -54,8 +54,8 @@ jobs: - name: Build and Install run: | cmake -S . -B build -G "${{ matrix.generator }}" -D PICO_SDK_PATH="${{ github.workspace }}/pico-sdk" ${{ matrix.libusb && '-D PICOTOOL_NO_LIBUSB=1' || '' }} ${{ matrix.compile && '-D USE_PRECOMPILED=false' || '' }} - cmake --build . - cmake --install . + cmake --build build + cmake --install build - name: Test run: | From 15babc8c67dde04d646f8985033bfcb4f98f4b1c Mon Sep 17 00:00:00 2001 From: William Vinnicombe Date: Fri, 30 Aug 2024 18:10:07 +0100 Subject: [PATCH 04/14] Fix install --- .github/workflows/test.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 61338f6..d135b70 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -43,7 +43,7 @@ jobs: - name: Install dependencies (Linux) if: runner.os == '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 + - name: Checkout Pico SDK uses: actions/checkout@v4 with: repository: raspberrypi/pico-sdk @@ -55,7 +55,10 @@ jobs: run: | cmake -S . -B build -G "${{ matrix.generator }}" -D PICO_SDK_PATH="${{ github.workspace }}/pico-sdk" ${{ matrix.libusb && '-D PICOTOOL_NO_LIBUSB=1' || '' }} ${{ matrix.compile && '-D USE_PRECOMPILED=false' || '' }} cmake --build build - cmake --install build + ${{ matrix.os == 'windows-latest' && '' || 'sudo' }} cmake --install build + - name: Add to path (Windows) + if: runner.os == 'Windows' + run: echo "C:\Program Files (x86)\picotool\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - name: Test run: | From 9f4b7edf50f51654af717f9a233af1ceeebf7ddf Mon Sep 17 00:00:00 2001 From: will-v-pi <108662275+will-v-pi@users.noreply.github.com> Date: Fri, 30 Aug 2024 19:18:57 +0100 Subject: [PATCH 05/14] No sudo on windows --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d135b70..7fd0afb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -55,7 +55,7 @@ jobs: run: | cmake -S . -B build -G "${{ matrix.generator }}" -D PICO_SDK_PATH="${{ github.workspace }}/pico-sdk" ${{ matrix.libusb && '-D PICOTOOL_NO_LIBUSB=1' || '' }} ${{ matrix.compile && '-D USE_PRECOMPILED=false' || '' }} cmake --build build - ${{ matrix.os == 'windows-latest' && '' || 'sudo' }} cmake --install build + ${{ runner.os == 'Windows' && '' || 'sudo' }} cmake --install build - name: Add to path (Windows) if: runner.os == 'Windows' run: echo "C:\Program Files (x86)\picotool\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append From 3a14140636f3b7eff29ee170cbcdd6af0b06c4ee Mon Sep 17 00:00:00 2001 From: will-v-pi <108662275+will-v-pi@users.noreply.github.com> Date: Fri, 30 Aug 2024 19:38:44 +0100 Subject: [PATCH 06/14] Fix sudo ternary --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7fd0afb..3c1694a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -55,7 +55,7 @@ jobs: run: | cmake -S . -B build -G "${{ matrix.generator }}" -D PICO_SDK_PATH="${{ github.workspace }}/pico-sdk" ${{ matrix.libusb && '-D PICOTOOL_NO_LIBUSB=1' || '' }} ${{ matrix.compile && '-D USE_PRECOMPILED=false' || '' }} cmake --build build - ${{ runner.os == 'Windows' && '' || 'sudo' }} cmake --install build + ${{ runner.os != 'Windows' && 'sudo' || '' }} cmake --install build - name: Add to path (Windows) if: runner.os == 'Windows' run: echo "C:\Program Files (x86)\picotool\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append From 5a2224a6be1ee8e94834fc9dd59539bab6dce4c4 Mon Sep 17 00:00:00 2001 From: William Vinnicombe Date: Mon, 2 Sep 2024 13:11:41 +0100 Subject: [PATCH 07/14] Fix inconsistent indent --- .github/workflows/choco_packages.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/choco_packages.config b/.github/workflows/choco_packages.config index d07b4ce..c25cc06 100644 --- a/.github/workflows/choco_packages.config +++ b/.github/workflows/choco_packages.config @@ -4,6 +4,6 @@ - + From 9c0071d7988c0997f05d73263b0057f216162886 Mon Sep 17 00:00:00 2001 From: William Vinnicombe Date: Mon, 2 Sep 2024 14:58:36 +0100 Subject: [PATCH 08/14] Use curl instead of wget, and preinstalled 7zip on windows --- .github/workflows/choco_packages.config | 2 -- .github/workflows/test.yml | 10 +++++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/choco_packages.config b/.github/workflows/choco_packages.config index c25cc06..b2d3db1 100644 --- a/.github/workflows/choco_packages.config +++ b/.github/workflows/choco_packages.config @@ -4,6 +4,4 @@ - - diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3c1694a..f074130 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,7 +27,7 @@ jobs: if: runner.os == 'Windows' run: | choco install -y .github/workflows/choco_packages.config - wget https://github.com/libusb/libusb/releases/download/v1.0.27/libusb-1.0.27.7z -O libusb.7z + curl https://github.com/libusb/libusb/releases/download/v1.0.27/libusb-1.0.27.7z -o libusb.7z 7z x libusb.7z -olibusb - name: Set LIBUSB_ROOT (Windows) if: runner.os == 'Windows' @@ -37,7 +37,7 @@ jobs: - name: Install dependencies (macOS) if: runner.os == 'macOS' run: | - brew install cmake libusb pkg-config ninja wget + brew install cmake libusb pkg-config ninja brew install --cask gcc-arm-embedded - name: Install dependencies (Linux) @@ -63,9 +63,9 @@ jobs: - name: Test run: | picotool help - wget https://datasheets.raspberrypi.com/soft/blink.uf2 -O blink.uf2 - wget https://datasheets.raspberrypi.com/soft/hello_world.uf2 -O hello_world.uf2 - wget https://datasheets.raspberrypi.com/soft/flash_nuke.uf2 -O flash_nuke.uf2 + curl https://datasheets.raspberrypi.com/soft/blink.uf2 -o blink.uf2 + curl https://datasheets.raspberrypi.com/soft/hello_world.uf2 -o hello_world.uf2 + curl https://datasheets.raspberrypi.com/soft/flash_nuke.uf2 -o flash_nuke.uf2 picotool info -a blink.uf2 picotool info -a hello_world.uf2 picotool info -a flash_nuke.uf2 From c4b8630d499592330c563a6b6a2a782562d3c009 Mon Sep 17 00:00:00 2001 From: William Vinnicombe Date: Mon, 2 Sep 2024 14:59:44 +0100 Subject: [PATCH 09/14] Ensure no picotool needed for xip_ram_perms and flash_id compilation --- picoboot_flash_id/CMakeLists.txt | 2 ++ xip_ram_perms/CMakeLists.txt | 2 ++ 2 files changed, 4 insertions(+) diff --git a/picoboot_flash_id/CMakeLists.txt b/picoboot_flash_id/CMakeLists.txt index 9110f8d..efbaafb 100644 --- a/picoboot_flash_id/CMakeLists.txt +++ b/picoboot_flash_id/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 3.12) if (NOT USE_PRECOMPILED) + set(PICO_NO_PICOTOOL 1) + # default build type set(CMAKE_BUILD_TYPE "MinSizeRel" CACHE STRING "build type") diff --git a/xip_ram_perms/CMakeLists.txt b/xip_ram_perms/CMakeLists.txt index 524921f..3d2a991 100644 --- a/xip_ram_perms/CMakeLists.txt +++ b/xip_ram_perms/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 3.12) if (NOT USE_PRECOMPILED) + set(PICO_NO_PICOTOOL 1) + set(PICO_PLATFORM rp2350-arm-s) # Pull in SDK (must be before project) From c3df0b03ef2264adc98f28757b57e6ce48060717 Mon Sep 17 00:00:00 2001 From: William Vinnicombe Date: Mon, 2 Sep 2024 15:00:20 +0100 Subject: [PATCH 10/14] Improve job names --- .github/workflows/test.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f074130..ebd1a6f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,14 +10,14 @@ jobs: matrix: os: [ubuntu-latest, windows-latest, macos-latest] generator: ["Ninja", "Unix Makefiles"] - mbedtls: [true, false] - libusb: [true, false] - compile: [true, false] + mbedtls: ["mbedtls", ""] + libusb: ["libusb", ""] + compile: ["compile", ""] exclude: - os: 'windows-latest' generator: "Unix Makefiles" - - libusb: false - compile: false + - libusb: "" + compile: "compile" runs-on: ${{ matrix.os }} steps: From 22ac8e35fbd8c1c59d25a69ae19383dd89afcb14 Mon Sep 17 00:00:00 2001 From: William Vinnicombe Date: Mon, 2 Sep 2024 15:28:06 +0100 Subject: [PATCH 11/14] Debug curl 7z issue --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ebd1a6f..13780dd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,6 +4,8 @@ on: jobs: build: + # Prevent running twice for PRs from same repo + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name name: Build & Test strategy: fail-fast: false @@ -28,6 +30,7 @@ jobs: run: | choco install -y .github/workflows/choco_packages.config curl https://github.com/libusb/libusb/releases/download/v1.0.27/libusb-1.0.27.7z -o libusb.7z + dir 7z x libusb.7z -olibusb - name: Set LIBUSB_ROOT (Windows) if: runner.os == 'Windows' From c3f222c5f59f3ddd4fdc01d3ac1fd4cebaf2da1f Mon Sep 17 00:00:00 2001 From: William Vinnicombe Date: Mon, 2 Sep 2024 15:37:03 +0100 Subject: [PATCH 12/14] Follow redirects with curl --- .github/workflows/test.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 13780dd..abbc0d5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,8 +29,7 @@ jobs: if: runner.os == 'Windows' run: | choco install -y .github/workflows/choco_packages.config - curl https://github.com/libusb/libusb/releases/download/v1.0.27/libusb-1.0.27.7z -o libusb.7z - dir + curl -L https://github.com/libusb/libusb/releases/download/v1.0.27/libusb-1.0.27.7z -o libusb.7z 7z x libusb.7z -olibusb - name: Set LIBUSB_ROOT (Windows) if: runner.os == 'Windows' @@ -66,9 +65,9 @@ jobs: - name: Test run: | picotool help - curl https://datasheets.raspberrypi.com/soft/blink.uf2 -o blink.uf2 - curl https://datasheets.raspberrypi.com/soft/hello_world.uf2 -o hello_world.uf2 - curl https://datasheets.raspberrypi.com/soft/flash_nuke.uf2 -o flash_nuke.uf2 + curl -L https://datasheets.raspberrypi.com/soft/blink.uf2 -o blink.uf2 + curl -L https://datasheets.raspberrypi.com/soft/hello_world.uf2 -o hello_world.uf2 + curl -L https://datasheets.raspberrypi.com/soft/flash_nuke.uf2 -o flash_nuke.uf2 picotool info -a blink.uf2 picotool info -a hello_world.uf2 picotool info -a flash_nuke.uf2 From 9274b8c9e72bb9feb14ef7e702ef099be1d7456b Mon Sep 17 00:00:00 2001 From: William Vinnicombe Date: Mon, 2 Sep 2024 18:38:52 +0100 Subject: [PATCH 13/14] Fix sense of libusb, and fix mbedtls --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index abbc0d5..e79a342 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -51,11 +51,11 @@ jobs: repository: raspberrypi/pico-sdk ref: develop path: pico-sdk - submodules: ${{ matrix.mbedtls }} + submodules: ${{ !(!matrix.mbedtls) }} - name: Build and Install run: | - cmake -S . -B build -G "${{ matrix.generator }}" -D PICO_SDK_PATH="${{ github.workspace }}/pico-sdk" ${{ matrix.libusb && '-D PICOTOOL_NO_LIBUSB=1' || '' }} ${{ matrix.compile && '-D USE_PRECOMPILED=false' || '' }} + cmake -S . -B build -G "${{ matrix.generator }}" -D PICO_SDK_PATH="${{ github.workspace }}/pico-sdk" ${{ !matrix.libusb && '-D PICOTOOL_NO_LIBUSB=1' || '' }} ${{ matrix.compile && '-D USE_PRECOMPILED=false' || '' }} cmake --build build ${{ runner.os != 'Windows' && 'sudo' || '' }} cmake --install build - name: Add to path (Windows) From 26bcf6b6c5939e82c5e024ab74650113a9e4f581 Mon Sep 17 00:00:00 2001 From: William Vinnicombe Date: Mon, 9 Sep 2024 10:59:13 +0100 Subject: [PATCH 14/14] Still check LIBUSB_ROOT if pkgconfig libusb not found --- cmake/FindLIBUSB.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmake/FindLIBUSB.cmake b/cmake/FindLIBUSB.cmake index 85825aa..e5defef 100644 --- a/cmake/FindLIBUSB.cmake +++ b/cmake/FindLIBUSB.cmake @@ -25,7 +25,9 @@ else (LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES) if (PKG_CONFIG_FOUND) pkg_check_modules(PC_LIBUSB libusb-1.0) - else () + endif() + + if (NOT PC_LIBUSB_FOUND) # As the pkg-config was not found we are probably building under windows. # Determine the architecture of the host, to choose right library if (NOT DEFINED ARCHITECTURE)