wolfSSL / wolfBoot

wolfBoot is a portable, OS-agnostic, secure bootloader for microcontrollers, supporting firmware authentication and firmware update mechanisms.
https://www.wolfssl.com
GNU General Public License v3.0
331 stars 95 forks source link

Add support for MIMXRT1042XJM5B #405

Closed MulattoKid closed 4 months ago

MulattoKid commented 4 months ago

This PR adds support for MIMXRT1042XJM5B. I've tested this locally on the EVK and a custom PCB, and it works on both.

My approach was:

I added local support for patching the test app's ELF file to add the signature to it. Doing so I could flash both wolfBoot and the test app through VSCode, and was able to get to both binaries main entrypoints.

I've not tested that this doesn't break any of the other RT targets.

@danielinux This is the support we discussed during our call. Hopefully this can help getting 1042 support included in wolfBoot.

Kind regards, Daniel

dgarske commented 4 months ago

See ZD 17479

MulattoKid commented 4 months ago

One thing I forgot to mention was that in uart_init in hal/imx_rt.c I had to specifically configure the pins used for debug output like so:

CLOCK_EnableClock(kCLOCK_Iomuxc);
IOMUXC_SetPinMux(IOMUXC_GPIO_AD_B0_12_LPUART1_TX, 0U);
IOMUXC_SetPinMux(IOMUXC_GPIO_AD_B0_13_LPUART1_RX, 0U);
IOMUXC_SetPinConfig(IOMUXC_GPIO_AD_B0_12_LPUART1_TX, 0x10B0U);
IOMUXC_SetPinConfig(IOMUXC_GPIO_AD_B0_13_LPUART1_RX, 0x10B0U);

When not doing this, I didn't get any debug output from the bootloader. I did compile with

DEBUG_UART?=1
PRINTF_ENABLED?=1

in my .config. Not sure if I'm missing something?

dgarske commented 4 months ago

Hi @MulattoKid ,

Thank you so much for this PR. Your contributor agreement has been accepted and placed on file.

We've assigned this PR to @bigbrett for review.

Thanks, David Garske, wolfSSL

bigbrett commented 4 months ago

One thing I forgot to mention was that in uart_init in hal/imx_rt.c I had to specifically configure the pins used for debug output like so:

CLOCK_EnableClock(kCLOCK_Iomuxc);
IOMUXC_SetPinMux(IOMUXC_GPIO_AD_B0_12_LPUART1_TX, 0U);
IOMUXC_SetPinMux(IOMUXC_GPIO_AD_B0_13_LPUART1_RX, 0U);
IOMUXC_SetPinConfig(IOMUXC_GPIO_AD_B0_12_LPUART1_TX, 0x10B0U);
IOMUXC_SetPinConfig(IOMUXC_GPIO_AD_B0_13_LPUART1_RX, 0x10B0U);

When not doing this, I didn't get any debug output from the bootloader. I did compile with

DEBUG_UART?=1
PRINTF_ENABLED?=1

in my .config. Not sure if I'm missing something?

@MulattoKid Not sure off the top of my head, I will look into this more. It doesn't appear that the hal layer does this pin mux initialization, which could be why printouts don't show up. Regardless, I don't want this to block your PR.

MulattoKid commented 4 months ago

Thanks for the quick responses :)