The STM32MP15 SOC platform includes a low-power Cortex-M4 processor with a low gate count and low interrupt latency. The Cortex-M4 implements the ARMv7E-M instruction set architecture (ISA) and adds significant capabilities with digital signal processor (DSP) and single instruction multiple data (SIMD) extensions. The Cortex-M4 operates as a coprocessor, either autonomously as any external microcontroller (such as an STM32F4) could, or by communicating with the main processor (Cortex-A7) via the RPMsg communication pipe.
1. Download the SDK and toolchain
STMicroelectronics offers an IDE that facilitates firmware development for the Cortex-M4 core. The SDK provides examples demonstrating how to access the peripherals available on this subsystem.
-
Go to https://www.st.com/en/development-tools/stm32cubeide.html.
You may have to register with STMicroelectronics. -
Click Get latest for your OS.
Before building the Cortex-M4 firmware, you must download and install the SDK, which includes example applications and the toolchain to build your firmware application.
-
The examples included in the SDK are made for the STMicroelectronics hardware and require modifications to work on the ConnectCore MP15
2. Install the IDE, SDK and toolchain
Decompress and install the IDE in your PC. The installation includes the SDK and Cortex-M4 examples.
3. Build a demo application
-
Launch the STM32CubeIDE on your PC.
-
Go into the workspace project view and import an existing project. Each project example contains a top project and sub project.
-
Select both projects, for instance OpenAMP_TTY_echo and OpenAMP_TTY_echo_M4, and click the Build button on the IDE. This creates an
*.elf
file atApplications\OpenAMP\OpenAMP_TTY_echo\STM32CubeIDE\CM4\Debug\OpenAMP_TTY_echo_M4.elf
. (This path may vary based on your installation location.) -
Load the file onto on the Cortex-M4.
For more information, see Modify, rebuild and reload a firmware. |
4. Deploy the application onto the target
There are several ways to deploy the application onto the Cortex-M4:
4.1. Run your application with Remoteproc from Linux
The remote processor (RPROC) framework allows the different platforms/architectures to control (power on, load firmware, power off) remote processors while abstracting the hardware differences. The application must either be stored on a partition of an external device or included in the rootfs image.
The firmware components are stored in the file system, by default in the /lib/firmware/
folder.
You can optionally set a different location with the following command:
# echo -n <firmware_path> > /sys/module/firmware_class/parameters/path
Note that if a location is provided, the remoteproc framework parses this path first.
-
Load the firmware application on the target device, where X is the remoteproc instance number, set to 0 by default:
# echo -n <firmware_name.elf> > /sys/class/remoteproc/remoteprocX/firmware
-
Start the firmware:
# echo start > /sys/class/remoteproc/remoteprocX/state
-
When the firmware is running, access the output log from the firmware with:
# cat /sys/kernel/debug/remoteproc/remoteprocX/trace0
-
Stop the running firmware with:
# echo stop > /sys/class/remoteproc/remoteprocX/state
-
Start Linux and let it run the firmware automatically at boot if the
st,auto_boot
property is defined in theremoteproc
device tree node.Linux device tree&m4_rproc { st,auto-boot = <1>; };
For more information about the STM32CubeIDE, see https://wiki.st.com/stm32mpu/wiki/Category:STM32CubeIDE.
4.2. Boot your application from U-Boot
You can load and start the firmware application from U-Boot with the rproc
command.
Note that this example is reading the file from a USB stick into RAM memory.
=> usb start
=> fatload usb 0:1 ${loadaddr} <firmware_name.elf>
=> rproc init
=> rproc load 0 ${loadaddr} ${filesize}
Once you have loaded the firmware application, you can run the firmware from U-Boot:
=> rproc start 0
Launch and debug your application using a debugger
You can use this ST-LINK debuggerV2 or this ST-LINK_debuggerV3 debugger to download and debug the firmware through the IDE.
To download and debug your application, first create a debug connection in the IDE.
-
Select your CM4 project
-
Right click on the project and select Debug As > Debug configurations This opens the debug configuration panel
-
If not already created, create your debug configuration by clicking on the STM32 C/C++ Application and opening the Debugger panel.
-
On the Debugger tab, select thru Linuxcore (Production mode) This requires that your target is running a Linux OS.
-
Select the ST-Link serial port available on the Serial Port. The IDE will automatically detect ST-Link serial port and use it to manage the firmware download.
-
Set the IP address of your target in the Inet Address field. The IDE will create a SSH connection to the target for the firmware download.
-
When all configurations are done, click Apply.
For the best GDB debug experience, Digi recommends you upgrade the onboard ST-Link version with the latest release by going to Help > ST-Link Upgrade in the STM32CubeIDE menu. |
For more information, refer to the STM32CubeIDE documentation.