Advertisement
Guest User

apm4-startup.sh

a guest
Feb 13th, 2015
439
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.32 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #This script is launched automatically in the BeagleBone Black
  4. #on every boot and loads everything that the board needs to
  5. #act as an autopilot. The COPY_CAPES environment variable copies
  6. #the capies on every boot if set to 1.
  7. #
  8. # Victor Mayoral Vilches - Erle Robotics [victor@erlerobot.com]
  9.  
  10. # Cape source location
  11. LOCATION="/root/ardupilot/Tools/Linux_HAL_Essentials"
  12.  
  13. # Copy capes
  14. COPY_CAPES=1
  15.  
  16. if (($COPY_CAPES == 1)); then
  17.         cp $LOCATION/BB-SPI0-PXF-01-00A0.dtbo /lib/firmware/
  18.         cp $LOCATION/BB-SPI1-PXF-01-00A0.dtbo /lib/firmware/
  19.         cp $LOCATION/BB-BONE-PRU-05-00A0.dtbo /lib/firmware/
  20.         cp $LOCATION/rcinpru0 /lib/firmware
  21.         cp $LOCATION/pwmpru1 /lib/firmware
  22. fi
  23.  
  24. # Loading the capes
  25. echo BB-BONE-PRU-05 > /sys/devices/bone_capemgr.*/slots
  26. echo BB-SPI0-PXF-01 > /sys/devices/bone_capemgr.*/slots
  27. echo BB-SPI1-PXF-01 > /sys/devices/bone_capemgr.*/slots
  28. echo BB-UART5 > /sys/devices/bone_capemgr.*/slots
  29. echo BB-UART4 > /sys/devices/bone_capemgr.*/slots
  30. echo BB-UART2 > /sys/devices/bone_capemgr.*/slots
  31. echo am33xx_pwm > /sys/devices/bone_capemgr.*/slots
  32. echo bone_pwm_P8_36 > /sys/devices/bone_capemgr.*/slots
  33. echo BB-ADC   > /sys/devices/bone_capemgr.*/slots
  34.  
  35. # Line for making PREEMPT_RT work
  36. #echo 0:rcinpru0 > /sys/devices/ocp.3/4a300000.prurproc/load
  37.  
  38. # Logging
  39. dmesg | grep "SPI"
  40. dmesg | grep "PRU"
  41. cat /sys/devices/bone_capemgr.*/slots
  42.  
  43. # Force the ip address of the hotspot
  44. ifconfig wlan4 11.0.0.1
  45.  
  46. # Give the system time to load all the capes
  47. #   experienced has proved that generally the buzzer needs some time
  48. sleep 1
  49.  
  50. cd /root
  51. (
  52.     date
  53.     init 3
  54.     #killall -q udhcpd
  55.     while :; do
  56.         # Set CPU at max speed
  57.         cpufreq-set -f 1000MHz
  58.         # Start copter, modify if other vehicle is needed
  59.         #./ArduCopter.elf -A udp:192.168.7.2:6000 -B /dev/ttyO5
  60.         ./ArduCopter.elf -A udp:11.0.0.2:6000 -B /dev/ttyO5
  61.         #./ArduCopter.elf -A /dev/ttyO0 -B /dev/ttyO5
  62.         #./ArduCopter.elf -A tcp:*:6000:wait -B /dev/ttyO5
  63.         #./ArduCopter_bmp085.elf -A tcp:*:6000:wait -B /dev/ttyO5
  64.         #./ArduCopter_2baro.elf -A tcp:*:6000:wait -B /dev/ttyO5
  65.         #./ArduCopter_bmp085.elf -A udp:11.0.0.2:6000 -B /dev/ttyO5
  66.         #./ArduCopter_2baro.elf -A udp:11.0.0.2:6000 -B /dev/ttyO5
  67.     done
  68. ) >> ~/copter.log 2>&1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement