Skip to content

Commit

Permalink
Add support for iMX RT1050 and RT1060 wolfBoot_printf using DEBUG_UAR…
Browse files Browse the repository at this point in the history
…T=1.
  • Loading branch information
dgarske committed Aug 17, 2023
1 parent 20e402e commit c0e2af8
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 16 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Due to the minimalist design of the bootloader and the tiny HAL API, wolfBoot is
from any OS or bare-metal application, and can be easily ported and integrated in existing embedded software
projects to provide a secure firmware update mechanism.

Design based on [RFC 9019](https://datatracker.ietf.org/doc/rfc9019/) - A Firmware Update Architecture for Internet of Things.

## Features
- Multi-slot partitioning of the flash device
- Integrity verification of the firmware image(s)
Expand Down
30 changes: 14 additions & 16 deletions arch.mk
Original file line number Diff line number Diff line change
Expand Up @@ -262,48 +262,46 @@ endif

ifeq ($(TARGET),imx_rt)
CORTEX_M7=1
CFLAGS+=-I$(MCUXPRESSO_DRIVERS)/drivers -I$(MCUXPRESSO_DRIVERS) \
CFLAGS+=\
-I$(MCUXPRESSO_DRIVERS)/drivers \
-I$(MCUXPRESSO_DRIVERS) \
-I$(MCUXPRESSO_DRIVERS)/utilities/debug_console/ \
-I$(MCUXPRESSO_DRIVERS)/utilities/str/ \
-I$(MCUXPRESSO)/components/uart/ \
-I$(MCUXPRESSO)/components/flash/nor \
-I$(MCUXPRESSO)/components/flash/nor/flexspi \
-I$(MCUXPRESSO)/components/serial_manager/ \
-DCPU_$(MCUXPRESSO_CPU) -I$(MCUXPRESSO_CMSIS)/Include \
-DCPU_$(MCUXPRESSO_CPU) -I$(MCUXPRESSO_CMSIS)/Core/Include \
-I$(MCUXPRESSO_CMSIS)/Include \
-I$(MCUXPRESSO_CMSIS)/Core/Include \
-DCPU_$(MCUXPRESSO_CPU) \
-DDEBUG_CONSOLE_ASSERT_DISABLE=1 -I$(MCUXPRESSO_DRIVERS)/project_template/ \
-DXIP_EXTERNAL_FLASH=1 -DDEBUG_CONSOLE_ASSERT_DISABLE=1 -DPRINTF_ADVANCED_ENABLE=1 \
-DSCANF_ADVANCED_ENABLE=1 -DSERIAL_PORT_TYPE_UART=1 -DNDEBUG=1

OBJS+= $(MCUXPRESSO_DRIVERS)/drivers/fsl_clock.o $(MCUXPRESSO_DRIVERS)/drivers/fsl_flexspi.o
ifeq ($(DEBUG_UART),1)
OBJS+= $(MCUXPRESSO_DRIVERS)/drivers/fsl_lpuart.o
endif

ifeq ($(MCUXPRESSO_CPU),MIMXRT1064DVL6A)
ARCH_FLASH_OFFSET=0x70000000
CFLAGS+=-I$(MCUXPRESSO)/boards/evkmimxrt1064/xip/
ifeq ($(PKA),1)
PKA_EXTRA_OBJS+= $(MCUXPRESSO)/devices/MIMXRT1064/drivers/fsl_dcp.o
endif
ARCH_FLASH_OFFSET=0x70000000
CFLAGS+=-I$(MCUXPRESSO)/boards/evkmimxrt1064/xip/
endif

ifeq ($(MCUXPRESSO_CPU),MIMXRT1062DVL6A)
ARCH_FLASH_OFFSET=0x60000000
CFLAGS+=-I$(MCUXPRESSO)/boards/evkmimxrt1060/xip/
ifeq ($(PKA),1)
PKA_EXTRA_OBJS+= $(MCUXPRESSO)/devices/MIMXRT1062/drivers/fsl_dcp.o
endif
endif

ifeq ($(MCUXPRESSO_CPU),MIMXRT1052DVJ6B)
ARCH_FLASH_OFFSET=0x60000000
CFLAGS+=-I$(MCUXPRESSO)/boards/evkbimxrt1050/xip/
ifeq ($(PKA),1)
PKA_EXTRA_OBJS+= $(MCUXPRESSO)/devices/MIMXRT1052/drivers/fsl_dcp.o
endif
endif

ifeq ($(PKA),1)
PKA_EXTRA_OBJS+=./lib/wolfssl/wolfcrypt/src/port/nxp/dcp_port.o
PKA_EXTRA_CFLAGS+=-DWOLFSSL_IMXRT_DCP
PKA_EXTRA_OBJS+= $(MCUXPRESSO_DRIVERS)/drivers/fsl_dcp.o
PKA_EXTRA_OBJS+=./lib/wolfssl/wolfcrypt/src/port/nxp/dcp_port.o
PKA_EXTRA_CFLAGS+=-DWOLFSSL_IMXRT_DCP
endif
endif

Expand Down
33 changes: 33 additions & 0 deletions hal/imx_rt.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
#include "fsl_iomuxc.h"
#include "fsl_nor_flash.h"
#include "fsl_flexspi.h"
#ifdef DEBUG_UART
#include "fsl_lpuart.h"
#endif

#ifdef CPU_MIMXRT1062DVL6A
#include "evkmimxrt1060_flexspi_nor_config.h"
Expand Down Expand Up @@ -675,6 +678,32 @@ static void clock_init(void)
}


#ifdef DEBUG_UART

#define UART_BASEADDR LPUART1
#define UART_BAUDRATE (115200U)

void uart_init(void)
{
lpuart_config_t config;
uint32_t uartClkSrcFreq = 20000000U; /* 20 MHz */

LPUART_GetDefaultConfig(&config);
config.baudRate_Bps = UART_BAUDRATE;
config.enableTx = true;
config.enableRx = true;

LPUART_Init(UART_BASEADDR, &config, uartClkSrcFreq);
}

void uart_write(const char* buf, uint32_t sz)
{
LPUART_WriteBlocking(UART_BASEADDR, (const uint8_t*)buf, sz);
}

#endif /* DEBUG_UART */


extern void ARM_MPU_Disable(void);
extern int wc_dcp_init(void);
static int hal_flash_init(void);
Expand All @@ -686,6 +715,10 @@ void hal_init(void)
#endif
ARM_MPU_Disable();
clock_init();
#ifdef DEBUG_UART
uart_init();
uart_write("wolfBoot HAL Init\n", 19);
#endif
hal_flash_init();
}

Expand Down

0 comments on commit c0e2af8

Please sign in to comment.