diff --git a/arch.mk b/arch.mk index 75fb67cf..4791ba6b 100644 --- a/arch.mk +++ b/arch.mk @@ -781,5 +781,9 @@ ifeq ($(DEBUG_UART),1) CFLAGS+=-DDEBUG_UART endif +ifeq ($(NXP_CUSTOM_DCD),1) + CFLAGS+=-DNXP_CUSTOM_DCD +endif + CFLAGS+=-DWOLFBOOT_ARCH_$(ARCH) CFLAGS+=-DTARGET_$(TARGET) diff --git a/docs/Targets.md b/docs/Targets.md index 5adfaba6..5a32dc35 100644 --- a/docs/Targets.md +++ b/docs/Targets.md @@ -1164,6 +1164,20 @@ You can also get the SDK and CMSIS bundles using these repositories: * https://github.com/nxp-mcuxpresso/CMSIS_5 Use MCUXSDK=1 with this option, since the pack paths are different. +### Custom Device Configuration Data (DCD) + +On iMX-RT10xx it is possible to load a custom DCD section from an external +source file. A customized DCD section should be declared within the `.dcd_data` +section, e.g.: + + +`const uint8_t __attribute__((section(".dcd_data"))) dcd_data[] = { /* ... */ };` + + +If an external `.dcd_data` section is provided, the option `NXP_CUSTOM_DCD=1` must +be added to the configuration. + + ### Testing Update First make the update partition, pre-triggered for update diff --git a/hal/imx_rt.c b/hal/imx_rt.c index 3f7e1e8f..4dae197c 100644 --- a/hal/imx_rt.c +++ b/hal/imx_rt.c @@ -568,14 +568,23 @@ const BOOT_DATA_T __attribute__((section(".boot_data"))) boot_data = { 0xFFFFFFFF /* empty - extra data word */ }; -const uint8_t dcd_data[1] = {0}; + extern void isr_reset(void); +extern const uint32_t __dcd_data_start; +const uint32_t dcd_data_addr = (uint32_t) &__dcd_data_start; + +#ifndef NXP_CUSTOM_DCD +/* If a DCD section is populated, it should be mapped to the .dcd_data section. + * By default, provide an empty section. + */ +const uint8_t __attribute__((section(".dcd_data"))) dcd_data[sizeof(uint32_t)] = { 0 }; +#endif const ivt __attribute__((section(".image_vt"))) image_vector_table = { IVT_HEADER, /* IVT Header */ (uint32_t)isr_reset, /* Image Entry Function */ IVT_RSVD, /* Reserved = 0 */ - (uint32_t)dcd_data, /* Address where DCD information is stored */ + (uint32_t)dcd_data_addr, /* Address where DCD information is stored */ (uint32_t)&boot_data, /* Address where BOOT Data Structure is stored */ (uint32_t)&image_vector_table, /* Pointer to IVT Self (absolute address */ (uint32_t)CSF_ADDRESS, /* Address where CSF file is stored */ diff --git a/hal/imx_rt.ld b/hal/imx_rt.ld index f00d8846..af834714 100644 --- a/hal/imx_rt.ld +++ b/hal/imx_rt.ld @@ -15,6 +15,7 @@ SECTIONS . = ORIGIN(FLASH) + 0x1000; KEEP(*(.image_vt)) KEEP(*(.boot_data)) + __dcd_data_start = .; KEEP(*(.dcd_data)) . = ORIGIN(FLASH) + 0x2000; KEEP(*(.isr_vector)) diff --git a/tools/config.mk b/tools/config.mk index e7706fb3..edd053ef 100644 --- a/tools/config.mk +++ b/tools/config.mk @@ -10,6 +10,7 @@ ifeq ($(ARCH),) MCUXPRESSO_DRIVERS?=$(MCUXPRESSO)/devices/MK64F12 MCUXPRESSO_CMSIS?=$(PWD)/CMSIS_5/CMSIS FREEDOM_E_SDK?=$(HOME)/src/freedom-e-sdk + NXP_CUSTOM_DCD=0 STM32CUBE?=$(HOME)/STM32Cube/Repository/STM32Cube_FW_WB_V1.3.0 CYPRESS_PDL?=$(HOME)/src/psoc6pdl CYPRESS_TARGET_LIB?=$(HOME)/src/TARGET_CY8CKIT-062S2-43012 @@ -95,4 +96,5 @@ CONFIG_VARS:= ARCH TARGET SIGN HASH MCUXSDK MCUXPRESSO MCUXPRESSO_CPU MCUXPRESSO LMS_LEVELS LMS_HEIGHT LMS_WINTERNITZ \ WOLFBOOT_UNIVERSAL_KEYSTORE \ XMSS_PARAMS \ - ELF + ELF \ + NXP_CUSTOM_DCD