mirror of https://github.com/wolfSSL/wolfBoot.git
Draft support for MCX W71
parent
71346b8b81
commit
4d1bf5df28
34
arch.mk
34
arch.mk
|
@ -638,6 +638,40 @@ ifeq ($(TARGET),mcxa)
|
|||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET),mcxw)
|
||||
CORTEX_M33=1
|
||||
CFLAGS+=\
|
||||
-I$(MCUXPRESSO_DRIVERS) \
|
||||
-I$(MCUXPRESSO_DRIVERS)/drivers \
|
||||
-I$(MCUXPRESSO_DRIVERS)/periph2 \
|
||||
-I$(MCUXPRESSO)/drivers \
|
||||
-I$(MCUXPRESSO)/drivers/common \
|
||||
-I$(MCUXPRESSO_CMSIS)/Include \
|
||||
-I$(MCUXPRESSO_CMSIS)/Core/Include
|
||||
CFLAGS+=-DCPU_$(MCUXPRESSO_CPU) -DDEBUG_CONSOLE_ASSERT_DISABLE=1
|
||||
CFLAGS+=-DWOLFSSL_SP_NO_UMAAL
|
||||
CFLAGS+=-Wno-old-style-declaration
|
||||
CFLAGS+=-mcpu=cortex-m33 -DCORTEX_M33 -U__ARM_FEATURE_DSP
|
||||
LDFLAGS+=-mcpu=cortex-m33
|
||||
OBJS+=\
|
||||
$(MCUXPRESSO_DRIVERS)/drivers/fsl_clock.o \
|
||||
$(MCUXPRESSO_DRIVERS)/drivers/fsl_spc.o \
|
||||
$(MCUXPRESSO_DRIVERS)/project_template/clock_config.o \
|
||||
$(MCUXPRESSO_DRIVERS)/drivers/fsl_ccm32k.o \
|
||||
$(MCUXPRESSO_DRIVERS)/drivers/fsl_romapi.o
|
||||
|
||||
ifeq ($(MCUXSDK),1)
|
||||
CFLAGS+=\
|
||||
-I$(MCUXPRESSO)/drivers/flash \
|
||||
-I$(MCUXPRESSO)/drivers/sysmpu \
|
||||
-I$(MCUXPRESSO)/drivers/ltc \
|
||||
-I$(MCUXPRESSO)/drivers/port \
|
||||
-I$(MCUXPRESSO)/drivers/gpio
|
||||
|
||||
else
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET),imx_rt)
|
||||
CFLAGS+=\
|
||||
-I$(MCUXPRESSO_DRIVERS) \
|
||||
|
|
|
@ -0,0 +1,154 @@
|
|||
/* mcxw.c
|
||||
*
|
||||
* Stubs for custom HAL implementation. Defines the
|
||||
* functions used by wolfboot for a specific target.
|
||||
*
|
||||
* Copyright (C) 2025 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfBoot.
|
||||
*
|
||||
* wolfBoot is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfBoot is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <target.h>
|
||||
#include "image.h"
|
||||
/* FSL includes */
|
||||
#include "fsl_common.h"
|
||||
|
||||
/* Clock + RAM voltage settings */
|
||||
#include "fsl_clock.h"
|
||||
#include "fsl_spc.h"
|
||||
|
||||
/* Flash driver */
|
||||
#include "fsl_device_registers.h"
|
||||
#include "fsl_lpspi_flash.h"
|
||||
#include "fsl_k4_flash.h"
|
||||
|
||||
/*!< Core clock frequency: 48000000Hz */
|
||||
#define BOARD_BOOTCLOCKRUN_CORE_CLOCK 48000000U
|
||||
static flash_config_t pflash;
|
||||
static uint32_t pflash_sector_size = WOLFBOOT_SECTOR_SIZE;
|
||||
|
||||
uint32_t SystemCoreClock;
|
||||
|
||||
|
||||
#ifdef __WOLFBOOT
|
||||
|
||||
extern void BOARD_BootClockRUN(void);
|
||||
|
||||
|
||||
|
||||
/* Assert hook needed by Kinetis SDK */
|
||||
void __assert_func(const char *a, int b, const char *c, const char *d)
|
||||
{
|
||||
while(1)
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
void hal_prepare_boot(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void hal_init(void)
|
||||
{
|
||||
#ifdef __WOLFBOOT
|
||||
/* Clock setting */
|
||||
BOARD_BootClockRUN();
|
||||
#endif
|
||||
|
||||
/* Flash driver init */
|
||||
flash_config_t pflash;
|
||||
/* Clear the FLASH configuration structure */
|
||||
memset(&pflash, 0, sizeof(pflash));
|
||||
/* FLASH driver init */
|
||||
FLASH_Init(&pflash);
|
||||
FLASH_GetProperty(&pflash, kFLASH_PropertyPflash0SectorSize,
|
||||
&pflash_sector_size);
|
||||
}
|
||||
|
||||
int RAMFUNCTION hal_flash_write(uint32_t address, const uint8_t *data, int len)
|
||||
{
|
||||
int ret;
|
||||
int w = 0;
|
||||
const uint8_t empty_qword[16] = {
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
|
||||
};
|
||||
|
||||
while (len > 0) {
|
||||
if ((len < 16) || address & 0x0F) {
|
||||
uint8_t aligned_qword[16];
|
||||
uint32_t address_align = address - (address & 0x0F);
|
||||
uint32_t start_off = address - address_align;
|
||||
int i;
|
||||
|
||||
memcpy(aligned_qword, (void*)address_align, 16);
|
||||
for (i = start_off; ((i < 16) && (i < len + (int)start_off)); i++) {
|
||||
aligned_qword[i] = data[w++];
|
||||
}
|
||||
if (memcmp(aligned_qword, empty_qword, 16) != 0) {
|
||||
ret = FLASH_Program(&pflash, FLASH, address_align, aligned_qword, 16);
|
||||
if (ret != kStatus_Success)
|
||||
return -1;
|
||||
}
|
||||
address += i;
|
||||
len -= i;
|
||||
}
|
||||
else {
|
||||
uint32_t len_align = len - (len & 0x0F);
|
||||
ret = FLASH_Program(&pflash, FLASH, address, (uint8_t*)data + w, len_align);
|
||||
if (ret != kStatus_Success)
|
||||
return -1;
|
||||
len -= len_align;
|
||||
address += len_align;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RAMFUNCTION hal_flash_unlock(void)
|
||||
{
|
||||
}
|
||||
|
||||
void RAMFUNCTION hal_flash_lock(void)
|
||||
{
|
||||
}
|
||||
|
||||
int RAMFUNCTION hal_flash_erase(uint32_t address, int len)
|
||||
{
|
||||
status_t result;
|
||||
if (address % pflash_sector_size)
|
||||
address -= address % pflash_sector_size;
|
||||
while (len > 0) {
|
||||
result = FLASH_Erase(&pflash, FLASH, address, pflash_sector_size,
|
||||
kFLASH_ApiEraseKey);
|
||||
if (kStatus_FLASH_Success != result)
|
||||
return -1;
|
||||
|
||||
/* Verify sector if it's been erased. */
|
||||
result = FLASH_VerifyEraseSector(&pflash, FLASH, address,
|
||||
pflash_sector_size);
|
||||
if (kStatus_FLASH_Success != result)
|
||||
return -1;
|
||||
len -= pflash_sector_size;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
MEMORY
|
||||
{
|
||||
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = @BOOTLOADER_PARTITION_SIZE@
|
||||
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 24K
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
|
||||
.text :
|
||||
{
|
||||
_start_text = .;
|
||||
KEEP(*(.isr_vector))
|
||||
. = 0x200;
|
||||
*(.keystore*)
|
||||
*(.text*)
|
||||
*(.rodata*)
|
||||
*(.init*)
|
||||
*(.fini*)
|
||||
. = ALIGN(4);
|
||||
_end_text = .;
|
||||
} > FLASH
|
||||
|
||||
.edidx :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*(.ARM.exidx*)
|
||||
} > FLASH
|
||||
|
||||
_stored_data = .;
|
||||
|
||||
.data : AT (_stored_data)
|
||||
{
|
||||
_start_data = .;
|
||||
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,0 +1,57 @@
|
|||
MEMORY
|
||||
{
|
||||
FLASH (rx) : ORIGIN = @WOLFBOOT_TEST_APP_ADDRESS@, LENGTH = @WOLFBOOT_TEST_APP_SIZE@
|
||||
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 24K
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.text :
|
||||
{
|
||||
_start_text = .;
|
||||
KEEP(*(.isr_vector))
|
||||
*(.init)
|
||||
*(.fini)
|
||||
*(.text*)
|
||||
KEEP(*(.rodata*))
|
||||
. = ALIGN(4);
|
||||
_end_text = .;
|
||||
} > FLASH
|
||||
|
||||
.ARM :
|
||||
{
|
||||
__exidx_start = .;
|
||||
*(.ARM.exidx*)
|
||||
__exidx_end = .;
|
||||
} > FLASH
|
||||
|
||||
_stored_data = .;
|
||||
|
||||
.data : AT (_stored_data)
|
||||
{
|
||||
_start_data = .;
|
||||
KEEP(*(.data*))
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.ramcode))
|
||||
. = ALIGN(4);
|
||||
_end_data = .;
|
||||
} > RAM
|
||||
|
||||
.bss :
|
||||
{
|
||||
_start_bss = .;
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
. = ALIGN(4);
|
||||
_end_bss = .;
|
||||
_end = .;
|
||||
} > RAM
|
||||
}
|
||||
|
||||
_wolfboot_partition_boot_address = @WOLFBOOT_PARTITION_BOOT_ADDRESS@;
|
||||
_wolfboot_partition_size = @WOLFBOOT_PARTITION_SIZE@;
|
||||
_wolfboot_partition_update_address = @WOLFBOOT_PARTITION_UPDATE_ADDRESS@;
|
||||
_wolfboot_partition_swap_address = @WOLFBOOT_PARTITION_SWAP_ADDRESS@;
|
||||
|
||||
PROVIDE(_start_heap = _end);
|
||||
PROVIDE(_end_stack = ORIGIN(RAM) + LENGTH(RAM));
|
|
@ -302,6 +302,16 @@ ifeq ($(TARGET),mcxa)
|
|||
APP_OBJS+=$(MCUXPRESSO_DRIVERS)/drivers/fsl_spc.o
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET),mcxw)
|
||||
LSCRIPT_TEMPLATE=ARM-mcxw.ld
|
||||
APP_OBJS+=$(MCUXPRESSO_DRIVERS)/drivers/fsl_clock.o
|
||||
APP_OBJS+=$(MCUXPRESSO_DRIVERS)/drivers/fsl_gpio.o
|
||||
APP_OBJS+=$(MCUXPRESSO_DRIVERS)/drivers/fsl_spc.o
|
||||
APP_OBJS+=$(MCUXPRESSO_DRIVERS)/project_template/clock_config.o
|
||||
APP_OBJS+=$(MCUXPRESSO_DRIVERS)/drivers/fsl_ccm32k.o
|
||||
APP_OBJS+=$(MCUXPRESSO_DRIVERS)/drivers/fsl_romapi.o
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET),imx_rt)
|
||||
LDFLAGS+=\
|
||||
-mcpu=cortex-m7 -Wall --specs=nosys.specs -fno-common -ffunction-sections -fdata-sections \
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
/* app_mcxa.c
|
||||
*
|
||||
* Test bare-metal boot-led-on application
|
||||
*
|
||||
* Copyright (C) 2024 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfBoot.
|
||||
*
|
||||
* wolfBoot is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfBoot is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include "fsl_common.h"
|
||||
#include "fsl_port.h"
|
||||
#include "fsl_gpio.h"
|
||||
#include "fsl_clock.h"
|
||||
|
||||
#include "wolfboot/wolfboot.h"
|
||||
#include "target.h"
|
||||
|
||||
extern void hal_init(void);
|
||||
|
||||
/* init gpio for port 3 */
|
||||
void gpio_portA_init(int pin)
|
||||
{
|
||||
const port_pin_config_t GPIO_OUT_LED = {
|
||||
(uint16_t)kPORT_PullDisable,
|
||||
(uint16_t)kPORT_LowPullResistor,
|
||||
(uint16_t)kPORT_FastSlewRate,
|
||||
(uint16_t)kPORT_PassiveFilterDisable,
|
||||
(uint16_t)kPORT_OpenDrainDisable,
|
||||
(uint16_t)kPORT_LowDriveStrength,
|
||||
(uint16_t)kPORT_NormalDriveStrength,
|
||||
(uint16_t)kPORT_MuxAsGpio,
|
||||
(uint16_t)kPORT_UnlockRegister
|
||||
};
|
||||
|
||||
const gpio_pin_config_t GPIO_OUT_LED_config = {
|
||||
.pinDirection = kGPIO_DigitalOutput,
|
||||
.outputLogic = 0U
|
||||
};
|
||||
|
||||
|
||||
/* Initialize GPIO functionality on pin */
|
||||
GPIO_PinInit(GPIOA, pin, &GPIO_OUT_LED_config);
|
||||
PORT_SetPinConfig(PORTA, pin, &GPIO_OUT_LED);
|
||||
GPIO_PinWrite(GPIOA, pin, 1);
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
int i = 0;
|
||||
uint8_t* bootPart = (uint8_t*)WOLFBOOT_PARTITION_BOOT_ADDRESS;
|
||||
uint32_t bootVer = wolfBoot_get_blob_version(bootPart);
|
||||
/* Enable GPIO port clocks */
|
||||
CLOCK_EnableClock(kCLOCK_GpioA);
|
||||
CLOCK_EnableClock(kCLOCK_PortA);
|
||||
CLOCK_EnableClock(kCLOCK_PortC);
|
||||
gpio_portA_init(18);
|
||||
gpio_portA_init(19);
|
||||
gpio_portA_init(20);
|
||||
|
||||
hal_init();
|
||||
if (bootVer == 1) {
|
||||
GPIO_PinWrite(GPIOA, 20, 0);
|
||||
wolfBoot_update_trigger();
|
||||
}
|
||||
else {
|
||||
/* Green LED GPIOA port A pin 19 */
|
||||
GPIO_PinWrite(GPIOA, 19, 0);
|
||||
/* mark boot successful */
|
||||
wolfBoot_success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* busy wait */
|
||||
while (1) {
|
||||
__WFI();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue