Created
August 18, 2019 10:58
-
-
Save jancumps/db2baaad81ab15e47826bade1b3c69aa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| PRU_STEPPER_link="$(readlink -f /home/debian/bin/bb_PRU_STEPPER.out)" | |
| fw0_link=${PRU_STEPPER_link} | |
| if [ ${fw0_link} ]; | |
| then | |
| echo "stop the program if running" | |
| echo 'stop' > /sys/class/remoteproc/remoteproc1/state 2>/dev/null | |
| echo "remove existing PRU firmware link if it exists" | |
| rm /lib/firmware/am335x-pru0-fw &> /dev/null | |
| echo "link and load the firmware to PRU" | |
| ln -s ${fw0_link} /lib/firmware/am335x-pru0-fw | |
| echo 'am335x-pru0-fw' > /sys/class/remoteproc/remoteproc1/firmware | |
| echo "start the program" | |
| echo 'start' > /sys/class/remoteproc/remoteproc1/state | |
| echo "" | |
| echo "Firmware is running" | |
| echo "" | |
| else | |
| echo "Firmware .out files does not seem to exist. Did you place " ${PRU_STEPPER_link} "?" | |
| echo "" | |
| fi | |
| echo "sleep on" | |
| echo out > /sys/class/gpio/gpio30/direction | |
| echo 0 > /sys/class/gpio/gpio30/value | |
| echo "reset off" | |
| echo out > /sys/class/gpio/gpio31/direction | |
| echo 0 > /sys/class/gpio/gpio31/value | |
| echo "set pin 29 and 31 as PRU GPIO out" | |
| config-pin P9_31 pruout | |
| config-pin P9_29 pruout | |
| echo "initialise SPI" | |
| /home/debian/bin/bb_LINUX_STEPPER_SPI | |
| echo "stepper motor control ready from PRU0" | |
| while test $# -gt 0 | |
| do | |
| case "$1" in | |
| --test) | |
| echo "test requested" | |
| echo "sleep off" | |
| echo 1 > /sys/class/gpio/gpio30/value | |
| echo "motor move start" | |
| echo '1100' > /dev/rpmsg_pru30 | |
| echo '0100' > /dev/rpmsg_pru30 | |
| echo "motor move stop" | |
| echo "short pause before activating motor sleep..." | |
| sleep 2s | |
| echo "sleep on" | |
| echo 0 > /sys/class/gpio/gpio30/value | |
| ;; | |
| esac | |
| shift | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment