diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a1acdee..f54e8e2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -name: 🏗️ Build pioasm, picosdk, picotool +name: 🏗️ Build all packages on: workflow_dispatch: @@ -31,7 +31,7 @@ jobs: build: strategy: matrix: - os: [ubuntu-24.04, macos-latest] + os: [ubuntu-24.04, macos-latest, windows-2022] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 @@ -41,17 +41,17 @@ jobs: # Build picosdk 2.2.0 - - run: conan create pioasm --version=2.2.0 -pr:a hal/tc/llvm -b missing - run: conan create pico-sdk --version=2.2.0 + - run: conan create pioasm --version=2.2.0 -pr:a hal/tc/llvm -b missing - if: ${{ startsWith(matrix.os, 'macos') }} - run: conan create picotool -b missing --version=2.2.0 -pr:a hal/tc/llvm -pr:a profiles/macos-build + run: conan create picotool -b missing --version=2.2.0 -pr:a hal/tc/llvm -c tools.build:sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk - if: ${{ startsWith(matrix.os, 'ubuntu') }} run: sudo -E $(which conan) create picotool -b missing --version=2.2.0 -pr:a hal/tc/llvm -c tools.system.package_manager:mode=install - if: ${{ startsWith(matrix.os, 'windows') }} - run: conan create picotool -b missing --version=2.2.0 -pr:a hal/tc/llvm + run: conan create picotool -b missing --version=2.2.0 -c tools.cmake.cmaketoolchain:generator="NMake Makefiles" - name: 📡 Sign into JFrog Artifactory env: @@ -61,19 +61,11 @@ jobs: # TODO(#5): Check that demo builds correctly - # Upload Packages: disabled for now as we fix - - # - if: ${{ startsWith(github.ref, 'refs/tags/') }} - # run: conan upload "libusb/*" --confirm -r=libhal - - # - if: ${{ startsWith(github.ref, 'refs/tags/') }} - # run: conan upload "mbedlts/*" --confirm -r=libhal - - # - if: ${{ startsWith(github.ref, 'refs/tags/') }} - # run: conan upload "pioasm/*" --confirm -r=libhal + - if: ${{ startsWith(github.ref, 'refs/tags/') }} + run: conan upload "pioasm/*" --confirm -r=libhal - # - if: ${{ startsWith(github.ref, 'refs/tags/') }} - # run: conan upload "pico-sdk/*" --confirm -r=libhal + - if: ${{ startsWith(github.ref, 'refs/tags/') }} + run: conan upload "pico-sdk/*" --confirm -r=libhal - if: ${{ startsWith(github.ref, 'refs/tags/') }} run: conan upload "picotool/*" --confirm -r=libhal diff --git a/README.md b/README.md index be0aecb..b23a0d0 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # Pico Packages + These are conan packages for the Pico SDK for the Raspberry Pi Pico family of microcontrollers. @@ -23,21 +24,46 @@ Versions: - 2.1.1 - 2.2.0 +- 2.2.1-alpha Packages contained: - pioasm - picotool/pioasm/pico-sdk: -## Building the Packages +## Building + +`pico-sdk` is a pure source package and does not require any profile to build. +Use `conan create pico-sdk --version ` and it should just work. The current +version that is supported is `2.2.1-alpha` since it has hard-floating point ABI support. +`2.2.0` is also supported for soft-fp ABI, and is required to build picotool and pioasm. + +```sh +conan create pico-sdk --version 2.2.1-alpha +``` + +`picotool` is a host software used to generate uf2 files and upload firmware. Use either +the default conan profile, or whatever conan profile you use to build host software. `picotool` +is currently tested to work on `2.2.0`, which depends on `pico-sdk/2.2.0`. + +```sh +conan create picotool --version 2.2.0 +``` + +`pioasm` is a host software used to assemble pio programs. It is not necessary unless you are +developing programs using the pio peripheral. `pioasm` is currently known to build on `2.2.0`, which +depends on `pico-sdk/2.2.0`. + +```sh +conan create pioasm --version 2.2.0 +``` -First build the tool packages needed for picosdk to build PIO assembly code +`test_package` is a small program demonstrating the usage of `pico-sdk` and `picotool`. It is intended +as a guide on configuring dependents on how to use `pico-sdk`. -```bash -conan create pioasm --version=2.2.0 -pr:a hal/tc/llvm -b missing -conan create piosdk --version=2.2.0 -conan create picotool --version=2.2.0 -pr:a hal/tc/llvm -b missing +```sh +conan build test_package -pr:h hal/tc/arm-gcc-14.2 -pr:h feather-rp2350 -of build ``` -For macOS add `-pr:a profiles/macos-build` in order to ensure that the LLVM -toolchain gets its sysroot set. +Using `pico-sdk/2.2.1-alpha` with `picotool/2.2.0` is perfectly acceptable and the expected way to build +projects until `pico-sdk/2.2.1` becomes formally released. \ No newline at end of file diff --git a/board-headers/micromod/conanfile.py b/board-headers/micromod/conanfile.py deleted file mode 100644 index c3513a9..0000000 --- a/board-headers/micromod/conanfile.py +++ /dev/null @@ -1,53 +0,0 @@ -# MIT License -# -# Copyright (c) 2025 Shin Umeda -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -from conan import ConanFile -from conan.tools.files import copy - - -class MicromodHeader(ConanFile): - name = "rp-board-header-rp2350-micromod" - package_type = "header-library" - - license = "BSD-3" - author = " " - url = "https://github.com/DolphinGui/ppackage" - description = "A header for Picos on micromod" - topics = ("Embedded", "Raspberry Pi Pico", "ARM") - - settings = "os", "compiler", "build_type", "arch" - options = {} - default_options = {} - - exports_sources = "*.h" - - def package(self): - copy(self, "*", self.export_sources_folder, self.package_folder) - - def package_info(self): - self.buildenv_info.append("PICO_BOARD_HEADER_DIRS", - self.package_folder, separator=";") - self.cpp_info.includedirs = [] # no actual include directories - self.cpp_info.libdirs = [] # nothing is being built - - def package_id(self): - self.info.settings.clear() diff --git a/board-headers/micromod/libhal_rp2350_micromod.h b/board-headers/micromod/libhal_rp2350_micromod.h deleted file mode 100644 index f66f48d..0000000 --- a/board-headers/micromod/libhal_rp2350_micromod.h +++ /dev/null @@ -1,87 +0,0 @@ -/** - * MIT License - * - * Copyright (c) 2025 Shin Umeda - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef _rp2350_micromod_h -#define _rp2350_micromod_h - -pico_board_cmake_set(PICO_PLATFORM, rp2350) - -#define PICO_RP2350A 0 // use RP2350B - -#ifndef PICO_DEFAULT_UART -#define PICO_DEFAULT_UART 0 -#endif -#ifndef PICO_DEFAULT_UART_TX_PIN -#define PICO_DEFAULT_UART_TX_PIN 12 -#endif -#ifndef PICO_DEFAULT_UART_RX_PIN -#define PICO_DEFAULT_UART_RX_PIN 13 -#endif - -// --- LED --- -#ifndef PICO_DEFAULT_LED_PIN -#define PICO_DEFAULT_LED_PIN 46 -#endif - -#ifndef PICO_DEFAULT_I2C -#define PICO_DEFAULT_I2C 0 -#endif -#ifndef PICO_DEFAULT_I2C_SDA_PIN -#define PICO_DEFAULT_I2C_SDA_PIN 16 -#endif -#ifndef PICO_DEFAULT_I2C_SCL_PIN -#define PICO_DEFAULT_I2C_SCL_PIN 17 -#endif - -// --- SPI --- -#ifndef PICO_DEFAULT_SPI -#define PICO_DEFAULT_SPI 0 -#endif -#ifndef PICO_DEFAULT_SPI_SCK_PIN -#define PICO_DEFAULT_SPI_SCK_PIN 34 -#endif -#ifndef PICO_DEFAULT_SPI_TX_PIN -#define PICO_DEFAULT_SPI_TX_PIN 35 -#endif -#ifndef PICO_DEFAULT_SPI_RX_PIN -#define PICO_DEFAULT_SPI_RX_PIN 36 -#endif - -#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1 - -#ifndef PICO_FLASH_SPI_CLKDIV -#define PICO_FLASH_SPI_CLKDIV 2 -#endif - - pico_board_cmake_set_default(PICO_FLASH_SIZE_BYTES, (16 * 1024 * 1024)) -#ifndef PICO_FLASH_SIZE_BYTES -#define PICO_FLASH_SIZE_BYTES (16 * 1024 * 1024) -#endif - - pico_board_cmake_set_default(PICO_RP2350_A2_SUPPORTED, 1) -#ifndef PICO_RP2350_A2_SUPPORTED -#define PICO_RP2350_A2_SUPPORTED 1 -#endif - -#endif diff --git a/picotool/conanfile.py b/picotool/conanfile.py index ef3fa00..ae8bd5e 100644 --- a/picotool/conanfile.py +++ b/picotool/conanfile.py @@ -74,6 +74,7 @@ def generate(self): deps = CMakeDeps(self) deps.generate() tc = CMakeToolchain(self) + tc.preprocessor_definitions["NOMINMAX"] = "1" tc.generate() def build(self): diff --git a/profiles/feather-rp2350 b/profiles/feather-rp2350 new file mode 100644 index 0000000..f808d59 --- /dev/null +++ b/profiles/feather-rp2350 @@ -0,0 +1,5 @@ +include(rp2350a) + +[options] +*:board=adafruit_feather_rp2350 + diff --git a/profiles/macos-build b/profiles/macos-build deleted file mode 100644 index cde3b0c..0000000 --- a/profiles/macos-build +++ /dev/null @@ -1,2 +0,0 @@ -[conf] -tools.build:sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk diff --git a/profiles/micromod-rp2350 b/profiles/micromod-rp2350 new file mode 100644 index 0000000..3f04d6f --- /dev/null +++ b/profiles/micromod-rp2350 @@ -0,0 +1,7 @@ +include(rp2350b) + +[options] +*:flash_size=(8 * 1024 * 1024) +*:flash_clkdiv=2 +*:rp_revision=a2 +*:use_w25q_flash=True diff --git a/profiles/rp2350 b/profiles/rp2350 index f2f1183..ba18aa6 100644 --- a/profiles/rp2350 +++ b/profiles/rp2350 @@ -1,8 +1,17 @@ [settings] -build_type=MinSizeRel +build_type=Release os=baremetal -arch=cortex-m33 -build_type=RelWithDebInfo +arch=cortex-m33f [options] *:platform=rp2350-arm-s +prebuilt-picolibc/*:oslib=semihost +prebuilt-picolibc/*:crt0=none + +[buildenv] +CC=arm-none-eabi-gcc +CXX=arm-none-eabi-g++ +LD=arm-none-eabi-ld + +[conf] +tools.cmake.cmaketoolchain:generator=Ninja diff --git a/profiles/rp2350a b/profiles/rp2350a new file mode 100644 index 0000000..70dee5f --- /dev/null +++ b/profiles/rp2350a @@ -0,0 +1,5 @@ +include(rp2350) + +[options] +*:variant=rp2350a + diff --git a/profiles/rp2350b b/profiles/rp2350b new file mode 100644 index 0000000..1ba6308 --- /dev/null +++ b/profiles/rp2350b @@ -0,0 +1,5 @@ +include(rp2350) + +[options] +*:variant=rp2350b + diff --git a/test_package/.gitignore b/test_package/.gitignore new file mode 100644 index 0000000..d835f77 --- /dev/null +++ b/test_package/.gitignore @@ -0,0 +1,2 @@ +build +.cache \ No newline at end of file diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt new file mode 100644 index 0000000..6b48e13 --- /dev/null +++ b/test_package/CMakeLists.txt @@ -0,0 +1,29 @@ +cmake_minimum_required(VERSION 3.15) +set(CMAKE_EXECUTABLE_SUFFIX_ASM .elf) +set(CMAKE_EXECUTABLE_SUFFIX_C .elf) +set(CMAKE_EXECUTABLE_SUFFIX_CXX .elf) +set(PICO_CXX_ENABLE_EXCEPTIONS On) + +set(CMAKE_VERBOSE_MAKEFILE ON) + +include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake) + +project(raspberry_pico_test C CXX ASM) + +pico_sdk_init() +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +add_executable(main main.cpp) + +target_compile_options(main PRIVATE -Wall -Werror) +target_link_libraries(main pico_stdlib hardware_gpio pico_stdio) +# This is necessary to get LTO to work, but for some reason it doesn't build when +# it's off. TODO investigate further +target_compile_definitions(main PUBLIC PICO_STDIO_SHORT_CIRCUIT_CLIB_FUNCS=0) + +include(CheckIPOSupported) +check_ipo_supported() +set_property(TARGET main PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) + +pico_add_extra_outputs(main) +pico_enable_stdio_usb(main 1) +pico_enable_stdio_uart(main 0) diff --git a/test_package/CMakeUserPresets.json b/test_package/CMakeUserPresets.json new file mode 100644 index 0000000..945b382 --- /dev/null +++ b/test_package/CMakeUserPresets.json @@ -0,0 +1,9 @@ +{ + "version": 4, + "vendor": { + "conan": {} + }, + "include": [ + "build/CMakePresets.json" + ] +} \ No newline at end of file diff --git a/test_package/activate.sh b/test_package/activate.sh new file mode 100644 index 0000000..8d5616c --- /dev/null +++ b/test_package/activate.sh @@ -0,0 +1,6 @@ +# This file should be sourced + +if [ -e build/conanbuild.sh ] +then +source build/conanbuild.sh +fi diff --git a/test_package/conanfile.py b/test_package/conanfile.py new file mode 100644 index 0000000..6c19482 --- /dev/null +++ b/test_package/conanfile.py @@ -0,0 +1,33 @@ + +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain + + +class CompressorRecipe(ConanFile): + settings = "os", "compiler", "build_type", "arch" + options = {"board": ["ANY"], "platform": ["ANY"], "variant": ["ANY"]} + generators = "VirtualBuildEnv" + + def requirements(self): + self.requires("picosdk/2.2.0") + + def build_requirements(self): + self.tool_requires("pioasm/2.2.0") + self.tool_requires("picotool/2.2.0") + + def generate(self): + tc = CMakeToolchain(self) + if str(self.options.platform).startswith("rp2"): + if self.options.board: + tc.cache_variables["PICO_BOARD"] = str(self.options.board) + tc.generate() + deps = CMakeDeps(self) + deps.generate() + + def build(self): + cmake = CMake(self) + defs = { + "CMAKE_ASM_FLAGS_INIT": "-mcpu=cortex-m33 -mfloat-abi=soft", + } + cmake.configure(variables=defs) + cmake.build() diff --git a/test_package/configure.sh b/test_package/configure.sh new file mode 100644 index 0000000..9e43596 --- /dev/null +++ b/test_package/configure.sh @@ -0,0 +1,5 @@ +#!/usr/bin/sh + +set -ex + +conan install . -pr:h=../profiles/rp2350 -pr:h=arm-gcc-12.3 --build=missing -of build diff --git a/test_package/ldscripts/pico_flash_region.ld b/test_package/ldscripts/pico_flash_region.ld new file mode 100644 index 0000000..5cef943 --- /dev/null +++ b/test_package/ldscripts/pico_flash_region.ld @@ -0,0 +1 @@ +FLASH(rx) : ORIGIN = 0x10000000, LENGTH = 16 * 1024 * 1024 diff --git a/test_package/main.cpp b/test_package/main.cpp new file mode 100644 index 0000000..a5caf1a --- /dev/null +++ b/test_package/main.cpp @@ -0,0 +1,21 @@ +#include + +#include "hardware/gpio.h" +#include "pico/stdio.h" +#include "pico/time.h" + +int +main() +{ + gpio_set_function(46, gpio_function_t::GPIO_FUNC_SIO); + gpio_set_dir(46, GPIO_OUT); + stdio_init_all(); + while (true) { + gpio_put(46, true); + printf("On!\n"); + sleep_ms(500); + gpio_put(46, false); + printf("Off!\n"); + sleep_ms(500); + } +} diff --git a/test_package/startocd.sh b/test_package/startocd.sh new file mode 100644 index 0000000..936db82 --- /dev/null +++ b/test_package/startocd.sh @@ -0,0 +1,3 @@ +#!/usr/bin/sh + +openocd -s debugscripts -f interface/cmsis-dap.cfg -f interface/rp2350.cfg -c "adapter speed 5000"