Skip to content

Commit

Permalink
tools/rp2040: Building picotool if necessary
Browse files Browse the repository at this point in the history
Improved
  1. The pre-installed "picotool" should not depend on `PICO_SDK_PATH`

  2. Perhaps we should compile "picotool" from `PICO_SDK_PATH` if it was not found in $PATH

Tests
  1. The "picotool" is pre-installed or built from `PICO_SDK_PATH`

     LD: nuttx
     Generating: nuttx.uf2
     Done.

  2. `PICO_SDK_PATH` is specified but "picotool" is not installed

     LD: nuttx
     Building: picotool
     Generating: nuttx.uf2
     Done.

  3. Neither "picotool" nor `PICO_SDK_PATH` are installed/specified

     LD: nuttx
     PICO_SDK_PATH/picotool must be specified/installed for flash boot

Signed-off-by: wangjianyu3 <[email protected]>
  • Loading branch information
JianyuWang0623 authored and xiaoxiang781216 committed Nov 11, 2024
1 parent 482be69 commit f41b0d0
Showing 1 changed file with 27 additions and 11 deletions.
38 changes: 27 additions & 11 deletions tools/rp2040/Config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,33 @@

# POSTBUILD -- Perform post build operations

ifeq ($(CONFIG_RP2040_UF2_BINARY),y)
ifdef PICO_SDK_PATH
define POSTBUILD
$(Q)echo "Generating: nuttx.uf2"; \
PICOTOOL_BIN_PATH?=$(PICO_SDK_PATH)$(DELIM)_deps$(DELIM)picotool$(DELIM)picotool

picotool$(HOSTEXEEXT) uf2 convert --quiet -t elf nuttx nuttx.uf2;
$(Q)([ $$? -eq 0 ] && echo nuttx.uf2 >> nuttx.manifest && echo "Done.")
endef
else
define POSTBUILD
$(Q) echo "PICO_SDK_PATH must be specified for flash boot"
define GEN_PICO_UF2
$(Q)echo "Generating: nuttx.uf2"; \

$(Q)$1 uf2 convert --quiet -t elf nuttx nuttx.uf2;
$(Q)([ $$? -eq 0 ] && echo nuttx.uf2 >> nuttx.manifest && echo "Done.")
endef
endif

ifeq ($(CONFIG_RP2040_UF2_BINARY),y)
ifneq ($(shell which picotool),)
define POSTBUILD
$(call GEN_PICO_UF2, picotool)
endef
else ifdef PICO_SDK_PATH
define POSTBUILD
$(Q)(if ! $(PICOTOOL_BIN_PATH) help >&/dev/null; then \
echo "Building: picotool"; \
cd $(PICO_SDK_PATH); \
cmake . >&/dev/null; \
make picotoolBuild >&/dev/null; \
fi;)
$(call GEN_PICO_UF2, $(PICOTOOL_BIN_PATH))
endef
else
define POSTBUILD
$(Q) echo "PICO_SDK_PATH/picotool must be specified/installed for flash boot"
endef
endif
endif

0 comments on commit f41b0d0

Please sign in to comment.