Showing results for 
Search instead for 
Did you mean: 

How to start M4 on startup of STM32MP1?

Senior II

I realize this is probably a pretty basic question but I haven't found a way to have the M4 portion of the firmware startup when the STM32MP1 is powered up.  I'm currently using an STM32MP157D-DK1 board, if that helps. 

I was able to debug the code of the OpenAMP_TTY_echo_wakeup_CM4 example and all was working except trying to put the A7 to sleep (which made sense in my head.  Putting it to sleep could be problematic if I'm still debugging.  That said, it's still an issue when not in debug mode but I might save this for a separate thread).  When I end debug mode and reset the device, the program stops (which also makes sense as I assume either the M4 is not actually programmed or the program is not setup to start on reset). 

I found a video ( that shows how to load the firmware by moving the elf file via a flash drive and placing it in that folder (though apparently, putting it in debug mode essentially does the same thing, unless there's a difference between the built version in STM32CubeIDE and the debug version that is placed from debug mode, which could potentially explain why I'm having issues putting the A7 to sleep), and then running the following commands:


cd /
echo OpenAMP_TTY_echo_wakeup_CM4.elf > /sys/class/remoteproc/remoteproc0/firmware
echo start >/sys/class/remoteproc/remoteproc0/state


This seemed to work for me but, as expected, if I reset the board, the M4 program is no longer running.  Is there a way to set the board up so it starts starts up the program and runs a few additional scripts (such as setting up the ttyRMGSG0)?

Any help you can give me would be appreciated.  Thanks!


Bonus Issue (can put this in another thread if necessary)

I had a few other issues with putting the A7 to sleep.  I was running the following as recommended by the example


echo enabled > /sys/devices/platform/soc/4c001000.mailbox/power/wakeup (legitimately have no idea what this does)
echo "*delay" >/dev/ttyRPMSG0
systemctl suspend


But got the following back:


[  751.096596] Filesystems sync: 0.025 seconds
[  751.125951] Freezing user space processes
[  751.162043] Freezing user space processes completed (elapsed 0.033 seconds)
[  751.167838] OOM killer disabled.
[  751.170818] Freezing remaining freezable tasks
[  751.177208] Freezing remaining freezable tasks completed (elapsed 0.001 seconds)
[  751.183265] printk: Suspending console(s) (use no_console_suspend to debug)
[  751.199627] dwc2 49000000.usb-otg: suspending usb gadget configfs-gadget.g1
[  751.310081] stm32-dma 48001000.dma-controller: Suspend is prevented by Chan 1
[  751.310127] stm32-dma 48001000.dma-controller: PM: dpm_run_callback(): platform_pm_suspend+0x0/0x48 returns -16
[  751.310188] stm32-dma 48001000.dma-controller: PM: failed to suspend: error -16
[  751.310218] PM: Some devices failed to suspend, or early wake event detected
[  751.357342] dwmac4: Master AXI performs any burst length
[  751.357399] stm32-dwmac 5800a000.ethernet end0: No Safety Features support found
[  751.357446] stm32-dwmac 5800a000.ethernet end0: IEEE 1588-2008 Advanced Timestamp supported
[  751.357535] stm32-dwmac 5800a000.ethernet end0: configuring for phy/rgmii-id link mode
[  751.470050] dwc2 49000000.usb-otg: resuming usb gadget configfs-gadget.g1
[  751.671732] dwc2 49000000.usb-otg: new device is high-speed
[  751.777167] onboard-usb-hub 1-1: reset high-speed USB device number 2 using ehci-platform
[  751.799892] dwc2 49000000.usb-otg: new device is high-speed
[  751.872899] dwc2 49000000.usb-otg: new address 51
[  756.227589] OOM killer enabled.
[  756.230635] Restarting tasks ... 
[  756.232538] usb 1-1.1: USB disconnect, device number 3
[  756.242584] done.
[  756.243203] random: crng reseeded on system resumption
[  756.251900] PM: suspend exit


The issues seem to start on line 9.  Something seems to be stopping the device from going into suspend mode, no idea what "Chan 1" is or why it's blocking it. 

Senior II

Well, I managed to resolve my "bonus" problem.  Turns out I need to ensure I have the M4 examples mode selected, so I have a few things I need to figure out related to the startup at this point:
1) How do I setup the startup so that it:

a) Selects the M4 Examples option without needing to be prompted

b) Starts up the M4 project on startup (as described above)

2) I need to find out what selecting the 3 different options at startup are actually doing (are they configuring the device tree differently?)  What is it doing differently in the M4 startup from the plain OpenSTLinux?

Any chance someone can point me the right direction where to look to find this info?

ST Employee


yes, starter package allows to choose different device tree for Linux kernel in order to run examples.


Regarding Bonus, please have a look to
Seems you have DMA2 channel 1 not stopped (need to did to see who is using it).
Did you try using "echo mem > /sys/power/state" instead ?


In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.


Thanks for the quick reply!  As per my update post, I managed to get the errors to go away by selecting the M4 examples from the Starter package, which at least gets my program running. 

My current goal is to setup a project that can get access to the M4 peripherals (so, effectively select the M4 peripherals automatically without being prompted) and to automatically start running the A7 firmware without being prompted with the example linux commands shown below:

cd /
echo OpenAMP_TTY_echo_wakeup_CM4.elf > /sys/class/remoteproc/remoteproc0/firmware
echo start >/sys/class/remoteproc/remoteproc0/state

I have a number of items I still want to do (such as to setup the M4 as the primary processor and set the status of the A7 to either wake or sleep) but I'm trying to learn to walk before I can run.  Right now though, I want to focus on the M4 code running without any linux prompts (ie on startup).  I assume this is probably relatively straight forward once I know where to look but I'm still learning where everything is (this is obviously a lot more complicated than a basic M4 project, which is my background thus far). 

It might be this is a limitation of the Starter package (which would make sense) and I would need to use the developer or distributor package in order to modify the startup scripts (maybe the startup of the starter mode is preconfigured and can't be altered as it's just loading a prebuilt image, which would make sense).  If that's the case, any recommendations on what version I need to run, what files to look in/edit, etc would be greatly appreciated. 

Thanks for your help with this!  Sorry for the delay, I wanted to look into this a bit further before responding, make sure I'm not missing anything too *** before I responded!