Skip to content

Commit

Permalink
Merge pull request #475 from danielinux/imx-rt-hab
Browse files Browse the repository at this point in the history
Add support for building for HAB for i.MX RT targets
  • Loading branch information
dgarske authored Jul 22, 2024
2 parents f493526 + e081d74 commit 8a5c039
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 1 deletion.
7 changes: 6 additions & 1 deletion arch.mk
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,12 @@ ifeq ($(TARGET),imx_rt)
ifeq ($(DEBUG_UART),1)
OBJS+= $(MCUXPRESSO_DRIVERS)/drivers/fsl_lpuart.o
endif
endif
ifeq ($(TARGET_IMX_HAB),1)
LSCRIPT_IN:=hal/$(TARGET)_hab.ld
else
LSCRIPT_IN:=hal/$(TARGET).ld
endif
endif

ifeq ($(MCUXPRESSO_CPU),MIMXRT1064DVL6A)
ARCH_FLASH_OFFSET=0x70000000
Expand Down
33 changes: 33 additions & 0 deletions config/examples/imx-rt1060_hab.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
ARCH?=ARM
TARGET?=imx_rt
TARGET_IMX_HAB?=1
SIGN?=ECC256
HASH?=SHA256
MCUXSDK?=0
MCUXPRESSO?=$(PWD)/../SDK-2.11.0_EVK-MIMXRT1060
MCUXPRESSO_CMSIS?=$(MCUXPRESSO)/CMSIS
MCUXPRESSO_CPU?=MIMXRT1062DVL6A
MCUXPRESSO_DRIVERS?=$(MCUXPRESSO)/devices/MIMXRT1062
DEBUG?=0
VTOR?=1
CORTEX_M0?=0
NO_ASM?=0
NO_MPU=1
EXT_FLASH?=0
SPI_FLASH?=0
ALLOW_DOWNGRADE?=0
NVM_FLASH_WRITEONCE?=1
WOLFBOOT_VERSION?=0
V?=0
SPMATH?=1
RAM_CODE?=0
DUALBANK_SWAP?=0
PKA?=0
WOLFBOOT_PARTITION_SIZE?=0x20000
WOLFBOOT_SECTOR_SIZE?=0x1000
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0x60010000
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x60030000
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x60050000
WOLFBOOT_SMALL_STACK?=1

CFLAGS_EXTRA+=-DDCP_USE_DCACHE=0
4 changes: 4 additions & 0 deletions docs/Targets.md
Original file line number Diff line number Diff line change
Expand Up @@ -1407,6 +1407,10 @@ section, e.g.:
If an external `.dcd_data` section is provided, the option `NXP_CUSTOM_DCD=1` must
be added to the configuration.

### Building wolfBoot for HAB (High Assurance Boot)

The `imx_rt` target supports building without a flash configuration, IVT, Boot Data and DCD. This is needed when wanting to use HAB through NXP's *Secure Provisioning Tool* to sign wolfBoot to enable secure boot. To build wolfBoot this way `TARGET_IMX_HAB` needs to be set to 1 in the configuration file (see `config/examples/imx-rt1060 _hab.config` for an example). When built with `TARGET_IMX_HAB=1` wolfBoot must be written to flash using NXP's *Secure Provisioning Tool*.

### Flashing

Firmware can be directly uploaded to the target by copying `factory.bin` to the virtual USB drive associated to the device, or by loading the image directly into flash using a JTAG/SWD debugger.
Expand Down
62 changes: 62 additions & 0 deletions hal/imx_rt_hab.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/* Specify the memory areas */
MEMORY
{
FLASH(rx) : ORIGIN = @ARCH_FLASH_OFFSET@ + 0x2000, LENGTH = @BOOTLOADER_PARTITION_SIZE@
RAM(rwx) : ORIGIN = 0x20000000, LENGTH = 0x0001FFF0
}

/* Define output sections */
SECTIONS
{
.text :
{
_start_text = @ARCH_FLASH_OFFSET@;
KEEP(*(.isr_vector))
. = ALIGN(0x8);
*(.text*)
*(.rodata*)
*(.glue_7) /* glue arm to thumb code */
*(.glue_7t) /* glue thumb to arm code */
*(.eh_frame)
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
_end_text = .;
} > FLASH
.ARM.extab :
{
*(.ARM.extab* .gnu.linkonce.armextab.*)
} > FLASH
.ARM :
{
__exidx_start = .;
*(.ARM.exidx*)
__exidx_end = .;
} > FLASH
_stored_data = .;

.data : AT (_stored_data)
{
_start_data = .;
KEEP(*(.ramcode*))
. = ALIGN(4);
KEEP(*(.data*))
. = ALIGN(4);
_end_data = .;
} > RAM

.bss (NOLOAD) :
{
_start_bss = .;
__bss_start__ = .;
*(.bss*)
*(COMMON)
. = ALIGN(4);
_end_bss = .;
__bss_end__ = .;
_end = .;
} > RAM
. = ALIGN(4);
}

END_STACK = ORIGIN(RAM) + LENGTH(RAM);

0 comments on commit 8a5c039

Please sign in to comment.