Skip to content

Commit 8cf3f5b

Browse files
committed
boards: imx93_evk: add spsdk runner support for A55 Core
Added SPSDK runner support, it could be used to flash Zephyr image. Signed-off-by: Jiafei Pan <Jiafei.Pan@nxp.com>
1 parent 3ea2951 commit 8cf3f5b

File tree

4 files changed

+154
-6
lines changed

4 files changed

+154
-6
lines changed
Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,86 @@
11
#
2-
# Copyright 2025 NXP
2+
# Copyright 2025-2026 NXP
33
#
44
# SPDX-License-Identifier: Apache-2.0
55

6+
if(CONFIG_BOARD_NXP_SPSDK_IMAGE OR (DEFINED ENV{USE_NXP_SPSDK_IMAGE}
7+
AND "$ENV{USE_NXP_SPSDK_IMAGE}" STREQUAL "y"))
8+
find_program(7Z_EXECUTABLE 7z REQUIRED)
9+
set(FIRMWARE_RELEASE "imx93evk-boot-firmware-0.1")
10+
# Parse SPSDK version
11+
execute_process(
12+
COMMAND spsdk --version
13+
OUTPUT_VARIABLE SPSDK_VERSION_OUTPUT
14+
OUTPUT_STRIP_TRAILING_WHITESPACE
15+
)
16+
string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" SPSDK_VERSION "${SPSDK_VERSION_OUTPUT}")
17+
message(STATUS "SPSDK version is ${SPSDK_VERSION}")
18+
19+
if(CONFIG_SOC_MIMX9352_A55)
20+
file(WRITE ${CMAKE_BINARY_DIR}/zephyr/imx93_evk_mimx9352_a55_ahab_primary.yaml
21+
"
22+
family: mimx9352
23+
revision: a1
24+
target_memory: serial_downloader
25+
output: ${CMAKE_BINARY_DIR}/zephyr/primary_ahab.bin
26+
containers:
27+
- binary_container:
28+
path: ${CMAKE_BINARY_DIR}/zephyr/${FIRMWARE_RELEASE}/mx93a1-ahab-container.img
29+
- container:
30+
srk_set: none
31+
images:
32+
- lpddr_imem_1d: ${CMAKE_BINARY_DIR}/zephyr/${FIRMWARE_RELEASE}/lpddr4_imem_1d_v202201.bin
33+
lpddr_imem_2d: ${CMAKE_BINARY_DIR}/zephyr/${FIRMWARE_RELEASE}/lpddr4_imem_2d_v202201.bin
34+
lpddr_dmem_1d: ${CMAKE_BINARY_DIR}/zephyr/${FIRMWARE_RELEASE}/lpddr4_dmem_1d_v202201.bin
35+
lpddr_dmem_2d: ${CMAKE_BINARY_DIR}/zephyr/${FIRMWARE_RELEASE}/lpddr4_dmem_2d_v202201.bin
36+
spl_ddr: ${CMAKE_BINARY_DIR}/zephyr/${FIRMWARE_RELEASE}/u-boot-spl.bin-imx93evk-sd
37+
")
38+
file(WRITE ${CMAKE_BINARY_DIR}/zephyr/imx93_evk_mimx9352_a55_ahab_secondary.yaml
39+
"
40+
family: mimx9352
41+
revision: a1
42+
target_memory: serial_downloader
43+
output: ${CMAKE_BINARY_DIR}/zephyr/secondary_ahab.bin
44+
containers:
45+
- container:
46+
srk_set: none
47+
images:
48+
- atf: ${CMAKE_BINARY_DIR}/zephyr/${FIRMWARE_RELEASE}/bl31-imx93-zephyr.bin
49+
- image_path: ${CMAKE_BINARY_DIR}/zephyr/${CONFIG_KERNEL_BIN_NAME}.bin
50+
load_address: '${CONFIG_SRAM_BASE_ADDRESS}'
51+
entry_point: '${CONFIG_SRAM_BASE_ADDRESS}'
52+
image_type: executable
53+
core_id: cortex-a55
54+
is_encrypted: false
55+
")
56+
file(WRITE ${CMAKE_BINARY_DIR}/zephyr/imx93_evk_mimx9352_a55_ahab_flash_template.yaml
57+
"
58+
family: mimx9352
59+
revision: a1
60+
memory_type: serial_downloader
61+
primary_image_container_set: ${CMAKE_BINARY_DIR}/zephyr/imx93_evk_mimx9352_a55_ahab_primary.yaml
62+
secondary_image_container_set: ${CMAKE_BINARY_DIR}/zephyr/imx93_evk_mimx9352_a55_ahab_secondary.yaml
63+
")
64+
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
65+
COMMAND ${7Z_EXECUTABLE} x ${ZEPHYR_HAL_NXP_MODULE_DIR}/zephyr/blobs/imx-boot-firmware/${FIRMWARE_RELEASE}.bin -o./imx-boot-firmware -aos -bso0 -bse1
66+
COMMAND ${7Z_EXECUTABLE} x imx-boot-firmware/${FIRMWARE_RELEASE} -aos -bso0 -bse1
67+
)
68+
if(SPSDK_VERSION VERSION_GREATER_EQUAL "3.0.0")
69+
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
70+
COMMAND nxpimage bootable-image export -c ${CMAKE_BINARY_DIR}/zephyr/imx93_evk_mimx9352_a55_ahab_flash_template.yaml -o flash.bin
71+
)
72+
else()
73+
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
74+
COMMAND nxpimage bootable-image merge -c ${CMAKE_BINARY_DIR}/zephyr/imx93_evk_mimx9352_a55_ahab_flash_template.yaml -o flash.bin
75+
)
76+
endif()
77+
else()
78+
message(FATAL_ERROR "SPSDK Image not supported on the platform!")
79+
endif()
80+
zephyr_blobs_verify(FILES
81+
${ZEPHYR_HAL_NXP_MODULE_DIR}/zephyr/blobs/imx-boot-firmware/${FIRMWARE_RELEASE}.bin
82+
REQUIRED)
83+
endif()
84+
685
zephyr_library()
786
zephyr_library_sources(board.c)

boards/nxp/imx93_evk/Kconfig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# i.MX 93 EVK board configuration
22

3-
# Copyright 2024 NXP
3+
# Copyright 2024-2026 NXP
44
# SPDX-License-Identifier: Apache-2.0
55

66
config BOARD_MIMX93_EVK_EXP_SEL_INIT
@@ -14,3 +14,5 @@ config BOARD_MIMX93_EVK_EXP_SEL_INIT_PRIO
1414
module = BOARD_MIMX93_EVK
1515
module-str = Board Control
1616
source "subsys/logging/Kconfig.template.log_config"
17+
18+
source "boards/nxp/common/Kconfig"

boards/nxp/imx93_evk/board.cmake

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
#
2-
# Copyright 2025 NXP
2+
# Copyright 2025-2026 NXP
33
#
44
# SPDX-License-Identifier: Apache-2.0
55

6-
if(CONFIG_SOC_MIMX9352_A55)
6+
if(CONFIG_BOARD_NXP_SPSDK_IMAGE OR (DEFINED ENV{USE_NXP_SPSDK_IMAGE}
7+
AND "$ENV{USE_NXP_SPSDK_IMAGE}" STREQUAL "y"))
8+
board_set_flasher_ifnset(spsdk)
79

8-
board_runner_args(jlink "--device=MIMX9352_A55_0" "--no-reset" "--flash-sram")
10+
board_runner_args(spsdk "--family=mimx9352")
11+
board_runner_args(spsdk "--bootloader=${CMAKE_BINARY_DIR}/zephyr/imx93evk-boot-firmware-0.1/imx-boot-imx93evk-sd.bin-flash_singleboot")
12+
board_runner_args(spsdk "--flashbin=${CMAKE_BINARY_DIR}/zephyr/flash.bin")
13+
if(CONFIG_CPU_CORTEX_A55)
14+
board_runner_args(spsdk "--containers=one")
15+
else()
16+
board_runner_args(spsdk "--containers=one")
17+
endif()
918

10-
include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake)
19+
include(${ZEPHYR_BASE}/boards/common/spsdk.board.cmake)
20+
endif()
1121

22+
if(CONFIG_SOC_MIMX9352_A55)
23+
board_runner_args(jlink "--device=MIMX9352_A55_0" "--no-reset" "--flash-sram")
24+
include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake)
1225
endif()

boards/nxp/imx93_evk/doc/index.rst

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,60 @@ display the following console output:
289289
thread_a: Hello World from cpu 0 on imx93_evk!
290290
thread_b: Hello World from cpu 0 on imx93_evk!
291291
292+
Option 4. Boot Zephyr by Using SPSDK Runner
293+
===========================================
294+
295+
SPSDK runner leverages SPSDK tools (https://spsdk.readthedocs.io), it builds an
296+
bootable flash image ``flash.bin`` which includes all necessary firmware components.
297+
Using west flash command will download the boot image flash.bin to DDR memory, SD card
298+
or eMMC flash. By using flash.bin, as no U-Boot image is available, so TF-A will boot
299+
up Zephyr on the first Cortex-A55 Core directly.
300+
301+
In order to use SPSDK runner, it requires fetching binary blobs, which can be achieved
302+
by running the following command:
303+
304+
.. code-block:: console
305+
306+
west blobs fetch hal_nxp
307+
308+
.. note::
309+
310+
It is recommended running the command above after :file:`west update`.
311+
312+
SPSDK runner is enabled by configure item :kconfig:option:`CONFIG_BOARD_NXP_SPSDK_IMAGE`, currently
313+
it is not enabled by default for i.MX93 EVK board, so use this configuration to enable
314+
it, for example, with the :zephyr:code-sample:`synchronization` sample:
315+
316+
.. zephyr-app-commands::
317+
:zephyr-app: samples/synchronization
318+
:host-os: unix
319+
:board: imx93_evk/mimx9352/a55
320+
:goals: build
321+
:gen-args: -DCONFIG_BOARD_NXP_SPSDK_IMAGE=y
322+
323+
If :kconfig:option:`CONFIG_BOARD_NXP_SPSDK_IMAGE` is available and enabled for the board variant,
324+
``flash.bin`` will be built automatically. The programming could be through below commands.
325+
Before that, onboard switch SW1302[4:1] should be configured to 0b0011 for usb download mode
326+
to boot, and USB1 and DBG ports should be connected to Linux host PC. There are 4 serial ports
327+
enumerated (115200 8n1), fourth serial port will be used for Cortex-A55 Zephyr.
328+
(The flasher is spsdk which already installed via scripts/requirements.txt.
329+
On linux host, usb device permission should be configured per Installation Guide
330+
of https://spsdk.readthedocs.io)
331+
332+
.. code-block:: none
333+
334+
# load and run without programming. for next flashing, execute 'reset' in the
335+
# fourth serail port
336+
$ west flash -r spsdk
337+
338+
# program to SD card, then set SW1302[4:1]=0b0010 to reboot from SD
339+
$ west flash -r spsdk --bootdevice sd
340+
341+
# program to emmc card, then set SW1302[4:1]=0b0000 to reboot from EMMC
342+
$ west flash -r spsdk --bootdevice=emmc
343+
344+
Then the Zephyr log will displayed in the fourth serial port console.
345+
292346
System Reboot (A55)
293347
===================
294348

0 commit comments

Comments
 (0)