Production Programming for the Cortex-M
Introduction
This article will guide you through the production programming workflow for Cortex-M. Note that this procedure is supported in both Torizon OS and BSP Reference Images.
This article complies with the typographic conventions.
Typographic Conventions
Throughout the Toradex documentation, the following typographic conventions are used:
$ (dollar sign) Command in the host computer (e.g. your PC)
$ Command in your PC
$$ (double dollar sign) Command in a container in the host computer (e.g. your PC)
$$ Command inside a container in your PC
# (hashtag) Command in the target device/board (e.g. Linux terminal)
# Command in the target board, e.g. Colibri iMX6
## (double hashtag) Command inside a container in the target device (Torizon)
## Command inside a container in Torizon
> (greater-than sign) Command in the bootloader (e.g. U-Boot console)
> Command in the Bootloader
No symbol: Command output
$ Command waiting for output
Output
Step-by-Step
In this section, ${SDK_INSTALL_PATH} refers to the path where the SDK is installed. The default installation path is ${HOME}/ti/mcu_plus_sdk_<SoC>_<version>/.
TorizonCore Builder offers a fast and easy way to perform production programming by capturing the changes already made to a running Torizon OS device. The procedure involves copying the firmware (built using the MCU+ SDK) to your module, moving it to a specific folder on the Linux rootfs, and capturing the changes (see Capturing Changes in the Configuration of a Board on Torizon OS) to provision devices at scale.
The TorizonCore Builder isolate command captures all the changes under the /etc folder. Create a folder under /etc to place the Cortex-M firmware (root permissions needed):
# sudo mkdir /etc/cortex-m-firmware
Transfer and rename the built firmware using the scp command, replacing <hostname> as described at (SSH - Connect Through Network)[/software/development-resources/ssh/#using-the-hostname]:
$ scp ${SDK_INSTALL_PATH}/examples/hello_world/am62x-sk/m4fss0-0_freertos/ti-arm-clang/hello_world.release.out torizon@<hostname>:/home/torizon/am62-mcu-m4f0_0-fw
Then, access the module's terminal and move the firmware to the right location:
# sudo mv am62-mcu-m4f0_0-fw /etc/cortex-m-firmware/
Use the torizoncore-builder isolate command to capture the latest changes:
$ torizoncore-builder isolate --remote-host <hostname> --remote-username <username> --remote-password <password> --changes-directory changes
Replace the arguments --remote-host, --remote-username and --remote-password for your board's hostname, username and password, respectively.
As a result, you should now have a new folder on the host machine named changes/, which contains the modifications made to the root filesystem. Edit the tcbuild.yaml configuration file to reference this folder.
Set the kernel.arguments.firmware_class.path to reference the previously created /etc/cortex-m-firmware folder. This property defines the directory where remoteproc searches for the firmware (see Customizing Kernel Arguments in Torizon for more information).
The example below shows the correct tcbuild.yaml configuration for building a custom image that enables the verdin-am62_uart4-mcu_overlay.dts overlay and includes the Cortex-M firmware captured in the previous steps. We recommend enabling the MCU UART overlay to allow debugging via the MCU serial interface. For more information, refer to Configuring Serial Port Debug Console (Linux/U-Boot).
# Sample configuration file:
input:
easy-installer:
local: images/torizon-docker-verdin-am62-Tezi_7.0.0+build.1.tar
customization:
filesystem:
- changes/
device-tree:
include-dirs:
- linux/include
overlays:
add:
- device-trees/overlays/verdin-am62_uart4-mcu_overlay.dts
kernel:
arguments:
- firmware_class.path=/etc/cortex-m-firmware
output:
easy-installer:
local: torizon-docker-verdin-am62-Tezi_7.0.0+build.CUSTOM
To build the image, you can simply run:
$ torizoncore-builder build
Then, to deploy the image directly to the board, run:
$ torizoncore-builder images unpack torizon-docker-verdin-am62-Tezi_7.0.0+build.CUSTOM
$ torizoncore-builder deploy --remote-host <hostname> --remote-username <username> --remote-password password --reboot
You should now see the Hello World! message successfully printed on the Cortex-M serial terminal.
The procedure requires you to create your own Yocto layer, enable the UART overlay, and copy the firmware into /lib/firmware on the root file system.
If using Toradex BSP Reference Images, we recommend having a solid understanding of Yocto before proceeding. By having control over the customization of your Embedded Linux distro, you will be able to move the firmware to its expected location.
If you're not familiar with how to do that, we recommend checking the Yocto Project documentation for more information.