Skip to content

pico-sdk 2.1.0 Downloading Picotool runs always upon repeated CMake calls #2308

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sdbbs opened this issue Feb 20, 2025 · 6 comments
Closed

Comments

@sdbbs
Copy link

sdbbs commented Feb 20, 2025

I noticed the same problem as in #2081 using pico-sdk 2.1.0.

Sometimes (like these days) I end up in a situation that where I exclusively work on CMakeLists.txt, and I have to run cmake multiple times - and that is how I managed up end up irritated with this: because every time I run CMake, I get this "Downloading Picotool"! (Even worse, I work with a structure with multiple subfolders inside ./build, so every time I run cmake (even when I run that command repeatedly after each other), I have to see through multiple times "Downloading Picotool" !!

Also, now that I see "Downloading Picotool" which ends up in my project, I'd prefer using that downloaded picotool locally for my project.

I would argue that this is a documentation problem, because nowhere in https://github.com/raspberrypi/picotool/blob/develop/README.md#usage-by-the-raspberry-pi-pico-sdk (or #2081) is neither implied nor explicitly stated, that if I get "Downloading Picotool" during CMake configuration, and I choose to use that downloaded one in my project, I have to build it myself manually. Also, I'd like a method to have this build done automatically (have a comment on this at end)


Here is an example to demonstrate (note, done in MINGW64 (MSYS2) bash shell of Windows 10):

#include <stdio.h>
#include "pico/stdlib.h"

int main() {
    stdio_init_all();
    printf("Hello, world!\n");
    return 0;
}
  • CMakeLists.txt also right from the README.md
cmake_minimum_required(VERSION 3.13)

# initialize the SDK directly
include($ENV{PICO_SDK_PATH}/pico_sdk_init.cmake)

project(my_project)

# initialize the Raspberry Pi Pico SDK
pico_sdk_init()

# rest of your project

add_executable(hello_world
    main.c
)

# Add pico_stdlib library which aggregates commonly used features
target_link_libraries(hello_world pico_stdlib)

# create map/bin/hex/uf2 file in addition to ELF.
pico_add_extra_outputs(hello_world)

I put these in /tmp/test, then I setup to run CMake:

$ cd /tmp/test
$ tree .
.
├── CMakeLists.txt
└── main.c

1 directory, 2 files

$ mkdir build && cd build

$ /c/Program\ Files/CMake/bin/cmake.exe ../ -DCMAKE_BUILD_TYPE=Debug -G "MSYS Makefiles"
PICO_SDK_PATH is C:/src/pico-sdk
Defaulting platform (PICO_PLATFORM) to 'rp2040' since not specified.
Defaulting target board (PICO_BOARD) to 'pico' since not specified.
Using board configuration from C:/src/pico-sdk/src/boards/include/boards/pico.h
Pico Platform (PICO_PLATFORM) is 'rp2040'.
Defaulting compiler (PICO_COMPILER) to 'pico_arm_cortex_m0plus_gcc' since not specified.
Configuring toolchain based on PICO_COMPILER 'pico_arm_cortex_m0plus_gcc'
Defaulting PICO_GCC_TRIPLE to 'arm-none-eabi'
-- The C compiler identification is GNU 13.3.0
-- The CXX compiler identification is GNU 13.3.0
-- Check for working C compiler: C:/msys64/mingw64/bin/arm-none-eabi-gcc.exe
-- Check for working C compiler: C:/msys64/mingw64/bin/arm-none-eabi-gcc.exe - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/msys64/mingw64/bin/arm-none-eabi-g++.exe
-- Check for working CXX compiler: C:/msys64/mingw64/bin/arm-none-eabi-g++.exe - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The ASM compiler identification is GNU
-- Found assembler: C:/msys64/mingw64/bin/arm-none-eabi-gcc.exe
Build type is Debug
Using regular optimized debug build (set PICO_DEOPTIMIZED_DEBUG=1 to de-optimize)
-- Found Python3: C:/Program Files (x86)/Microsoft Visual Studio/Shared/Python36_64/python.exe (found version "3.6.6") found components: Interpreter
TinyUSB available at C:/src/pico-sdk/lib/tinyusb/src/portable/raspberrypi/rp2040; enabling build support for USB.
Compiling TinyUSB with CFG_TUSB_DEBUG=1
BTstack available at C:/src/pico-sdk/lib/btstack
cyw43-driver available at C:/src/pico-sdk/lib/cyw43-driver
lwIP available at C:/src/pico-sdk/lib/lwip
mbedtls available at C:/src/pico-sdk/lib/mbedtls
Using PICO_EXAMPLES_PATH from environment ('C:/src/pico-examples')
CMake Warning at C:/src/pico-sdk/tools/Findpicotool.cmake:28 (message):
  No installed picotool with version 2.1.0 found - building from source

  It is recommended to build and install picotool separately, or to set
  PICOTOOL_FETCH_FROM_GIT_PATH to a common directory for all your SDK
  projects
Call Stack (most recent call first):
  C:/src/pico-sdk/tools/CMakeLists.txt:138 (find_package)
  C:/src/pico-sdk/tools/CMakeLists.txt:485 (pico_init_picotool)
  C:/src/pico-sdk/src/cmake/on_device.cmake:57 (picotool_postprocess_binary)
  CMakeLists.txt:21 (pico_add_extra_outputs)


Downloading Picotool
-- Configuring done
-- Generating done
-- Build files have been written to: C:/msys64/tmp/test/build

OK, so I've got the "Downloading Picotool" message, and apparently I've got picotool downloaded in my project build folder now? Let's check:

$ find . \( -name 'picotool*.exe' -o -name 'picotool*.cmake' \)
./_deps/picotool-src/cmake/picotoolConfig.cmake
./_deps/picotool-subbuild/picotool-populate-prefix/tmp/picotool-populate-gitclone.cmake
./_deps/picotool-subbuild/picotool-populate-prefix/tmp/picotool-populate-gitupdate.cmake

$ find . -name 'picotool*' -exec ls -ld {} +
drwxr-xr-x 1 user None    0 Feb 20 06:03 ./_deps/picotool-build
drwxr-xr-x 1 user None    0 Feb 20 06:03 ./_deps/picotool-src
-rw-r--r-- 1 user None   96 Feb 20 06:03 ./_deps/picotool-src/cmake/picotoolConfig.cmake
drwxr-xr-x 1 user None    0 Feb 20 06:03 ./_deps/picotool-subbuild
drwxr-xr-x 1 user None    0 Feb 20 06:03 ./_deps/picotool-subbuild/CMakeFiles/picotool-populate.dir
-rw-r--r-- 1 user None    0 Feb 20 06:03 ./_deps/picotool-subbuild/CMakeFiles/picotool-populate-complete
drwxr-xr-x 1 user None    0 Feb 20 06:03 ./_deps/picotool-subbuild/picotool-populate-prefix
drwxr-xr-x 1 user None    0 Feb 20 06:03 ./_deps/picotool-subbuild/picotool-populate-prefix/src/picotool-populate-stamp
-rw-r--r-- 1 user None    0 Feb 20 06:03 ./_deps/picotool-subbuild/picotool-populate-prefix/src/picotool-populate-stamp/picotool-populate-build
-rw-r--r-- 1 user None    0 Feb 20 06:03 ./_deps/picotool-subbuild/picotool-populate-prefix/src/picotool-populate-stamp/picotool-populate-configure
-rw-r--r-- 1 user None    0 Feb 20 06:03 ./_deps/picotool-subbuild/picotool-populate-prefix/src/picotool-populate-stamp/picotool-populate-done
-rw-r--r-- 1 user None    0 Feb 20 06:03 ./_deps/picotool-subbuild/picotool-populate-prefix/src/picotool-populate-stamp/picotool-populate-download
-rw-r--r-- 1 user None   83 Feb 20 06:03 ./_deps/picotool-subbuild/picotool-populate-prefix/src/picotool-populate-stamp/picotool-populate-gitclone-lastrun.txt
-rw-r--r-- 1 user None   83 Feb 20 06:03 ./_deps/picotool-subbuild/picotool-populate-prefix/src/picotool-populate-stamp/picotool-populate-gitinfo.txt
-rw-r--r-- 1 user None    0 Feb 20 06:03 ./_deps/picotool-subbuild/picotool-populate-prefix/src/picotool-populate-stamp/picotool-populate-install
-rw-r--r-- 1 user None    0 Feb 20 06:03 ./_deps/picotool-subbuild/picotool-populate-prefix/src/picotool-populate-stamp/picotool-populate-mkdir
-rw-r--r-- 1 user None    0 Feb 20 06:03 ./_deps/picotool-subbuild/picotool-populate-prefix/src/picotool-populate-stamp/picotool-populate-patch
-rw-r--r-- 1 user None    0 Feb 20 06:03 ./_deps/picotool-subbuild/picotool-populate-prefix/src/picotool-populate-stamp/picotool-populate-test
-rw-r--r-- 1 user None    8 Feb 20 06:03 ./_deps/picotool-subbuild/picotool-populate-prefix/tmp/picotool-populate-cfgcmd.txt
-rw-r--r-- 1 user None   13 Feb 20 06:03 ./_deps/picotool-subbuild/picotool-populate-prefix/tmp/picotool-populate-cfgcmd.txt.in
-rw-r--r-- 1 user None 2876 Feb 20 06:03 ./_deps/picotool-subbuild/picotool-populate-prefix/tmp/picotool-populate-gitclone.cmake
-rw-r--r-- 1 user None 5805 Feb 20 06:03 ./_deps/picotool-subbuild/picotool-populate-prefix/tmp/picotool-populate-gitupdate.cmake
drwxr-xr-x 1 user None    0 Feb 20 06:03 ./CMakeFiles/picotoolBuild.dir
drwxr-xr-x 1 user None    0 Feb 20 06:03 ./CMakeFiles/picotoolForceReconfigure.dir
drwxr-xr-x 1 user None    0 Feb 20 06:03 ./picotool
drwxr-xr-x 1 user None    0 Feb 20 06:03 ./picotool/src/picotoolBuild-stamp
-rw-r--r-- 1 user None  379 Feb 20 06:03 ./picotool/tmp/picotoolBuild-cfgcmd.txt
-rw-r--r-- 1 user None   13 Feb 20 06:03 ./picotool/tmp/picotoolBuild-cfgcmd.txt.in

So, we got a bunch of files and directories with "picotool" in the name - however, no .exe files, and only picotoolConfig.cmake is present.

Let's run cmake again:

$ /c/Program\ Files/CMake/bin/cmake.exe ../ -DCMAKE_BUILD_TYPE=Debug -G "MSYS Makefiles"
PICO_SDK_PATH is C:/src/pico-sdk
Target board (PICO_BOARD) is 'pico'.
Using board configuration from C:/src/pico-sdk/src/boards/include/boards/pico.h
Pico Platform (PICO_PLATFORM) is 'rp2040'.
Build type is Debug
Using regular optimized debug build (set PICO_DEOPTIMIZED_DEBUG=1 to de-optimize)
TinyUSB available at C:/src/pico-sdk/lib/tinyusb/src/portable/raspberrypi/rp2040; enabling build support for USB.
Compiling TinyUSB with CFG_TUSB_DEBUG=1
BTstack available at C:/src/pico-sdk/lib/btstack
cyw43-driver available at C:/src/pico-sdk/lib/cyw43-driver
lwIP available at C:/src/pico-sdk/lib/lwip
mbedtls available at C:/src/pico-sdk/lib/mbedtls
Using PICO_EXAMPLES_PATH from environment ('C:/src/pico-examples')
CMake Warning at C:/src/pico-sdk/tools/Findpicotool.cmake:28 (message):
  No installed picotool with version 2.1.0 found - building from source

  It is recommended to build and install picotool separately, or to set
  PICOTOOL_FETCH_FROM_GIT_PATH to a common directory for all your SDK
  projects
Call Stack (most recent call first):
  C:/src/pico-sdk/tools/CMakeLists.txt:138 (find_package)
  C:/src/pico-sdk/tools/CMakeLists.txt:485 (pico_init_picotool)
  C:/src/pico-sdk/src/cmake/on_device.cmake:57 (picotool_postprocess_binary)
  CMakeLists.txt:21 (pico_add_extra_outputs)


Downloading Picotool
-- Configuring done
-- Generating done
-- Build files have been written to: C:/msys64/tmp/test/build

Oh, damn it - there it is, "Downloading Picotool" again! So picotool may have been downloaded, but it was never built!

Ok, so how do we build it? Turns out, in the Makefile that this cmake run produces, there is a target picotoolBuild - so, as I'm still in the ./build subfolder, let's try it:

$ make picotoolBuild
Scanning dependencies of target picotoolForceReconfigure
[  0%] Built target picotoolForceReconfigure
Scanning dependencies of target picotoolBuild
[ 11%] Creating directories for 'picotoolBuild'
[ 22%] No download step for 'picotoolBuild'
[ 33%] No patch step for 'picotoolBuild'
[ 44%] No update step for 'picotoolBuild'
[ 55%] Performing configure step for 'picotoolBuild'
Not searching for unused variables given on the command line.
-- The C compiler identification is GNU 14.2.0
-- The CXX compiler identification is GNU 14.2.0
-- Check for working C compiler: C:/msys64/mingw64/bin/gcc.exe
-- Check for working C compiler: C:/msys64/mingw64/bin/gcc.exe - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/msys64/mingw64/bin/g++.exe
-- Check for working CXX compiler: C:/msys64/mingw64/bin/g++.exe - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
./C:/msys64/tmp/test/build/_deps/picotool/
-- Using the single-header code from C:/msys64/tmp/test/build/_deps/picotool-src/lib/nlohmann_json/single_include/
-- Found Python3: C:/ProgramData/Anaconda3/python.exe (found version "3.7.3") found components: Interpreter
-- Performing Test C_COMPILER_SUPPORTS_WFORMAT_SIGNEDNESS
-- Performing Test C_COMPILER_SUPPORTS_WFORMAT_SIGNEDNESS - Success
PICOTOOL_NO_LIBUSB is set - no USB support will be built
-- Configuring done
-- Generating done
-- Build files have been written to: C:/msys64/tmp/test/build/_deps/picotool-build
[ 66%] Performing build step for 'picotoolBuild'
Scanning dependencies of target mbedcrypto
[ 67%] Built target mbedcrypto
Scanning dependencies of target errors
[ 69%] Built target errors
Scanning dependencies of target elf
[ 70%] Built target elf
Scanning dependencies of target mbedx509
[ 79%] Built target mbedx509
Scanning dependencies of target mbedtls
[ 89%] Built target mbedtls
Scanning dependencies of target bintool
[ 92%] Built target bintool
Scanning dependencies of target elf2uf2
[ 94%] Built target elf2uf2
Scanning dependencies of target picotool
[100%] Built target picotool
[ 77%] Performing install step for 'picotoolBuild'
[ 67%] Built target mbedcrypto
[ 69%] Built target errors
[ 70%] Built target elf
[ 79%] Built target mbedx509
[ 89%] Built target mbedtls
[ 92%] Built target bintool
[ 94%] Built target elf2uf2
[100%] Built target picotool
Install the project...
-- Install configuration: "Release"
[ 88%] Performing test step for 'picotoolBuild'
picotool v2.1.2-develop (Windows, GNU-14.2.0, Release)
[100%] Completed 'picotoolBuild'
[100%] Built target picotoolBuild

Ah - that's more like it; note also at end of make picotoolBuild, we got a message "Install the project".

Let's now check what sort of picotool* files we got in the ./build subfolder:

$ find . \( -name 'picotool*.exe' -o -name 'picotool*.cmake' \)
./_deps/picotool/picotool.exe
./_deps/picotool/picotoolConfig.cmake
./_deps/picotool/picotoolConfigVersion.cmake
./_deps/picotool/picotoolTargets-release.cmake
./_deps/picotool/picotoolTargets.cmake
./_deps/picotool-build/CMakeFiles/Export/picotool/picotoolTargets-release.cmake
./_deps/picotool-build/CMakeFiles/Export/picotool/picotoolTargets.cmake
./_deps/picotool-build/picotool.exe
./_deps/picotool-build/picotoolConfig.cmake
./_deps/picotool-build/picotoolConfigVersion.cmake
./_deps/picotool-src/cmake/picotoolConfig.cmake
./_deps/picotool-subbuild/picotool-populate-prefix/tmp/picotool-populate-gitclone.cmake
./_deps/picotool-subbuild/picotool-populate-prefix/tmp/picotool-populate-gitupdate.cmake

Ahh, finally: picotool.exe, picotoolConfig.cmake and picotoolTargets.cmake are all present.

And now, if we run CMake for a third time:

$ /c/Program\ Files/CMake/bin/cmake.exe ../ -DCMAKE_BUILD_TYPE=Debug -G "MSYS Makefiles"
PICO_SDK_PATH is C:/src/pico-sdk
Target board (PICO_BOARD) is 'pico'.
Using board configuration from C:/src/pico-sdk/src/boards/include/boards/pico.h
Pico Platform (PICO_PLATFORM) is 'rp2040'.
Build type is Debug
Using regular optimized debug build (set PICO_DEOPTIMIZED_DEBUG=1 to de-optimize)
TinyUSB available at C:/src/pico-sdk/lib/tinyusb/src/portable/raspberrypi/rp2040; enabling build support for USB.
Compiling TinyUSB with CFG_TUSB_DEBUG=1
BTstack available at C:/src/pico-sdk/lib/btstack
cyw43-driver available at C:/src/pico-sdk/lib/cyw43-driver
lwIP available at C:/src/pico-sdk/lib/lwip
mbedtls available at C:/src/pico-sdk/lib/mbedtls
Using PICO_EXAMPLES_PATH from environment ('C:/src/pico-examples')
-- Configuring done
-- Generating done
-- Build files have been written to: C:/msys64/tmp/test/build

... finally, there is no "Downloading Picotool" step anymore!


So, in order to get the build process to use the picotool obtained by the "Downloading Picotool" CMake step, I had to build picotool myself, by manually issuing the make picotoolBuild command.

Now, I would prefer NOT having to do this manual build of picotool - instead, I'd prefer setting up something in my project's CMakeLists.txt, so that if cmake is ran from an empty ./build subfolder (or generally, a build state which triggers the "Downloading Picotool" step), then picotool should be automatically built right after the "Downloading Picotool" step - so I never see (and wait for) this step again if I have to run cmake again afterwards.

I'm aware that "Downloading Picotool" comes from Findpicotool.cmake, which is triggered by the CMake function pico_init_picotool() in pico-sdk/tools/CMakeLists.txt.

So, I thought that I could somehow force a call to make picotoolBuild from my own project's CMakeLists.txt at start (so all the other points in my CMakeLists.txt that would otherwise trigger "Downloading Picotool" would see the built picotool, and avoid running the download unnecessarily) - provided I call pico_init_picotool() beforehand. However, https://stackoverflow.com/questions/79452002/force-cmake-to-generate-build-files-makefile-at-arbitrary-point-in-cmakelists implies that such an approach would not really be possible.

So, what other options do I have, to setup the CMake configuration -- so that picotool gets automatically built, right after the very first time "Downloading Picotool" is triggered?

@will-v-pi
Copy link
Contributor

I think you’re misunderstanding how CMake works - the cmake command itself does not do any building, it’s only the subsequent make command that actually does the build. The cmake command just configures all the directories and files so that the build tool (make/ninja/etc) can then build them. This is just how CMake works.

You do not need to manually build picotool using the picotoolBuild target - it will be automatically built as a dependency when you build your SDK project (ie when you run make). You will continue to get the “Downloading Picotool” message until you do this, but it will go away the first time you run make. This is the documented method of building the SDK, so I don’t think there is a documentation issue there.

Alternatively, if you just want to run cmake a lot without running make, you can just pass -DPICO_NO_PICOTOOL=1 until your final cmake command where you can pass -DPICO_NO_PICOTOOL=0. This is not recommended, but should work fine if you’re insisting on not running make until the end.

The best solution would be to follow the advice in the warning and build & install picotool separately systemwide - that way you’ll never be annoyed by “Downloading Picotool” again.

@sdbbs
Copy link
Author

sdbbs commented Feb 20, 2025

Thanks, @will-v-pi :

I think you’re misunderstanding how CMake works - the cmake command itself does not do any building, it’s only the subsequent make command that actually does the build. The cmake command just configures all the directories and files so that the build tool (make/ninja/etc) can then build them. This is just how CMake works.

I think my misunderstanding comes from not applying the configuration nature of CMake to build dependencies (and I consider picotool in this case to be a build dependency); otherwise I was of course aware that CMake only does configuration on the level of a project - and then I'd have to call the build tool, here make, to actually build the project.

I guess being in a situation of calling CMake multiple times in a row (without calling make in between), and seeing "Downloading Picotool" multiple times per CMake call (due to my own modifications of CMakeLists.txt), made me lose perspective that the configuration nature of CMake applies to not just project dependencies, but also to build dependencies such as related tools.

You do not need to manually build picotool using the picotoolBuild target - it will be automatically built as a dependency when you build your SDK project (ie when you run make).

Yeah - for some reason I lost this from sight, in spite of this not being the first time I compile a pico-sdk project with CMake.

You will continue to get the “Downloading Picotool” message until you do this, but it will go away the first time you run make. This is the documented method of building the SDK, so I don’t think there is a documentation issue there.

Ok, I have to agree with this; I guess I only noticed this to begin with because of being put in a situation to run CMake multiple times in a row (to fix bugs in my modifications of CMakeLists.txt), without running make in between.

Alternatively, if you just want to run cmake a lot without running make, you can just pass -DPICO_NO_PICOTOOL=1 until your final cmake command where you can pass -DPICO_NO_PICOTOOL=0. This is not recommended, but should work fine if you’re insisting on not running make until the end.

Nice - this seems like a decent workaround, if you need to run CMake multiple times (for instance to fix bugs or inspect variable values in a CMakeLists.txt) without running make

The best solution would be to follow the advice in the warning and build & install picotool separately systemwide - that way you’ll never be annoyed by “Downloading Picotool” again.

I guess I thought that having separate versions of picotool for each project appealed to me, because projects would appear more isolated from each other, and plus I try to "install" source projects as rarely as possible (I either use package manager, or if building some tool from source, I try to call it with absolute path with the possible LD_LIBRARY_PATH and such - not sure where I picked up that habit)

Anyways, thanks for helping me put things in perspective - I guess now I realize I don't really have much to ask for in this case, so I'll be closing this.

@sdbbs sdbbs closed this as completed Feb 20, 2025
@sdbbs
Copy link
Author

sdbbs commented Feb 20, 2025

I also arrived at a CMakeLists.txt setup to "prebuild" picotool at start of the CMakeLists.txt, so that later code in CMakeLists.txt considers picotool to be found, and it does not initiate "Downloading Picotool".

This is done by creating a "dummy" directory with CMakeLists.txt project in ./build, before any CMakeCache.txt is generated by the real project; building that via execute_process (so cmake inside that process is effectively a child of / separate from the "real" one), and finally cleaning up the CMakeCache.txt so it does not interfere with the configuration initiated by the remainder of the "real"/"master" CMakeLists.txt. As a consequence of this:

  • The final Makefile will not have a picotoolBuild target anymore
  • The cmake picotool prebuild works only if you start from an empty ./build subfolder; otherwise, if you run cmake again, the prebuild code will fail with 'CMake Error: The source "...CMakeLists.txt" does not match the source "(other)...CMakeLists.txt" used to generate cache.' (but that's OK for me, at least that does not interfere with the rest of the "real" CMakeLists.txt functionality).

Otherwise, I think it works, because in the end, a .uf2 file does get generated.

Here is modified CMakeLists.txt (relative to the project given in OP):

cmake_minimum_required(VERSION 3.13)

message("\n### prebuild picotool vvvvvvvvvv\n")
# https://crascit.com/2022/01/25/quoting-in-cmake/
file(WRITE ${CMAKE_BINARY_DIR}/pbptest/CMakeLists.txt [=[
cmake_minimum_required(VERSION 3.13...3.27)
include($ENV{PICO_SDK_PATH}/pico_sdk_init.cmake)
project(pbptest)
pico_sdk_init()
pico_init_picotool()
]=])
file(TOUCH ${CMAKE_BINARY_DIR}/pbptest/main.c)
message("Created ${CMAKE_BINARY_DIR}/pbptest/{CMakeLists.txt,main.c}")
message("Running `cmake -S pbptest -B . -G '${CMAKE_GENERATOR}'` in ${CMAKE_BINARY_DIR}")
execute_process(
  COMMAND ${CMAKE_COMMAND} -S pbptest -B . -G ${CMAKE_GENERATOR}
  WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
message("Running `make picotoolBuild` in ${CMAKE_BINARY_DIR}")
execute_process(
  COMMAND ${CMAKE_COMMAND} --build . --target picotoolBuild
  WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
execute_process(
  COMMAND find . -name picotool*
  WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
message("Running `rm CMakeCache.txt` in ${CMAKE_BINARY_DIR} (for rest of original CMakeLists.txt)")
file(REMOVE "${CMAKE_BINARY_DIR}/CMakeCache.txt")
message("Running `rm -rf pbptest` in ${CMAKE_BINARY_DIR} (cleanup)")
file(REMOVE_RECURSE "${CMAKE_BINARY_DIR}/pbptest")
message("\n### end prebuild picotool ^^^^^^\n")


# initialize the SDK directly
include($ENV{PICO_SDK_PATH}/pico_sdk_init.cmake)

project(my_project)

# initialize the Raspberry Pi Pico SDK
pico_sdk_init()

# rest of your project

add_executable(hello_world
    main.c
)

# Add pico_stdlib library which aggregates commonly used features
target_link_libraries(hello_world pico_stdlib)

# create map/bin/hex/uf2 file in addition to ELF.
pico_add_extra_outputs(hello_world)

And here is the output:

cmake and make log (click to expand)
$ /c/Program\ Files/CMake/bin/cmake.exe ../ -DCMAKE_BUILD_TYPE=Debug -G "MSYS Makefiles"

### prebuild picotool vvvvvvvvvv

Created C:/msys64/tmp/test/build/pbptest/{CMakeLists.txt,main.c}
Running `cmake -S pbptest -B . -G 'MSYS Makefiles'` in C:/msys64/tmp/test/build
PICO_SDK_PATH is C:/src/pico-sdk
Defaulting platform (PICO_PLATFORM) to 'rp2040' since not specified.
Defaulting target board (PICO_BOARD) to 'pico' since not specified.
Using board configuration from C:/src/pico-sdk/src/boards/include/boards/pico.h
Pico Platform (PICO_PLATFORM) is 'rp2040'.
-- Defaulting build type to 'Release' since not specified.
Defaulting compiler (PICO_COMPILER) to 'pico_arm_cortex_m0plus_gcc' since not specified.
Configuring toolchain based on PICO_COMPILER 'pico_arm_cortex_m0plus_gcc'
Defaulting PICO_GCC_TRIPLE to 'arm-none-eabi'
-- The C compiler identification is GNU 13.3.0
-- The CXX compiler identification is GNU 13.3.0
-- Check for working C compiler: C:/msys64/mingw64/bin/arm-none-eabi-gcc.exe
-- Check for working C compiler: C:/msys64/mingw64/bin/arm-none-eabi-gcc.exe - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/msys64/mingw64/bin/arm-none-eabi-g++.exe
-- Check for working CXX compiler: C:/msys64/mingw64/bin/arm-none-eabi-g++.exe - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The ASM compiler identification is GNU
-- Found assembler: C:/msys64/mingw64/bin/arm-none-eabi-gcc.exe
Build type is Release
-- Found Python3: C:/Program Files (x86)/Microsoft Visual Studio/Shared/Python36_64/python.exe (found version "3.6.6") found components: Interpreter
TinyUSB available at C:/src/pico-sdk/lib/tinyusb/src/portable/raspberrypi/rp2040; enabling build support for USB.
BTstack available at C:/src/pico-sdk/lib/btstack
cyw43-driver available at C:/src/pico-sdk/lib/cyw43-driver
lwIP available at C:/src/pico-sdk/lib/lwip
mbedtls available at C:/src/pico-sdk/lib/mbedtls
Using PICO_EXAMPLES_PATH from environment ('C:/src/pico-examples')
CMake Warning at C:/src/pico-sdk/tools/Findpicotool.cmake:28 (message):
  No installed picotool with version 2.1.0 found - building from source

  It is recommended to build and install picotool separately, or to set
  PICOTOOL_FETCH_FROM_GIT_PATH to a common directory for all your SDK
  projects
Call Stack (most recent call first):
  C:/src/pico-sdk/tools/CMakeLists.txt:138 (find_package)
  CMakeLists.txt:5 (pico_init_picotool)


Downloading Picotool
-- Configuring done
-- Generating done
-- Build files have been written to: C:/msys64/tmp/test/build
Running `make picotoolBuild` in C:/msys64/tmp/test/build
Scanning dependencies of target picotoolForceReconfigure
[  0%] Built target picotoolForceReconfigure
Scanning dependencies of target picotoolBuild
[ 11%] Creating directories for 'picotoolBuild'
[ 22%] No download step for 'picotoolBuild'
[ 33%] No patch step for 'picotoolBuild'
[ 44%] No update step for 'picotoolBuild'
[ 55%] Performing configure step for 'picotoolBuild'
Not searching for unused variables given on the command line.
-- The C compiler identification is GNU 14.2.0
-- The CXX compiler identification is GNU 14.2.0
-- Check for working C compiler: C:/msys64/mingw64/bin/gcc.exe
-- Check for working C compiler: C:/msys64/mingw64/bin/gcc.exe - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/msys64/mingw64/bin/g++.exe
-- Check for working CXX compiler: C:/msys64/mingw64/bin/g++.exe - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
./C:/msys64/tmp/test/build/_deps/picotool/
-- Using the single-header code from C:/msys64/tmp/test/build/_deps/picotool-src/lib/nlohmann_json/single_include/
-- Found Python3: C:/ProgramData/Anaconda3/python.exe (found version "3.7.3") found components: Interpreter
-- Performing Test C_COMPILER_SUPPORTS_WFORMAT_SIGNEDNESS
-- Performing Test C_COMPILER_SUPPORTS_WFORMAT_SIGNEDNESS - Success
PICOTOOL_NO_LIBUSB is set - no USB support will be built
-- Configuring done
-- Generating done
-- Build files have been written to: C:/msys64/tmp/test/build/_deps/picotool-build
[ 66%] Performing build step for 'picotoolBuild'
Scanning dependencies of target mbedcrypto
[ 67%] Built target mbedcrypto
Scanning dependencies of target mbedx509
[ 76%] Built target mbedx509
Scanning dependencies of target mbedtls
[ 86%] Built target mbedtls
Scanning dependencies of target errors
[ 88%] Built target errors
Scanning dependencies of target elf
[ 89%] Built target elf
Scanning dependencies of target bintool
[ 92%] Built target bintool
Scanning dependencies of target elf2uf2
[ 94%] Built target elf2uf2
Scanning dependencies of target picotool
[100%] Built target picotool
[ 77%] Performing install step for 'picotoolBuild'
[ 67%] Built target mbedcrypto
[ 76%] Built target mbedx509
[ 86%] Built target mbedtls
[ 88%] Built target errors
[ 89%] Built target elf
[ 92%] Built target bintool
[ 94%] Built target elf2uf2
[100%] Built target picotool
Install the project...
-- Install configuration: "Release"
[ 88%] Performing test step for 'picotoolBuild'
picotool v2.1.2-develop (Windows, GNU-14.2.0, Release)
[100%] Completed 'picotoolBuild'
[100%] Built target picotoolBuild
FINC: Parameter format not correct
Running `rm CMakeCache.txt` in C:/msys64/tmp/test/build (for rest of original CMakeLists.txt)
Running `rm -rf pbptest` in C:/msys64/tmp/test/build (cleanup)

### end prebuild picotool ^^^^^^

PICO_SDK_PATH is C:/src/pico-sdk
Defaulting platform (PICO_PLATFORM) to 'rp2040' since not specified.
Defaulting target board (PICO_BOARD) to 'pico' since not specified.
Using board configuration from C:/src/pico-sdk/src/boards/include/boards/pico.h
Pico Platform (PICO_PLATFORM) is 'rp2040'.
Defaulting compiler (PICO_COMPILER) to 'pico_arm_cortex_m0plus_gcc' since not specified.
Configuring toolchain based on PICO_COMPILER 'pico_arm_cortex_m0plus_gcc'
Defaulting PICO_GCC_TRIPLE to 'arm-none-eabi'
-- The C compiler identification is GNU 13.3.0
-- The CXX compiler identification is GNU 13.3.0
-- Check for working C compiler: C:/msys64/mingw64/bin/arm-none-eabi-gcc.exe
-- Check for working C compiler: C:/msys64/mingw64/bin/arm-none-eabi-gcc.exe - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/msys64/mingw64/bin/arm-none-eabi-g++.exe
-- Check for working CXX compiler: C:/msys64/mingw64/bin/arm-none-eabi-g++.exe - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The ASM compiler identification is GNU
-- Found assembler: C:/msys64/mingw64/bin/arm-none-eabi-gcc.exe
Build type is Debug
Using regular optimized debug build (set PICO_DEOPTIMIZED_DEBUG=1 to de-optimize)
-- Found Python3: C:/Program Files (x86)/Microsoft Visual Studio/Shared/Python36_64/python.exe (found version "3.6.6") found components: Interpreter
TinyUSB available at C:/src/pico-sdk/lib/tinyusb/src/portable/raspberrypi/rp2040; enabling build support for USB.
Compiling TinyUSB with CFG_TUSB_DEBUG=1
BTstack available at C:/src/pico-sdk/lib/btstack
cyw43-driver available at C:/src/pico-sdk/lib/cyw43-driver
lwIP available at C:/src/pico-sdk/lib/lwip
mbedtls available at C:/src/pico-sdk/lib/mbedtls
Using PICO_EXAMPLES_PATH from environment ('C:/src/pico-examples')
-- Configuring done
-- Generating done
-- Build files have been written to: C:/msys64/tmp/test/build

$ make #[TAB here]
make.exe          makeconv.exe      MakeLangId.exe    makensisw.exe     makepkg-mingw
make_f2fs.exe     makeindex.exe     makemhr.exe       makepatch         makepkg-template
makecab.exe       makeinfo          makensis.exe      makepkg

$ make
Scanning dependencies of target bs2_default
[  1%] Building ASM object pico-sdk/src/rp2040/boot_stage2/CMakeFiles/bs2_default.dir/compile_time_choice.S.obj
[  3%] Linking ASM executable bs2_default.elf
[  3%] Built target bs2_default
[  4%] Generating bs2_default.bin
[  6%] Generating bs2_default_padded_checksummed.S
Scanning dependencies of target bs2_default_library
[  7%] Building ASM object pico-sdk/src/rp2040/boot_stage2/CMakeFiles/bs2_default_library.dir/bs2_default_padded_checksummed.S.obj
[  7%] Built target bs2_default_library
Scanning dependencies of target hello_world
[  9%] Building C object CMakeFiles/hello_world.dir/main.c.obj
[ 11%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/pico_stdlib/stdlib.c.obj
[ 12%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/hardware_gpio/gpio.c.obj
[ 14%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2040/pico_platform/platform.c.obj
[ 15%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/pico_platform_panic/panic.c.obj
[ 17%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/common/hardware_claim/claim.c.obj
[ 19%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/hardware_sync/sync.c.obj
[ 20%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/hardware_sync_spin_lock/sync_spin_lock.c.obj
[ 22%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/hardware_irq/irq.c.obj
[ 23%] Building ASM object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/hardware_irq/irq_handler_chain.S.obj
[ 25%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/common/pico_sync/sem.c.obj
[ 26%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/common/pico_sync/lock_core.c.obj
[ 28%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/common/pico_sync/mutex.c.obj
[ 30%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/common/pico_sync/critical_section.c.obj
[ 31%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/common/pico_time/time.c.obj
[ 33%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/common/pico_time/timeout_helper.c.obj
[ 34%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/hardware_timer/timer.c.obj
[ 36%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/common/pico_util/datetime.c.obj
[ 38%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/common/pico_util/pheap.c.obj
[ 39%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/common/pico_util/queue.c.obj
[ 41%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/hardware_uart/uart.c.obj
[ 42%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/hardware_clocks/clocks.c.obj
[ 44%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/hardware_pll/pll.c.obj
[ 46%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/hardware_vreg/vreg.c.obj
[ 47%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/hardware_watchdog/watchdog.c.obj
[ 49%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/hardware_ticks/ticks.c.obj
[ 50%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/pico_bootrom/bootrom.c.obj
[ 52%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/pico_bootrom/bootrom_lock.c.obj
[ 53%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/hardware_boot_lock/boot_lock.c.obj
[ 55%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/pico_flash/flash.c.obj
[ 57%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/hardware_xosc/xosc.c.obj
[ 58%] Building ASM object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/hardware_divider/divider.S.obj
[ 60%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/pico_runtime/runtime.c.obj
[ 61%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/pico_runtime_init/runtime_init.c.obj
[ 63%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/pico_runtime_init/runtime_init_clocks.c.obj
[ 65%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/pico_runtime_init/runtime_init_stack_guard.c.obj
[ 66%] Building ASM object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/pico_bit_ops/bit_ops_aeabi.S.obj
[ 68%] Building ASM object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/pico_divider/divider_hardware.S.obj
[ 69%] Building ASM object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/pico_double/double_aeabi_rp2040.S.obj
[ 71%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/pico_double/double_init_rom_rp2040.c.obj
[ 73%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/pico_double/double_math.c.obj
[ 74%] Building ASM object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/pico_double/double_v1_rom_shim_rp2040.S.obj
[ 76%] Building ASM object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/pico_int64_ops/pico_int64_ops_aeabi.S.obj
[ 77%] Building ASM object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/pico_float/float_aeabi_rp2040.S.obj
[ 79%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/pico_float/float_init_rom_rp2040.c.obj
[ 80%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/pico_float/float_math.c.obj
[ 82%] Building ASM object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/pico_float/float_v1_rom_shim_rp2040.S.obj
[ 84%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/pico_malloc/malloc.c.obj
[ 85%] Building ASM object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/pico_mem_ops/mem_ops_aeabi.S.obj
[ 87%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/pico_atomic/atomic.c.obj
[ 88%] Building CXX object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/pico_cxx_options/new_delete.cpp.obj
[ 90%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/pico_standard_binary_info/standard_binary_info.c.obj
[ 92%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/pico_printf/printf.c.obj
[ 93%] Building ASM object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/pico_crt0/crt0.S.obj
[ 95%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/pico_clib_interface/newlib_interface.c.obj
[ 96%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/pico_stdio/stdio.c.obj
[ 98%] Building C object CMakeFiles/hello_world.dir/C_/src/pico-sdk/src/rp2_common/pico_stdio_uart/stdio_uart.c.obj
[100%] Linking CXX executable hello_world.elf
[100%] Built target hello_world

# cmake again ( second time )

$ /c/Program\ Files/CMake/bin/cmake.exe ../ -DCMAKE_BUILD_TYPE=Debug -G "MSYS Makefiles"

### prebuild picotool vvvvvvvvvv

Created C:/msys64/tmp/test/build/pbptest/{CMakeLists.txt,main.c}
Running `cmake -S pbptest -B . -G 'MSYS Makefiles'` in C:/msys64/tmp/test/build
CMake Error: The source "C:/msys64/tmp/test/build/pbptest/CMakeLists.txt" does not match the source "C:/msys64/tmp/test/CMakeLists.txt" used to generate cache.  Re-run cmake with a different source directory.
Running `make picotoolBuild` in C:/msys64/tmp/test/build
make: *** No rule to make target 'picotoolBuild'.  Stop.
FINC: Parameter format not correct
Running `rm CMakeCache.txt` in C:/msys64/tmp/test/build (for rest of original CMakeLists.txt)
Running `rm -rf pbptest` in C:/msys64/tmp/test/build (cleanup)

### end prebuild picotool ^^^^^^

PICO_SDK_PATH is C:/src/pico-sdk
Target board (PICO_BOARD) is 'pico'.
Using board configuration from C:/src/pico-sdk/src/boards/include/boards/pico.h
Pico Platform (PICO_PLATFORM) is 'rp2040'.
Build type is Debug
Using regular optimized debug build (set PICO_DEOPTIMIZED_DEBUG=1 to de-optimize)
TinyUSB available at C:/src/pico-sdk/lib/tinyusb/src/portable/raspberrypi/rp2040; enabling build support for USB.
Compiling TinyUSB with CFG_TUSB_DEBUG=1
BTstack available at C:/src/pico-sdk/lib/btstack
cyw43-driver available at C:/src/pico-sdk/lib/cyw43-driver
lwIP available at C:/src/pico-sdk/lib/lwip
mbedtls available at C:/src/pico-sdk/lib/mbedtls
Using PICO_EXAMPLES_PATH from environment ('C:/src/pico-examples')
-- Configuring done
-- Generating done
-- Build files have been written to: C:/msys64/tmp/test/build


$ ls
_deps/       picotool/            CMakeCache.txt              hello_world.dis      hello_world.uf2
CMakeFiles/  pioasm/              CMakeDoxyfile.in            hello_world.elf      Makefile
generated/   pioasm-install/      CMakeDoxygenDefaults.cmake  hello_world.elf.map  pico_flash_region.ld
pico-sdk/    cmake_install.cmake  hello_world.bin             hello_world.hex

@lurch
Copy link
Contributor

lurch commented Feb 20, 2025

I guess I thought that having separate versions of picotool for each project appealed to me, because projects would appear more isolated from each other, and plus I try to "install" source projects as rarely as possible (I either use package manager, or if building some tool from source, I try to call it with absolute path with the possible LD_LIBRARY_PATH and such - not sure where I picked up that habit)

If you want to be able to use a "local" version of picotool without installing it globally, you also might be interested in using the picotool_DIR option. https://github.com/raspberrypi/pico-sdk/blob/develop/tools/CMakeLists.txt#L122
See raspberrypi/pico-examples#531 for an example 🙂

@sdbbs
Copy link
Author

sdbbs commented Feb 20, 2025

Thanks @lurch :

you also might be interested in using the picotool_DIR option

I had already seen picotool_DIR, but it kept confusing me, because I saw https://github.com/raspberrypi/pico-sdk/blob/2.1.0/tools/CMakeLists.txt#L120 :

set(picotool_DIR ${picotool_INSTALL_DIR}/picotool)

... and I couldn't parse - is that /picotool appended the executable file, or the directory?

Finally got that resolved after perceiving https://github.com/raspberrypi/pico-sdk/blob/2.1.0/tools/Findpicotool.cmake#L78

set(picotool_EXECUTABLE ${picotool_INSTALL_DIR}/picotool/picotool)

so, indeed, picotool_DIR is expected to have a "leaf" directory also called picotool (and that /picotool at end of picotool_DIR is intended to represent that "leaf" directory, not the executable)

@lurch
Copy link
Contributor

lurch commented Feb 20, 2025

https://github.com/raspberrypi/picotool?tab=readme-ov-file#usage-by-the-raspberry-pi-pico-sdk 😉
(I forgot to provide this link in my previous comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants