Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add downloader selection #2997

Merged
merged 8 commits into from
May 26, 2023
2 changes: 1 addition & 1 deletion hw/bsp/nordic_pca10095/bsp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ bsp.linkerscript.BOOT_LOADER.OVERWRITE:
- "hw/bsp/nordic_pca10095/boot-nrf5340.ld"
- "@apache-mynewt-core/hw/mcu/nordic/nrf5340/nrf5340.ld"
bsp.part2linkerscript: "hw/bsp/nordic_pca10095/split-nordic_pca10095.ld"
bsp.downloadscript: "hw/bsp/nordic_pca10095/nordic_pca10095_download.sh"
bsp.downloadscript: "hw/scripts/download.sh"
bsp.debugscript: "hw/bsp/nordic_pca10095/nordic_pca10095_debug.sh"

bsp.flash_map:
Expand Down
1 change: 1 addition & 0 deletions hw/bsp/nordic_pca10095/pkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pkg.cflags.HARDFLOAT:
- -mfloat-abi=hard -mfpu=fpv4-sp-d16

pkg.deps:
- "@apache-mynewt-core/hw/scripts"
- "@apache-mynewt-core/hw/mcu/nordic/nrf5340"
- "@apache-mynewt-core/libc/baselibc"
- "@apache-mynewt-core/sys/flash_map"
Expand Down
5 changes: 5 additions & 0 deletions hw/bsp/nordic_pca10095/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ syscfg.vals:
QSPI_XIP_OFFSET: 0x10000000
FLASH_MAP_SYSINIT_STAGE: 15

# Flasher parameters
MYNEWT_DOWNLOADER: jlink
JLINK_TARGET: NRF5340_XXAA_APP
MYNEWT_DOWNLOADER_MFG_IMAGE_FLASH_OFFSET: 0x0

syscfg.vals.!BOOT_LOADER:
MCU_LFCLK_SOURCE: LFXO
MCU_LFCLK_XO_INTCAP: c9pf
Expand Down
2 changes: 1 addition & 1 deletion hw/bsp/nordic_pca10095_net/bsp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ bsp.linkerscript.BOOT_LOADER.OVERWRITE:
- "hw/bsp/nordic_pca10095_net/boot-nrf5340_net.ld"
- "@apache-mynewt-core/hw/mcu/nordic/nrf5340_net/nrf5340_net.ld"
bsp.part2linkerscript: "hw/bsp/nordic_pca10095_net/split-nordic_pca10095_net.ld"
bsp.downloadscript: "hw/bsp/nordic_pca10095_net/nordic_pca10095_net_download.sh"
bsp.downloadscript: "hw/scripts/download.sh"
bsp.debugscript: "hw/bsp/nordic_pca10095_net/nordic_pca10095_net_debug.sh"

bsp.flash_map:
Expand Down
1 change: 1 addition & 0 deletions hw/bsp/nordic_pca10095_net/pkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pkg.cflags:
- '-DNRF5340_XXAA_NETWORK'

pkg.deps:
- "@apache-mynewt-core/hw/scripts"
- "@apache-mynewt-core/hw/mcu/nordic/nrf5340_net"
- "@apache-mynewt-core/libc/baselibc"
- "@apache-mynewt-core/sys/flash_map"
Expand Down
3 changes: 3 additions & 0 deletions hw/bsp/nordic_pca10095_net/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ syscfg.defs:
value: 0

syscfg.vals:
MYNEWT_DOWNLOADER: jlink
JLINK_TARGET: NRF5340_XXAA_NET
NRFJPROG_COPROCESSOR: CP_NETWORK
# Set default pins for peripherals
UART_0_PIN_TX: 20
UART_0_PIN_RX: 22
Expand Down
4 changes: 1 addition & 3 deletions hw/bsp/nucleo-f411re/bsp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ bsp.linkerscript:
bsp.linkerscript.BOOT_LOADER.OVERWRITE:
- "hw/bsp/nucleo-f411re/boot-nucleo-f411re.ld"
- "@apache-mynewt-core/hw/mcu/stm/stm32f4xx/stm32f411.ld"
bsp.downloadscript: "hw/bsp/nucleo-f411re/nucleo-f411re_download.sh"
bsp.downloadscript: "hw/scripts/download.sh"
bsp.debugscript: "hw/bsp/nucleo-f411re/nucleo-f411re_debug.sh"
bsp.downloadscript.WINDOWS.OVERWRITE: "hw/bsp/nucleo-f411re/nucleo-f411re_download.cmd"
bsp.debugscript.WINDOWS.OVERWRITE: "hw/bsp/nucleo-f411re/nucleo-f411re_debug.cmd"

bsp.flash_map:
areas:
Expand Down
22 changes: 0 additions & 22 deletions hw/bsp/nucleo-f411re/nucleo-f411re_debug.cmd

This file was deleted.

22 changes: 0 additions & 22 deletions hw/bsp/nucleo-f411re/nucleo-f411re_download.cmd

This file was deleted.

1 change: 1 addition & 0 deletions hw/bsp/nucleo-f411re/pkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ pkg.cflags.HARDFLOAT:
pkg.deps:
- "@apache-mynewt-core/hw/mcu/stm/stm32f4xx"
- "@apache-mynewt-core/libc/baselibc"
- "@apache-mynewt-core/hw/scripts"
4 changes: 4 additions & 0 deletions hw/bsp/nucleo-f411re/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,7 @@ syscfg.vals:
I2C_2_PIN_SCL: 'MCU_GPIO_PORTA(8)'
I2C_2_PIN_SDA: 'MCU_GPIO_PORTC(9)'
TIMER_0_TIM: 'TIM9'
MYNEWT_DOWNLOADER: stflash
MYNEWT_DOWNLOADER_MFG_IMAGE_FLASH_OFFSET: 0x08000000
PYOCD_TARGET: stm32f412xe
JLINK_TARGET: STM32F411RE
4 changes: 1 addition & 3 deletions hw/bsp/nucleo-f767zi/bsp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ bsp.linkerscript:
bsp.linkerscript.BOOT_LOADER.OVERWRITE:
- "hw/bsp/nucleo-f767zi/boot-nucleo-f767zi.ld"
- "@apache-mynewt-core/hw/mcu/stm/stm32f7xx/stm32f767.ld"
bsp.downloadscript: "hw/bsp/nucleo-f767zi/nucleo-f767zi_download.sh"
bsp.downloadscript: "hw/scripts/download.sh"
bsp.debugscript: "hw/bsp/nucleo-f767zi/nucleo-f767zi_debug.sh"
bsp.downloadscript.WINDOWS.OVERWRITE: "hw/bsp/nucleo-f767zi/nucleo-f767zi_download.cmd"
bsp.debugscript.WINDOWS.OVERWRITE: "hw/bsp/nucleo-f767zi/nucleo-f767zi_debug.cmd"

bsp.flash_map:
areas:
Expand Down
22 changes: 0 additions & 22 deletions hw/bsp/nucleo-f767zi/nucleo-f767zi_debug.cmd

This file was deleted.

22 changes: 0 additions & 22 deletions hw/bsp/nucleo-f767zi/nucleo-f767zi_download.cmd

This file was deleted.

41 changes: 0 additions & 41 deletions hw/bsp/nucleo-f767zi/nucleo-f767zi_download.sh

This file was deleted.

1 change: 1 addition & 0 deletions hw/bsp/nucleo-f767zi/pkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ pkg.cflags.HARDFLOAT:
pkg.deps:
- "@apache-mynewt-core/hw/mcu/stm/stm32f7xx"
- "@apache-mynewt-core/libc/baselibc"
- "@apache-mynewt-core/hw/scripts"
6 changes: 6 additions & 0 deletions hw/bsp/nucleo-f767zi/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,9 @@ syscfg.vals:
TIMER_0_TIM: 'TIM9'
TIMER_1_TIM: 'TIM10'
TIMER_2_TIM: 'TIM11'
MYNEWT_DOWNLOADER: openocd
MYNEWT_DOWNLOADER_OPENOCD_CFG: nucleo-f767zi.cfg
MYNEWT_DOWNLOADER_OPENOCD_INTERFACE: interface/stlink-v2-1.cfg
MYNEWT_DOWNLOADER_MFG_IMAGE_FLASH_OFFSET: 0x08000000
PYOCD_TARGET: stm32f767zi
JLINK_TARGET: STM32F767ZI
102 changes: 102 additions & 0 deletions hw/scripts/download.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#!/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

if [ "$MFG_IMAGE" ]; then
if [ -z "$MYNEWT_VAL_MYNEWT_DOWNLOADER_MFG_IMAGE_FLASH_OFFSET"] ; then
>&2 echo "Syscfg value MYNEWT_DOWNLOADER_MFG_IMAGE_FLASH_OFFSET not set"
exit -1
fi
FLASH_OFFSET=${MYNEWT_VAL_MYNEWT_DOWNLOADER_MFG_IMAGE_FLASH_OFFSET}
fi

case "${MYNEWT_VAL_MYNEWT_DOWNLOADER}" in
"ezflashcli")
. $CORE_PATH/hw/scripts/ezflashcli.sh
common_file_to_load
ezflashcli_load
;;
"jlink")
. $CORE_PATH/hw/scripts/jlink.sh
if [ -z "${MYNEWT_VAL_JLINK_TARGET}"] ; then
>&2 echo -e "\n\nSyscfg value MYNEWT_DOWNLOADER set to 'jlink' but JLINK_TARGET not set in syscfg."
exit -1
fi
JLINK_DEV=${MYNEWT_VAL_JLINK_TARGET}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we complain if the required variable is not set? The same applies to openocd case.

This might save users some debug time...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea, fix on the way

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

common_file_to_load
jlink_load
;;
"nrfjprog")
. $CORE_PATH/hw/scripts/nrfjprog.sh
common_file_to_load
nrfjprog_load
;;
"openocd")
. $CORE_PATH/hw/scripts/openocd.sh
if [ -n "${MYNEWT_VAL_MYNEWT_DOWNLOADER_OPENOCD_INTERFACE}" ] ; then
CFG="-f ${MYNEWT_VAL_MYNEWT_DOWNLOADER_OPENOCD_INTERFACE}"
fi
if [ -n "${MYNEWT_VAL_MYNEWT_DOWNLOADER_OPENOCD_BOARD}" ] ; then
CFG="${CFG} -f ${MYNEWT_VAL_MYNEWT_DOWNLOADER_OPENOCD_BOARD}"
fi
if [ -n "${MYNEWT_VAL_MYNEWT_DOWNLOADER_OPENOCD_CFG}" ] ; then
CFG="${CFG} -s $BSP_PATH -f ${MYNEWT_VAL_MYNEWT_DOWNLOADER_OPENOCD_CFG}"
fi
if [ -z "${CFG}"] ; then
>&2 echo -e "\n\nSyscfg value MYNEWT_DOWNLOADER set to 'openocd' but none of the following syscfg values is not set:"
>&2 echo -e "\tMYNEWT_DOWNLOADER_OPENOCD_INTERFACE\n\tMYNEWT_DOWNLOADER_OPENOCD_BOARD\n\tMYNEWT_DOWNLOADER_OPENOCD_CFG"
exit -1
fi
common_file_to_load
openocd_load
openocd_reset_run
;;
"pyocd")
. $CORE_PATH/hw/scripts/pyocd.sh
if [ -z "${MYNEWT_VAL_PYOCD_TARGET}" ] ; then
>&2 echo -e "\n\nSyscfg value MYNEWT_DOWNLOADER set to 'pyocd' but PYOCD_TARGET not set in syscfg."
>&2 echo -e "pyocd supported targets can be found with 'pyocd list --targets'\n"
exit -1
fi
TARGET=${MYNEWT_VAL_PYOCD_TARGET}
common_file_to_load
pyocd_load
;;
"stflash")
. $CORE_PATH/hw/scripts/stlink.sh
common_file_to_load
stlink_load
;;
"stm32_programmer_cli")
. $CORE_PATH/hw/scripts/stm32_programmer.sh
common_file_to_load
stlink_load
;;
esac