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 253ad046ed4360625ece055354436962a432b2d6 Author: Jerzy Kasenberg <[email protected]> AuthorDate: Fri May 19 14:01:43 2023 +0200 hw/scripts: download: Add support for nrfjprog This change adds support for nrfjprog as an option to flash NRF devices Signed-off-by: Jerzy Kasenberg <[email protected]> --- hw/scripts/download.sh | 5 +++++ hw/scripts/nrfjprog.sh | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ hw/scripts/syscfg.yml | 7 +++++++ 3 files changed, 67 insertions(+) diff --git a/hw/scripts/download.sh b/hw/scripts/download.sh index 78a63195f..840a019c3 100644 --- a/hw/scripts/download.sh +++ b/hw/scripts/download.sh @@ -48,6 +48,11 @@ case "${MYNEWT_VAL_MYNEWT_DOWNLOADER}" in 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 diff --git a/hw/scripts/nrfjprog.sh b/hw/scripts/nrfjprog.sh new file mode 100644 index 000000000..9df2a705c --- /dev/null +++ b/hw/scripts/nrfjprog.sh @@ -0,0 +1,55 @@ +# 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 + +# +# FILE_NAME must contain the name of the file to load +# FLASH_OFFSET must contain the offset in flash where to place it +# +nrfjprog_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 + + if [ -n "${MYNEWT_VAL_NRFJPROG_COPROCESSOR}" ] ; then + NRFJPROG_ARG="${NRFJPROG_ARG} --coprocessor ${MYNEWT_VAL_NRFJPROG_COPROCESSOR}" + fi + arm-none-eabi-objcopy -O ihex -I binary --adjust-vma ${FLASH_OFFSET} ${FILE_NAME} ${BIN_BASENAME}.hex + + echo "Downloading" $FILE_NAME "to" $FLASH_OFFSET + + nrfjprog ${NRFJPROG_ARG} --program ${BIN_BASENAME}.hex --sectorerase + + if [ $? -ne 0 ]; then + exit 1 + fi + nrfjprog --reset + + return 0 +} diff --git a/hw/scripts/syscfg.yml b/hw/scripts/syscfg.yml index 98a76ce92..f0ac27713 100644 --- a/hw/scripts/syscfg.yml +++ b/hw/scripts/syscfg.yml @@ -30,6 +30,8 @@ syscfg.defs: - stflash - openocd - pyocd + # Nordic Semiconductor tool for NRF5x devices + - nrfjprog value: MYNEWT_DEBUGGER: description: > @@ -71,3 +73,8 @@ syscfg.defs: pyocd list --targets shows supported targets. value: + NRFJPROG_COPROCESSOR: + description: > + Some NRF have more then one core. This can specify non-default core + (i.e. CP_NETWORK for NRF5340). + value:
