From 37cdfeed9bcae8b37e955e53713bbc136a00da20 Mon Sep 17 00:00:00 2001 From: raiden00pl Date: Tue, 30 May 2023 12:22:21 +0200 Subject: [PATCH] boards/nrf52840-dk: add MCUboot configurations Added configurations: - mcuboot_loader - MCUboot loader - mcuboot_app - MCUboot compatible application. Needs to be signed manually: imgtool.py sign nuttx.hex nuttx_img.hex --align 8 -v 1.0.0 -H 0x200 -S 0x30000 --pad-header --pad --- .../nrf52840-dk/configs/mcuboot_app/defconfig | 49 +++++++++++++++++++ .../configs/mcuboot_loader/defconfig | 39 +++++++++++++++ .../arm/nrf52/nrf52840-dk/scripts/Make.defs | 7 ++- .../arm/nrf52/nrf52840-dk/src/nrf52_bringup.c | 12 +++++ 4 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 boards/arm/nrf52/nrf52840-dk/configs/mcuboot_app/defconfig create mode 100644 boards/arm/nrf52/nrf52840-dk/configs/mcuboot_loader/defconfig diff --git a/boards/arm/nrf52/nrf52840-dk/configs/mcuboot_app/defconfig b/boards/arm/nrf52/nrf52840-dk/configs/mcuboot_app/defconfig new file mode 100644 index 0000000000..32dd332354 --- /dev/null +++ b/boards/arm/nrf52/nrf52840-dk/configs/mcuboot_app/defconfig @@ -0,0 +1,49 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_ARCH_FPU is not set +# CONFIG_NSH_DISABLE_IFCONFIG is not set +# CONFIG_NSH_DISABLE_PS is not set +CONFIG_ALLOW_BSD_COMPONENTS=y +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="nrf52840-dk" +CONFIG_ARCH_BOARD_COMMON=y +CONFIG_ARCH_BOARD_NRF52840_DK=y +CONFIG_ARCH_CHIP="nrf52" +CONFIG_ARCH_CHIP_NRF52840=y +CONFIG_ARCH_CHIP_NRF52=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH_STDARG_H=y +CONFIG_BOARD_LOOPSPERMSEC=5500 +CONFIG_BUILTIN=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_EXAMPLES_HELLO=y +CONFIG_EXAMPLES_MCUBOOT_SLOT_CONFIRM=y +CONFIG_EXAMPLES_MCUBOOT_SWAP_TEST=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INTELHEX_BINARY=y +CONFIG_MM_REGIONS=2 +CONFIG_NRF52_APP_FORMAT_MCUBOOT=y +CONFIG_NRF52_PROGMEM_OTA_PARTITION=y +CONFIG_NRF52_UART0=y +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_LINELEN=64 +CONFIG_NSH_READLINE=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAM_SIZE=65535 +CONFIG_RAM_START=0x20000000 +CONFIG_RAW_BINARY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_START_DAY=26 +CONFIG_START_MONTH=3 +CONFIG_SYMTAB_ORDEREDBYNAME=y +CONFIG_SYSTEM_NSH=y +CONFIG_TASK_NAME_SIZE=0 +CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/arm/nrf52/nrf52840-dk/configs/mcuboot_loader/defconfig b/boards/arm/nrf52/nrf52840-dk/configs/mcuboot_loader/defconfig new file mode 100644 index 0000000000..4e41a9c361 --- /dev/null +++ b/boards/arm/nrf52/nrf52840-dk/configs/mcuboot_loader/defconfig @@ -0,0 +1,39 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_ARCH_FPU is not set +CONFIG_ALLOW_BSD_COMPONENTS=y +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="nrf52840-dk" +CONFIG_ARCH_BOARD_COMMON=y +CONFIG_ARCH_BOARD_NRF52840_DK=y +CONFIG_ARCH_CHIP="nrf52" +CONFIG_ARCH_CHIP_NRF52840=y +CONFIG_ARCH_CHIP_NRF52=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH_STDARG_H=y +CONFIG_BOARD_LOOPSPERMSEC=5500 +CONFIG_BOOT_MCUBOOT=y +CONFIG_INIT_ENTRYPOINT="mcuboot_loader_main" +CONFIG_INTELHEX_BINARY=y +CONFIG_MCUBOOT_BOOTLOADER=y +CONFIG_MCUBOOT_VERSION="414ac87cfd8d9cedeb781f812ad6f5072e6d8a39" +CONFIG_MM_REGIONS=2 +CONFIG_NRF52_APP_FORMAT_MCUBOOT=y +CONFIG_NRF52_PROGMEM_OTA_PARTITION=y +CONFIG_NRF52_UART0=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAM_SIZE=65535 +CONFIG_RAM_START=0x20000000 +CONFIG_RAW_BINARY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_START_DAY=26 +CONFIG_START_MONTH=3 +CONFIG_SYMTAB_ORDEREDBYNAME=y +CONFIG_TASK_NAME_SIZE=0 +CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/arm/nrf52/nrf52840-dk/scripts/Make.defs b/boards/arm/nrf52/nrf52840-dk/scripts/Make.defs index 63557429d3..ef9347fc3c 100644 --- a/boards/arm/nrf52/nrf52840-dk/scripts/Make.defs +++ b/boards/arm/nrf52/nrf52840-dk/scripts/Make.defs @@ -22,8 +22,11 @@ include $(TOPDIR)/.config include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs -LDSCRIPT = flash_config.ld -ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) +ifeq ($(CONFIG_ARCH_BOARD_COMMON),y) + ARCHSCRIPT += $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)flash_config.ld +else + ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)flash_config.ld +endif ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 diff --git a/boards/arm/nrf52/nrf52840-dk/src/nrf52_bringup.c b/boards/arm/nrf52/nrf52840-dk/src/nrf52_bringup.c index cf44336ee7..cc2ceac865 100644 --- a/boards/arm/nrf52/nrf52840-dk/src/nrf52_bringup.c +++ b/boards/arm/nrf52/nrf52840-dk/src/nrf52_bringup.c @@ -49,6 +49,10 @@ # include "nrf52_timer.h" #endif +#ifdef CONFIG_NRF52_PROGMEM +# include "nrf52_progmem.h" +#endif + #ifdef CONFIG_NRF52_SOFTDEVICE_CONTROLLER # include "nrf52_sdc.h" #endif @@ -283,6 +287,14 @@ int nrf52_bringup(void) } #endif +#ifdef CONFIG_NRF52_PROGMEM + ret = nrf52_progmem_init(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to initialize MTD progmem: %d\n", ret); + } +#endif /* CONFIG_MTD */ + UNUSED(ret); return OK; }