How to specify desired version of an installed framework?

TL;DR, when using libdep=, one can specify the exact lib version to use. It is possible to specify also a specific framework version?

I am using @wizio Pico/baremetal framework and install it per the instructions:

https://github.com/Wiz-IO/wizio-pico

A few months ago, this installed version 1.0.8 of framework-wizio-pico. A new installation today installed version 1.0.9. Is there a way to specify an exact version for better stability/reproducibility of the dev environment.

Ideally this would be in a checked in file such as platformio.ini such that it stays with the project, as libdep does.

platform 1.0.8 and 1.0.9 - are the same
framework 1.0.9 support SDK 1.2.0 and 1.1.2

Thanks Wizio. Yes, there we some reports on the Pico SDK forums about issues with SDK 1.2.0 so I wanted to control which one I use. (I also noticed slightly better memory and cpu optimization with 1.2.0).

Is there a way to specify that the project uses 1.0.8?

on this stage - no … or give ideas

in code / sdk

Thanks @wizio. I am getting “1.1.2.WizIO”. Will add a build time assertion that this is the version, since this is what I tested.

I also added a platformio feature request at Feature request: allow to specify in a project a specific framework version · Issue #3972 · platformio/platformio-core · GitHub

I believe that being able to check out a project and automatically reproducing the development environment, including versions of the various components, is an important aspect of platformio. Otherwise results are non predictable.

All PlatformIO core platforms can do this. WizIO’s platform is slightly different due to it still being in development and not having Github releases or being integrated / recongized as a builtin PlatformIO platform yet.

The way things usually work is that you have a “platform”, e.g. https://github.com/platformio/platform-ststm32/. This platform is specific to one microcontroller platform, say STM32 chips or the Raspberry Pi RP2040 series. It contains:

  1. Board definitions
  2. Platform code (platform.py, connects the platform code to the PlatformIO core, sets up various things such as uploader methods)
  3. Builder code (builder/main.py, builder/frameworks/arduino.py, …, this tells SCons how to build the firmware for a specific framework, say Arduino)
  4. Declaration of packages used by the platform (platform.json)
  5. Miscellenous stuff (SVD files, …)

A platform of one particular version in term makes use of packages. These packages are declared in the platform.json manifest file, see e.g. here.

A package can contain anything. Typical packages are the compiler (toolchain-gccarmnoneeabi), upload tools (tool-openocd) and framework code (framework-arduinoststm32). The packages reside in the PlatformIO trusted package repository (accessed by pio package publish .. etc on the CLI).

The platform.json specifies the default version of a used package. See e.g.

this is from the STSTM32 14.0.0 version of the file, stating that the package framework-arduinoststm32 shall be used in the version ~4.20000.0, which is a SemVer encoded version string for Arduino Core 2.0.0 (~ meaning ‘circa’, aka minor version updates are allowed).

In the platformio.ini you can control what version of the platform you are using. This is true for all platforms as this is a PlatformIO core feature. See e.g. here.

By doing

platform = ststm32

you instruct PlatformIO to use whatever the latest ST STM32 platform is that you have installed in PlatformIO. By doing e.g.

platform = ststm32@7.0.0

you will get the 7.0.0 release of the platform which first introduced Arduino core 1.9.0, which you also see in the platform.json

So by stating which release version of a platform you want, you can thus also control what e.g. Arduino core version you want, which is controlled by the package version the platform specifies.

However, you can also control it independently by using the platform_packages directive in the platformio.ini. With this you are able to set an explicit (semantic) version for a package that PlatformIO shall use. So you can say, use the latest platform code but with an older package (e.g. an older Arduino core), say with

platform = ststm32@14.0.0
platform_packages =
   framework-arduinoststm32@~4.10900.0

you are able to specify that you want the fixed platform version 14.0.0, which would give you Arduino core 2.0.0, but then we also override the to-be-used version of the framework-arduinoststm32 package to the 1.9.0 version.

You will see however that the platform = wizio-pico@<version> syntax will not work because they are not released in the PlatformIO package system. A request for https://api.registry.platformio.org/v3/packages/platformio/platform/wizio-pico will give 404 whereas e.g. https://api.registry.platformio.org/v3/packages/platformio/platform/ststm32 will show you all the available versions. Also there are no releases here which the platforms usually have.

However, you can still refer to a specific git commit hash or branch, as shown e.g. here and here. This works universally. You can also inspect all branches here and all commits here.

So a perfectly valid thing to do is saying

platform = https://github.com/Wiz-IO/wizio-pico.git#ad2d813e2deee73ef4e162ce07f5560236cd7ed5

(current master commit) and that will freeze the entire platform. Not the packages because there’s another caveat, below.

One can also e.g. do

platform = https://github.com/Wiz-IO/wizio-pico.git#v106

to refer to a brach (this branch is 2 months old so you shouldn’t use it, just an example).

And finally you can also independently change the package version. As you can see in here and

https://github.com/Wiz-IO/wizio-pico/blob/ad2d813e2deee73ef4e162ce07f5560236cd7ed5/platform.json#L33-L37

the platform does not a fixed version string to refer to the package where the SDK code is stored but uses a git reference. This has a nasty side effect that even if you specify older platform versions the platform.json of these will still point to the framework via git and will thus pull the latest version on the default branch of that repo. This is not the way it’s usually done in PlatformIO-controlled platforms, as I’ve shown above with STSTM32 and version strings refering to the PlatformIO package repository. Again, framework-wizio-pico is not registered with the PlatformIO registry, as opposed to e.g. framework-arduinoststm32.

But, as I’ve already shown above we can still manually control the version of the used package with platform_packages, and inside those expressions we can refer to a git repo’s commit hash and branch.

So, once you’ve e.g. tested your firmware to be compilable and working on one particular platform and package version, you can extract those commit hashes (execute git log -n1 in the platform and framework folder, e.g. C:\Users\<user>\.platformio\platforms\wizio-pico and C:\Users\<user>\.platformio\packages\framework-wizio-pico) and hardcode them into the platformio.ini.

For example with taking the most recent commits of both, one can do

platform = https://github.com/Wiz-IO/wizio-pico.git#ad2d813e2deee73ef4e162ce07f5560236cd7ed5
platform_packages = 
   framework-wizio-pico@https://github.com/Wiz-IO/framework-wizio-pico.git#62054597f18cec5c7e312c1286289e24de1d756b

and that will freeze the platform and framework package code version, giving you reproducable results.

As explained above, to make this easier, the developer of the platform should register the platform and the packages it uses with the PlatformIO registry, so that a versioning exists for these things that can be refered to with the usual @<version> syntax. The platform.json should then also be changed to not refer to a git link, but to a particular publish version in the registry.

1 Like

Thanks @maxgerhardt!. Very useful and informative and answered my question and beyond.

I will ready it carefully and will see how I can apply it to my projects.

@wizio, this is very interesting material. How about registering ‘baremetal’ as a out of the box platform? (‘sdk’ may be a more descriptive name than ‘baremetal’ ?).

Hi, @maxgerhardt, I determined the two commit hashes I want to use (an older version) and set them up in my platformio.ini. When I build, they seems to be fetched correctly but I am getting a warning about an ambiguous source for the compiler (with your name in it ;-))

Any suggestion?

Warning
=======
Tool Manager: Installing toolchain-gccarmnoneeabi @ =1.70201.0
Tool Manager: Warning! More than one package has been found by toolchain-gccarmnoneeabi @ =1.70201.0 requirements:
 - platformio/toolchain-gccarmnoneeabi @ 1.50401.210106
 - maxgerhardt/toolchain-gccarmnoneeabi @ 1.40903.0

platformio.ini

[env:raspberry-pi-pico]

platform = https://github.com/Wiz-IO/wizio-pico.git#3250e0732cf4c0ff72d4c689317fc7481a34b612
platform_packages = 
   framework-wizio-pico@https://github.com/Wiz-IO/framework-wizio-pico.git#6f1e42f31a10441688c67588d98ffc9473a2470d
board = raspberry-pi-pico
framework = baremetal
upload_protocol = picoprobe
debug_tool = picoprobe
monitor_port = COM3
; This enables Pico's int64 printf.
board_build.nano = disable
board_build.pio = src/display/tft_driver.pio
build_flags = 
    -O3
    -Wno-missing-field-initializers
    -I src
    -I "$PROJECT_CORE_DIR/packages/framework-wizio-pico/SDK111/hardware"
    -I "$PROJECT_CORE_DIR/packages/framework-wizio-pico/SDK/pico"
    -D PICO_STDIO_USB
lib_ignore = freertos, wiring

Build log:

Processing raspberry-pi-pico (platform: https://github.com/Wiz-IO/wizio-pico.git#3250e0732cf4c0ff72d4c689317fc7481a34b612; board: raspberry-pi-pico; framework: baremetal)
---------------------------------------------------------------------------------------------------------------------------------------------------------Platform Manager: Installing git+https://github.com/Wiz-IO/wizio-pico.git#3250e0732cf4c0ff72d4c689317fc7481a34b612
git version 2.31.1.windows.1
Cloning into 'C:\Users\user\.platformio\.cache\tmp\pkg-installing-x9n40vmn'...
remote: Enumerating objects: 1673, done.
remote: Counting objects: 100% (701/701), done.
remote: Compressing objects: 100% (525/525), done.
Receiving objects:  96% (1607/16reused 314 (delta 161), pack-reused 972 eceiving objects:  95% (1590/1673), 812.01 KiB | 1.57 MiB/s
Receiving objects: 100% (1673/1673), 861.80 KiB | 1.64 MiB/s, done.
Resolving deltas: 100% (785/785), done.
HEAD is now at 3250e07 Update README.md
Platform Manager: wizio-pico @ 1.0.8+sha.3250e07 has been installed!
The platform 'https://github.com/Wiz-IO/wizio-pico.git#3250e0732cf4c0ff72d4c689317fc7481a34b612' has been successfully installed!
The rest of the packages will be installed later depending on your build environment.
Tool Manager: Installing git+https://github.com/Wiz-IO/framework-wizio-pico.git#6f1e42f31a10441688c67588d98ffc9473a2470d
git version 2.31.1.windows.1
Cloning into 'C:\Users\user\.platformio\.cache\tmp\pkg-installing-8ra4atd0'...
remote: Enumerating objects: 2736, done.
remote: Counting objects: 100% (941/941), done.
remote: Compressing objects: 100% (647/647), done.
remote: Total 2736 (delta 298), reused 740 (delta 247), pack-reused 1795
Receiving objects: 100% (2736/2736), 3.70 MiB | 984.00 KiB/s, done.
Resolving deltas: 100% (947/947), done.
Updating files: 100% (1109/1109), done.
Updating files: 100% (716/716), done.
HEAD is now at 6f1e42f Add files via upload
Tool Manager: framework-wizio-pico @ 1.0.8+sha.6f1e42f has been installed!
Tool Manager: Installing toolchain-gccarmnoneeabi @ =1.70201.0
Tool Manager: Warning! More than one package has been found by toolchain-gccarmnoneeabi @ =1.70201.0 requirements:
 - platformio/toolchain-gccarmnoneeabi @ 1.50401.210106
 - maxgerhardt/toolchain-gccarmnoneeabi @ 1.40903.0
Tool Manager: Please specify detailed REQUIREMENTS using package owner and version (showed above) to avoid name conflicts
Unpacking  [####################################]  100%

offtopic @zapta
PICO_STDIO_UART now ( SDK 1.2 ) is LIB_PICO_STDIO_UART :slight_smile:

Funny. The version requement is @ =1.70201.0 yet it lists a 1.50401.210106 and a 1.40903.0 version which are clearly completely out of range. But I think I observed that behavior too.

Later in the build / after unpacking and installing everything, it should print PACKAGES: with the used packages and their version. What is the compiler version there?

This is what I see when building with those two commit ids

<<<<<<<<<<<< WIZIO - RASPBERRY PI PICO ( PICOPROBE ) 2021 Georgi Angelov >>>>>>>>>>>>
[PIO-ASM] File ( tft_driver.pio.h ) exist
CONFIGURATION: https://docs.platformio.org/page/boards/wizio-pico/raspberry-pi-pico.html
PLATFORM: WizIO - Raspberry Pi Pico (1.0.8+sha.3250e07) > WizIO - Raspberry Pi Pico ( PICOPROBE )
HARDWARE: RP2040 125MHz, 256KB RAM, 2MB Flash
DEBUG: Current (picoprobe) External (cmsis-dap, picoprobe)
PACKAGES:

  • framework-wizio-pico 1.0.8+sha.6f1e42f
  • tool-wizio-pico 1.0.0+sha.3a504e1
  • toolchain-gccarmnoneeabi 1.70201.0 (7.2.1)

Okay so it indeed found the package of the correct version, which is nice. Maybe the package warning is just a general warning, even though it is not related to the actual packages used. I will open an issue in the core for that.

Edit: Issue PlatformIO shows warning about package conflict for unrelated versions · Issue #3975 · platformio/platformio-core · GitHub is open for that.

Thanks @maxgerhardt.

@wizio, what is the way to set printf to USB CDC serial, with the latest version?

I am using this, which uses the latest Wizio-pico but it doesn’t enable the USB serial.

[env:raspberry-pi-pico]
platform = https://github.com/Wiz-IO/wizio-pico.git
platform_packages =
    framework-wizio-pico@https://github.com/Wiz-IO/framework-wizio-pico.git
board = raspberry-pi-pico
framework = baremetal
upload_protocol = picoprobe
debug_tool = picoprobe
monitor_port = COM3
; This enables Pico's int64 printf.
board_build.nano = disable
board_build.pio = src/display/tft_driver.pio
build_flags = 
    -O3
    -Wno-missing-field-initializers
    -I src
    -I "$PROJECT_CORE_DIR/packages/framework-wizio-pico/SDK111/hardware"
    -I "$PROJECT_CORE_DIR/packages/framework-wizio-pico/SDK/pico"
    -D LIB_PICO_STDIO_USB
lib_ignore = freertos, wiring

:slight_smile: refresh platform and test

build_flags = 
    -D LIB_PICO_STDIO_UART
    -D LIB_PICO_STDIO_USB

Thanks @wizio. I tried these two platformio.ini but it doesn’t work. The serial port is established, the uploaded uses it successfully to enter boot mode, and the program runs but I don’t see any output. Do you happen to have a hello world with the latest version that printf to USB/CDC?

[env:raspberry-pi-pico]
; Fixing to Wizio 1.08 which is known to be good.
platform = https://github.com/Wiz-IO/wizio-pico.git
platform_packages =
	framework-wizio-pico@https://github.com/Wiz-IO/framework-wizio-pico.git
board = raspberry-pi-pico
framework = baremetal
upload_protocol = picoprobe
debug_tool = picoprobe
; Adjust it to the COM port used by the analyzer on your system.
monitor_port = COM4
; This enables Pico's int64 printf.
board_build.nano = disable
board_build.pio = src/display/tft_driver.pio
build_flags = 
	-O3
	-Wno-missing-field-initializers
	-I src
	-I "$PROJECT_CORE_DIR/packages/framework-wizio-pico/SDK111/hardware"
	-I "$PROJECT_CORE_DIR/packages/framework-wizio-pico/SDK/pico"
    -D LIB_PICO_STDIO_USB
lib_ignore = freertos, wiring




[env:raspberry-pi-pico]
; Fixing to Wizio 1.08 which is known to be good.
platform = https://github.com/Wiz-IO/wizio-pico.git
platform_packages =
	framework-wizio-pico@https://github.com/Wiz-IO/framework-wizio-pico.git
board = raspberry-pi-pico
framework = baremetal
upload_protocol = picoprobe
debug_tool = picoprobe
; Adjust it to the COM port used by the analyzer on your system.
monitor_port = COM4
; This enables Pico's int64 printf.
board_build.nano = disable
board_build.pio = src/display/tft_driver.pio
build_flags = 
	-O3
	-Wno-missing-field-initializers
	-I src
	-I "$PROJECT_CORE_DIR/packages/framework-wizio-pico/SDK111/hardware"
	-I "$PROJECT_CORE_DIR/packages/framework-wizio-pico/SDK/pico"
    -D LIB_PICO_STDIO_UART
    -D LIB_PICO_STDIO_USB
lib_ignore = freertos, wiring

I will look at what is wrong these days…