From 58ad290b0e66d7a2a0ab59b2c422c1573e8cecb5 Mon Sep 17 00:00:00 2001 From: raiden00pl Date: Wed, 31 May 2023 13:15:37 +0200 Subject: [PATCH] boards/nrf5340-dk: add MCUboot configurations for the app core Added configurations: - mcuboot_loader_cpuapp - MCUboot loader - mcuboot_app_cpuapp - 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 0x70000 --pad-header --pad --- .../configs/mcuboot_app_cpuapp/defconfig | 53 +++++++++++++++++++ .../configs/mcuboot_loader_cpuapp/defconfig | 43 +++++++++++++++ boards/arm/nrf53/nrf5340-dk/scripts/Make.defs | 22 +++++--- .../arm/nrf53/nrf5340-dk/src/nrf53_bringup.c | 12 +++++ 4 files changed, 122 insertions(+), 8 deletions(-) create mode 100644 boards/arm/nrf53/nrf5340-dk/configs/mcuboot_app_cpuapp/defconfig create mode 100644 boards/arm/nrf53/nrf5340-dk/configs/mcuboot_loader_cpuapp/defconfig diff --git a/boards/arm/nrf53/nrf5340-dk/configs/mcuboot_app_cpuapp/defconfig b/boards/arm/nrf53/nrf5340-dk/configs/mcuboot_app_cpuapp/defconfig new file mode 100644 index 0000000000..0f3863b53a --- /dev/null +++ b/boards/arm/nrf53/nrf5340-dk/configs/mcuboot_app_cpuapp/defconfig @@ -0,0 +1,53 @@ +# +# 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_NSH_DISABLE_IFCONFIG is not set +# CONFIG_NSH_DISABLE_PS is not set +# CONFIG_STANDARD_SERIAL is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="nrf5340-dk" +CONFIG_ARCH_BOARD_COMMON=y +CONFIG_ARCH_BOARD_NRF5340_DK=y +CONFIG_ARCH_CHIP="nrf53" +CONFIG_ARCH_CHIP_NRF5340=y +CONFIG_ARCH_CHIP_NRF5340_CPUAPP=y +CONFIG_ARCH_CHIP_NRF53=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH_STDARG_H=y +CONFIG_BOARD_LOOPSPERMSEC=5500 +CONFIG_BUILTIN=y +CONFIG_EXAMPLES_HELLO=y +CONFIG_EXAMPLES_MCUBOOT_SLOT_CONFIRM=y +CONFIG_EXAMPLES_MCUBOOT_SWAP_TEST=y +CONFIG_EXPERIMENTAL=y +CONFIG_FAT_LCNAMES=y +CONFIG_FAT_LFN=y +CONFIG_FS_FAT=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INTELHEX_BINARY=y +CONFIG_MM_REGIONS=2 +CONFIG_NRF53_APP_FORMAT_MCUBOOT=y +CONFIG_NRF53_MCUBOOT_HAVE_SCRACH=y +CONFIG_NRF53_PROGMEM_OTA_PARTITION=y +CONFIG_NRF53_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=524288 +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/nrf53/nrf5340-dk/configs/mcuboot_loader_cpuapp/defconfig b/boards/arm/nrf53/nrf5340-dk/configs/mcuboot_loader_cpuapp/defconfig new file mode 100644 index 0000000000..8eaeb6cac6 --- /dev/null +++ b/boards/arm/nrf53/nrf5340-dk/configs/mcuboot_loader_cpuapp/defconfig @@ -0,0 +1,43 @@ +# +# 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_STANDARD_SERIAL is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="nrf5340-dk" +CONFIG_ARCH_BOARD_COMMON=y +CONFIG_ARCH_BOARD_NRF5340_DK=y +CONFIG_ARCH_CHIP="nrf53" +CONFIG_ARCH_CHIP_NRF5340=y +CONFIG_ARCH_CHIP_NRF5340_CPUAPP=y +CONFIG_ARCH_CHIP_NRF53=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH_STDARG_H=y +CONFIG_BOARD_LOOPSPERMSEC=5500 +CONFIG_BOOT_MCUBOOT=y +CONFIG_EXPERIMENTAL=y +CONFIG_FAT_LCNAMES=y +CONFIG_FAT_LFN=y +CONFIG_FS_FAT=y +CONFIG_INIT_ENTRYPOINT="mcuboot_loader_main" +CONFIG_INTELHEX_BINARY=y +CONFIG_MCUBOOT_BOOTLOADER=y +CONFIG_MM_REGIONS=2 +CONFIG_NRF53_APP_FORMAT_MCUBOOT=y +CONFIG_NRF53_MCUBOOT_HAVE_SCRACH=y +CONFIG_NRF53_PROGMEM_OTA_PARTITION=y +CONFIG_NRF53_UART0=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAM_SIZE=524288 +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/nrf53/nrf5340-dk/scripts/Make.defs b/boards/arm/nrf53/nrf5340-dk/scripts/Make.defs index 634299fccb..8f1cbce766 100644 --- a/boards/arm/nrf53/nrf5340-dk/scripts/Make.defs +++ b/boards/arm/nrf53/nrf5340-dk/scripts/Make.defs @@ -22,16 +22,22 @@ include $(TOPDIR)/.config include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv8-m/Toolchain.defs -ifeq ($(CONFIG_ARCH_CHIP_NRF5340_CPUAPP),y) -LDSCRIPT = flash_app.ld +ifeq ($(CONFIG_ARCH_BOARD_COMMON),y) + ifeq ($(CONFIG_ARCH_CHIP_NRF5340_CPUAPP),y) + ARCHSCRIPT += $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)flash_app.ld + endif + ifeq ($(CONFIG_ARCH_CHIP_NRF5340_CPUNET),y) + ARCHSCRIPT += $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)flash_net.ld + endif +else + ifeq ($(CONFIG_ARCH_CHIP_NRF5340_CPUAPP),y) + ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)flash_app.ld + endif + ifeq ($(CONFIG_ARCH_CHIP_NRF5340_CPUNET),y) + ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)flash_net.ld + endif endif -ifeq ($(CONFIG_ARCH_CHIP_NRF5340_CPUNET),y) -LDSCRIPT = flash_net.ld -endif - -ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) - ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe diff --git a/boards/arm/nrf53/nrf5340-dk/src/nrf53_bringup.c b/boards/arm/nrf53/nrf5340-dk/src/nrf53_bringup.c index c59768f9f8..785f57931e 100644 --- a/boards/arm/nrf53/nrf5340-dk/src/nrf53_bringup.c +++ b/boards/arm/nrf53/nrf5340-dk/src/nrf53_bringup.c @@ -64,6 +64,10 @@ # include "nrf53_rptun.h" #endif +#ifdef CONFIG_NRF53_PROGMEM +# include "nrf53_progmem.h" +#endif + #ifdef CONFIG_TIMER # include "nrf53_timer.h" #endif @@ -311,6 +315,14 @@ int nrf53_bringup(void) } #endif +#ifdef CONFIG_NRF53_PROGMEM + ret = nrf53_progmem_init(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to initialize MTD progmem: %d\n", ret); + } +#endif /* CONFIG_MTD */ + UNUSED(ret); return OK; }