Skip to content

Commit f4c0b9b

Browse files
committed
boards: nxp: add frdm_mcxe31b board support
- support XIP way to boot - add board doc and picture - enable cases below: hello_world/blinky/button/ philosophers/synchronization/ gpio_basic_api Signed-off-by: Lucien Zhao <[email protected]>
1 parent 8e77d53 commit f4c0b9b

File tree

15 files changed

+571
-0
lines changed

15 files changed

+571
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Copyright 2025 NXP
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
if(CONFIG_BOARD_NXP_MCXE31X_BOOT_HEADER)
5+
zephyr_library_sources(boot_header/boot_header.c)
6+
zephyr_library_include_directories(boot_header)
7+
endif()

boards/nxp/frdm_mcxe31b/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright 2025 NXP
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config BOARD_NXP_MCXE31X_BOOT_HEADER
5+
bool "MCXE31x boot header support"
6+
select SOC_NXP_MCXE31X_BOOT_HEADER
7+
default y
8+
help
9+
Enable this option to include the MCXE31x boot header in the final
10+
image. The boot header is required for proper operation of the
11+
on-chip bootloader.
12+
See the MCXE31x reference manual for more details.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright 2025 NXP
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config BOARD_FRDM_MCXE31B
5+
select SOC_PART_NUMBER_MCXE31BMPB
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright 2025 NXP
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
board_runner_args(jlink "--device=MCXE31B")
5+
board_runner_args(linkserver "--device=MCXE31B:FRDM-MCXE31B")
6+
7+
include(${ZEPHYR_BASE}/boards/common/linkserver.board.cmake)
8+
include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake)

boards/nxp/frdm_mcxe31b/board.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
board:
2+
name: frdm_mcxe31b
3+
full_name: FRDM-MCXE31B
4+
vendor: nxp
5+
socs:
6+
- name: mcxe31b
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/*
2+
* Copyright 2025 NXP
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include "boot_header.h"
8+
#include "fsl_common.h"
9+
10+
/******************************************************************************
11+
* External references
12+
******************************************************************************/
13+
#if defined(CONFIG_BOARD_NXP_MCXE31X_BOOT_HEADER) && (CONFIG_BOARD_NXP_MCXE31X_BOOT_HEADER != 0U)
14+
15+
extern void *const _vector_start;
16+
17+
/******************************************************************************
18+
* Boot Header
19+
******************************************************************************/
20+
typedef struct image_vector_table {
21+
uint32_t header; /* header */
22+
uint32_t boot_config; /* Boot configuration Word */
23+
const uint32_t reserved1; /* Reserved */
24+
const uint32_t *cm7_0_start_address; /* Start address of CM7_0 Core */
25+
const uint32_t reserved2; /* Reserved */
26+
const uint32_t *reserved3; /* Reserved */
27+
const uint32_t reserved4; /* Reserved */
28+
const uint32_t *reserved5; /* Reserved */
29+
const uint32_t *reserved6; /* Reserved */
30+
const uint32_t *lcc_config; /* Address of LC config */
31+
uint8_t reserved7[216]; /* Reserved for future use */
32+
} ivt_t;
33+
34+
/******************************************************************************
35+
* SBAF definitions
36+
******************************************************************************/
37+
/* CM7_0_ENABLE: */
38+
/* 0- Cortex-M7_0 application core clock gated after boot */
39+
/* 1- Cortex-M7_0 application core clock un-gated after boot */
40+
#define CM7_0_ENABLE_MASK 1U
41+
42+
/* Control the boot flow of the application: */
43+
/* 0- Non-Secure Boot- Application image is started by SBAF without any */
44+
/* authentication in parallel to HSE firmware. */
45+
/* 1- Secure Boot- Application image is executed by HSE firmware after the */
46+
/* authentication. SBAF only starts the HSE firmware after successful */
47+
/* authentication. */
48+
#define BOOT_SEQ_MASK 8U
49+
50+
/* APP_SWT_INIT: Control SWT0 before starting application core(s): */
51+
/* 0- Disable. */
52+
/* 1- Enable. SBAF initializes SWT0 before enabling application cores. */
53+
/* SBAF scans this bit only when BOOT_SEQ bit is 0. */
54+
#define APP_SWT_INIT_MASK 32U
55+
56+
/*!
57+
* @brief Sets register field in peripheral configuration structure.
58+
* @details This macro sets register field <c>mask</c> in the peripheral
59+
* configuration structure.
60+
* @param mask Register field to be set.
61+
* @note Implemented as a macro.
62+
*/
63+
#define SET(mask) (mask)
64+
65+
/*!
66+
* @brief Clears register field in peripheral configuration structure.
67+
* @details This macro clears register field <c>mask</c> in the peripheral
68+
* configuration structure.
69+
* @param mask Register field to be cleared.
70+
* @note Implemented as a macro.
71+
*/
72+
#define CLR(mask) 0
73+
74+
const ivt_t _boot_header __attribute__((used, section(".boot_header"))) = {
75+
.header = 0x5AA55AA5,
76+
.boot_config = SET(CM7_0_ENABLE_MASK) | /* booting core is core0 */
77+
CLR(BOOT_SEQ_MASK) | /* unsecure boot is only supported */
78+
CLR(APP_SWT_INIT_MASK), /* SWT0 is not setup by BAF */
79+
.cm7_0_start_address = (const uint32_t *)&_vector_start,
80+
.lcc_config = (const uint32_t *)&lc_config};
81+
82+
/******************************************************************************
83+
* Default configurations that can be overridden by strong definitions
84+
******************************************************************************/
85+
86+
__WEAK const boot_lc_config_t lc_config = 0xffffffff;
87+
88+
#endif /* CONFIG_BOARD_NXP_MCXE31X_BOOT_HEADER */
89+
/******************************************************************************
90+
* End of module
91+
******************************************************************************/
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright 2025 NXP
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef ZEPHYR_INCLUDE_BOOT_HEADER_H_
8+
#define ZEPHYR_INCLUDE_BOOT_HEADER_H_
9+
10+
#include "fsl_common.h"
11+
12+
/******************************************************************************
13+
* Configuration structure definition *
14+
******************************************************************************/
15+
16+
typedef uint32_t boot_lc_config_t;
17+
extern const boot_lc_config_t lc_config;
18+
19+
#endif /* ZEPHYR_INCLUDE_BOOT_HEADER_H_ */
41.8 KB
Loading
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
.. zephyr:board:: frdm_mcxe31b
2+
3+
Overview
4+
********
5+
The FRDM-MCXE31B board is a design and evaluation platform based on the NXP MCXE31B
6+
microcontroller (MCU). NXP MCXE31B MCU based on an Arm Cortex-M7 core, running at
7+
speeds of up to 160 MHz with a 2.97 to 5.5V supply.
8+
9+
Hardware
10+
********
11+
12+
- MCXE31B Arm Cortex-M7 microcontroller running up to 160 MHz
13+
- 4MB dual-bank on chip Flash
14+
- 320KB SRAM + 192KB TCM
15+
- 2x I2C
16+
- 6x SPI
17+
- 16x UART
18+
- On-board MCU-Link debugger with CMSIS-DAP
19+
- Arduino Header, mikroBUS
20+
21+
For more information about the MCXE31B SoC and FRDM-MCXE31B board, see:
22+
23+
- `MCXE31X Datasheet`_
24+
- `MCXE31X Reference Manual`_
25+
- `FRDM-MCXE31B Board User Manual`_
26+
27+
Supported Features
28+
==================
29+
30+
.. zephyr:board-supported-hw::
31+
32+
Connections and IOs
33+
===================
34+
35+
Each GPIO port is divided into two banks: low bank, from pin 0 to 15, and high
36+
bank, from pin 16 to 31. For example, ``PTA2`` is the pin 2 of ``gpioa_l`` (low
37+
bank), and ``PTA20`` is the pin 4 of ``gpioa_h`` (high bank).
38+
39+
The GPIO controller provides the option to route external input pad interrupts
40+
to either the SIUL2 EIRQ or WKPU interrupt controllers, as supported by the SoC.
41+
By default, GPIO interrupts are routed to SIUL2 EIRQ interrupt controller,
42+
unless they are explicity configured to be directed to the WKPU interrupt
43+
controller, as outlined in :zephyr_file:`dts/bindings/gpio/nxp,siul2-gpio.yaml`.
44+
45+
To find information about which GPIOs are compatible with each interrupt
46+
controller, refer to the device reference manual.
47+
48+
+-------+-------------+---------------------------+
49+
| Name | Function | Usage |
50+
+=======+=============+===========================+
51+
| PTC16 | GPIO | Red LED |
52+
+-------+-------------+---------------------------+
53+
| PTB22 | GPIO | Green LED |
54+
+-------+-------------+---------------------------+
55+
| PTC14 | GPIO | Blue LED |
56+
+-------+-------------+---------------------------+
57+
| PTE3 | LPUART5_RX | UART Console |
58+
+-------+-------------+---------------------------+
59+
| PTE14 | LPUART5_TX | UART Console |
60+
+-------+-------------+---------------------------+
61+
62+
System Clock
63+
============
64+
65+
The MCXE31B SoC is configured to use PLL running at 160MHz as a source for
66+
the system clock.
67+
68+
Serial Port
69+
===========
70+
71+
The MCXE31B LPUART5 is used for the console.
72+
73+
Programming and Debugging
74+
*************************
75+
76+
.. zephyr:board-supported-runners::
77+
78+
Build and flash applications as usual (see :ref:`build_an_application` and
79+
:ref:`application_run` for more details).
80+
81+
Configuring a Debug Probe
82+
=========================
83+
84+
A debug probe is used for both flashing and debugging the board. This board is
85+
configured by default to use the MCU-Link CMSIS-DAP Onboard Debug Probe.
86+
87+
Using LinkServer
88+
----------------
89+
90+
Linkserver is the default runner for this board, and supports the factory
91+
default MCU-Link firmware. Follow the instructions in
92+
:ref:`mcu-link-cmsis-onboard-debug-probe` to reprogram the default MCU-Link
93+
firmware. This only needs to be done if the default onboard debug circuit
94+
firmware was changed. To put the board in ``ISP mode`` to program the firmware,
95+
short jumper JP3.
96+
97+
Using J-Link
98+
------------
99+
100+
There are two options. The onboard debug circuit can be updated with Segger
101+
J-Link firmware by following the instructions in
102+
:ref:`mcu-link-jlink-onboard-debug-probe`.
103+
To be able to program the firmware, you need to put the board in ``ISP mode``
104+
by shorting the jumper JP3.
105+
The second option is to attach a :ref:`jlink-external-debug-probe` to the
106+
10-pin SWD connector (J14) of the board.
107+
For both options use the ``-r jlink`` option with west to use the jlink runner.
108+
109+
.. code-block:: console
110+
111+
west flash -r jlink
112+
113+
Configuring a Console
114+
=====================
115+
116+
Connect a USB cable from your PC to J13, and use the serial terminal of your choice
117+
(minicom, putty, etc.) with the following settings:
118+
119+
- Speed: 115200
120+
- Data: 8 bits
121+
- Parity: None
122+
- Stop bits: 1
123+
124+
Flashing
125+
========
126+
127+
Here is an example for the :zephyr:code-sample:`hello_world` application.
128+
129+
.. zephyr-app-commands::
130+
:zephyr-app: samples/hello_world
131+
:board: frdm_mcxe31b
132+
:goals: flash
133+
134+
Open a serial terminal, reset the board (press the RESET button), and you should
135+
see the following message in the terminal:
136+
137+
.. code-block:: console
138+
139+
*** Booting Zephyr OS build v4.2.0-2092-g17e93a718422 ***
140+
Hello World! frdm_mcxe31b/mcxe31b
141+
142+
Debugging
143+
=========
144+
145+
Here is an example for the :zephyr:code-sample:`hello_world` application.
146+
147+
.. zephyr-app-commands::
148+
:zephyr-app: samples/hello_world
149+
:board: frdm_mcxe31b
150+
:goals: debug
151+
152+
Open a serial terminal, step through the application in your debugger, and you
153+
should see the following message in the terminal:
154+
155+
.. code-block:: console
156+
157+
*** Booting Zephyr OS build v4.2.0-2092-g17e93a718422 ***
158+
Hello World! frdm_mcxe31b/mcxe31b
159+
160+
Troubleshooting
161+
===============
162+
163+
.. include:: ../../common/segger-ecc-systemview.rst.inc
164+
165+
.. include:: ../../common/board-footer.rst.inc
166+
167+
.. _MCXE31X Datasheet:
168+
https://www.nxp.com/docs/en/data-sheet/MCXEP172M160FB0.pdf
169+
170+
.. _MCXE31X Reference Manual:
171+
https://www.nxp.com/webapp/Download?colCode=MCXE31XRM&location=null
172+
173+
.. _FRDM-MCXE31B Board User Manual:
174+
https://www.nxp.com/webapp/Download?colCode=UM12330&location=null&isHTMLorPDF=HTML
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright 2025 NXP
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
7+
#include <nxp/mcx/MCXE31BMPB-pinctrl.h>
8+
9+
&pinctrl {
10+
eirq0_default: eirq0_default {
11+
group1 {
12+
pinmux = <PTD5_EIRQ13>;
13+
input-enable;
14+
};
15+
};
16+
17+
pinmux_lpuart_5: pinmux_lpuart_5 {
18+
group1 {
19+
pinmux = <PTE14_LPUART5_TX_O>;
20+
output-enable;
21+
};
22+
23+
group2 {
24+
pinmux = <PTE3_LPUART5_RX>;
25+
input-enable;
26+
};
27+
};
28+
};

0 commit comments

Comments
 (0)