Skip to content

Commit

Permalink
Update picotool and implement missing make targets
Browse files Browse the repository at this point in the history
  • Loading branch information
mikee47 committed Nov 29, 2024
1 parent 02edcfd commit d7c0c52
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 31 deletions.
45 changes: 42 additions & 3 deletions Sming/Arch/Rp2040/Components/picotool/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,49 @@ $(COMPONENT_RULE)$(PICOTOOL):
$(Q) mkdir -p $(@D)
$(Q) cd $(@D) && $(CMAKE) $(PICOTOOL_CMAKE_OPTIONS) $(PICOTOOL_SRC) && $(MAKE)

##@Flashing

.PHONY: picotool
picotool: ##Pass options to picotool, e.g. `make picotool -- help`
$(Q) $(PICOTOOL) $(CMD)

comma := ,
XIP_BASE := 0x10000000

define CalcHex
$$(printf "0x%x" $$(( $1 )))
endef

define RangeStart
$(call CalcHex,$(XIP_BASE) + $(firstword $(subst $(comma), ,$1)))
endef

define RangeEnd
$(call CalcHex,$(XIP_BASE) + $(firstword $(subst $(comma), ,$1)) + $(word 2,$(subst $(comma), ,$1)))
endef

# Read flash memory into file
# $1 -> `Offset,Size` chunk
# $2 -> Output filename
define ReadFlash
$(info ReadFlash $1,$2)
$(Q) $(PICOTOOL) save -r $(call RangeStart,$1) $(call RangeEnd,$1) $2 -t bin
endef

# Read flash manufacturer ID and determine actual size
define ReadFlashID
$(info ReadFlashID)
$(Q) $(PICOTOOL) info -a $(TARGET_BIN)
# $(PICOTOOL) help info
endef
$(Q) $(PICOTOOL) info -a
endef

# Erase a region of Flash
# $1 -> Offset,Size
define EraseFlashRegion
$(info EraseFlashRegion $1)
$(Q) $(PICOTOOL) erase -r $(call RangeStart,$1) $(call RangeEnd,$1)
endef

# Erase flash memory contents
define EraseFlash
$(Q) $(PICOTOOL) erase -a
endef
2 changes: 1 addition & 1 deletion Sming/Arch/Rp2040/Components/picotool/picotool
Submodule picotool updated 98 files
+1 −0 .bazelignore
+1 −0 .bazelrc
+36 −0 .github/workflows/bazel_build.yml
+7 −0 .github/workflows/choco_packages.config
+73 −0 .github/workflows/test.yml
+5 −1 .gitignore
+123 −0 BUILD.bazel
+316 −23 CMakeLists.txt
+26 −0 MODULE.bazel
+968 −59 README.md
+0 −0 WORKSPACE
+21 −0 bazel/BUILD.bazel
+49 −0 bazel/README.md
+71 −0 bazel/binh.py
+5 −0 bazel/data_locs.cpp
+40 −0 bazel/defs.bzl
+60 −0 bazel/jsonh.py
+18 −0 bazel/mbedtls.BUILD
+35 −0 bintool/BUILD.bazel
+32 −0 bintool/CMakeLists.txt
+1,028 −0 bintool/bintool.cpp
+42 −0 bintool/bintool.h
+242 −0 bintool/mbedtls_wrapper.c
+60 −0 bintool/mbedtls_wrapper.h
+707 −0 bintool/metadata.h
+ bootrom.end.bin
+182 −51 cli.h
+48 −11 cmake/FindLIBUSB.cmake
+5 −0 cmake/bin.template.h
+28 −0 cmake/binh.cmake
+2 −0 cmake/jsonh.cmake
+3 −0 cmake/picotoolConfig.cmake
+6 −0 cmake/rp2350.json.template.h
+5 −0 data_locs.h
+7 −0 data_locs.template.cpp
+0 −60 elf.h
+20 −0 elf/BUILD.bazel
+6 −0 elf/CMakeLists.txt
+94 −0 elf/addresses.h
+126 −0 elf/elf.h
+548 −0 elf/elf_file.cpp
+74 −0 elf/elf_file.h
+167 −0 elf/portable_endian.h
+20 −0 elf2uf2/BUILD.bazel
+6 −0 elf2uf2/CMakeLists.txt
+344 −0 elf2uf2/elf2uf2.cpp
+28 −0 elf2uf2/elf2uf2.h
+8 −0 errors/BUILD.bazel
+3 −0 errors/CMakeLists.txt
+16 −0 errors/errors.cpp
+41 −0 errors/errors.h
+37 −0 json/default-pt.json
+27 −0 json/sample-permissions.json
+26 −0 json/sample-wl.json
+77 −0 json/schemas/otp-contents-schema.json
+50 −0 json/schemas/otp-schema.json
+158 −0 json/schemas/partition-table-schema.json
+52 −0 json/schemas/permissions-schema.json
+124 −0 json/schemas/whitelabel-schema.json
+6 −0 lib/BUILD.bazel
+27 −0 lib/CMakeLists.txt
+4,217 −0 lib/include/mbedtls_config.h
+7 −0 lib/nlohmann_json/BUILD.bazel
+126 −0 lib/nlohmann_json/CMakeLists.txt
+21 −0 lib/nlohmann_json/LICENSE.MIT
+24,766 −0 lib/nlohmann_json/single_include/nlohmann/json.hpp
+14 −0 lib/whereami/BUILD.bazel
+7 −0 lib/whereami/CMakeLists.txt
+101 −0 lib/whereami/whereami++.cpp
+66 −0 lib/whereami/whereami++.h
+801 −0 lib/whereami/whereami.c
+64 −0 lib/whereami/whereami.h
+6,556 −783 main.cpp
+23 −0 no_otp.cpp
+84 −0 otp.cpp
+97 −0 otp.h
+19 −0 otp_header_parser/BUILD.bazel
+18 −0 otp_header_parser/CMakeLists.txt
+389 −0 otp_header_parser/otp_header_parse.cpp
+31,174 −0 otp_header_parser/rp2350.json.h
+24 −0 picoboot_connection/BUILD.bazel
+5 −2 picoboot_connection/CMakeLists.txt
+731 −0 picoboot_connection/picoboot_connection.c
+0 −428 picoboot_connection/picoboot_connection.cpp
+65 −25 picoboot_connection/picoboot_connection.h
+35 −0 picoboot_connection/picoboot_connection_cxx.cpp
+17 −2 picoboot_connection/picoboot_connection_cxx.h
+8 −0 picoboot_flash_id/BUILD.bazel
+36 −0 picoboot_flash_id/CMakeLists.txt
+ picoboot_flash_id/flash_id.bin
+70 −0 picoboot_flash_id/flash_id.c
+24 −0 udev/99-picotool.rules
+39 −0 xip_ram_perms.cpp
+12 −0 xip_ram_perms.h
+17 −0 xip_ram_perms/BUILD.bazel
+53 −0 xip_ram_perms/CMakeLists.txt
+192 −0 xip_ram_perms/set_perms.c
+ xip_ram_perms/xip_ram_perms.elf
28 changes: 28 additions & 0 deletions Sming/Arch/Rp2040/Components/picotool/picotool.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
diff --git a/lib/whereami/whereami.c b/lib/whereami/whereami.c
index d052e14..940736e 100644
--- a/lib/whereami/whereami.c
+++ b/lib/whereami/whereami.c
@@ -60,8 +60,9 @@ extern "C" {
#if defined(_MSC_VER)
#pragma warning(push, 3)
#endif
+#undef _WIN32_WINNT
+#define _WIN32_WINNT _WIN32_WINNT_WINXP
#include <windows.h>
-#include <intrin.h>
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
diff --git a/picoboot_connection/picoboot_connection.c b/picoboot_connection/picoboot_connection.c
index 265608c..e487714 100644
--- a/picoboot_connection/picoboot_connection.c
+++ b/picoboot_connection/picoboot_connection.c
@@ -9,6 +9,8 @@
#include <stdbool.h>
#include <inttypes.h>

+#define static_assert _Static_assert
+
#include "picoboot_connection.h"
#include "boot/bootrom_constants.h"
#include "pico/stdio_usb/reset_interface.h"
1 change: 1 addition & 0 deletions Sming/Arch/Rp2040/Components/sming-arch/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ COMPONENT_DEPENDS := \
libc \
rp2040 \
uf2 \
picotool \
driver \
gdbstub \
spi_flash
Expand Down
27 changes: 0 additions & 27 deletions Sming/Arch/Rp2040/Components/uf2/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@ else
Uf2Conv = $(PYTHON) $(UF2CONV_PY) $(if $V,--verbose) $1
endif


# Read flash manufacturer ID and determine actual size
define ReadFlashID
$(info Reading Flash ID)
$(call Uf2Conv,--list --verbose)
endef

# Write file contents to Flash
# $1 -> List of `Offset=File` chunks
define WriteFlash
Expand All @@ -46,23 +39,3 @@ define VerifyFlash
$(info ** NOT IMPLEMENTED **)
)
endef

# Read flash memory into file
# $1 -> `Offset,Size` chunk
# $2 -> Output filename
define ReadFlash
$(info ReadFlash $1,$2)
$(info ** NOT IMPLEMENTED **)
endef

# Erase a region of Flash
# $1 -> Offset,Size
define EraseFlashRegion
$(info EraseFlashRegion $1)
$(info ** NOT IMPLEMENTED **)
endef

# Erase flash memory contents
define EraseFlash
$(info ** NOT IMPLEMENTED **)
endef

0 comments on commit d7c0c52

Please sign in to comment.