Skip to content

Commit 62e7fa8

Browse files
NOT READY FOR UPSTREAM: west flash support
This commit adds support for directly running west flash on the am243x_launchpad. It does this via a new script with minimal XMODEM1k support and a new sample. The code and documentation isn't finished and should not be submitted upstream yet! Signed-off-by: Mika Braunschweig <mika.braunschweig@siemens.com>
1 parent a70e897 commit 62e7fa8

11 files changed

Lines changed: 825 additions & 61 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Copyright (c) 2025 Siemens Mobility GmbH
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
board_set_flasher_ifnset(xmodem1k_sender)
6+
board_finalize_runner_args(xmodem1k_sender)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copyright (c) 2025 Siemens Mobility GmbH
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
if(NORMALIZED_BOARD_TARGET STREQUAL "am243x_launchpad_am2434_r5f0_0_boot")
6+
board_runner_args(xmodem1k_sender "--flash-offset=0x0" "--file=${PROJECT_BINARY_DIR}/zephyr.k3_rom_loadable.bin")
7+
include(${ZEPHYR_BASE}/boards/common/xmodem1k_sender.board.cmake)
8+
elseif(NORMALIZED_BOARD_TARGET STREQUAL "am243x_launchpad_am2434_r5f0_0")
9+
board_runner_args(xmodem1k_sender "--flash-offset=0x80000" "--file=${PROJECT_BINARY_DIR}/zephyr.signed.bin")
10+
include(${ZEPHYR_BASE}/boards/common/xmodem1k_sender.board.cmake)
11+
endif()

boards/ti/am243x_launchpad/doc/index.rst

Lines changed: 31 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
.. zephyr:board:: am243x_launchpad
22
3+
.. TODO: Improve formatting and descriptions!
4+
.. This documentation isn't ready for upstream yet!
5+
36
Overview
47
********
58

@@ -93,10 +96,11 @@ MCU+ SDK to set up some peripherals like UART clocks. Only in this bootmode the
9396
TCM memory can be used.
9497

9598
Depending on the boot mode selection you require different parts of the MCU+
96-
SDK. If you want to start an application only via UART you need the Python tools
97-
of the MCU+ SDK and binary files of the repo.
98-
If you want to boot from flash via MCUboot or chain-load after a SBL bootloader
99-
from the TI MCU+ SDK you need to fully set up the SDK and build some of the examples.
99+
SDK.
100+
If you want to load a Zephyr application via UART or load an Zephyr application
101+
after MCUboot from flash you only need binary files from the MCU+ SDK.
102+
If you want to chain-load a Zephyr application after a SBL bootloader from the
103+
TI MCU+ SDK you need to fully set up the SDK and build some of the examples.
100104

101105

102106
Setting up the MCU+ SDK
@@ -236,60 +240,19 @@ the ``mcu_plus_sdk``.
236240
Loading an application via UART
237241
-------------------------------
238242
To run an application via UART you need to change the boot DIP switches on the
239-
board into ``11100000`` position. After that you need to connect the board and
240-
run the ``uart_bootloader.py`` script with the venv active, if you created one
241-
during setup. The script is under ``tools/boot`` inside the ``mcu_plus_sdk``
242-
directory. You additionally need to provide the UART interface (e.g.
243-
``/dev/ttyACM0`` under Linux) and the file you want to run.
244-
245-
.. code-block:: console
246-
247-
python3 uart_bootloader.py -p /dev/ttyACM0 --bootloader=<file-to-run>
248-
249-
250-
Flashing data onto the flash
251-
----------------------------
252-
253-
To flash data onto the flash you need to create a config file first. It should
254-
have the following contents:
255-
256-
.. code-block::
257-
258-
--flash-writer=<sbl_uart_uniflash-tiimage-output>
259-
--file=<file-to-flash> --operation=flash --flash-offset=<flash-offset>
260-
261-
The ``<sbl_uart_uniflash-tiimage-output>`` needs to be replaced with the path to
262-
the output file you got when building the ``sbl_uart_uniflash`` example.
263-
264-
The ``<file-to-flash>`` needs to replaced with the file you want to flash,
265-
usually a Zephyr application, MCUboot or the ``sbl_ospi`` bootloader.
266-
267-
The ``<flash-offset>`` is the place where the file should be flashed in
268-
hexadecimal. For bootloaders or when starting Zephyr directly it's ``0x0`` and
269-
for Zephyr applications after the bootloader it's usually ``0x80000``.
270-
271-
Then you need switch the boot DIP switches into ``11100000`` position and run
272-
the ``uart_uniflash.py`` script that can be found under ``tools/boot`` with the
273-
MCU+ SDK venv activated, if you created one.
243+
board into ``11100000`` position, build an application for the ``boot`` variant
244+
with the Kconfig options set correctly in `Required binary files`_. After that
245+
you can just run
274246

275247
.. code-block:: console
276-
python3 uart_uniflash.py -p /dev/ttyACM0 --cfg <path-to-config>
277-
278-
279-
Booting Zephyr via UART
280-
-----------------------
281-
282-
To boot via UART you need to build your application for the ``boot`` target,
283-
including setting the Kconfig options as described in `Required binary files`_.
284-
285-
After that you can run it as described in `Loading an application via UART`_.
286-
The file you need to run is
287-
``<your-build-directory>/zephyr/zephyr.k3_rom_loadable.bin``.
248+
west flash --no-header
288249
289250
290251
Booting Zephyr from Flash via MCUboot
291252
-------------------------------------
292253

254+
The following sections will describe how to configure MCUboot and the Zephyr
255+
application and booting it from flash.
293256

294257
Building and flashing MCUboot
295258
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -298,7 +261,8 @@ First you need to build MCUboot for the ``boot`` target. Please make sure your
298261
version is new enough for Cortex-R support. You need to set the Kconfig options
299262
described in `Loading an application via UART`_.
300263

301-
Additionally you need to set the following Kconfig options manually:
264+
Additionally you need to set the following Kconfig options additionally to the
265+
ones described in `Required binary files`_ manually:
302266

303267
+----------------------------------------+------------+
304268
| Symbol | Value |
@@ -308,16 +272,22 @@ Additionally you need to set the following Kconfig options manually:
308272
| CONFIG_BOOT_IMAGE_EXECUTABLE_RAM_START | 0x70080000 |
309273
+----------------------------------------+------------+
310274

311-
After building you need to flash the file
312-
``<your-build-directory>/zephyr/zephyr.k3_rom_loadable.bin`` to ``0x0`` as
313-
described in `Flashing data onto the flash`_.
275+
Additionally you also need to to build the sample called ``xmodem1k_flasher``
276+
that can be found under ``samples/drivers/uart/xmodem1k_flasher`` for the
277+
``boot`` board variant with the Kconfig options set that are described in
278+
`Loading an application via UART`_.
279+
280+
Then you need to temporarly execute the ``xmodem1k_flasher`` by running ``west
281+
flash`` inside the directory of the sample. After that you can simply flash
282+
MCUboot to external flash by running ``west flash``, while the
283+
``xmodem1k_flasher`` sample is running on the board.
314284

315285

316286
Building and flashing a Zephyr application
317287
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
318288

319289
Next you can build your Zephyr application (for the non-boot variant!). Here you
320-
also need to manually change some Kconfig options.
290+
also need to manually change some Kconfig options:
321291

322292
+-----------------------------------------+------------+
323293
| Symbol | Value |
@@ -331,12 +301,12 @@ also need to manually change some Kconfig options.
331301

332302
The ``CONFIG_MCUBOOT_SIGNATURE_KEY_FILE`` leads to your private key with which
333303
you signed the application. The default private key is inside the mcuboot
334-
project with the name ``root-rsa-2048.pem``.
335-
336-
You then need to flash the file
337-
``<your-build-directory>/zephyr/zephyr.signed.bin`` at the offset ``0x80000`` as
338-
described in `Flashing data onto the flash`_.
304+
project with the name ``root-rsa-2048.pem``. You shouldn't set the
305+
``CONFIG_TI_K3_*`` options since they are not required.
339306

307+
Then you should reset the board, run the ``xmodem1k_flasher`` sample again and
308+
run ``west flash`` from inside your application directory while the
309+
``xmodem1k_flasher`` is running on the board.
340310

341311
Running
342312
^^^^^^^
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright (c) 2025 Siemens Mobility GmbH
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
cmake_minimum_required(VERSION 3.28.0)
6+
7+
# The AM2434 can receive binary files via the XModem1k protocol for execution.
8+
# In this case the file needs to be sent without any default header that the
9+
# code in this sample could parse
10+
macro(app_set_runner_args)
11+
# TODO: This should ideally be board agnostic and only check for the am2434 SoC!
12+
if(NORMALIZED_BOARD_TARGET STREQUAL "am243x_launchpad_am2434_r5f0_0_boot")
13+
board_runner_args(xmodem1k_sender "--no-header")
14+
endif()
15+
endmacro()
16+
17+
find_package(Zephyr)
18+
project(xmodem1k_flasher)
19+
20+
message(WARNING "This sample is not compliant to the XMODEM1k protocol in terms \
21+
of retransmissions and timeouts. Please take a look at the comment inside \
22+
samples/drivers/uart/xmodem1k_flasher/main.c")
23+
24+
target_sources(app PRIVATE src/main.c)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
.. zephyr:code-sample:: xmodem1k_flasher
2+
:name: XMODEM1k based flashing sample
3+
:relevant-api: uart_interface flash_interface
4+
5+
Flash data received via the XMODEM1k protocol to connected external flash
6+
7+
Overview
8+
********
9+
10+
TODO: Write
11+
12+
Requirements
13+
************
14+
15+
TODO: Write
16+
17+
Building and Running
18+
********************
19+
20+
TODO: Write
21+
22+
.. zephyr-app-commands::
23+
:zephyr-app: samples/drivers/uart/xmodem1k_flasher
24+
:board: TODO
25+
:goals: build flash
26+
:compact:
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright (c) 2025 Siemens Mobility GmbH
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
CONFIG_SERIAL=y
6+
CONFIG_UART_INTERRUPT_DRIVEN=y
7+
CONFIG_FLASH=y
8+
CONFIG_FLASH_PAGE_LAYOUT=y
9+
CONFIG_CRC=y
10+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# TODO: Write

0 commit comments

Comments
 (0)