rp2040: support pico-sdk 2.0.0

Since the introduction of the rp2350, the pico-sdk project has been
re-arranged and elf2uf2 has been merged in to a new 'picotool' binary
which is supplied and installed separately.
This commit is contained in:
George White 2024-09-08 09:51:43 +01:00 committed by Xiang Xiao
parent 5f0230d79f
commit 3f00c4aae0
3 changed files with 11 additions and 44 deletions

View File

@ -24,7 +24,7 @@ BOOT_STAGE2 = rp2040_boot_stage2
CONFIG_RP2040_FLASH_CHIP := $(patsubst "%",%,$(strip $(CONFIG_RP2040_FLASH_CHIP)))
BOOT2DIR = $(PICO_SDK_PATH)/src/rp2_common/boot_stage2
BOOT2DIR = $(PICO_SDK_PATH)/src/rp2040/boot_stage2
BOOT2SRC = $(BOOT2DIR)/boot2_$(CONFIG_RP2040_FLASH_CHIP).S
BOOT2CFLAGS += -DPICO_BOARD=\"pico\"
@ -35,9 +35,12 @@ BOOT2CFLAGS += -Ichip/boot2
BOOT2CFLAGS += -I$(BOOT2DIR)/asminclude
BOOT2CFLAGS += -I$(PICO_SDK_PATH)/src/rp2040/hardware_regs/include
BOOT2CFLAGS += -I$(PICO_SDK_PATH)/src/rp2_common/hardware_base/include
BOOT2CFLAGS += -I$(PICO_SDK_PATH)/src/common/pico_base/include
BOOT2CFLAGS += -I$(PICO_SDK_PATH)/src/common/pico_base_headers/include
BOOT2CFLAGS += -I$(PICO_SDK_PATH)/src/boards/include
BOOT2CFLAGS += -I$(PICO_SDK_PATH)/src/rp2_common/pico_platform/include
BOOT2CFLAGS += -I$(PICO_SDK_PATH)/src/rp2040/pico_platform/include
BOOT2CFLAGS += -I$(PICO_SDK_PATH)/src/rp2_common/pico_platform_compiler/include
BOOT2CFLAGS += -I$(PICO_SDK_PATH)/src/rp2_common/pico_platform_sections/include
BOOT2CFLAGS += -I$(PICO_SDK_PATH)/src/rp2_common/pico_platform_panic/include
$(BOOT_STAGE2).S: %.S: %.bin
python3 $(BOOT2DIR)/pad_checksum -s 0xffffffff $< $@
@ -46,10 +49,10 @@ $(BOOT_STAGE2).bin: %.bin: %.elf
$(OBJCOPY) -Obinary $< $@
$(BOOT_STAGE2).elf: $(BOOT2SRC)
$(Q) touch $(PICO_SDK_PATH)/src/common/pico_base/include/pico/version.h
$(Q) touch $(PICO_SDK_PATH)/src/common/pico_base/include/pico/config_autogen.h
$(Q) touch $(PICO_SDK_PATH)/src/common/pico_base_headers/include/pico/version.h
$(Q) touch $(PICO_SDK_PATH)/src/common/pico_base_headers/include/pico/config_autogen.h
$(CC) -nostdlib -T$(ARCHSCRIPT) $(BOOT2CFLAGS) -o $@ $<
$(DELFILE) $(PICO_SDK_PATH)/src/common/pico_base/include/pico/version.h
$(DELFILE) $(PICO_SDK_PATH)/src/common/pico_base/include/pico/config_autogen.h
$(DELFILE) $(PICO_SDK_PATH)/src/common/pico_base_headers/include/pico/version.h
$(DELFILE) $(PICO_SDK_PATH)/src/common/pico_base_headers/include/pico/config_autogen.h
EXTRADELFILE = $(BOOT_STAGE2).*

View File

@ -29,8 +29,7 @@ ifdef PICO_SDK_PATH
define POSTBUILD
$(Q)echo "Generating: nuttx.uf2"; \
+$(Q) $(MAKE) -C $(TOPDIR)$(DELIM)tools$(DELIM)rp2040 -f Makefile.host
tools$(DELIM)rp2040$(DELIM)elf2uf2$(HOSTEXEEXT) nuttx nuttx.uf2;
picotool$(HOSTEXEEXT) uf2 convert --quiet -t elf nuttx nuttx.uf2;
$(Q)([ $$? -eq 0 ] && echo nuttx.uf2 >> nuttx.manifest && echo "Done.")
endef
else

View File

@ -1,35 +0,0 @@
############################################################################
# tools/rp2040/Makefile.host
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
all: elf2uf2
default: elf2uf2
.PHONY: clean
# Add CFLAGS=-g on the make command line to build debug versions
CFLAGS = -O2 -std=c++14
CFLAGS += -I$(PICO_SDK_PATH)/src/common/boot_uf2/include
elf2uf2: $(PICO_SDK_PATH)/tools/elf2uf2/main.cpp
@g++ $(CFLAGS) -o $@ $<
clean:
@rm -f *.o *.a *.dSYM *~ .*.swp
@rm -f elf2uf2 elf2uf2.exe