From a54a5e04d93820cef896b3372dbfe345ff1ccc6d Mon Sep 17 00:00:00 2001 From: Mathieu Kardous Date: Mon, 13 Nov 2023 08:51:09 -0500 Subject: [PATCH] add rps ext to flasher tools --- scripts/examples/gn_silabs_example.sh | 8 +++++++- ..._firmware_utils.py => silabs_firmware_utils.py} | 14 ++++++++++++-- third_party/silabs/silabs_board.gni | 7 +++++++ third_party/silabs/silabs_executable.gni | 12 +++++++++--- 4 files changed, 35 insertions(+), 6 deletions(-) rename scripts/flashing/{efr32_firmware_utils.py => silabs_firmware_utils.py} (93%) diff --git a/scripts/examples/gn_silabs_example.sh b/scripts/examples/gn_silabs_example.sh index 717783cff2925f..0ed6f1815dc984 100755 --- a/scripts/examples/gn_silabs_example.sh +++ b/scripts/examples/gn_silabs_example.sh @@ -31,6 +31,7 @@ fi set -x env USE_WIFI=false +USE_RPS_EXTENSION=false USE_DOCKER=false USE_GIT_SHA_FOR_VERSION=true USE_SLC=false @@ -281,9 +282,10 @@ else fi # 917 exception. TODO find a more generic way - if [ "$SILABS_BOARD" == "BRD4325B" ] || [ "$SILABS_BOARD" == "BRD4325C" ] || [ "$SILABS_BOARD" == "BRD4338A" ]; then + if [ "$SILABS_BOARD" == "BRD4325B" ] || [ "$SILABS_BOARD" == "BRD4325C" ] || [ "$SILABS_BOARD" == "BRD4338A" ] || [ "$SILABS_BOARD" == "BRD4325G" ]; then echo "Compiling for 917 WiFi SOC" USE_WIFI=true + USE_RPS_EXTENSION=true optArgs+="chip_device_platform =\"SiWx917\" " fi @@ -336,6 +338,10 @@ else #print stats arm-none-eabi-size -A "$BUILD_DIR"/*.out + # Generate RPS file from .s37 for 917 SoC builds + # if ["USE_RPS_EXTENSION" == true]; then + # fi + # add bootloader to generated image if [ "$USE_BOOTLOADER" == true ]; then diff --git a/scripts/flashing/efr32_firmware_utils.py b/scripts/flashing/silabs_firmware_utils.py similarity index 93% rename from scripts/flashing/efr32_firmware_utils.py rename to scripts/flashing/silabs_firmware_utils.py index 989cc97f19ca32..969864e138ada8 100755 --- a/scripts/flashing/efr32_firmware_utils.py +++ b/scripts/flashing/silabs_firmware_utils.py @@ -19,7 +19,7 @@ For `Flasher`, see the class documentation. For the parse_command() interface or standalone execution: -usage: efr32_firmware_utils.py [-h] [--verbose] [--erase] [--application FILE] +usage: silabs_firmware_utils.py [-h] [--verbose] [--erase] [--application FILE] [--verify_application] [--reset] [--skip_reset] [--commander FILE] [--device DEVICE] [--serialno SERIAL] [--ip ADDRESS] @@ -49,6 +49,7 @@ Do not reset device after flashing """ +import os import sys import firmware_utils @@ -133,9 +134,18 @@ def verify(self, image): def flash(self, image): """Flash image.""" + ext = os.path.splitext(image)[-1].lower() + + if ext == ".rps": + # rps load command for .rps files + arguments = ['rps', 'load'] + else: + # flash command for .s37 files + arguments = ['flash'] + return self.run_tool( 'commander', - ['flash', self.DEVICE_ARGUMENTS, image], + [arguments, self.DEVICE_ARGUMENTS, image], name='Flash') def reset(self): diff --git a/third_party/silabs/silabs_board.gni b/third_party/silabs/silabs_board.gni index cd433ed61da49c..dd34fc6e04ef9a 100644 --- a/third_party/silabs/silabs_board.gni +++ b/third_party/silabs/silabs_board.gni @@ -51,6 +51,9 @@ declare_args() { # Self-provision enabled use_provision_channel = false + + # Board required .rps file to flash instead of .s37 + use_rps_extension = false } declare_args() { @@ -111,6 +114,7 @@ if (silabs_board == "BRD4304A") { show_qr_code = false wifi_soc = true silabs_board_lower = "brd4325b" + use_rps_extension = true } else if (silabs_board == "BRD4325C") { silabs_family = "SiWx917-common" silabs_mcu = "SiWG917M111MGTBA" @@ -119,6 +123,7 @@ if (silabs_board == "BRD4304A") { wifi_soc = true wifi_soc_common_flash = true silabs_board_lower = "brd4325c" + use_rps_extension = true } else if (silabs_board == "BRD4325G") { silabs_family = "SiWx917-common" silabs_mcu = "SiWG917M111MGTBA" @@ -127,6 +132,7 @@ if (silabs_board == "BRD4304A") { wifi_soc = true wifi_soc_common_flash = true silabs_board_lower = "brd4325g" + use_rps_extension = true } else if (silabs_board == "BRD4338A") { silabs_family = "SiWx917-common" silabs_mcu = "SiWG917M111MGTBA" @@ -135,6 +141,7 @@ if (silabs_board == "BRD4304A") { wifi_soc = true wifi_soc_common_flash = true silabs_board_lower = "brd4338a" + use_rps_extension = true } else if (silabs_board == "BRD4180A") { assert( false, diff --git a/third_party/silabs/silabs_executable.gni b/third_party/silabs/silabs_executable.gni index 5d3c73c0998906..600088d265eadd 100644 --- a/third_party/silabs/silabs_executable.gni +++ b/third_party/silabs/silabs_executable.gni @@ -14,13 +14,19 @@ import("//build_overrides/build.gni") import("//build_overrides/chip.gni") - import("${build_root}/toolchain/flashable_executable.gni") +import("silabs_board.gni") template("silabs_executable") { output_base_name = get_path_info(invoker.output_name, "name") - objcopy_image_name = output_base_name + ".s37" + if (use_rps_extension) { + extension = ".rps" + } else { + extension = ".s37" + } + + objcopy_image_name = output_base_name + extension objcopy_image_format = "srec" objcopy = "arm-none-eabi-objcopy" @@ -31,7 +37,7 @@ template("silabs_executable") { flashing_runtime_target = target_name + ".flashing_runtime" flashing_script_inputs = [ - "${chip_root}/scripts/flashing/efr32_firmware_utils.py", + "${chip_root}/scripts/flashing/silabs_firmware_utils.py", "${chip_root}/scripts/flashing/firmware_utils.py", ] copy(flashing_runtime_target) {