diff --git a/records/board/thingy91.yaml b/records/board/thingy91.yaml index 0a7d2c8478..68fc42d230 100644 --- a/records/board/thingy91.yaml +++ b/records/board/thingy91.yaml @@ -1,6 +1,8 @@ common: macros: + - THINGY91 - NRF_SECURE_BOOTLOADER + - NRF_SECURE_BOOTLOADER_OFFSET=0x12200 sources: board: - source/board/thingy91.c diff --git a/source/daplink/drag-n-drop/iap_flash_intf.c b/source/daplink/drag-n-drop/iap_flash_intf.c index ca7b274cef..79903a17dd 100644 --- a/source/daplink/drag-n-drop/iap_flash_intf.c +++ b/source/daplink/drag-n-drop/iap_flash_intf.c @@ -30,6 +30,7 @@ #include "crc.h" #include "info.h" +#if !defined(DISABLE_FLASH_INTF_CHECKS) // Application start must be aligned to page write COMPILER_ASSERT(DAPLINK_ROM_APP_START % DAPLINK_MIN_WRITE_SIZE == 0); // Application size must be a multiple of write size @@ -42,6 +43,7 @@ COMPILER_ASSERT(DAPLINK_ROM_APP_START % DAPLINK_SECTOR_SIZE == 0); COMPILER_ASSERT(DAPLINK_ROM_UPDATE_START % DAPLINK_SECTOR_SIZE == 0); // Update size must be a multiple of sector size COMPILER_ASSERT(DAPLINK_ROM_UPDATE_SIZE % DAPLINK_SECTOR_SIZE == 0); +#endif typedef enum { STATE_CLOSED, diff --git a/source/hic_hal/nordic/nrf52840/daplink_addr.h b/source/hic_hal/nordic/nrf52840/daplink_addr.h index d1a00ef18a..b89337d82e 100644 --- a/source/hic_hal/nordic/nrf52840/daplink_addr.h +++ b/source/hic_hal/nordic/nrf52840/daplink_addr.h @@ -24,14 +24,11 @@ #define DAPLINK_ROM_START 0x00000000 #define DAPLINK_ROM_SIZE 0x00040000 // 256 KiB - #define DAPLINK_RAM_START 0x20000000 #define DAPLINK_RAM_SIZE 0x00010000 // 64 KiB /* ROM sizes */ - - #define DAPLINK_ROM_BL_START 0x00000000 #if !defined(NRF_SECURE_BOOTLOADER) @@ -51,12 +48,13 @@ #else // NRF_SECURE_BOOTLOADER -#define DAPLINK_ROM_BL_SIZE 0x00013000 // 76 KiB MCUBOOT -#define DAPLINK_ROM_IF_START 0x00013000 -#define DAPLINK_ROM_IF_SIZE 0x0002C000 +#define DISABLE_FLASH_INTF_CHECKS +#define DAPLINK_ROM_BL_SIZE NRF_SECURE_BOOTLOADER_OFFSET // MCUBOOT +#define DAPLINK_ROM_IF_START NRF_SECURE_BOOTLOADER_OFFSET +#define DAPLINK_ROM_IF_SIZE (0x00040000-NRF_SECURE_BOOTLOADER_OFFSET) #define NON_CONTIGUOUS_USER_CONFIG -#define DAPLINK_ROM_CONFIG_USER_START 0x000F7000 +#define DAPLINK_ROM_CONFIG_USER_START 0x000FE000 #define DAPLINK_ROM_CONFIG_USER_SIZE 0x00001000 #endif diff --git a/source/hic_hal/nordic/nrf52840/gcc/gcc_startup_nrf52840.S b/source/hic_hal/nordic/nrf52840/gcc/gcc_startup_nrf52840.S index 1eb57971c7..6ecf28fcbc 100644 --- a/source/hic_hal/nordic/nrf52840/gcc/gcc_startup_nrf52840.S +++ b/source/hic_hal/nordic/nrf52840/gcc/gcc_startup_nrf52840.S @@ -197,6 +197,13 @@ Reset_Handler: .L_loop1_done: #endif +#ifdef NRF_SECURE_BOOTLOADER + movs r3, #0 + msr CONTROL, r3 + msr PSP, r3 + msr PRIMASK, r3 +#endif + /* This part of work usually is done in C library startup code. Otherwise, * define __STARTUP_CLEAR_BSS to enable it in this startup. This section * clears the RAM where BSS data is located.