Skip to content

Commit dfc53df

Browse files
committed
Added support for NXP MCXA153
1 parent cf05199 commit dfc53df

File tree

8 files changed

+458
-0
lines changed

8 files changed

+458
-0
lines changed

arch.mk

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,36 @@ ifeq ($(TARGET),kinetis)
335335
endif
336336
endif
337337

338+
ifeq ($(TARGET),mcxa)
339+
CORTEX_M33=1
340+
CFLAGS+=\
341+
-I$(MCUXPRESSO_DRIVERS) \
342+
-I$(MCUXPRESSO_DRIVERS)/drivers \
343+
-I$(MCUXPRESSO)/drivers \
344+
-I$(MCUXPRESSO)/drivers/common \
345+
-I$(MCUXPRESSO_CMSIS)/Include \
346+
-I$(MCUXPRESSO_CMSIS)/Core/Include
347+
CFLAGS+=\
348+
-DCPU_$(MCUXPRESSO_CPU) -DDEBUG_CONSOLE_ASSERT_DISABLE=1 -DNVM_FLASH_WRITEONCE=1
349+
CFLAGS+=-Wno-old-style-declaration
350+
CFLAGS+=-mcpu=cortex-m33 -DCORTEX_M33 -U__ARM_FEATURE_DSP
351+
LDFLAGS+=-mcpu=cortex-m33
352+
OBJS+=\
353+
$(MCUXPRESSO_DRIVERS)/drivers/fsl_clock.o \
354+
$(MCUXPRESSO_DRIVERS)/drivers/fsl_spc.o
355+
356+
ifeq ($(MCUXSDK),1)
357+
CFLAGS+=\
358+
-I$(MCUXPRESSO)/drivers/flash \
359+
-I$(MCUXPRESSO)/drivers/sysmpu \
360+
-I$(MCUXPRESSO)/drivers/ltc \
361+
-I$(MCUXPRESSO)/drivers/port \
362+
-I$(MCUXPRESSO)/drivers/gpio
363+
364+
else
365+
endif
366+
endif
367+
338368
ifeq ($(TARGET),imx_rt)
339369
CFLAGS+=\
340370
-I$(MCUXPRESSO_DRIVERS) \

config/examples/mcxa.config

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
ARCH?=ARM
2+
TARGET?=mcxa
3+
SIGN?=ECC256
4+
HASH?=SHA256
5+
MCUXSDK?=0
6+
MCUXPRESSO?=$(PWD)/../NXP/MCXA153
7+
MCUXPRESSO_CMSIS?=$(MCUXPRESSO)/CMSIS
8+
MCUXPRESSO_CPU?=MCXA153VLH
9+
MCUXPRESSO_DRIVERS?=$(MCUXPRESSO)/devices/MCXA153
10+
DEBUG?=0
11+
VTOR?=1
12+
CORTEX_M0?=0
13+
NO_ASM?=1
14+
EXT_FLASH?=0
15+
SPI_FLASH?=0
16+
ALLOW_DOWNGRADE?=0
17+
NVM_FLASH_WRITEONCE?=1
18+
WOLFBOOT_VERSION?=0
19+
V?=0
20+
SPMATH?=1
21+
RAM_CODE?=1
22+
DUALBANK_SWAP?=0
23+
PKA?=1
24+
WOLFBOOT_PARTITION_SIZE?=0xB000
25+
WOLFBOOT_SECTOR_SIZE?=0x2000
26+
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0x8000
27+
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x13000
28+
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x1E000

docs/Targets.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ This README describes configuration of supported targets.
1414
* [NXP P1021 PPC](#nxp-qoriq-p1021-ppc)
1515
* [NXP T1024 PPC](#nxp-qoriq-t1024-ppc)
1616
* [NXP T2080 PPC](#nxp-qoriq-t2080-ppc)
17+
* [NXP MCXA153](#nxp-mcxa153)
1718
* [SiFive HiFive1 RISC-V](#sifive-hifive1-risc-v)
1819
* [STM32F4](#stm32f4)
1920
* [STM32F7](#stm32f7)
@@ -1710,6 +1711,35 @@ Executing Initialization File: /opt/Freescale/CodeWarrior_PA_10.5.1/PA/PA_Suppor
17101711
thread break: Stopped, 0x0, 0x0, cpuPowerPCBig, Connected (state, tid, pid, cpu, target)
17111712
```
17121713

1714+
## NXP MCXA153
1715+
1716+
NXP MCXA153 is a Cortex-M33 microcontroller running at 96MHz.
1717+
The support has been tested using FRDM-MCXA153 with the onboard MCU-Link
1718+
configured in JLink mode.
1719+
1720+
### Configuring and compiling
1721+
1722+
Copy the example configuration file:
1723+
1724+
`cp config/examples/mcxa.config .config`
1725+
1726+
Compile via:
1727+
1728+
`make`
1729+
1730+
### Loading the firmware
1731+
1732+
Use JLinkExe tool to upload the initial firmware:
1733+
1734+
`JLinkExe -if swd -Device MCXA153`
1735+
1736+
At the Jlink prompt, type:
1737+
1738+
```
1739+
J-Link>loadbin factory.bin 0
1740+
```
1741+
1742+
17131743

17141744
## TI Hercules TMS570LC435
17151745

hal/mcxa.c

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
/* mcxa.c
2+
*
3+
* Copyright (C) 2021 wolfSSL Inc.
4+
*
5+
* This file is part of wolfBoot.
6+
*
7+
* wolfBoot is free software; you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation; either version 2 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* wolfBoot is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program; if not, write to the Free Software
19+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20+
*/
21+
22+
#include <stdint.h>
23+
#include <target.h>
24+
#include "image.h"
25+
/* FSL includes */
26+
#include "fsl_common.h"
27+
28+
/* Clock + RAM voltage settings */
29+
#include "fsl_clock.h"
30+
#include "fsl_spc.h"
31+
32+
/* Flash driver */
33+
#include "fsl_romapi.h"
34+
35+
#define BOARD_BOOTCLOCKFRO96M_CORE_CLOCK 96000000U /*!< Core clock frequency: 96000000Hz */
36+
37+
static flash_config_t pflash;
38+
//static ftfx_cache_config_t pcache;
39+
static int flash_init = 0;
40+
41+
#ifdef __WOLFBOOT
42+
/* Assert hook needed by Kinetis SDK */
43+
void __assert_func(const char *a, int b, const char *c, const char *d)
44+
{
45+
while(1)
46+
;
47+
}
48+
49+
/* The following clock setting function is autogenerated by the MCUXpresso IDE */
50+
void BOARD_BootClockFRO96M(void)
51+
{
52+
uint32_t coreFreq;
53+
spc_active_mode_core_ldo_option_t ldoOption;
54+
spc_sram_voltage_config_t sramOption;
55+
56+
/* Get the CPU Core frequency */
57+
coreFreq = CLOCK_GetCoreSysClkFreq();
58+
59+
/* The flow of increasing voltage and frequency */
60+
if (coreFreq <= BOARD_BOOTCLOCKFRO96M_CORE_CLOCK) {
61+
/* Set the LDO_CORE VDD regulator level */
62+
ldoOption.CoreLDOVoltage = kSPC_CoreLDO_NormalVoltage;
63+
ldoOption.CoreLDODriveStrength = kSPC_CoreLDO_NormalDriveStrength;
64+
(void)SPC_SetActiveModeCoreLDORegulatorConfig(SPC0, &ldoOption);
65+
/* Configure Flash to support different voltage level and frequency */
66+
FMU0->FCTRL = (FMU0->FCTRL & ~((uint32_t)FMU_FCTRL_RWSC_MASK)) | (FMU_FCTRL_RWSC(0x2U));
67+
/* Specifies the operating voltage for the SRAM's read/write timing margin */
68+
sramOption.operateVoltage = kSPC_sramOperateAt1P1V;
69+
sramOption.requestVoltageUpdate = true;
70+
(void)SPC_SetSRAMOperateVoltage(SPC0, &sramOption);
71+
}
72+
73+
CLOCK_SetupFROHFClocking(96000000U); /*!< Enable FRO HF(96MHz) output */
74+
75+
CLOCK_SetupFRO12MClocking(); /*!< Setup FRO12M clock */
76+
77+
CLOCK_AttachClk(kFRO_HF_to_MAIN_CLK); /* !< Switch MAIN_CLK to FRO_HF */
78+
79+
/* The flow of decreasing voltage and frequency */
80+
if (coreFreq > BOARD_BOOTCLOCKFRO96M_CORE_CLOCK) {
81+
/* Configure Flash to support different voltage level and frequency */
82+
FMU0->FCTRL = (FMU0->FCTRL & ~((uint32_t)FMU_FCTRL_RWSC_MASK)) | (FMU_FCTRL_RWSC(0x2U));
83+
/* Specifies the operating voltage for the SRAM's read/write timing margin */
84+
sramOption.operateVoltage = kSPC_sramOperateAt1P1V;
85+
sramOption.requestVoltageUpdate = true;
86+
(void)SPC_SetSRAMOperateVoltage(SPC0, &sramOption);
87+
/* Set the LDO_CORE VDD regulator level */
88+
ldoOption.CoreLDOVoltage = kSPC_CoreLDO_NormalVoltage;
89+
ldoOption.CoreLDODriveStrength = kSPC_CoreLDO_NormalDriveStrength;
90+
(void)SPC_SetActiveModeCoreLDORegulatorConfig(SPC0, &ldoOption);
91+
}
92+
93+
/*!< Set up clock selectors - Attach clocks to the peripheries */
94+
95+
/*!< Set up dividers */
96+
CLOCK_SetClockDiv(kCLOCK_DivAHBCLK, 1U); /* !< Set AHBCLKDIV divider to value 1 */
97+
CLOCK_SetClockDiv(kCLOCK_DivFRO_HF_DIV, 1U); /* !< Set FROHFDIV divider to value 1 */
98+
}
99+
100+
101+
void hal_init(void)
102+
{
103+
/* Clock setting */
104+
BOARD_BootClockFRO96M();
105+
106+
/* Clear the FLASH configuration structure */
107+
memset(&pflash, 0, sizeof(pflash));
108+
/* FLASH driver init */
109+
FLASH_Init(&pflash);
110+
}
111+
112+
void hal_prepare_boot(void)
113+
{
114+
}
115+
116+
117+
#endif
118+
119+
int RAMFUNCTION hal_flash_write(uint32_t address, const uint8_t *data, int len)
120+
{
121+
int w = 0;
122+
int ret;
123+
const uint8_t empty_qword[16] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
124+
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
125+
126+
while (len > 0) {
127+
if ((len < 16) || address & 0x0F) {
128+
uint8_t aligned_qword[16];
129+
uint32_t address_align = address - (address & 0x0F);
130+
uint32_t start_off = address - address_align;
131+
int i;
132+
memcpy(aligned_qword, (void*)address_align, 16);
133+
for (i = start_off; ((i < 16) && (i < len + (int)start_off)); i++)
134+
aligned_qword[i] = data[w++];
135+
if (memcmp(aligned_qword, empty_qword, 16) != 0) {
136+
ret = FLASH_ProgramPhrase(&pflash, address_align, aligned_qword, 16);
137+
if (ret != kStatus_Success)
138+
return -1;
139+
}
140+
address += i;
141+
len -= i;
142+
} else {
143+
uint32_t len_align = len - (len & 0x0F);
144+
ret = FLASH_ProgramPhrase(&pflash, address, (uint8_t*)data + w, len_align);
145+
if (ret != kStatus_Success)
146+
return -1;
147+
len -= len_align;
148+
address += len_align;
149+
}
150+
}
151+
return 0;
152+
}
153+
154+
void RAMFUNCTION hal_flash_unlock(void)
155+
{
156+
}
157+
158+
void RAMFUNCTION hal_flash_lock(void)
159+
{
160+
}
161+
162+
163+
int RAMFUNCTION hal_flash_erase(uint32_t address, int len)
164+
{
165+
while ((address % 4) != 0)
166+
address --;
167+
if (FLASH_EraseSector(&pflash, address, len, kFLASH_ApiEraseKey) != kStatus_Success)
168+
return -1;
169+
return 0;
170+
}
171+
172+

hal/mcxa.ld

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
MEMORY
2+
{
3+
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = @BOOTLOADER_PARTITION_SIZE@
4+
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 24K
5+
}
6+
7+
SECTIONS
8+
{
9+
10+
.text :
11+
{
12+
_start_text = .;
13+
KEEP(*(.isr_vector))
14+
. = 0x200;
15+
*(.keystore*)
16+
*(.text*)
17+
*(.rodata*)
18+
*(.init*)
19+
*(.fini*)
20+
. = ALIGN(4);
21+
_end_text = .;
22+
} > FLASH
23+
24+
.edidx :
25+
{
26+
. = ALIGN(4);
27+
*(.ARM.exidx*)
28+
} > FLASH
29+
30+
_stored_data = .;
31+
32+
.data : AT (_stored_data)
33+
{
34+
_start_data = .;
35+
KEEP(*(.data*))
36+
. = ALIGN(4);
37+
_end_data = .;
38+
} > RAM
39+
40+
.bss (NOLOAD) :
41+
{
42+
_start_bss = .;
43+
__bss_start__ = .;
44+
*(.bss*)
45+
*(COMMON)
46+
. = ALIGN(4);
47+
_end_bss = .;
48+
__bss_end__ = .;
49+
_end = .;
50+
} > RAM
51+
. = ALIGN(4);
52+
}
53+
54+
END_STACK = ORIGIN(RAM) + LENGTH(RAM);

test-app/ARM-mcxa.ld

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
MEMORY
2+
{
3+
FLASH (rx) : ORIGIN = @WOLFBOOT_TEST_APP_ADDRESS@, LENGTH = @WOLFBOOT_TEST_APP_SIZE@
4+
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 24K
5+
}
6+
7+
SECTIONS
8+
{
9+
.text :
10+
{
11+
_start_text = .;
12+
KEEP(*(.isr_vector))
13+
*(.init)
14+
*(.fini)
15+
*(.text*)
16+
KEEP(*(.rodata*))
17+
. = ALIGN(4);
18+
_end_text = .;
19+
} > FLASH
20+
21+
.ARM :
22+
{
23+
__exidx_start = .;
24+
*(.ARM.exidx*)
25+
__exidx_end = .;
26+
} > FLASH
27+
28+
_stored_data = .;
29+
30+
.data : AT (_stored_data)
31+
{
32+
_start_data = .;
33+
KEEP(*(.data*))
34+
. = ALIGN(4);
35+
KEEP(*(.ramcode))
36+
. = ALIGN(4);
37+
_end_data = .;
38+
} > RAM
39+
40+
.bss :
41+
{
42+
_start_bss = .;
43+
*(.bss*)
44+
*(COMMON)
45+
. = ALIGN(4);
46+
_end_bss = .;
47+
_end = .;
48+
} > RAM
49+
}
50+
51+
_wolfboot_partition_boot_address = @WOLFBOOT_PARTITION_BOOT_ADDRESS@;
52+
_wolfboot_partition_size = @WOLFBOOT_PARTITION_SIZE@;
53+
_wolfboot_partition_update_address = @WOLFBOOT_PARTITION_UPDATE_ADDRESS@;
54+
_wolfboot_partition_swap_address = @WOLFBOOT_PARTITION_SWAP_ADDRESS@;
55+
56+
PROVIDE(_start_heap = _end);
57+
PROVIDE(_end_stack = ORIGIN(RAM) + LENGTH(RAM));

0 commit comments

Comments
 (0)