STM32MP1 M4 firmware loading and dual machine communication

Continue to toss on the STM32MP157C development board of Mill Technology. Unlike the teacher, the programmer research and development board will not cover everything. They often find solutions with problems.

After the cross-compilation of the cortex-A application is implemented, there are two problems to be solved in the next step

  • M4 program development and download
  • Communication between cortex_A processor and cortex-M4

After all, we are aimed at heterogeneous processor architecture.

This article references: STM32MP157-Remoteproc and RPMsg article

1. Generate M4 firmware

Theoretically, M4 programming is not much different from ordinary STM32F series programming. The only difference is the configuration of the interface on the processor.

   You can use STM32CubeIDE to configure M4 pins and develop related applications.

 

  

2. How to load M4 firmware

There are two ways to download M4 firmware

Engineering Mode

Similar to using ST-LINK emulator to burn STM32 MCU to RAM, it is suitable for M4 power-on startup mode without loading A7 core. Because it is programmed into RAM, the power-down program will be lost, and it is generally used for debugging. .

Production Mode

   The M4 program is stored in the file of the A7 linux system. After the A7 core is started first, the M4 core is booted through the remoteproc software, and the firmware is loaded and executed.

I prefer to use production methods directly from the beginning.

3 remoteproc mechanism

  Remoteproc( Remote Processor Framework), the main function is to manage the life cycle of the remote processor (that is, M4), that is, to start and stop the remote processor.

 

 In actual operation, you can use the ready-made Linux command line on the development board to achieve. state powering and so on. Use fw_cortex_m4.sh in Mir development board

However, the relevant file directory on the Mill Technology Development Board is different from its manual, and it is buried deep enough.

root@myir:/usr/local/Cube-M4-examples/STM32MP157C-EV1/Applications/OpenAMP/OpenAMP_TTY_echo# ls
README	fw_cortex_m4.sh  lib

And the OpenAMP_TTY_echo.elf file has been placed in the lib, which is also very considerate.

4 RPMsg framework for information exchange between cortex-A and cortex-M

The information exchange between the two processors is implemented using the RPMsg framework.

From the figure, it is further realized by openAMP. ST company simulated the processor information exchange into a TTY terminal on the A7 side. And emulate it as a virtual UART on the M4 side. Thus, the communication between the two processors becomes as simple and direct as serial communication. It's just that the speed of this serial port is very large, because they are done entirely in memory.

5 Test

First run fw_cortex_m4.sh

root@myir:/usr/local/Cube-M4-examples/STM32MP157C-EV1/Applications/OpenAMP/OpenAMP_TTY_echo# ./fw_cortex_m4.sh start
fw_cortex_m4.sh: fmw_name=OpenAMP_TTY_echo.elf

In order to see the ttyRPMSG0 and ttyRPMSG1 virtual terminals in the /dev directory.

root@myir:/usr/local/Cube-M4-examples/STM32MP157C-EV1/Applications/OpenAMP/OpenAMP_TTY_echo# ls -l /dev/ttyRPMSG*
crw-rw---- 1 root dialout 5, 3 Apr  9 11:50 /dev/ttyRPMSG0
crw-rw---- 1 root dialout 5, 4 Apr  9 12:56 /dev/ttyRPMSG1
root@myir:/usr/local/Cube-M4-examples/STM32MP157C-EV1/Applications/OpenAMP/OpenAMP_TTY_echo# stty -onlcr -echo -F /dev/ttyRPMSG0
root@myir:/usr/local/Cube-M4-examples/STM32MP157C-EV1/Applications/OpenAMP/OpenAMP_TTY_echo# cat /dev/ttyRPMSG0 & 
root@myir:/usr/local/Cube-M4-examples/STM32MP157C-EV1/Applications/OpenAMP/OpenAMP_TTY_echo# stty -onlcr -echo -F /dev/ttyRPMSG1
root@myir:/usr/local/Cube-M4-examples/STM32MP157C-EV1/Applications/OpenAMP/OpenAMP_TTY_echo# cat /dev/ttyRPMSG1 &
root@myir:/usr/local/Cube-M4-examples/STM32MP157C-EV1/Applications/OpenAMP/OpenAMP_TTY_echo# echo "hello virtual UART0" >/dev/ttyRPMSG0
hello virtual UART0
root@myir:/usr/local/Cube-M4-examples/STM32MP157C-EV1/Applications/OpenAMP/OpenAMP_TTY_echo# echo "hello virtual UART1" >/dev/ttyRPMSG0
hello virtual UART1

That's it, let's test the STM32Cube IDE to compile the M4 program.

 

Guess you like

Origin blog.csdn.net/yaojiawan/article/details/109201648