Problems booting with PRU

Hi. I managed to compile a PRU binary and get it running.

I created a simple web app to start at bootup, with a simple script to configure the pins before starting the server. It turned out that the file /sys/class/remoteproc/remoteproc2/state was not present for the first ~20 seconds after boot, causing the configuration script to fail. I created the following script to overcome this:

$ cat configure_pru.sh
#/bin/sh

while [ ! -e /sys/class/remoteproc/remoteproc2/state ]
do
echo "waiting for remoteproc to start"
sleep 1
done

config-pin 8.45 pruout
config-pin 8.46 pruin
config-pin 8.39 pruout
config-pin 8.40 pruin
config-pin 8.27 pruout
config-pin 8.29 pruin
config-pin 8.28 pruout
config-pin 8.30 pruin
echo -n start > /sys/class/remoteproc/remoteproc2/state

This worked well as a kludge until I upgraded my kernel. Now at kernel 4.14.108-ti-r124 this no longer works, as the file will be present immediately after boot.

Right now, the PRU code will not run correctly if I start the web service just after boot. It I wait half a minute before configuring the PRU, everything works well. I expect that I need to wait for some service to start up after boot, before initializing the PRU, but I have not found any documentation mention of how to do this.

So my question is: how could I detect that the PRU is ready for use after boot. Just now I am using a sleep, but this is not a robust solution.

Extra question: Is there a way to boot the PRU code automatically at boot without having to echo start to the statefile?

Thx

I was able to rewrite my configuration script into this, which is again working. I would still like to hear if anyone has better ways of achieving this.

#/bin/sh

config-pin 8.45 pruout
config-pin 8.46 pruin
config-pin 8.39 pruout
config-pin 8.40 pruin
config-pin 8.27 pruout
config-pin 8.29 pruin
config-pin 8.28 pruout
config-pin 8.30 pruin

while [ ! -e /dev/rpmsg_pru31 ]
do
echo "Trying to start PRU remoteproc "
echo -n start > /sys/class/remoteproc/remoteproc2/state
sleep 1
done

Does anyone know why it takes > 30 sec to boot the PRU after ssh login? Would be really nice if it just started by itself, working on boot…

Sure, there’s a simple way: