This is an automated email from the ASF dual-hosted git repository.

jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 3ecb548f8b741b14414995a10a84ff041d5bc699
Author: Jerzy Kasenberg <jerzy.kasenb...@codecoup.pl>
AuthorDate: Mon May 22 12:38:52 2023 +0200

    hw/scripts: download: Add support for stm32_programmer_cli
    
    This adds explicit support for stm32_programmer_cli.
    It was possible to use this tool instead of st-flash
    with environment variable.
    
    Signed-off-by: Jerzy Kasenberg <jerzy.kasenb...@codecoup.pl>
---
 hw/scripts/download.sh         |  5 +++++
 hw/scripts/stm32_programmer.sh | 50 ++++++++++++++++++++++++++++++++++++++++++
 hw/scripts/syscfg.yml          |  2 ++
 3 files changed, 57 insertions(+)

diff --git a/hw/scripts/download.sh b/hw/scripts/download.sh
index c5f6b1444..aa723a869 100644
--- a/hw/scripts/download.sh
+++ b/hw/scripts/download.sh
@@ -94,4 +94,9 @@ case "${MYNEWT_VAL_MYNEWT_DOWNLOADER}" in
     common_file_to_load
     stlink_load
     ;;
+  "stm32_programmer_cli")
+    . $CORE_PATH/hw/scripts/stm32_programmer.sh
+    common_file_to_load
+    stlink_load
+    ;;
 esac
diff --git a/hw/scripts/stm32_programmer.sh b/hw/scripts/stm32_programmer.sh
new file mode 100644
index 000000000..b982a7a99
--- /dev/null
+++ b/hw/scripts/stm32_programmer.sh
@@ -0,0 +1,50 @@
+# 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.
+#
+. $CORE_PATH/hw/scripts/common.sh
+
+GDB=arm-none-eabi-gdb
+
+#
+# FILE_NAME must contain the name of the file to load
+# FLASH_OFFSET must contain the offset in flash where to place it
+#
+stlink_load () {
+    if [ -z $FILE_NAME ]; then
+        echo "Missing filename"
+        exit 1
+    fi
+    if [ ! -f "$FILE_NAME" ]; then
+        # tries stripping current path for readability
+        FILE=${FILE_NAME##$(pwd)/}
+        echo "Cannot find file" $FILE
+        exit 1
+    fi
+    if [ -z $FLASH_OFFSET ]; then
+        echo "Missing flash offset"
+        exit 1
+    fi
+
+    echo "Downloading" $FILE_NAME "to" $FLASH_OFFSET
+
+    STM32_Programmer_CLI -c port=SWD -d $FILE_NAME $FLASH_OFFSET -rst
+
+    if [ $? -ne 0 ]; then
+        exit 1
+    fi
+    return 0
+}
diff --git a/hw/scripts/syscfg.yml b/hw/scripts/syscfg.yml
index f21c72f28..6814a692c 100644
--- a/hw/scripts/syscfg.yml
+++ b/hw/scripts/syscfg.yml
@@ -28,6 +28,8 @@ syscfg.defs:
             - jlink
             # open source st-flash for STM32Fxx devices
             - stflash
+            # ST propitiatory flasher STM32_Programmer_CLI for STM32Fxx devices
+            - stm32_programmer_cli
             - openocd
             - pyocd
             # Nordic Semiconductor tool for NRF5x devices

Reply via email to