diff --git a/boards.txt b/boards.txt index 8a0b9dbf2..55bbb1c96 100644 --- a/boards.txt +++ b/boards.txt @@ -46,6 +46,7 @@ giga.upload.vid=0x2341 giga.upload.pid=0x0366 giga.upload.interface=0 giga.upload.use_1200bps_touch=true +giga.upload.use_pre_upload_check=true giga.upload.wait_for_upload_port=true giga.upload.native_usb=true giga.upload.maximum_size=1966080 diff --git a/loader/CMakeLists.txt b/loader/CMakeLists.txt index 428885a70..c3325e7c6 100644 --- a/loader/CMakeLists.txt +++ b/loader/CMakeLists.txt @@ -37,6 +37,10 @@ target_sources_ifdef(CONFIG_USB_DEVICE_STACK_NEXT app PRIVATE FILE(GLOB app_sources *.c) target_sources(app PRIVATE ${app_sources}) -target_compile_definitions(app PUBLIC _XOPEN_SOURCE=700) + +zephyr_compile_definitions( + -D_XOPEN_SOURCE=700 + -DCONFIG_USB_CONFIGURATION_STRING_DESC=STRINGIFY\(BUILD_VERSION\) +) target_link_libraries(app PUBLIC blobs) diff --git a/loader/prj.conf b/loader/prj.conf index 20d861491..840a80f27 100644 --- a/loader/prj.conf +++ b/loader/prj.conf @@ -49,3 +49,5 @@ CONFIG_RTC=y CONFIG_RTC_ALARM=y CONFIG_RTC_UPDATE=y CONFIG_RTC_CALIBRATION=y + +CONFIG_USB_CONFIGURATION_STRING_DESC_ENABLE=y diff --git a/platform.txt b/platform.txt index ee295bd0a..2fa9aa8c9 100644 --- a/platform.txt +++ b/platform.txt @@ -225,6 +225,10 @@ tools.stm32flash.erase.pattern="{path}/{cmd}" {serial.port} -e 1024 -b 2400 # DFU_UTIL # +tools.dfu-util.pre_cmd.linux={build.variant.path}/check_loader_version.sh +tools.dfu-util.pre_upload_check.pattern="{pre_cmd}" {upload.port.properties.configuration} +tools.dfu-util.pre_upload.pattern="{path}/{cmd}" --device ,{bootloader.vid}:{bootloader.pid} -D "{runtime.platform.path}/firmwares/{bootloader.file}" -a{bootloader.interface} --dfuse-address={bootloader.address} + upload.dfuse=--dfuse-address={upload.address}:leave bootloader.dfuse=--dfuse-address={bootloader.address}:leave diff --git a/variants/arduino_giga_r1_stm32h747xx_m7/check_loader_version.sh b/variants/arduino_giga_r1_stm32h747xx_m7/check_loader_version.sh new file mode 100755 index 000000000..af50bc1aa --- /dev/null +++ b/variants/arduino_giga_r1_stm32h747xx_m7/check_loader_version.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +DIR=$(dirname "$(readlink -f "$0")") +VERSION=$(grep "define BUILD_VERSION" ${DIR}/llext-edk/include/zephyr/include/generated/zephyr/version.h | cut -f3 -d " ") +if [ "$VERSION" != "$1" ]; then + echo "Loader version mismatch: expected $1, got $VERSION, reflashing loader" + exit 1 +fi +exit 0 \ No newline at end of file diff --git a/west.yml b/west.yml index e8b1b3103..f0d113174 100644 --- a/west.yml +++ b/west.yml @@ -21,7 +21,7 @@ manifest: projects: - name: zephyr remote: arduino - revision: zephyr-arduino-v4.2.0 + revision: zephyr-arduino-v4.2.0+iConfig import: name-allowlist: - cmsis