diff --git a/.editorconfig b/.editorconfig index be651a8..996cdc7 100644 --- a/.editorconfig +++ b/.editorconfig @@ -12,3 +12,6 @@ trim_trailing_whitespace = true [*.md] max_line_length = off trim_trailing_whitespace = false + +[*.sh] +end_of_line = lf diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 370ea4f..e3b9a05 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,7 +7,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Test scripts shell: pwsh @@ -29,8 +29,7 @@ jobs: Invoke-Pester -Configuration $pesterConfig - name: Upload test results - uses: actions/upload-artifact@v2 - if: ${{ always() }} + uses: actions/upload-artifact@v4 with: name: Pester-Test-Results path: testResults.xml @@ -41,31 +40,42 @@ jobs: strategy: fail-fast: false matrix: - config: [x86, x64, x64-standalone] + config: [x64, x64-standalone] build-type: [system] include: - { config: x64-standalone, build-type: user } steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup MSYS2 uses: msys2/setup-msys2@v2 + - name: Turn off git autocrlf + shell: pwsh + run: git config --global core.autocrlf false + - name: Check OpenOCD repository shell: pwsh - run: | - $OpenOCDCommit = ((Get-Content .\config\repositories.json | ConvertFrom-Json).repositories | Where-Object { $_.href -like '*openocd.git' } | ForEach-Object { git ls-remote $_.href $_.tree }).Split("`t")[0] - $Bitness = (Get-Content .\config\${{ matrix.config }}.json | ConvertFrom-Json).bitness - Add-Content -Path $env:GITHUB_ENV -Value "OPENOCD_BUILD_ID=openocd-$OpenOCDCommit-$Bitness" + run: .\packages\common\build-id.ps1 openocd .\config\${{ matrix.config }}.json >> $env:GITHUB_ENV - name: Cache OpenOCD build - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: build/openocd-install key: ${{ env.OPENOCD_BUILD_ID }} + - name: Check riscv-gnu-toolchain repository + shell: pwsh + run: .\packages\common\build-id.ps1 riscv-gnu-toolchain .\config\${{ matrix.config }}.json >> $env:GITHUB_ENV + + - name: Cache riscv-gnu-toolchain build + uses: actions/cache@v4 + with: + path: build/riscv-gnu-toolchain-install + key: ${{ env.RISCV-GNU-TOOLCHAIN_BUILD_ID }} + - name: Build ${{ matrix.config }} (${{ matrix.build-type }}) shell: pwsh run: | @@ -73,10 +83,13 @@ jobs: $ErrorActionPreference = 'Stop' $ProgressPreference = 'SilentlyContinue' + subst P: . + P: + .\build.ps1 .\config\${{ matrix.config }}.json -MSYS2Path (msys2 -c 'cygpath -m /').TrimEnd('\/') -SkipSigning -Compression zlib -BuildType ${{ matrix.build-type }} - name: Upload build artifacts - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: Package-${{ matrix.config }}-${{ matrix.build-type }} path: bin/ @@ -95,22 +108,22 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Download installer artifact - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4 with: name: Package-${{ matrix.config }}-${{ matrix.build-type }} path: bin - name: Test ${{ matrix.config }} (${{ matrix.build-type }}) shell: pwsh - run: docker run --rm -v "$(Get-Location):C:\repo" mcr.microsoft.com/windows/servercore:ltsc${{ matrix.winver }} - powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command "cd C:\repo; .\tests\setup.ps1" + run: docker run --rm -v "$(Get-Location):C:\repo" -w C:\repo + mcr.microsoft.com/windows/servercore:ltsc${{ matrix.winver }} + powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -File .\tests\setup.ps1 - name: Upload installer logs - uses: actions/upload-artifact@v2 - if: ${{ always() }} + uses: actions/upload-artifact@v4 with: name: Installer-Logs-Windows-${{ matrix.winver }}-${{ matrix.config }}-${{ matrix.build-type }} path: logs/ diff --git a/.gitignore b/.gitignore index ac2898b..d7e0e50 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ bin/ # Builds/staging build/ +build-*/ diff --git a/README.md b/README.md index 3cf2f81..83d2406 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ The rest of this README document is about developing the installer itself. If yo - [Arm GNU Toolchain](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads) - [CMake](https://cmake.org/download/) - [Ninja](https://github.com/ninja-build/ninja/releases) -- [Python 3.9](https://www.python.org/downloads/windows/) +- [Python 3.12](https://www.python.org/downloads/windows/) - [Git for Windows](https://git-scm.com/download/win) - [Visual Studio Code](https://code.visualstudio.com/) - [OpenOCD](https://github.com/openocd-org/openocd/) diff --git a/build.ps1 b/build.ps1 index 95e7c74..d060548 100644 --- a/build.ps1 +++ b/build.ps1 @@ -48,7 +48,8 @@ $tools = (Get-Content '.\config\tools.json' | ConvertFrom-Json).tools $repositories = (Get-Content '.\config\repositories.json' | ConvertFrom-Json).repositories $config = Get-Content $ConfigFile | ConvertFrom-Json $bitness = $config.bitness -$mingw_arch = $config.mingwArch +$env:MSYSTEM = $config.msysEnv +$msysEnv = $config.msysEnv.ToLowerInvariant() $downloads = $config.downloads $componentSelection = ($config | Get-Member componentSelection) ? $config.componentSelection : $false @@ -139,7 +140,7 @@ if (Test-Path .\build\python\python.exe) { } # Clone additional Pico-specific submodules in TinyUSB -exec { git -C .\build\pico-sdk\lib\tinyusb submodule update --init --depth=1 hw\mcu\raspberry_pi } +# exec { git -C .\build\pico-sdk\lib\tinyusb submodule update --init --depth=1 hw\mcu\raspberry_pi } $sdkVersion = (cmake -P .\packages\pico-setup-windows\pico-sdk-version.cmake -N | Select-String -Pattern 'PICO_SDK_VERSION_STRING=(.*)$').Matches.Groups[1].Value if (-not ($sdkVersion -match $versionRegEx)) { @@ -187,8 +188,8 @@ function msys { # Preserve the current working directory $env:CHERE_INVOKING = 'yes' -# Start MINGW32/64 environment -$env:MSYSTEM = "MINGW$bitness" +# Use real symlinks +$env:MSYS = "winsymlinks:nativestrict" if (-not $SkipDownload) { # First run setup @@ -198,21 +199,27 @@ if (-not $SkipDownload) { # Normal update msys 'pacman --noconfirm -Suu' - msys "pacman -S --noconfirm --needed autoconf automake git libtool make pactoys pkg-config wget" + msys "pacman -S --noconfirm --needed autoconf automake base-devel expat git libtool pactoys patchutils pkg-config" + # pacboy adds MINGW_PACKAGE_PREFIX to package names suffixed with :p - msys "pacboy -S --noconfirm --needed cmake:p ninja:p toolchain:p libusb:p hidapi:p" + msys "pacboy -S --noconfirm --needed cmake:p ninja:p toolchain:p libusb:p hidapi:p libslirp:p" +} + +if (-not (Test-Path ".\build\picotool-install\$msysEnv")) { + msys "cd build && ../packages/picotool/build-picotool.sh" } -if (-not (Test-Path ".\build\openocd-install\mingw$bitness")) { - msys "cd build && ../packages/openocd/build-openocd.sh $bitness $mingw_arch" +if (-not (Test-Path ".\build\openocd-install\$msysEnv")) { + msys "cd build && ../packages/openocd/build-openocd.sh" } -if (-not (Test-Path ".\build\picotool-install\mingw$bitness")) { - msys "cd build && ../packages/picotool/build-picotool.sh $bitness $mingw_arch" +if (-not (Test-Path ".\build\riscv-gnu-toolchain-install\$msysEnv")) { + msys "cd build && ../packages/riscv/build-riscv-gcc.sh" } +exec { tar -a -cf "build\riscv-gnu-toolchain.zip" -C "build\riscv-gnu-toolchain-install\$msysEnv" '*' } $template = Get-Content ".\packages\pico-sdk-tools\pico-sdk-tools-config-version.cmake" -Raw -$ExecutionContext.InvokeCommand.ExpandString($template) | Set-Content ".\build\pico-sdk-tools\mingw$bitness\pico-sdk-tools-config-version.cmake" +$ExecutionContext.InvokeCommand.ExpandString($template) | Set-Content ".\build\pico-sdk-tools\$msysEnv\pico-sdk-tools-config-version.cmake" exec { .\build\pandoc\pandoc.exe --from gfm --to gfm --output .\build\ReadMe.txt .\docs\tutorial.md } @@ -391,6 +398,18 @@ $($componentSelection ? '!insertmacro MUI_PAGE_COMPONENTS' : '') !include "packages\pico-setup-windows\DumpLog.nsh" +!macro ExpandArchive archivePath + + SetCompress off + File "`${archivePath}" + `${GetFileName} "`${archivePath}" `$R0 + nsExec::ExecToLog ``powershell -NoProfile -ExecutionPolicy Bypass -Command "Expand-Archive '`$R0' -DestinationPath . -Force"`` + Pop `$0 + Delete /REBOOTOK "`$OUTDIR\`$R0" + SetCompress auto + +!macroend + Function .onInit SetShellVarContext $($BuildType -eq 'system' ? 'all' : 'current') @@ -523,9 +542,16 @@ LangString DESC_Sec$($_.shortName) `${LANG_ENGLISH} "$($_.name)" Section "-OpenOCD" SecOpenOCD SetOutPath "`$INSTDIR\openocd" - File "build\openocd-install\mingw$bitness\bin\*.*" + File "build\openocd-install\$msysEnv\bin\*.*" SetOutPath "`$INSTDIR\openocd\scripts" - File /r "build\openocd-install\mingw$bitness\share\openocd\scripts\*.*" + File /r "build\openocd-install\$msysEnv\share\openocd\scripts\*.*" + +SectionEnd + +Section "-riscv-gnu-toolchain" SecRiscV + + SetOutPath "`$INSTDIR\riscv-gnu-toolchain" + !insertmacro ExpandArchive "build\riscv-gnu-toolchain.zip" SectionEnd @@ -555,12 +581,9 @@ Section "-Pico environment" SecPico File /r "build\pico-sdk\*.*" SetOutPath "`$INSTDIR\pico-sdk-tools" - File "build\pico-sdk-tools\mingw$bitness\*.*" + File /r "build\pico-sdk-tools\$msysEnv\*.*" WriteRegStr `${PICO_REG_ROOT} "Software\Kitware\CMake\Packages\pico-sdk-tools" "v$sdkVersion" "`$INSTDIR\pico-sdk-tools" - SetOutPath "`$INSTDIR\picotool" - File "build\picotool-install\mingw$bitness\*.*" - SetOutPath "`$INSTDIR" File "build\pico-examples.zip" WriteINIStr "`$INSTDIR\version.ini" "pico-setup-windows" "PICO_SDK_VERSION" "$sdkVersion" @@ -648,15 +671,15 @@ exec { .\build\NSIS\makensis /DBUILD_UNINSTALLER ".\$basename-$suffix.nsi" } # The 'installer' that just writes the uninstaller asks for admin access, which is not actually needed. $env:__COMPAT_LAYER = "RunAsInvoker" -exec { Start-Process -FilePath ".\build\build-uninstaller-$suffix.exe" -ArgumentList "/S /D=$PSScriptRoot\build" -Wait } +exec { Start-Process -FilePath ".\build\build-uninstaller-$suffix.exe" -ArgumentList "/S /D=$(Join-Path $PSScriptRoot 'build')" -Wait } $env:__COMPAT_LAYER = "" # Sign files before packaging up the installer sign "build\uninstall-$suffix.exe", -"build\openocd-install\mingw$bitness\bin\openocd.exe", -"build\pico-sdk-tools\mingw$bitness\elf2uf2.exe", -"build\pico-sdk-tools\mingw$bitness\pioasm.exe", -"build\picotool-install\mingw$bitness\picotool.exe" +"build\openocd-install\$msysEnv\bin\openocd.exe", +"build\pico-sdk-tools\$msysEnv\elf2uf2\elf2uf2.exe", +"build\pico-sdk-tools\$msysEnv\pioasm\pioasm.exe", +"build\pico-sdk-tools\$msysEnv\picotool\picotool.exe" exec { .\build\NSIS\makensis ".\$basename-$suffix.nsi" } Write-Host "Installer saved to $binfile" @@ -666,7 +689,7 @@ sign $binfile # Package OpenOCD separately as well -$version = (cmd /c ".\build\openocd-install\mingw$bitness\bin\openocd.exe" --version '2>&1')[0] +$version = (cmd /c ".\build\openocd-install\$msysEnv\bin\openocd.exe" --version '2>&1')[0] if (-not ($version -match 'Open On-Chip Debugger (?[a-zA-Z0-9\.\-+]+) \((?[0-9\-:]+)\)')) { Write-Error 'Could not determine openocd version' } @@ -677,4 +700,4 @@ $filename = 'openocd-{0}-{1}-{2}.zip' -f $suffix Write-Host "Saving OpenOCD package to $filename" -exec { tar -a -cf "bin\$filename" -C "build\openocd-install\mingw$bitness\bin" * -C "..\share\openocd" "scripts" } +exec { tar -a -cf "bin\$filename" -C "build\openocd-install\$msysEnv\bin" * -C "..\share\openocd" "scripts" } diff --git a/config/repositories.json b/config/repositories.json index b67c008..41d9c96 100644 --- a/config/repositories.json +++ b/config/repositories.json @@ -2,28 +2,32 @@ "repositories": [ { "href": "https://github.com/raspberrypi/pico-sdk.git", - "tree": "1.5.1", + "tree": "2.1.0", "submodules": true }, { "href": "https://github.com/raspberrypi/pico-examples.git", - "tree": "sdk-1.5.1" + "tree": "sdk-2.1.0" }, { "href": "https://github.com/raspberrypi/pico-extras.git", - "tree": "sdk-1.5.1" + "tree": "sdk-2.1.0" }, { "href": "https://github.com/raspberrypi/pico-playground.git", - "tree": "sdk-1.5.1" + "tree": "sdk-2.1.0" }, { "href": "https://github.com/raspberrypi/picotool.git", - "tree": "1.1.2" + "tree": "2.1.0" }, { "href": "https://github.com/raspberrypi/openocd.git", - "tree": "rp2040-v0.12.0" + "tree": "sdk-2.0.0" + }, + { + "href": "https://github.com/riscv/riscv-gnu-toolchain.git", + "tree": "master" } ] } diff --git a/config/tools.json b/config/tools.json index ffc3e5f..87d3323 100644 --- a/config/tools.json +++ b/config/tools.json @@ -2,20 +2,20 @@ "tools": [ { "name": "NSIS", - "file": "nsis-3.08.zip", - "href": "https://sourceforge.net/projects/nsis/files/NSIS%203/3.08/nsis-3.08.zip/download", + "file": "nsis-3.10.zip", + "href": "https://sourceforge.net/projects/nsis/files/NSIS%203/3.10/nsis-3.10.zip/download", "dirName": "NSIS", "extractStrip": 1 }, { "name": "MSYS2", "file": "msys2.exe", - "href": "https://github.com/msys2/msys2-installer/releases/download/2023-01-27/msys2-base-x86_64-20230127.sfx.exe" + "href": "https://github.com/msys2/msys2-installer/releases/download/2024-07-27/msys2-base-x86_64-20240727.sfx.exe" }, { "name": "pandoc", - "file": "pandoc-3.1-windows-x86_64.zip", - "href": "https://github.com/jgm/pandoc/releases/download/3.1/pandoc-3.1-windows-x86_64.zip", + "file": "pandoc-3.3-windows-x86_64.zip", + "href": "https://github.com/jgm/pandoc/releases/download/3.3/pandoc-3.3-windows-x86_64.zip", "dirName": "pandoc", "extractStrip": 1 }, diff --git a/config/x64-standalone.json b/config/x64-standalone.json index 86e563e..427941f 100644 --- a/config/x64-standalone.json +++ b/config/x64-standalone.json @@ -1,37 +1,37 @@ { "bitness": 64, - "mingwArch": "x86_64", + "msysEnv": "MINGW64", "downloads": [ { - "name": "GNU Arm Embedded Toolchain", - "file": "gcc-arm-none-eabi-10.3-2021.10-win32.zip", - "href": "https://developer.arm.com/-/media/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-win32.zip?rev=8f4a92e2ec2040f89912f372a55d8cf3&hash=8A9EAF77EF1957B779C59EADDBF2DAC118170BBF", - "dirName": "gcc-arm-none-eabi", + "name": "Arm GNU Toolchain", + "file": "arm-gnu-toolchain-13.3.rel1-mingw-w64-i686-arm-none-eabi.zip", + "href": "https://developer.arm.com/-/media/Files/downloads/gnu/13.3.rel1/binrel/arm-gnu-toolchain-13.3.rel1-mingw-w64-i686-arm-none-eabi.zip", + "dirName": "arm-gnu-toolchain", "extractStrip": 1 }, { "name": "CMake", - "file": "cmake-3.25.2-windows-x86_64.zip", - "href": "https://github.com/Kitware/CMake/releases/download/v3.25.2/cmake-3.25.2-windows-x86_64.zip", + "file": "cmake-3.30.2-windows-x86_64.zip", + "href": "https://github.com/Kitware/CMake/releases/download/v3.30.2/cmake-3.30.2-windows-x86_64.zip", "dirName": "cmake", "extractStrip": 1 }, { "name": "Ninja", "file": "ninja-win.zip", - "href": "https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-win.zip", + "href": "https://github.com/ninja-build/ninja/releases/download/v1.12.1/ninja-win.zip", "dirName": "ninja" }, { - "name": "Python 3.9", - "file": "python-3.9.13-embed-amd64.zip", - "href": "https://www.python.org/ftp/python/3.9.13/python-3.9.13-embed-amd64.zip", + "name": "Python 3.12", + "file": "python-3.12.5-embed-amd64.zip", + "href": "https://www.python.org/ftp/python/3.12.5/python-3.12.5-embed-amd64.zip", "dirName": "python" }, { "name": "Git for Windows", - "file": "MinGit-2.39.1-64-bit.zip", - "href": "https://github.com/git-for-windows/git/releases/download/v2.39.1.windows.1/MinGit-2.39.1-64-bit.zip", + "file": "MinGit-2.46.0-64-bit.zip", + "href": "https://github.com/git-for-windows/git/releases/download/v2.46.0.windows.1/MinGit-2.46.0-64-bit.zip", "dirName": "git" } ] diff --git a/config/x64.json b/config/x64.json index 3540d7c..b1d777f 100644 --- a/config/x64.json +++ b/config/x64.json @@ -1,37 +1,37 @@ { "bitness": 64, - "mingwArch": "x86_64", + "msysEnv": "MINGW64", "componentSelection": true, "downloads": [ { - "name": "GNU Arm Embedded Toolchain", - "file": "gcc-arm-none-eabi-10.3-2021.10-win32.exe", + "name": "Arm GNU Toolchain", + "file": "arm-gnu-toolchain-13.3.rel1-mingw-w64-i686-arm-none-eabi.exe", "exec": "\"$0\" /S /P /R", - "href": "https://developer.arm.com/-/media/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-win32.exe?rev=29bb46cfa0434fbda93abb33c1d480e6&hash=3C58D05EA5D32EF127B9E4D13B3244D26188713C" + "href": "https://developer.arm.com/-/media/Files/downloads/gnu/13.3.rel1/binrel/arm-gnu-toolchain-13.3.rel1-mingw-w64-i686-arm-none-eabi.exe" }, { "name": "CMake", - "file": "cmake-3.25.2-windows-x86_64.msi", + "file": "cmake-3.30.2-windows-x86_64.msi", "exec": "msiexec /i \"$0\" /qn /norestart ADD_CMAKE_TO_PATH=System", - "href": "https://github.com/Kitware/CMake/releases/download/v3.25.2/cmake-3.25.2-windows-x86_64.msi" + "href": "https://github.com/Kitware/CMake/releases/download/v3.30.2/cmake-3.30.2-windows-x86_64.msi" }, { "name": "Ninja", "file": "ninja-win.zip", - "href": "https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-win.zip", + "href": "https://github.com/ninja-build/ninja/releases/download/v1.12.1/ninja-win.zip", "dirName": "ninja" }, { - "name": "Python 3.9", - "file": "python-3.9.13-amd64.exe", + "name": "Python 3.12", + "file": "python-3.12.5-amd64.exe", "exec": "\"$0\" /quiet InstallAllUsers=1 PrependPath=1", - "href": "https://www.python.org/ftp/python/3.9.13/python-3.9.13-amd64.exe" + "href": "https://www.python.org/ftp/python/3.12.5/python-3.12.5-amd64.exe" }, { "name": "Git for Windows", - "file": "Git-2.39.1-64-bit.exe", + "file": "Git-2.46.0-64-bit.exe", "exec": "\"$0\" /VERYSILENT /NORESTART /NOCANCEL /SP- /CLOSEAPPLICATIONS /RESTARTAPPLICATIONS /SKIPDOWNGRADE=1 \"/LOADINF=$PLUGINSDIR\\git.inf\"", - "href": "https://github.com/git-for-windows/git/releases/download/v2.39.1.windows.1/Git-2.39.1-64-bit.exe", + "href": "https://github.com/git-for-windows/git/releases/download/v2.46.0.windows.1/Git-2.46.0-64-bit.exe", "additionalFiles": [ "packages\\pico-setup-windows\\git.inf" ] diff --git a/config/x86.json b/config/x86.json deleted file mode 100644 index 6205066..0000000 --- a/config/x86.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "bitness": 32, - "mingwArch": "i686", - "componentSelection": true, - "downloads": [ - { - "name": "GNU Arm Embedded Toolchain", - "file": "gcc-arm-none-eabi-10.3-2021.10-win32.exe", - "exec": "\"$0\" /S /P /R", - "href": "https://developer.arm.com/-/media/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-win32.exe?rev=29bb46cfa0434fbda93abb33c1d480e6&hash=3C58D05EA5D32EF127B9E4D13B3244D26188713C" - }, - { - "name": "CMake", - "file": "cmake-3.25.2-windows-i386.msi", - "exec": "msiexec /i \"$0\" /qn /norestart ADD_CMAKE_TO_PATH=System", - "href": "https://github.com/Kitware/CMake/releases/download/v3.25.2/cmake-3.25.2-windows-i386.msi" - }, - { - "name": "Python 3.9", - "file": "python-3.9.13.exe", - "exec": "\"$0\" /quiet InstallAllUsers=1 PrependPath=1", - "href": "https://www.python.org/ftp/python/3.9.13/python-3.9.13.exe" - }, - { - "name": "Git for Windows", - "file": "Git-2.39.1-32-bit.exe", - "exec": "\"$0\" /VERYSILENT /NORESTART /NOCANCEL /SP- /CLOSEAPPLICATIONS /RESTARTAPPLICATIONS /SKIPDOWNGRADE=1 \"/LOADINF=$PLUGINSDIR\\git.inf\"", - "href": "https://github.com/git-for-windows/git/releases/download/v2.39.1.windows.1/Git-2.39.1-32-bit.exe", - "additionalFiles": [ - "packages\\pico-setup-windows\\git.inf" - ] - } - ] -} diff --git a/packages/common/build-id.ps1 b/packages/common/build-id.ps1 new file mode 100644 index 0000000..e46950b --- /dev/null +++ b/packages/common/build-id.ps1 @@ -0,0 +1,29 @@ +param ( + [Parameter(Mandatory = $true, + Position = 0, + HelpMessage = "Base name of the repository to check.")] + [ValidateNotNullOrEmpty()] + [string] + $Repo, + + [Parameter(Mandatory = $true, + Position = 1, + HelpMessage = "Path to a JSON installer configuration file.")] + [Alias("PSPath")] + [ValidateNotNullOrEmpty()] + [string] + $ConfigFile +) + +#Requires -Version 7.2 + +Set-StrictMode -Version Latest +$ErrorActionPreference = 'Stop' + +$remoteCommit = ((Get-Content .\config\repositories.json | ConvertFrom-Json).repositories | + Where-Object { $_.href -like "*${Repo}.git" } | + ForEach-Object { git ls-remote $_.href $_.tree }).Split("`t")[0] + +$msystem = (Get-Content $ConfigFile | ConvertFrom-Json).msysEnv + +"$($Repo.ToUpperInvariant())_BUILD_ID=$Repo-$remoteCommit-$msystem" diff --git a/packages/common/copy-deps.sh b/packages/common/copy-deps.sh new file mode 100644 index 0000000..d08de27 --- /dev/null +++ b/packages/common/copy-deps.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -euo pipefail + +# Find all directories with exe files +find . -name '*.exe' -printf '%h\n' | sort -u | while read i +do + echo "Copying DLLs to $i" + pushd "$i" > /dev/null + + # We need to match just the DLL names, if they are from the MSYS2 libraries. + # (?<=...) is a positive lookbehind assertion, because we are looking for something like + # "libusb-1.0.dll => /mingw64/.../libusb-1.0.dll" + find . -maxdepth 1 -name '*.exe' -exec ldd {} ';' | (grep -Po "(?<==> )/${MSYSTEM,,}[^ ]+" || true) | sort -u | xargs -I{} cp -v {} . + + popd > /dev/null +done diff --git a/packages/openocd/build-openocd.sh b/packages/openocd/build-openocd.sh index 328c58d..91a33b7 100644 --- a/packages/openocd/build-openocd.sh +++ b/packages/openocd/build-openocd.sh @@ -1,15 +1,16 @@ -#!/bin/bash - -set -euo pipefail - -BITNESS=$1 -ARCH=$2 - -cd openocd -./bootstrap -./configure -make clean -make -j4 -DESTDIR="$PWD/../openocd-install" make install -cp "/mingw$BITNESS/bin/libhidapi-0.dll" "$PWD/../openocd-install/mingw$BITNESS/bin" -cp "/mingw$BITNESS/bin/libusb-1.0.dll" "$PWD/../openocd-install/mingw$BITNESS/bin" +#!/bin/bash + +set -euo pipefail + +BUILDDIR="$PWD" +INSTALLDIR="openocd-install" + +cd openocd +./bootstrap +./configure --disable-werror CFLAGS="-Duint=uint32_t" +make -j$(nproc) + +DESTDIR="$BUILDDIR/$INSTALLDIR" make install + +cd "$BUILDDIR/$INSTALLDIR/${MSYSTEM,,}/bin" +"$BUILDDIR/../packages/common/copy-deps.sh" diff --git a/packages/pico-examples/ide/vscode/c_cpp_properties.json b/packages/pico-examples/ide/vscode/c_cpp_properties.json index f066f7c..dbd5d4d 100644 --- a/packages/pico-examples/ide/vscode/c_cpp_properties.json +++ b/packages/pico-examples/ide/vscode/c_cpp_properties.json @@ -7,7 +7,7 @@ "${env:PICO_SDK_PATH}/**" ], "defines": [], - "compilerPath": "${env:PICO_INSTALL_PATH}/gcc-arm-none-eabi/bin/arm-none-eabi-gcc.exe", + "compilerPath": "${env:PICO_INSTALL_PATH}/arm-gnu-toolchain/bin/arm-none-eabi-gcc.exe", "cStandard": "c11", "cppStandard": "c++11", "intelliSenseMode": "linux-gcc-arm", diff --git a/packages/pico-examples/ide/vscode/cmake-kits.json b/packages/pico-examples/ide/vscode/cmake-kits.json deleted file mode 100644 index 33661c4..0000000 --- a/packages/pico-examples/ide/vscode/cmake-kits.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - { - "name": "Pico ARM GCC", - "description": "Pico SDK Toolchain with GCC arm-none-eabi", - "toolchainFile": "${env:PICO_SDK_PATH}/cmake/preload/toolchains/pico_arm_gcc.cmake" - } -] diff --git a/packages/pico-examples/ide/vscode/settings.json b/packages/pico-examples/ide/vscode/settings.json index 4551733..2449565 100644 --- a/packages/pico-examples/ide/vscode/settings.json +++ b/packages/pico-examples/ide/vscode/settings.json @@ -1,26 +1,18 @@ { - // These settings tweaks to the cmake plugin will ensure - // that you debug using cortex-debug instead of trying to launch - // a Pico binary on the host - "cmake.statusbar.advanced": { - "debug": { - "visibility": "hidden" + // These settings tweaks to the cmake plugin will ensure + // that you debug using cortex-debug instead of trying to launch + // a Pico binary on the host + "cmake.options.advanced": { + "launch": { + "statusBarVisibility": "hidden" + }, + "debug": { + "statusBarVisibility": "hidden" + } }, - "launch": { - "visibility": "hidden" - }, - "build": { - "visibility": "hidden" - }, - "buildTarget": { - "visibility": "hidden" - } - }, - "cmake.buildBeforeRun": true, - "cmake.configureOnOpen": true, - "cmake.configureSettings": { - "CMAKE_MODULE_PATH": "${env:PICO_INSTALL_PATH}/pico-sdk-tools" - }, - "cmake.generator": "Ninja", - "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools" + "cmake.buildBeforeRun": true, + "cmake.configureOnOpen": true, + "cmake.generator": "Ninja", + "cmake.configureSettings": { "PICO_BOARD": "pico" }, + "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools" } diff --git a/packages/pico-sdk-tools/pico-sdk-tools-config.cmake b/packages/pico-sdk-tools/pico-sdk-tools-config.cmake index 34febfb..5a8bda6 100644 --- a/packages/pico-sdk-tools/pico-sdk-tools-config.cmake +++ b/packages/pico-sdk-tools/pico-sdk-tools-config.cmake @@ -1,5 +1,5 @@ set(Pioasm_TARGET Pioasm) -set(Pioasm_EXECUTABLE ${pico-sdk-tools_DIR}/pioasm.exe) +set(Pioasm_EXECUTABLE ${pico-sdk-tools_DIR}/pioasm/pioasm.exe) if(NOT TARGET ${Pioasm_TARGET}) add_executable(${Pioasm_TARGET} IMPORTED) endif() @@ -7,7 +7,7 @@ set_property(TARGET ${Pioasm_TARGET} PROPERTY IMPORTED_LOCATION ${Pioasm_EXECUTA set(Pioasm_FOUND 1) set(ELF2UF2_TARGET ELF2UF2) -set(ELF2UF2_EXECUTABLE ${pico-sdk-tools_DIR}/elf2uf2.exe) +set(ELF2UF2_EXECUTABLE ${pico-sdk-tools_DIR}/elf2uf2/elf2uf2.exe) if(NOT TARGET ${ELF2UF2_TARGET}) add_executable(${ELF2UF2_TARGET} IMPORTED) endif() diff --git a/packages/pico-setup-windows/pico-env.cmd b/packages/pico-setup-windows/pico-env.cmd index 5f983ce..77cd302 100644 --- a/packages/pico-setup-windows/pico-env.cmd +++ b/packages/pico-setup-windows/pico-env.cmd @@ -81,12 +81,27 @@ rem directory if we do not set this. set "HOME=%USERPROFILE%" call :AddToPath "%PICO_INSTALL_PATH%\cmake\bin" -call :AddToPath "%PICO_INSTALL_PATH%\gcc-arm-none-eabi\bin" +call :AddToPath "%PICO_INSTALL_PATH%\arm-gnu-toolchain\bin" +call :AddToPath "%PICO_INSTALL_PATH%\riscv-gnu-toolchain\bin" call :AddToPath "%PICO_INSTALL_PATH%\ninja" call :AddToPath "%PICO_INSTALL_PATH%\python" call :AddToPath "%PICO_INSTALL_PATH%\git\cmd" call :AddToPath "%PICO_INSTALL_PATH%\pico-sdk-tools" -call :AddToPath "%PICO_INSTALL_PATH%\picotool" +call :AddToPath "%PICO_INSTALL_PATH%\pico-sdk-tools\elf2uf2" +call :AddToPath "%PICO_INSTALL_PATH%\pico-sdk-tools\pioasm" +call :AddToPath "%PICO_INSTALL_PATH%\pico-sdk-tools\picotool" + +for %%f in (arm-none-eabi-gcc.exe) do ( + set "PICO_ARM_TOOLCHAIN_PATH=%%~dp$PATH:f" +) +rem Remove trailing backslash - add a . then resolve with the 'f' modifier +for %%f in ("%PICO_ARM_TOOLCHAIN_PATH%.") do ( + set "PICO_ARM_TOOLCHAIN_PATH=%%~ff" +) + +if exist "%PICO_INSTALL_PATH%\riscv-gnu-toolchain\bin" ( + set "PICO_RISCV_TOOLCHAIN_PATH=%PICO_INSTALL_PATH%\riscv-gnu-toolchain\bin" +) call :VerifyExe "GNU Arm Embedded Toolchain" "arm-none-eabi-gcc --version" call :VerifyExe "CMake" "cmake --version" diff --git a/packages/pico-setup-windows/pico-env.ps1 b/packages/pico-setup-windows/pico-env.ps1 index 96df2c9..ad1e739 100644 --- a/packages/pico-setup-windows/pico-env.ps1 +++ b/packages/pico-setup-windows/pico-env.ps1 @@ -3,7 +3,7 @@ $ErrorActionPreference = 'Stop' $ProgressPreference = 'SilentlyContinue' # https://github.com/microsoft/vswhere/wiki/Start-Developer-Command-Prompt#using-powershell -& "${env:COMSPEC}" /s /c "`"$PSScriptRoot\pico-env.cmd`" && set" | ForEach-Object { +cmd.exe /s /c "`"$PSScriptRoot\pico-env.cmd`" && set" | ForEach-Object { $name, $value = $_ -split '=', 2 Set-Content env:\"$name" $value } diff --git a/packages/pico-setup-windows/pico-setup.cmd b/packages/pico-setup-windows/pico-setup.cmd index 3dd0a2f..8c4686e 100644 --- a/packages/pico-setup-windows/pico-setup.cmd +++ b/packages/pico-setup-windows/pico-setup.cmd @@ -38,17 +38,19 @@ for %%i in (examples extras playground) do ( ) rem Build a couple of examples -mkdir "%PICO_REPOS_PATH%\pico-examples\build" -pushd "%PICO_REPOS_PATH%\pico-examples\build" -cmake -G Ninja .. -DCMAKE_BUILD_TYPE=Debug --fresh || exit /b 1 +for %%j in (pico pico2) do ( + mkdir "%PICO_REPOS_PATH%\pico-examples\build-%%j" + pushd "%PICO_REPOS_PATH%\pico-examples\build-%%j" + cmake -G Ninja .. -DPICO_BOARD=%%j -DCMAKE_BUILD_TYPE=Debug --fresh || exit /b 1 + + for %%i in (blink "hello_world/all") do ( + echo Building %%i for %%j + ninja "%%i" || exit /b 1 + ) -for %%i in (blink "hello_world/all") do ( - echo Building %%i - ninja "%%i" || exit /b 1 + popd ) -popd - if "%interactive%" equ "1" ( rem Open repo folder in Explorer start . diff --git a/packages/picotool/build-picotool.sh b/packages/picotool/build-picotool.sh index b1e9472..55d4016 100644 --- a/packages/picotool/build-picotool.sh +++ b/packages/picotool/build-picotool.sh @@ -1,40 +1,31 @@ -#!/bin/bash - -set -euo pipefail - -BITNESS=$1 -ARCH=$2 - -export PICO_SDK_PATH="$PWD/pico-sdk" -export LDFLAGS="-static -static-libgcc -static-libstdc++" - -cd pico-sdk/tools/elf2uf2 -mkdir -p build -cd build -cmake -G Ninja .. -DCMAKE_BUILD_TYPE=Release -Wno-dev -cmake --build . - -cd ../../pioasm -mkdir -p build -cd build -cmake -G Ninja .. -DCMAKE_BUILD_TYPE=Release -Wno-dev -cmake --build . - -cd ../../../.. -INSTALLDIR="pico-sdk-tools/mingw$BITNESS" -mkdir -p $INSTALLDIR -cp pico-sdk/tools/elf2uf2/build/elf2uf2.exe $INSTALLDIR -cp pico-sdk/tools/pioasm/build/pioasm.exe $INSTALLDIR -cp ../packages/pico-sdk-tools/pico-sdk-tools-config.cmake $INSTALLDIR - -cd picotool -mkdir -p build -cd build -cmake -G Ninja .. -DCMAKE_BUILD_TYPE=Release -cmake --build . - -cd ../.. -INSTALLDIR="picotool-install/mingw$BITNESS" -mkdir -p $INSTALLDIR -cp picotool/build/picotool.exe $INSTALLDIR -cp "/mingw$BITNESS/bin/libusb-1.0.dll" $INSTALLDIR +#!/bin/bash + +set -euo pipefail + +BUILDDIR="$PWD" +INSTALLDIR="pico-sdk-tools/${MSYSTEM,,}" + +export PICO_SDK_PATH="$PWD/pico-sdk" +export LDFLAGS="-static -static-libgcc -static-libstdc++" + +build-tool () { + SRCDIR="$1" + TOOLDIR="$INSTALLDIR/$(basename "$SRCDIR")" + shift 1 + pushd "$SRCDIR" + mkdir -p build + cd build + cmake -G Ninja .. -DCMAKE_BUILD_TYPE=Release "$@" + cmake --build . + popd + mkdir -p "$TOOLDIR" + cmake --install "$SRCDIR/build" --prefix "$INSTALLDIR" || cp "$SRCDIR/build/*.exe" "$TOOLDIR" +} + +[ -d pico-sdk/tools/elf2uf2 ] && build-tool pico-sdk/tools/elf2uf2 -Wno-dev +build-tool pico-sdk/tools/pioasm -DPIOASM_FLAT_INSTALL=1 -Wno-dev +cp ../packages/pico-sdk-tools/pico-sdk-tools-config.cmake "$INSTALLDIR" + +build-tool picotool -DPICOTOOL_FLAT_INSTALL=1 +cd "$INSTALLDIR/picotool" +"$BUILDDIR/../packages/common/copy-deps.sh" diff --git a/packages/riscv/build-riscv-gcc.sh b/packages/riscv/build-riscv-gcc.sh new file mode 100644 index 0000000..7e0e79e --- /dev/null +++ b/packages/riscv/build-riscv-gcc.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# From pico-sdk-tools +# https://github.com/raspberrypi/pico-sdk-tools/blob/63a716bf0c50a37883a740e1526fde65af083493/packages/windows/riscv/build-riscv-gcc.sh + +set -euo pipefail + +BUILDDIR="$PWD" +INSTALLDIR="riscv-gnu-toolchain-install/${MSYSTEM,,}" +mkdir -p "$INSTALLDIR" + +# Currently this results in: +# - GCC is fully static +# - binutils has static libstdc++ and libgcc but needs a few other DLLs +# - GDB is not static at all +export LDFLAGS="-static -static-libgcc -static-libstdc++" + +cd riscv-gnu-toolchain +./configure \ + --prefix="$BUILDDIR/$INSTALLDIR" \ + --with-arch=rv32ima_zicsr_zifencei_zba_zbb_zbs_zbkb_zca_zcb \ + --with-abi=ilp32 \ + --with-multilib-generator="rv32ima_zicsr_zifencei_zba_zbb_zbs_zbkb_zca_zcb-ilp32--;rv32imac_zicsr_zifencei_zba_zbb_zbs_zbkb-ilp32--" +make -j$(nproc) + +cd "$BUILDDIR/$INSTALLDIR" +"$BUILDDIR/../packages/common/copy-deps.sh" diff --git a/tests/pico-build.cmd b/tests/pico-build.cmd index 7f48d4d..59fddfa 100644 --- a/tests/pico-build.cmd +++ b/tests/pico-build.cmd @@ -1,5 +1,18 @@ @if not defined _echo echo off +goto main + +:test-build + + mkdir "%BUILD_DIR%" + pushd "%BUILD_DIR%" + cmake "%SRC_DIR%" -G Ninja -DCMAKE_BUILD_TYPE=Debug --fresh %* || exit /b 1 + ninja --quiet || exit /b 1 + popd + goto :EOF + +:main + call "%PICO_INSTALL_PATH%\pico-env.cmd" || exit /b 1 pushd "%PICO_REPOS_PATH%" @@ -10,15 +23,22 @@ popd subst P: "%PICO_REPOS_PATH%" || exit /b 1 -pushd "P:\pico-examples\build" -cmake -G Ninja .. -DPICO_BOARD=pico_w -DWIFI_SSID=ssid -DWIFI_PASSWORD=pass "-DFREERTOS_KERNEL_PATH=P:\FreeRTOS-Kernel" -DTEST_TCP_SERVER_IP=10.10.10.10 -DCMAKE_BUILD_TYPE=Debug --fresh || exit /b 1 -ninja --quiet || exit /b 1 -popd +set "SRC_DIR=P:\pico-examples" -mkdir "P:\pico-sdk-build" -pushd "P:\pico-sdk-build" -cmake "%PICO_SDK_PATH%" -G Ninja -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Debug -DPICO_BOARD=pico_w --fresh || exit /b 1 -ninja --quiet || exit /b 1 -popd +set "BUILD_DIR=P:\pico-examples\build-pico" +call :test-build -DPICO_BOARD=pico || exit /b 1 + +set "BUILD_DIR=P:\pico-examples\build-pico2" +call :test-build -DPICO_BOARD=pico2 || exit /b 1 + +set "BUILD_DIR=P:\pico-examples\build-pico2-riscv" +call :test-build -DPICO_BOARD=pico2 -DPICO_PLATFORM=rp2350-riscv "-DPICO_RISCV_TOOLCHAIN_PATH=%PICO_RISCV_TOOLCHAIN_PATH%" "-DPICO_ARM_TOOLCHAIN_PATH=%PICO_ARM_TOOLCHAIN_PATH%" || exit /b 1 + +set "BUILD_DIR=P:\pico-examples\build-pico_w" +call :test-build -DPICO_BOARD=pico_w -DWIFI_SSID=ssid -DWIFI_PASSWORD=pass "-DFREERTOS_KERNEL_PATH=P:\FreeRTOS-Kernel" -DTEST_TCP_SERVER_IP=10.10.10.10 || exit /b 1 + +set "SRC_DIR=%PICO_SDK_PATH%" +set "BUILD_DIR=P:\pico-sdk-build" +call :test-build -DPICO_SDK_TESTS_ENABLED=1 -DPICO_BOARD=pico_w || exit /b 1 subst P: /d diff --git a/tests/setup.ps1 b/tests/setup.ps1 index b8ae1b1..bc3a398 100644 --- a/tests/setup.ps1 +++ b/tests/setup.ps1 @@ -2,9 +2,9 @@ Set-StrictMode -Version Latest $ErrorActionPreference = 'Stop' $ProgressPreference = 'SilentlyContinue' -$installer = Get-ChildItem bin\*.exe | Select-Object -First 1 -ExpandProperty FullName +$installer = Get-ChildItem bin\*.exe | Sort-Object LastWriteTime -Descending | Select-Object -First 1 -ExpandProperty FullName Write-Host "Starting $installer" -$elapsed = Measure-Command { Start-Process -FilePath $installer -ArgumentList "/S" -Wait } +$elapsed = Measure-Command { Start-Process -FilePath $installer -ArgumentList "/S" -PassThru | Wait-Process } Write-Host ("Finished in {0:hh':'mm':'ss}" -f $elapsed) $uninstRegKey = "Microsoft\Windows\CurrentVersion\Uninstall\Raspberry Pi Pico SDK*" @@ -30,3 +30,4 @@ function Update-EnvironmentVariables { Update-EnvironmentVariables cmd /c call "$installPath\pico-setup.cmd" "$([Environment]::GetFolderPath("MyDocuments"))\Pico" "&&" call "$PSScriptRoot\pico-build.cmd" +exit $LASTEXITCODE diff --git a/update.ps1 b/update.ps1 index 5b38ef4..8dc8652 100644 --- a/update.ps1 +++ b/update.ps1 @@ -32,11 +32,11 @@ function updateDownloadUrl { [uri]$newUrl = switch ($Download.name) { - 'GNU Arm Embedded Toolchain' { + 'Arm GNU Toolchain' { $ext = $Download.file -match '\.exe$' ? 'exe' : 'zip' - crawl 'https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads' | - Where-Object { $_ -match "-win32\.$ext" } | # There is no 64-bit build for Windows currently + crawl 'https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads' | + Where-Object { $_ -match "arm-gnu-toolchain-.*-mingw-w64-i686-arm-none-eabi\.$ext" } | # There is no 64-bit build for Windows currently Select-Object -First 1 } @@ -53,7 +53,7 @@ function updateDownloadUrl { getGitHubReleaseAssetUrl 'ninja-build/ninja' { $_.name -eq 'ninja-win.zip' } } - 'Python 3.9' { + 'Python 3.12' { $suffix = '' if ($Download.file -match '\.exe$') { @@ -63,7 +63,7 @@ function updateDownloadUrl { } crawl 'https://www.python.org/downloads/windows/' | - Where-Object { $_ -match "python-3\.9\.[0-9]+$suffix`$" } | + Where-Object { $_ -match "python-3\.12\.[0-9]+$suffix`$" } | Select-Object -First 1 } @@ -109,7 +109,7 @@ function updateDownloadUrl { } } -foreach ($arch in @('x86.json', 'x64.json', 'x64-standalone.json')) { +foreach ($arch in @('x64.json', 'x64-standalone.json')) { $config = Get-Content ".\config\$arch" | ConvertFrom-Json foreach ($i in $config.downloads) {