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

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

commit dc6516660b951d64c8f28e81cf6a3671dcfc915a
Author: Jerzy Kasenberg <[email protected]>
AuthorDate: Tue Oct 13 21:24:49 2026 +0200

    hw/bsp: Switch STM32 BSPs to use common download script
    
    Most STM32 BSPs already use hw/scripts/download.sh where download tool
    is selected with MYNEWT_DOWNLOADER syscfg value.  Remaining BSPs still
    had their own download scripts.  Switch them to common script, keeping
    tool that was used so far:
    
     - stflash: ada_feather_stm32f405, b-l072z-lrwan1, nucleo-f030r8,
       nucleo-f072rb, nucleo-f413zh, nucleo-f439zi, stm32f411discovery,
       stm32l152discovery
     - openocd: nucleo-f401re, nucleo-f746zg, olimex-p103,
       olimex_stm32-e407_devboard, stm32f429discovery, stm32f4discovery,
       stm32f7discovery
    
    JLINK_TARGET is also added so jlink can be selected in target.
    
    nucleo-f030r8, nucleo-f072rb and olimex-p103 do not use bootloader and
    their download scripts always loaded .elf.bin.  Those BSPs now define
    BOOT_LOADER (same as weact_g431cb) and place code in
    FLASH_AREA_BOOTLOADER, so newt passes BOOT_LOADER and bootloader
    offset to download script.
    
    Unused download scripts left in nucleo-f411re and bluepill are
    removed as well.
    
    Assisted-by: Claude:claude-opus-5-5
    Signed-off-by: Jerzy Kasenberg <[email protected]>
---
 .../ada_feather_stm32f405_download.sh              | 67 ----------------------
 hw/bsp/ada_feather_stm32f405/bsp.yml               |  2 +-
 hw/bsp/ada_feather_stm32f405/pkg.yml               |  1 +
 hw/bsp/ada_feather_stm32f405/syscfg.yml            |  4 ++
 hw/bsp/b-l072z-lrwan1/b-l072z-lrwan1_download.sh   | 39 -------------
 hw/bsp/b-l072z-lrwan1/bsp.yml                      |  2 +-
 hw/bsp/b-l072z-lrwan1/pkg.yml                      |  1 +
 hw/bsp/b-l072z-lrwan1/syscfg.yml                   |  4 ++
 hw/bsp/bluepill/bluepill_download.sh               | 41 -------------
 hw/bsp/nucleo-f030r8/bsp.yml                       | 12 ++--
 hw/bsp/nucleo-f030r8/nucleo-f030r8_download.sh     | 29 ----------
 hw/bsp/nucleo-f030r8/pkg.yml                       |  1 +
 hw/bsp/nucleo-f030r8/syscfg.yml                    |  9 +++
 hw/bsp/nucleo-f072rb/bsp.yml                       | 12 ++--
 hw/bsp/nucleo-f072rb/nucleo-f072rb_download.sh     | 41 -------------
 hw/bsp/nucleo-f072rb/pkg.yml                       |  1 +
 hw/bsp/nucleo-f072rb/syscfg.yml                    |  9 +++
 hw/bsp/nucleo-f401re/bsp.yml                       |  2 +-
 hw/bsp/nucleo-f401re/nucleo-f401re_download.sh     | 42 --------------
 hw/bsp/nucleo-f401re/pkg.yml                       |  1 +
 hw/bsp/nucleo-f401re/syscfg.yml                    |  5 ++
 hw/bsp/nucleo-f411re/nucleo-f411re_download.sh     | 40 -------------
 hw/bsp/nucleo-f413zh/bsp.yml                       |  2 +-
 hw/bsp/nucleo-f413zh/nucleo-f413zh_download.sh     | 38 ------------
 hw/bsp/nucleo-f413zh/pkg.yml                       |  1 +
 hw/bsp/nucleo-f413zh/syscfg.yml                    |  4 ++
 hw/bsp/nucleo-f439zi/bsp.yml                       |  2 +-
 hw/bsp/nucleo-f439zi/nucleo-f439zi_download.sh     | 38 ------------
 hw/bsp/nucleo-f439zi/pkg.yml                       |  1 +
 hw/bsp/nucleo-f439zi/syscfg.yml                    |  4 ++
 hw/bsp/nucleo-f746zg/bsp.yml                       |  2 +-
 hw/bsp/nucleo-f746zg/nucleo-f746zg_download.sh     | 41 -------------
 hw/bsp/olimex-p103/bsp.yml                         | 10 +++-
 hw/bsp/olimex-p103/olimex_p103_download.sh         | 43 --------------
 hw/bsp/olimex-p103/pkg.yml                         |  1 +
 hw/bsp/olimex-p103/syscfg.yml                      | 10 ++++
 hw/bsp/olimex_stm32-e407_devboard/bsp.yml          |  2 +-
 .../olimex_stm32-e407_devboard_download.sh         | 41 -------------
 hw/bsp/olimex_stm32-e407_devboard/pkg.yml          |  1 +
 hw/bsp/olimex_stm32-e407_devboard/syscfg.yml       |  6 ++
 hw/bsp/stm32f411discovery/bsp.yml                  |  2 +-
 hw/bsp/stm32f411discovery/pkg.yml                  |  1 +
 .../stm32f411discovery_download.sh                 | 38 ------------
 hw/bsp/stm32f411discovery/syscfg.yml               |  4 ++
 hw/bsp/stm32f429discovery/bsp.yml                  |  2 +-
 hw/bsp/stm32f429discovery/pkg.yml                  |  1 +
 .../stm32f429discovery_download.sh                 | 41 -------------
 hw/bsp/stm32f429discovery/syscfg.yml               |  5 ++
 hw/bsp/stm32f4discovery/bsp.yml                    |  2 +-
 hw/bsp/stm32f4discovery/pkg.yml                    |  1 +
 .../stm32f4discovery/stm32f4discovery_download.sh  | 41 -------------
 hw/bsp/stm32f4discovery/syscfg.yml                 |  5 ++
 hw/bsp/stm32f7discovery/bsp.yml                    |  2 +-
 .../stm32f7discovery/stm32f7discovery_download.sh  | 41 -------------
 hw/bsp/stm32l152discovery/bsp.yml                  |  2 +-
 hw/bsp/stm32l152discovery/pkg.yml                  |  1 +
 .../stm32l152discovery_download.sh                 | 39 -------------
 hw/bsp/stm32l152discovery/syscfg.yml               |  4 ++
 58 files changed, 120 insertions(+), 724 deletions(-)

diff --git a/hw/bsp/ada_feather_stm32f405/ada_feather_stm32f405_download.sh 
b/hw/bsp/ada_feather_stm32f405/ada_feather_stm32f405_download.sh
deleted file mode 100755
index f29c7287b..000000000
--- a/hw/bsp/ada_feather_stm32f405/ada_feather_stm32f405_download.sh
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/bin/sh
-# 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 is absolute path to @apache-mynewt-core
-#  - BSP_PATH is absolute path to hw/bsp/bsp_name
-#  - BIN_BASENAME is the path to prefix to target binary,
-#    .elf appended to name is the ELF file
-#  - IMAGE_SLOT is the image slot to download to (for non-mfg-image, non-boot)
-#  - FEATURES holds the target features string
-#  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
-#  - MFG_IMAGE is "1" if this is a manufacturing image
-#  - FLASH_OFFSET contains the flash offset to download to
-#  - BOOT_LOADER is set if downloading a bootloader
-#!/bin/sh
-# 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.
-
-# Called with following variables set:
-#  - CORE_PATH is absolute path to @apache-mynewt-core
-#  - BSP_PATH is absolute path to hw/bsp/bsp_name
-#  - BIN_BASENAME is the path to prefix to target binary,
-#    .elf appended to name is the ELF file
-#  - IMAGE_SLOT is the image slot to download to (for non-mfg-image, non-boot)
-#  - FEATURES holds the target features string
-#  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
-#  - MFG_IMAGE is "1" if this is a manufacturing image
-#  - FLASH_OFFSET contains the flash offset to download to
-#  - BOOT_LOADER is set if downloading a bootloader
-
-. $CORE_PATH/hw/scripts/stlink.sh
-
-if [ "$MFG_IMAGE" ]; then
-    FLASH_OFFSET=0x08000000
-fi
-
-common_file_to_load
-stlink_load
diff --git a/hw/bsp/ada_feather_stm32f405/bsp.yml 
b/hw/bsp/ada_feather_stm32f405/bsp.yml
index e54681ac6..5bfb79012 100644
--- a/hw/bsp/ada_feather_stm32f405/bsp.yml
+++ b/hw/bsp/ada_feather_stm32f405/bsp.yml
@@ -23,7 +23,7 @@ bsp.maker: "Adafruit Industries"
 bsp.arch: cortex_m4
 bsp.compiler: compiler/arm-none-eabi-m4
 bsp.linkerscript: autogenerated
-bsp.downloadscript: 
"hw/bsp/ada_feather_stm32f405/ada_feather_stm32f405_download.sh"
+bsp.downloadscript: "hw/scripts/download.sh"
 bsp.debugscript: "hw/bsp/ada_feather_stm32f405/ada_feather_stm32f405_debug.sh"
 
 bsp.flash_map:
diff --git a/hw/bsp/ada_feather_stm32f405/pkg.yml 
b/hw/bsp/ada_feather_stm32f405/pkg.yml
index c2f1d75dd..582c17006 100644
--- a/hw/bsp/ada_feather_stm32f405/pkg.yml
+++ b/hw/bsp/ada_feather_stm32f405/pkg.yml
@@ -39,3 +39,4 @@ pkg.deps:
     - "@apache-mynewt-core/hw/mcu/stm/stm32f4xx"
     - "@apache-mynewt-core/libc"
     - "@apache-mynewt-core/boot/startup"
+    - "@apache-mynewt-core/hw/scripts"
diff --git a/hw/bsp/ada_feather_stm32f405/syscfg.yml 
b/hw/bsp/ada_feather_stm32f405/syscfg.yml
index 5c383ddfe..6f942a04d 100644
--- a/hw/bsp/ada_feather_stm32f405/syscfg.yml
+++ b/hw/bsp/ada_feather_stm32f405/syscfg.yml
@@ -17,6 +17,10 @@
 #
 
 syscfg.vals:
+    MYNEWT_DOWNLOADER: stflash
+    MYNEWT_DOWNLOADER_MFG_IMAGE_FLASH_OFFSET: 0x08000000
+    JLINK_TARGET: STM32F405RG
+
     STM32_FLASH_SIZE_KB: 1024
     STM32_FLASH_NUM_AREAS: 12
     MCU_RAM_START: 0x20000000
diff --git a/hw/bsp/b-l072z-lrwan1/b-l072z-lrwan1_download.sh 
b/hw/bsp/b-l072z-lrwan1/b-l072z-lrwan1_download.sh
deleted file mode 100755
index 5d6d649ab..000000000
--- a/hw/bsp/b-l072z-lrwan1/b-l072z-lrwan1_download.sh
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/bin/sh
-# 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.
-#
-
-# Called with following variables set:
-#  - CORE_PATH is absolute path to @apache-mynewt-core
-#  - BSP_PATH is absolute path to hw/bsp/bsp_name
-#  - BIN_BASENAME is the path to prefix to target binary,
-#    .elf appended to name is the ELF file
-#  - IMAGE_SLOT is the image slot to download to (for non-mfg-image, non-boot)
-#  - FEATURES holds the target features string
-#  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
-#  - MFG_IMAGE is "1" if this is a manufacturing image
-#  - FLASH_OFFSET contains the flash offset to download to
-#  - BOOT_LOADER is set if downloading a bootloader
-
-. $CORE_PATH/hw/scripts/stlink.sh
-
-if [ "$MFG_IMAGE" ]; then
-    FLASH_OFFSET=0x08000000
-fi
-
-common_file_to_load
-stlink_load
diff --git a/hw/bsp/b-l072z-lrwan1/bsp.yml b/hw/bsp/b-l072z-lrwan1/bsp.yml
index 01c10546c..3e74ed5f6 100644
--- a/hw/bsp/b-l072z-lrwan1/bsp.yml
+++ b/hw/bsp/b-l072z-lrwan1/bsp.yml
@@ -23,7 +23,7 @@ bsp.maker: "STMicroelectronics"
 bsp.arch: cortex_m0
 bsp.compiler: compiler/arm-none-eabi-m0
 bsp.linkerscript: autogenerated
-bsp.downloadscript: "hw/bsp/b-l072z-lrwan1/b-l072z-lrwan1_download.sh"
+bsp.downloadscript: "hw/scripts/download.sh"
 bsp.debugscript: "hw/bsp/b-l072z-lrwan1/b-l072z-lrwan1_debug.sh"
 
 bsp.flash_map:
diff --git a/hw/bsp/b-l072z-lrwan1/pkg.yml b/hw/bsp/b-l072z-lrwan1/pkg.yml
index a8d42efdb..a4bb4db80 100644
--- a/hw/bsp/b-l072z-lrwan1/pkg.yml
+++ b/hw/bsp/b-l072z-lrwan1/pkg.yml
@@ -33,6 +33,7 @@ pkg.cflags:
 pkg.deps:
     - "@apache-mynewt-core/hw/mcu/stm/stm32l0xx"
     - "@apache-mynewt-core/libc"
+    - "@apache-mynewt-core/hw/scripts"
 
 pkg.deps.LORA_NODE:
     - "@apache-mynewt-core/hw/drivers/lora/sx1276"
diff --git a/hw/bsp/b-l072z-lrwan1/syscfg.yml b/hw/bsp/b-l072z-lrwan1/syscfg.yml
index eeb72c066..27aeafce6 100644
--- a/hw/bsp/b-l072z-lrwan1/syscfg.yml
+++ b/hw/bsp/b-l072z-lrwan1/syscfg.yml
@@ -18,6 +18,10 @@
 #
 
 syscfg.vals:
+    MYNEWT_DOWNLOADER: stflash
+    MYNEWT_DOWNLOADER_MFG_IMAGE_FLASH_OFFSET: 0x08000000
+    JLINK_TARGET: STM32L072CZ
+
     STM32_FLASH_SIZE_KB: 192
     MCU_RAM_START: 0x20000000
     MCU_RAM_SIZE: 20K
diff --git a/hw/bsp/bluepill/bluepill_download.sh 
b/hw/bsp/bluepill/bluepill_download.sh
deleted file mode 100755
index 3ebd41911..000000000
--- a/hw/bsp/bluepill/bluepill_download.sh
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/bin/sh
-# 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.
-#
-
-# Called with following variables set:
-#  - CORE_PATH is absolute path to @apache-mynewt-core
-#  - BSP_PATH is absolute path to hw/bsp/bsp_name
-#  - BIN_BASENAME is the path to prefix to target binary,
-#    .elf appended to name is the ELF file
-#  - IMAGE_SLOT is the image slot to download to (for non-mfg-image, non-boot)
-#  - FEATURES holds the target features string
-#  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
-#  - MFG_IMAGE is "1" if this is a manufacturing image
-#  - FLASH_OFFSET contains the flash offset to download to
-#  - BOOT_LOADER is set if downloading a bootloader
-. $CORE_PATH/hw/scripts/openocd.sh
-
-CFG="-s $BSP_PATH -f bluepill.cfg"
-
-if [ "$MFG_IMAGE" ]; then
-    FLASH_OFFSET=0x08000000
-fi
-
-common_file_to_load
-openocd_load
-openocd_reset_run
diff --git a/hw/bsp/nucleo-f030r8/bsp.yml b/hw/bsp/nucleo-f030r8/bsp.yml
index 498cf172c..467a0e973 100644
--- a/hw/bsp/nucleo-f030r8/bsp.yml
+++ b/hw/bsp/nucleo-f030r8/bsp.yml
@@ -23,20 +23,22 @@ bsp.maker: "STMicroelectronics"
 bsp.arch: cortex_m0
 bsp.compiler: compiler/arm-none-eabi-m0
 bsp.linkerscript: autogenerated
-bsp.downloadscript: "hw/bsp/nucleo-f030r8/nucleo-f030r8_download.sh"
+bsp.downloadscript: "hw/scripts/download.sh"
 bsp.debugscript: "hw/bsp/nucleo-f030r8/nucleo-f030r8_debug.sh"
 
 bsp.flash_map:
     areas:
         # System areas.
+        # Only one flash area for code
         FLASH_AREA_BOOTLOADER:
-            device: 0
-            offset: 0x08100000
-            size:   0kB
-        FLASH_AREA_IMAGE_0:
             device: 0
             offset: 0x08000000
             size:   64kB
+        # Empty flash area to allow build
+        FLASH_AREA_IMAGE_0:
+            device: 0
+            offset: 0x08100000
+            size:   0kB
         FLASH_AREA_IMAGE_1:
             device: 0
             offset: 0x08200000
diff --git a/hw/bsp/nucleo-f030r8/nucleo-f030r8_download.sh 
b/hw/bsp/nucleo-f030r8/nucleo-f030r8_download.sh
deleted file mode 100755
index 4063ed823..000000000
--- a/hw/bsp/nucleo-f030r8/nucleo-f030r8_download.sh
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/bash
-# 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/stlink.sh
-
-if [ "$MFG_IMAGE" ]; then
-    FLASH_OFFSET=0x08000000
-fi
-
-BOOT_LOADER=1
-
-common_file_to_load
-stlink_load
diff --git a/hw/bsp/nucleo-f030r8/pkg.yml b/hw/bsp/nucleo-f030r8/pkg.yml
index 2db9b08ef..14c129b02 100644
--- a/hw/bsp/nucleo-f030r8/pkg.yml
+++ b/hw/bsp/nucleo-f030r8/pkg.yml
@@ -37,3 +37,4 @@ pkg.deps:
     - "@apache-mynewt-core/hw/mcu/stm/stm32f0xx"
     - "@apache-mynewt-core/libc"
     - "@apache-mynewt-core/boot/startup"
+    - "@apache-mynewt-core/hw/scripts"
diff --git a/hw/bsp/nucleo-f030r8/syscfg.yml b/hw/bsp/nucleo-f030r8/syscfg.yml
index 81a19c0cd..cfc655545 100644
--- a/hw/bsp/nucleo-f030r8/syscfg.yml
+++ b/hw/bsp/nucleo-f030r8/syscfg.yml
@@ -17,7 +17,16 @@
 # under the License.
 #
 
+syscfg.defs:
+    BOOT_LOADER:
+        description: 'Build everything as bootloader'
+        value: 1
+
 syscfg.vals:
+    MYNEWT_DOWNLOADER: stflash
+    MYNEWT_DOWNLOADER_MFG_IMAGE_FLASH_OFFSET: 0x08000000
+    JLINK_TARGET: STM32F030R8
+
     STM32_FLASH_SIZE_KB: 64
     MCU_RAM_START: 0x20000000
     MCU_RAM_SIZE: 0x2000
diff --git a/hw/bsp/nucleo-f072rb/bsp.yml b/hw/bsp/nucleo-f072rb/bsp.yml
index 96c50c3c1..e8068362f 100644
--- a/hw/bsp/nucleo-f072rb/bsp.yml
+++ b/hw/bsp/nucleo-f072rb/bsp.yml
@@ -23,20 +23,22 @@ bsp.maker: "STMicroelectronics"
 bsp.arch: cortex_m0
 bsp.compiler: compiler/arm-none-eabi-m0
 bsp.linkerscript: autogenerated
-bsp.downloadscript: "hw/bsp/nucleo-f072rb/nucleo-f072rb_download.sh"
+bsp.downloadscript: "hw/scripts/download.sh"
 bsp.debugscript: "hw/bsp/nucleo-f072rb/nucleo-f072rb_debug.sh"
 
 bsp.flash_map:
     areas:
         # System areas.
+        # Only one flash area for code
         FLASH_AREA_BOOTLOADER:
-            device: 0
-            offset: 0x08100000
-            size:   0kB
-        FLASH_AREA_IMAGE_0:
             device: 0
             offset: 0x08000000
             size:   128kB
+        # Empty flash area to allow build
+        FLASH_AREA_IMAGE_0:
+            device: 0
+            offset: 0x08100000
+            size:   0kB
         FLASH_AREA_IMAGE_1:
             device: 0
             offset: 0x08200000
diff --git a/hw/bsp/nucleo-f072rb/nucleo-f072rb_download.sh 
b/hw/bsp/nucleo-f072rb/nucleo-f072rb_download.sh
deleted file mode 100755
index d4bcf66b6..000000000
--- a/hw/bsp/nucleo-f072rb/nucleo-f072rb_download.sh
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/bin/bash
-# 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.
-#
-
-# Called with following variables set:
-#  - CORE_PATH is absolute path to @apache-mynewt-core
-#  - BSP_PATH is absolute path to hw/bsp/bsp_name
-#  - BIN_BASENAME is the path to prefix to target binary,
-#    .elf appended to name is the ELF file
-#  - IMAGE_SLOT is the image slot to download to (for non-mfg-image, non-boot)
-#  - FEATURES holds the target features string
-#  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
-#  - MFG_IMAGE is "1" if this is a manufacturing image
-#  - FLASH_OFFSET contains the flash offset to download to
-#  - BOOT_LOADER is set if downloading a bootloader
-
-. $CORE_PATH/hw/scripts/stlink.sh
-
-if [ "$MFG_IMAGE" ]; then
-    FLASH_OFFSET=0x08000000
-fi
-
-BOOT_LOADER=1
-
-common_file_to_load
-stlink_load
diff --git a/hw/bsp/nucleo-f072rb/pkg.yml b/hw/bsp/nucleo-f072rb/pkg.yml
index 22c26efe9..6eb01bd18 100644
--- a/hw/bsp/nucleo-f072rb/pkg.yml
+++ b/hw/bsp/nucleo-f072rb/pkg.yml
@@ -37,3 +37,4 @@ pkg.deps:
     - "@apache-mynewt-core/hw/mcu/stm/stm32f0xx"
     - "@apache-mynewt-core/libc"
     - "@apache-mynewt-core/boot/startup"
+    - "@apache-mynewt-core/hw/scripts"
diff --git a/hw/bsp/nucleo-f072rb/syscfg.yml b/hw/bsp/nucleo-f072rb/syscfg.yml
index c346077f4..724442108 100644
--- a/hw/bsp/nucleo-f072rb/syscfg.yml
+++ b/hw/bsp/nucleo-f072rb/syscfg.yml
@@ -17,7 +17,16 @@
 # under the License.
 #
 
+syscfg.defs:
+    BOOT_LOADER:
+        description: 'Build everything as bootloader'
+        value: 1
+
 syscfg.vals:
+    MYNEWT_DOWNLOADER: stflash
+    MYNEWT_DOWNLOADER_MFG_IMAGE_FLASH_OFFSET: 0x08000000
+    JLINK_TARGET: STM32F072RB
+
     STM32_FLASH_SIZE_KB: 128
     MCU_RAM_START: 0x20000000
     MCU_RAM_SIZE: 0x4000
diff --git a/hw/bsp/nucleo-f401re/bsp.yml b/hw/bsp/nucleo-f401re/bsp.yml
index 8f1769d9a..f417447f2 100644
--- a/hw/bsp/nucleo-f401re/bsp.yml
+++ b/hw/bsp/nucleo-f401re/bsp.yml
@@ -23,7 +23,7 @@ bsp.maker: "STMicroelectronics"
 bsp.arch: cortex_m4
 bsp.compiler: compiler/arm-none-eabi-m4
 bsp.linkerscript: autogenerated
-bsp.downloadscript: "hw/bsp/nucleo-f401re/nucleo-f401re_download.sh"
+bsp.downloadscript: "hw/scripts/download.sh"
 bsp.debugscript: "hw/bsp/nucleo-f401re/nucleo-f401re_debug.sh"
 
 bsp.flash_map:
diff --git a/hw/bsp/nucleo-f401re/nucleo-f401re_download.sh 
b/hw/bsp/nucleo-f401re/nucleo-f401re_download.sh
deleted file mode 100755
index 0666699d9..000000000
--- a/hw/bsp/nucleo-f401re/nucleo-f401re_download.sh
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/bin/sh
-# 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.
-#
-
-# Called with following variables set:
-#  - CORE_PATH is absolute path to @apache-mynewt-core
-#  - BSP_PATH is absolute path to hw/bsp/bsp_name
-#  - BIN_BASENAME is the path to prefix to target binary,
-#    .elf appended to name is the ELF file
-#  - IMAGE_SLOT is the image slot to download to (for non-mfg-image, non-boot)
-#  - FEATURES holds the target features string
-#  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
-#  - MFG_IMAGE is "1" if this is a manufacturing image
-#  - FLASH_OFFSET contains the flash offset to download to
-#  - BOOT_LOADER is set if downloading a bootloader
-
-. $CORE_PATH/hw/scripts/openocd.sh
-
-CFG="-f board/st_nucleo_f4.cfg"
-
-if [ "$MFG_IMAGE" ]; then
-    FLASH_OFFSET=0x08000000
-fi
-
-common_file_to_load
-openocd_load
-openocd_reset_run
diff --git a/hw/bsp/nucleo-f401re/pkg.yml b/hw/bsp/nucleo-f401re/pkg.yml
index 43e0d2d7c..ca6d9f446 100644
--- a/hw/bsp/nucleo-f401re/pkg.yml
+++ b/hw/bsp/nucleo-f401re/pkg.yml
@@ -37,3 +37,4 @@ pkg.deps:
     - "@apache-mynewt-core/hw/mcu/stm/stm32f4xx"
     - "@apache-mynewt-core/libc"
     - "@apache-mynewt-core/boot/startup"
+    - "@apache-mynewt-core/hw/scripts"
diff --git a/hw/bsp/nucleo-f401re/syscfg.yml b/hw/bsp/nucleo-f401re/syscfg.yml
index e18b128f3..02f9b8738 100644
--- a/hw/bsp/nucleo-f401re/syscfg.yml
+++ b/hw/bsp/nucleo-f401re/syscfg.yml
@@ -18,6 +18,11 @@
 #
 
 syscfg.vals:
+    MYNEWT_DOWNLOADER: openocd
+    MYNEWT_DOWNLOADER_OPENOCD_BOARD: board/st_nucleo_f4.cfg
+    MYNEWT_DOWNLOADER_MFG_IMAGE_FLASH_OFFSET: 0x08000000
+    JLINK_TARGET: STM32F401RE
+
     STM32_FLASH_SIZE_KB: 512
     STM32_FLASH_NUM_AREAS: 8
     MCU_RAM_START: 0x20000000
diff --git a/hw/bsp/nucleo-f411re/nucleo-f411re_download.sh 
b/hw/bsp/nucleo-f411re/nucleo-f411re_download.sh
deleted file mode 100755
index f8e57889c..000000000
--- a/hw/bsp/nucleo-f411re/nucleo-f411re_download.sh
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/bin/sh
-# 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.
-#
-
-# Called with following variables set:
-#  - CORE_PATH is absolute path to @apache-mynewt-core
-#  - BSP_PATH is absolute path to hw/bsp/bsp_name
-#  - BIN_BASENAME is the path to prefix to target binary,
-#    .elf appended to name is the ELF file
-#  - IMAGE_SLOT is the image slot to download to (for non-mfg-image, non-boot)
-#  - FEATURES holds the target features string
-#  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
-#  - MFG_IMAGE is "1" if this is a manufacturing image
-#  - FLASH_OFFSET contains the flash offset to download to
-#  - BOOT_LOADER is set if downloading a bootloader
-
-. $CORE_PATH/hw/scripts/stlink.sh
-
-if [ "$MFG_IMAGE" ]; then
-    FLASH_OFFSET=0x08000000
-fi
-
-common_file_to_load
-stlink_load
-
diff --git a/hw/bsp/nucleo-f413zh/bsp.yml b/hw/bsp/nucleo-f413zh/bsp.yml
index d23d63b1e..f2320307c 100644
--- a/hw/bsp/nucleo-f413zh/bsp.yml
+++ b/hw/bsp/nucleo-f413zh/bsp.yml
@@ -23,7 +23,7 @@ bsp.maker: "STMicroelectronics"
 bsp.arch: cortex_m4
 bsp.compiler: compiler/arm-none-eabi-m4
 bsp.linkerscript: autogenerated
-bsp.downloadscript: "hw/bsp/nucleo-f413zh/nucleo-f413zh_download.sh"
+bsp.downloadscript: "hw/scripts/download.sh"
 bsp.debugscript: "hw/bsp/nucleo-f413zh/nucleo-f413zh_debug.sh"
 
 bsp.flash_map:
diff --git a/hw/bsp/nucleo-f413zh/nucleo-f413zh_download.sh 
b/hw/bsp/nucleo-f413zh/nucleo-f413zh_download.sh
deleted file mode 100755
index 14b94cef2..000000000
--- a/hw/bsp/nucleo-f413zh/nucleo-f413zh_download.sh
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/sh
-# 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.
-#
-
-# Called with following variables set:
-#  - CORE_PATH is absolute path to @apache-mynewt-core
-#  - BSP_PATH is absolute path to hw/bsp/bsp_name
-#  - BIN_BASENAME is the path to prefix to target binary,
-#    .elf appended to name is the ELF file
-#  - IMAGE_SLOT is the image slot to download to (for non-mfg-image, non-boot)
-#  - FEATURES holds the target features string
-#  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
-#  - MFG_IMAGE is "1" if this is a manufacturing image
-#  - FLASH_OFFSET contains the flash offset to download to
-#  - BOOT_LOADER is set if downloading a bootloader
-. $CORE_PATH/hw/scripts/stlink.sh
-
-if [ "$MFG_IMAGE" ]; then
-    FLASH_OFFSET=0x08000000
-fi
-
-common_file_to_load
-stlink_load 
diff --git a/hw/bsp/nucleo-f413zh/pkg.yml b/hw/bsp/nucleo-f413zh/pkg.yml
index 9ba2ec099..323542872 100644
--- a/hw/bsp/nucleo-f413zh/pkg.yml
+++ b/hw/bsp/nucleo-f413zh/pkg.yml
@@ -38,3 +38,4 @@ pkg.deps:
     - "@apache-mynewt-core/hw/mcu/stm/stm32f4xx"
     - "@apache-mynewt-core/libc"
     - "@apache-mynewt-core/boot/startup"
+    - "@apache-mynewt-core/hw/scripts"
diff --git a/hw/bsp/nucleo-f413zh/syscfg.yml b/hw/bsp/nucleo-f413zh/syscfg.yml
index 70de06f57..92d3d589c 100644
--- a/hw/bsp/nucleo-f413zh/syscfg.yml
+++ b/hw/bsp/nucleo-f413zh/syscfg.yml
@@ -18,6 +18,10 @@
 #
 
 syscfg.vals:
+    MYNEWT_DOWNLOADER: stflash
+    MYNEWT_DOWNLOADER_MFG_IMAGE_FLASH_OFFSET: 0x08000000
+    JLINK_TARGET: STM32F413ZH
+
     STM32_FLASH_SIZE_KB: 1536
     STM32_FLASH_NUM_AREAS: 16
     MCU_RAM_START: 0x20000000
diff --git a/hw/bsp/nucleo-f439zi/bsp.yml b/hw/bsp/nucleo-f439zi/bsp.yml
index 552d31fec..923c4df76 100644
--- a/hw/bsp/nucleo-f439zi/bsp.yml
+++ b/hw/bsp/nucleo-f439zi/bsp.yml
@@ -23,7 +23,7 @@ bsp.maker: "STMicroelectronics"
 bsp.arch: cortex_m4
 bsp.compiler: compiler/arm-none-eabi-m4
 bsp.linkerscript: autogenerated
-bsp.downloadscript: "hw/bsp/nucleo-f439zi/nucleo-f439zi_download.sh"
+bsp.downloadscript: "hw/scripts/download.sh"
 bsp.debugscript: "hw/bsp/nucleo-f439zi/nucleo-f439zi_debug.sh"
 
 bsp.flash_map:
diff --git a/hw/bsp/nucleo-f439zi/nucleo-f439zi_download.sh 
b/hw/bsp/nucleo-f439zi/nucleo-f439zi_download.sh
deleted file mode 100755
index f224f149a..000000000
--- a/hw/bsp/nucleo-f439zi/nucleo-f439zi_download.sh
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/sh
-# 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.
-#
-
-# Called with following variables set:
-#  - CORE_PATH is absolute path to @apache-mynewt-core
-#  - BSP_PATH is absolute path to hw/bsp/bsp_name
-#  - BIN_BASENAME is the path to prefix to target binary,
-#    .elf appended to name is the ELF file
-#  - IMAGE_SLOT is the image slot to download to (for non-mfg-image, non-boot)
-#  - FEATURES holds the target features string
-#  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
-#  - MFG_IMAGE is "1" if this is a manufacturing image
-#  - FLASH_OFFSET contains the flash offset to download to
-#  - BOOT_LOADER is set if downloading a bootloader
-. $CORE_PATH/hw/scripts/stlink.sh
-
-if [ "$MFG_IMAGE" ]; then
-    FLASH_OFFSET=0x08000000
-fi
-
-common_file_to_load
-stlink_load
diff --git a/hw/bsp/nucleo-f439zi/pkg.yml b/hw/bsp/nucleo-f439zi/pkg.yml
index ba1d6cae3..2d6da4b78 100644
--- a/hw/bsp/nucleo-f439zi/pkg.yml
+++ b/hw/bsp/nucleo-f439zi/pkg.yml
@@ -38,3 +38,4 @@ pkg.deps:
     - "@apache-mynewt-core/hw/mcu/stm/stm32f4xx"
     - "@apache-mynewt-core/libc"
     - "@apache-mynewt-core/boot/startup"
+    - "@apache-mynewt-core/hw/scripts"
diff --git a/hw/bsp/nucleo-f439zi/syscfg.yml b/hw/bsp/nucleo-f439zi/syscfg.yml
index 2d251c2ec..4dbb7036b 100644
--- a/hw/bsp/nucleo-f439zi/syscfg.yml
+++ b/hw/bsp/nucleo-f439zi/syscfg.yml
@@ -18,6 +18,10 @@
 #
 
 syscfg.vals:
+    MYNEWT_DOWNLOADER: stflash
+    MYNEWT_DOWNLOADER_MFG_IMAGE_FLASH_OFFSET: 0x08000000
+    JLINK_TARGET: STM32F439ZI
+
     STM32_FLASH_SIZE_KB: 2048
     STM32_FLASH_NUM_AREAS: 24
     MCU_RAM_START: 0x20000000
diff --git a/hw/bsp/nucleo-f746zg/bsp.yml b/hw/bsp/nucleo-f746zg/bsp.yml
index 708639e82..aed844d31 100644
--- a/hw/bsp/nucleo-f746zg/bsp.yml
+++ b/hw/bsp/nucleo-f746zg/bsp.yml
@@ -23,7 +23,7 @@ bsp.maker: "STMicroelectronics"
 bsp.arch: cortex_m7
 bsp.compiler: compiler/arm-none-eabi-m7
 bsp.linkerscript: autogenerated
-bsp.downloadscript: "hw/bsp/nucleo-f746zg/nucleo-f746zg_download.sh"
+bsp.downloadscript: "hw/scripts/download.sh"
 bsp.debugscript: "hw/bsp/nucleo-f746zg/nucleo-f746zg_debug.sh"
 
 bsp.flash_map:
diff --git a/hw/bsp/nucleo-f746zg/nucleo-f746zg_download.sh 
b/hw/bsp/nucleo-f746zg/nucleo-f746zg_download.sh
deleted file mode 100755
index 530b238d1..000000000
--- a/hw/bsp/nucleo-f746zg/nucleo-f746zg_download.sh
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/bin/sh
-# 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.
-#
-
-# Called with following variables set:
-#  - CORE_PATH is absolute path to @apache-mynewt-core
-#  - BSP_PATH is absolute path to hw/bsp/bsp_name
-#  - BIN_BASENAME is the path to prefix to target binary,
-#    .elf appended to name is the ELF file
-#  - IMAGE_SLOT is the image slot to download to (for non-mfg-image, non-boot)
-#  - FEATURES holds the target features string
-#  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
-#  - MFG_IMAGE is "1" if this is a manufacturing image
-#  - FLASH_OFFSET contains the flash offset to download to
-#  - BOOT_LOADER is set if downloading a bootloader
-. $CORE_PATH/hw/scripts/openocd.sh
-
-CFG="-s $BSP_PATH -f nucleo-f746zg.cfg"
-
-if [ "$MFG_IMAGE" ]; then
-    FLASH_OFFSET=0x08000000
-fi
-
-common_file_to_load
-openocd_load
-openocd_reset_run
diff --git a/hw/bsp/olimex-p103/bsp.yml b/hw/bsp/olimex-p103/bsp.yml
index 84303e44f..aa36350ae 100644
--- a/hw/bsp/olimex-p103/bsp.yml
+++ b/hw/bsp/olimex-p103/bsp.yml
@@ -23,16 +23,22 @@ bsp.maker: "Olimex"
 bsp.arch: cortex_m3
 bsp.compiler: compiler/arm-none-eabi-m3
 bsp.linkerscript: "autogenerated"
-bsp.downloadscript: "hw/bsp/olimex-p103/olimex_p103_download.sh"
+bsp.downloadscript: "hw/scripts/download.sh"
 bsp.debugscript: "hw/bsp/olimex-p103/olimex_p103_debug.sh"
 
 bsp.flash_map:
     areas:
         # System areas.
-        FLASH_AREA_IMAGE_0:
+        # Only one flash area for code
+        FLASH_AREA_BOOTLOADER:
             device: 0
             offset: 0x08000000
             size: 112kB
+        # Empty flash area to allow build
+        FLASH_AREA_IMAGE_0:
+            device: 0
+            offset: 0x08020000
+            size: 0kB
 
         # User areas.
         FLASH_AREA_REBOOT_LOG:
diff --git a/hw/bsp/olimex-p103/olimex_p103_download.sh 
b/hw/bsp/olimex-p103/olimex_p103_download.sh
deleted file mode 100755
index 48eaff7c6..000000000
--- a/hw/bsp/olimex-p103/olimex_p103_download.sh
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/bin/sh
-# 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.
-#
-
-# Called with following variables set:
-#  - CORE_PATH is absolute path to @apache-mynewt-core
-#  - BSP_PATH is absolute path to hw/bsp/bsp_name
-#  - BIN_BASENAME is the path to prefix to target binary,
-#    .elf appended to name is the ELF file
-#  - IMAGE_SLOT is the image slot to download to (for non-mfg-image, non-boot)
-#  - FEATURES holds the target features string
-#  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
-#  - MFG_IMAGE is "1" if this is a manufacturing image
-#  - FLASH_OFFSET contains the flash offset to download to
-#  - BOOT_LOADER is set if downloading a bootloader
-. $CORE_PATH/hw/scripts/openocd.sh
-
-CFG="-s $BSP_PATH -f olimex_p103.cfg"
-
-if [ "$MFG_IMAGE" ]; then
-    FLASH_OFFSET=0x08000000
-fi
-
-BOOT_LOADER=1
-
-common_file_to_load
-openocd_load
-openocd_reset_run
diff --git a/hw/bsp/olimex-p103/pkg.yml b/hw/bsp/olimex-p103/pkg.yml
index 8ae7dc126..21e3105ae 100644
--- a/hw/bsp/olimex-p103/pkg.yml
+++ b/hw/bsp/olimex-p103/pkg.yml
@@ -32,3 +32,4 @@ pkg.deps:
     - "@apache-mynewt-core/hw/mcu/stm/stm32f1xx"
     - "@apache-mynewt-core/libc"
     - "@apache-mynewt-core/boot/startup"
+    - "@apache-mynewt-core/hw/scripts"
diff --git a/hw/bsp/olimex-p103/syscfg.yml b/hw/bsp/olimex-p103/syscfg.yml
index d3e124e15..8eb28eda1 100644
--- a/hw/bsp/olimex-p103/syscfg.yml
+++ b/hw/bsp/olimex-p103/syscfg.yml
@@ -17,7 +17,17 @@
 # under the License.
 #
 
+syscfg.defs:
+    BOOT_LOADER:
+        description: 'Build everything as bootloader'
+        value: 1
+
 syscfg.vals:
+    MYNEWT_DOWNLOADER: openocd
+    MYNEWT_DOWNLOADER_OPENOCD_CFG: olimex_p103.cfg
+    MYNEWT_DOWNLOADER_MFG_IMAGE_FLASH_OFFSET: 0x08000000
+    JLINK_TARGET: STM32F103RB
+
     STM32_FLASH_SIZE_KB: 128
     MCU_RAM_START: 0x20000000
     MCU_RAM_SIZE: 20K
diff --git a/hw/bsp/olimex_stm32-e407_devboard/bsp.yml 
b/hw/bsp/olimex_stm32-e407_devboard/bsp.yml
index 9c4a2f6ac..6a6b18e08 100644
--- a/hw/bsp/olimex_stm32-e407_devboard/bsp.yml
+++ b/hw/bsp/olimex_stm32-e407_devboard/bsp.yml
@@ -23,7 +23,7 @@ bsp.maker: "Olimex"
 bsp.arch: cortex_m4
 bsp.compiler: compiler/arm-none-eabi-m4
 bsp.linkerscript: autogenerated
-bsp.downloadscript: 
"hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_download.sh"
+bsp.downloadscript: "hw/scripts/download.sh"
 bsp.debugscript: 
"hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_debug.sh"
 
 bsp.flash_map:
diff --git 
a/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_download.sh 
b/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_download.sh
deleted file mode 100755
index b58079567..000000000
--- a/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_download.sh
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/bin/sh
-# 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 is absolute path to @apache-mynewt-core
-#  - BSP_PATH is absolute path to hw/bsp/bsp_name
-#  - BIN_BASENAME is the path to prefix to target binary,
-#    .elf appended to name is the ELF file
-#  - IMAGE_SLOT is the image slot to download to (for non-mfg-image, non-boot)
-#  - FEATURES holds the target features string
-#  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
-#  - MFG_IMAGE is "1" if this is a manufacturing image
-#  - FLASH_OFFSET contains the flash offset to download to
-#  - BOOT_LOADER is set if downloading a bootloader
-
-. $CORE_PATH/hw/scripts/openocd.sh
-
-CFG="-f interface/ftdi/olimex-arm-usb-tiny-h.cfg -s $BSP_PATH -f 
target/stm32f4x.cfg"
-
-if [ "$MFG_IMAGE" ]; then
-    FLASH_OFFSET=0x08000000
-fi
-
-common_file_to_load
-openocd_load
-openocd_reset_run
diff --git a/hw/bsp/olimex_stm32-e407_devboard/pkg.yml 
b/hw/bsp/olimex_stm32-e407_devboard/pkg.yml
index 473630208..e9de0f14e 100644
--- a/hw/bsp/olimex_stm32-e407_devboard/pkg.yml
+++ b/hw/bsp/olimex_stm32-e407_devboard/pkg.yml
@@ -38,3 +38,4 @@ pkg.deps:
     - "@apache-mynewt-core/hw/mcu/stm/stm32f4xx"
     - "@apache-mynewt-core/libc"
     - "@apache-mynewt-core/boot/startup"
+    - "@apache-mynewt-core/hw/scripts"
diff --git a/hw/bsp/olimex_stm32-e407_devboard/syscfg.yml 
b/hw/bsp/olimex_stm32-e407_devboard/syscfg.yml
index 85e4bf02b..f86f86503 100644
--- a/hw/bsp/olimex_stm32-e407_devboard/syscfg.yml
+++ b/hw/bsp/olimex_stm32-e407_devboard/syscfg.yml
@@ -17,6 +17,12 @@
 #
 
 syscfg.vals:
+    MYNEWT_DOWNLOADER: openocd
+    MYNEWT_DOWNLOADER_OPENOCD_INTERFACE: 
interface/ftdi/olimex-arm-usb-tiny-h.cfg
+    MYNEWT_DOWNLOADER_OPENOCD_BOARD: target/stm32f4x.cfg
+    MYNEWT_DOWNLOADER_MFG_IMAGE_FLASH_OFFSET: 0x08000000
+    JLINK_TARGET: STM32F407ZG
+
     STM32_FLASH_SIZE_KB: 1024
     STM32_FLASH_NUM_AREAS: 12
     MCU_RAM_START: 0x20000000
diff --git a/hw/bsp/stm32f411discovery/bsp.yml 
b/hw/bsp/stm32f411discovery/bsp.yml
index 81a77f720..92a986ae8 100644
--- a/hw/bsp/stm32f411discovery/bsp.yml
+++ b/hw/bsp/stm32f411discovery/bsp.yml
@@ -23,7 +23,7 @@ bsp.maker: "STMicroelectronics"
 bsp.arch: cortex_m4
 bsp.compiler: compiler/arm-none-eabi-m4
 bsp.linkerscript: autogenerated
-bsp.downloadscript: "hw/bsp/stm32f411discovery/stm32f411discovery_download.sh"
+bsp.downloadscript: "hw/scripts/download.sh"
 bsp.debugscript: "hw/bsp/stm32f411discovery/stm32f411discovery_debug.sh"
 
 bsp.flash_map:
diff --git a/hw/bsp/stm32f411discovery/pkg.yml 
b/hw/bsp/stm32f411discovery/pkg.yml
index dfea62b7c..ab5a549d1 100644
--- a/hw/bsp/stm32f411discovery/pkg.yml
+++ b/hw/bsp/stm32f411discovery/pkg.yml
@@ -38,3 +38,4 @@ pkg.deps:
     - "@apache-mynewt-core/hw/mcu/stm/stm32f4xx"
     - "@apache-mynewt-core/libc"
     - "@apache-mynewt-core/boot/startup"
+    - "@apache-mynewt-core/hw/scripts"
diff --git a/hw/bsp/stm32f411discovery/stm32f411discovery_download.sh 
b/hw/bsp/stm32f411discovery/stm32f411discovery_download.sh
deleted file mode 100755
index 55f86d47d..000000000
--- a/hw/bsp/stm32f411discovery/stm32f411discovery_download.sh
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/sh
-# 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.
-#
-
-# Called with following variables set:
-#  - CORE_PATH is absolute path to @apache-mynewt-core
-#  - BSP_PATH is absolute path to hw/bsp/bsp_name
-#  - BIN_BASENAME is the path to prefix to target binary,
-#    .elf appended to name is the ELF file
-#  - IMAGE_SLOT is the image slot to download to (for non-mfg-image, non-boot)
-#  - FEATURES holds the target features string
-#  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
-#  - MFG_IMAGE is "1" if this is a manufacturing image
-#  - FLASH_OFFSET contains the flash offset to download to
-#  - BOOT_LOADER is set if downloading a bootloader
-. $CORE_PATH/hw/scripts/stlink.sh
-
-if [ "$MFG_IMAGE" ]; then
-    FLASH_OFFSET=0x08000000
-fi
-
-common_file_to_load
-stlink_load
diff --git a/hw/bsp/stm32f411discovery/syscfg.yml 
b/hw/bsp/stm32f411discovery/syscfg.yml
index 43d4cc35f..683838143 100644
--- a/hw/bsp/stm32f411discovery/syscfg.yml
+++ b/hw/bsp/stm32f411discovery/syscfg.yml
@@ -18,6 +18,10 @@
 #
 
 syscfg.vals:
+    MYNEWT_DOWNLOADER: stflash
+    MYNEWT_DOWNLOADER_MFG_IMAGE_FLASH_OFFSET: 0x08000000
+    JLINK_TARGET: STM32F411VE
+
     STM32_FLASH_SIZE_KB: 512
     STM32_FLASH_NUM_AREAS: 8
     MCU_RAM_START: 0x20000000
diff --git a/hw/bsp/stm32f429discovery/bsp.yml 
b/hw/bsp/stm32f429discovery/bsp.yml
index 0daaabe71..5e72f3496 100644
--- a/hw/bsp/stm32f429discovery/bsp.yml
+++ b/hw/bsp/stm32f429discovery/bsp.yml
@@ -23,7 +23,7 @@ bsp.maker: "STMicroelectronics"
 bsp.arch: cortex_m4
 bsp.compiler: compiler/arm-none-eabi-m4
 bsp.linkerscript: autogenerated
-bsp.downloadscript: "hw/bsp/stm32f429discovery/stm32f429discovery_download.sh"
+bsp.downloadscript: "hw/scripts/download.sh"
 bsp.debugscript: "hw/bsp/stm32f429discovery/stm32f429discovery_debug.sh"
 
 bsp.flash_map:
diff --git a/hw/bsp/stm32f429discovery/pkg.yml 
b/hw/bsp/stm32f429discovery/pkg.yml
index bba941659..f90a22805 100644
--- a/hw/bsp/stm32f429discovery/pkg.yml
+++ b/hw/bsp/stm32f429discovery/pkg.yml
@@ -36,3 +36,4 @@ pkg.deps:
     - "@apache-mynewt-core/hw/mcu/stm/stm32f4xx"
     - "@apache-mynewt-core/libc"
     - "@apache-mynewt-core/boot/startup"
+    - "@apache-mynewt-core/hw/scripts"
diff --git a/hw/bsp/stm32f429discovery/stm32f429discovery_download.sh 
b/hw/bsp/stm32f429discovery/stm32f429discovery_download.sh
deleted file mode 100755
index 8d7e558f5..000000000
--- a/hw/bsp/stm32f429discovery/stm32f429discovery_download.sh
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/bin/sh
-# 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.
-#
-
-# Called with following variables set:
-#  - CORE_PATH is absolute path to @apache-mynewt-core
-#  - BSP_PATH is absolute path to hw/bsp/bsp_name
-#  - BIN_BASENAME is the path to prefix to target binary,
-#    .elf appended to name is the ELF file
-#  - IMAGE_SLOT is the image slot to download to (for non-mfg-image, non-boot)
-#  - FEATURES holds the target features string
-#  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
-#  - MFG_IMAGE is "1" if this is a manufacturing image
-#  - FLASH_OFFSET contains the flash offset to download to
-#  - BOOT_LOADER is set if downloading a bootloader
-. $CORE_PATH/hw/scripts/openocd.sh
-
-CFG="-f board/stm32f429discovery.cfg"
-
-if [ "$MFG_IMAGE" ]; then
-    FLASH_OFFSET=0x08000000
-fi
-
-common_file_to_load
-openocd_load
-openocd_reset_run
diff --git a/hw/bsp/stm32f429discovery/syscfg.yml 
b/hw/bsp/stm32f429discovery/syscfg.yml
index cdce90744..c210c726f 100644
--- a/hw/bsp/stm32f429discovery/syscfg.yml
+++ b/hw/bsp/stm32f429discovery/syscfg.yml
@@ -18,6 +18,11 @@
 #
 
 syscfg.vals:
+    MYNEWT_DOWNLOADER: openocd
+    MYNEWT_DOWNLOADER_OPENOCD_BOARD: board/stm32f429discovery.cfg
+    MYNEWT_DOWNLOADER_MFG_IMAGE_FLASH_OFFSET: 0x08000000
+    JLINK_TARGET: STM32F429ZI
+
     STM32_FLASH_SIZE_KB: 2048
     STM32_FLASH_NUM_AREAS: 24
     MCU_RAM_START: 0x20000000
diff --git a/hw/bsp/stm32f4discovery/bsp.yml b/hw/bsp/stm32f4discovery/bsp.yml
index ece168870..8e9148a37 100644
--- a/hw/bsp/stm32f4discovery/bsp.yml
+++ b/hw/bsp/stm32f4discovery/bsp.yml
@@ -23,7 +23,7 @@ bsp.maker: "STMicroelectronics"
 bsp.arch: cortex_m4
 bsp.compiler: compiler/arm-none-eabi-m4
 bsp.linkerscript: autogenerated
-bsp.downloadscript: "hw/bsp/stm32f4discovery/stm32f4discovery_download.sh"
+bsp.downloadscript: "hw/scripts/download.sh"
 bsp.debugscript: "hw/bsp/stm32f4discovery/stm32f4discovery_debug.sh"
 
 bsp.flash_map:
diff --git a/hw/bsp/stm32f4discovery/pkg.yml b/hw/bsp/stm32f4discovery/pkg.yml
index 6556dff7b..11751307b 100644
--- a/hw/bsp/stm32f4discovery/pkg.yml
+++ b/hw/bsp/stm32f4discovery/pkg.yml
@@ -36,3 +36,4 @@ pkg.deps:
     - "@apache-mynewt-core/hw/mcu/stm/stm32f4xx"
     - "@apache-mynewt-core/libc"
     - "@apache-mynewt-core/boot/startup"
+    - "@apache-mynewt-core/hw/scripts"
diff --git a/hw/bsp/stm32f4discovery/stm32f4discovery_download.sh 
b/hw/bsp/stm32f4discovery/stm32f4discovery_download.sh
deleted file mode 100755
index 7a30cf5e9..000000000
--- a/hw/bsp/stm32f4discovery/stm32f4discovery_download.sh
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/bin/sh
-# 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.
-#
-
-# Called with following variables set:
-#  - CORE_PATH is absolute path to @apache-mynewt-core
-#  - BSP_PATH is absolute path to hw/bsp/bsp_name
-#  - BIN_BASENAME is the path to prefix to target binary,
-#    .elf appended to name is the ELF file
-#  - IMAGE_SLOT is the image slot to download to (for non-mfg-image, non-boot)
-#  - FEATURES holds the target features string
-#  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
-#  - MFG_IMAGE is "1" if this is a manufacturing image
-#  - FLASH_OFFSET contains the flash offset to download to
-#  - BOOT_LOADER is set if downloading a bootloader
-. $CORE_PATH/hw/scripts/openocd.sh
-
-CFG="-s $BSP_PATH -f f4discovery.cfg"
-
-if [ "$MFG_IMAGE" ]; then
-    FLASH_OFFSET=0x08000000
-fi
-
-common_file_to_load
-openocd_load
-openocd_reset_run
diff --git a/hw/bsp/stm32f4discovery/syscfg.yml 
b/hw/bsp/stm32f4discovery/syscfg.yml
index 82dcc8121..af95b5edb 100644
--- a/hw/bsp/stm32f4discovery/syscfg.yml
+++ b/hw/bsp/stm32f4discovery/syscfg.yml
@@ -18,6 +18,11 @@
 #
 
 syscfg.vals:
+    MYNEWT_DOWNLOADER: openocd
+    MYNEWT_DOWNLOADER_OPENOCD_CFG: f4discovery.cfg
+    MYNEWT_DOWNLOADER_MFG_IMAGE_FLASH_OFFSET: 0x08000000
+    JLINK_TARGET: STM32F407VG
+
     STM32_FLASH_SIZE_KB: 1024
     STM32_FLASH_NUM_AREAS: 12
     MCU_RAM_START: 0x20000000
diff --git a/hw/bsp/stm32f7discovery/bsp.yml b/hw/bsp/stm32f7discovery/bsp.yml
index 0b79ee44d..3f9833498 100644
--- a/hw/bsp/stm32f7discovery/bsp.yml
+++ b/hw/bsp/stm32f7discovery/bsp.yml
@@ -23,7 +23,7 @@ bsp.maker: "STMicroelectronics"
 bsp.arch: cortex_m7
 bsp.compiler: compiler/arm-none-eabi-m7
 bsp.linkerscript: autogenerated
-bsp.downloadscript: "hw/bsp/stm32f7discovery/stm32f7discovery_download.sh"
+bsp.downloadscript: "hw/scripts/download.sh"
 bsp.debugscript: "hw/bsp/stm32f7discovery/stm32f7discovery_debug.sh"
 
 bsp.flash_map:
diff --git a/hw/bsp/stm32f7discovery/stm32f7discovery_download.sh 
b/hw/bsp/stm32f7discovery/stm32f7discovery_download.sh
deleted file mode 100755
index 8d9b3b02d..000000000
--- a/hw/bsp/stm32f7discovery/stm32f7discovery_download.sh
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/bin/sh
-# 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.
-#
-
-# Called with following variables set:
-#  - CORE_PATH is absolute path to @apache-mynewt-core
-#  - BSP_PATH is absolute path to hw/bsp/bsp_name
-#  - BIN_BASENAME is the path to prefix to target binary,
-#    .elf appended to name is the ELF file
-#  - IMAGE_SLOT is the image slot to download to (for non-mfg-image, non-boot)
-#  - FEATURES holds the target features string
-#  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
-#  - MFG_IMAGE is "1" if this is a manufacturing image
-#  - FLASH_OFFSET contains the flash offset to download to
-#  - BOOT_LOADER is set if downloading a bootloader
-. $CORE_PATH/hw/scripts/openocd.sh
-
-CFG="-s $BSP_PATH -f stm32f7discovery.cfg"
-
-if [ "$MFG_IMAGE" ]; then
-    FLASH_OFFSET=0x08000000
-fi
-
-common_file_to_load
-openocd_load
-openocd_reset_run
diff --git a/hw/bsp/stm32l152discovery/bsp.yml 
b/hw/bsp/stm32l152discovery/bsp.yml
index adc2531ae..49a86fb05 100644
--- a/hw/bsp/stm32l152discovery/bsp.yml
+++ b/hw/bsp/stm32l152discovery/bsp.yml
@@ -28,7 +28,7 @@ bsp.linkerscript:
 bsp.linkerscript.BOOT_LOADER.OVERWRITE:
     - "hw/bsp/stm32l152discovery/boot-stm32l152discovery.ld"
     - "@apache-mynewt-core/hw/mcu/stm/stm32l1xx/stm32l152.ld"
-bsp.downloadscript: "hw/bsp/stm32l152discovery/stm32l152discovery_download.sh"
+bsp.downloadscript: "hw/scripts/download.sh"
 bsp.debugscript: "hw/bsp/stm32l152discovery/stm32l152discovery_debug.sh"
 
 bsp.flash_map:
diff --git a/hw/bsp/stm32l152discovery/pkg.yml 
b/hw/bsp/stm32l152discovery/pkg.yml
index 5dc3323a7..d02a943ff 100644
--- a/hw/bsp/stm32l152discovery/pkg.yml
+++ b/hw/bsp/stm32l152discovery/pkg.yml
@@ -32,3 +32,4 @@ pkg.cflags: -DSTM32L152xC
 pkg.deps:
     - "@apache-mynewt-core/hw/mcu/stm/stm32l1xx"
     - "@apache-mynewt-core/libc"
+    - "@apache-mynewt-core/hw/scripts"
diff --git a/hw/bsp/stm32l152discovery/stm32l152discovery_download.sh 
b/hw/bsp/stm32l152discovery/stm32l152discovery_download.sh
deleted file mode 100755
index 5d6d649ab..000000000
--- a/hw/bsp/stm32l152discovery/stm32l152discovery_download.sh
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/bin/sh
-# 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.
-#
-
-# Called with following variables set:
-#  - CORE_PATH is absolute path to @apache-mynewt-core
-#  - BSP_PATH is absolute path to hw/bsp/bsp_name
-#  - BIN_BASENAME is the path to prefix to target binary,
-#    .elf appended to name is the ELF file
-#  - IMAGE_SLOT is the image slot to download to (for non-mfg-image, non-boot)
-#  - FEATURES holds the target features string
-#  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
-#  - MFG_IMAGE is "1" if this is a manufacturing image
-#  - FLASH_OFFSET contains the flash offset to download to
-#  - BOOT_LOADER is set if downloading a bootloader
-
-. $CORE_PATH/hw/scripts/stlink.sh
-
-if [ "$MFG_IMAGE" ]; then
-    FLASH_OFFSET=0x08000000
-fi
-
-common_file_to_load
-stlink_load
diff --git a/hw/bsp/stm32l152discovery/syscfg.yml 
b/hw/bsp/stm32l152discovery/syscfg.yml
index 1e995d26d..05119d737 100644
--- a/hw/bsp/stm32l152discovery/syscfg.yml
+++ b/hw/bsp/stm32l152discovery/syscfg.yml
@@ -18,6 +18,10 @@
 #
 
 syscfg.vals:
+    MYNEWT_DOWNLOADER: stflash
+    MYNEWT_DOWNLOADER_MFG_IMAGE_FLASH_OFFSET: 0x08000000
+    JLINK_TARGET: STM32L152RC
+
     STM32_FLASH_SIZE_KB: 256
     STM32_CLOCK_VOLTAGESCALING_CONFIG: 'PWR_REGULATOR_VOLTAGE_SCALE1'
     STM32_CLOCK_LSI: 1

Reply via email to