Difference between revisions of "AERFX2 PC104 linux driver"

From Wiki for iCub and Friends
Jump to: navigation, search
(UDEV scripts)
Line 36: Line 36:
 
/etc/udev/rules.d/33-fxload.rules
 
/etc/udev/rules.d/33-fxload.rules
 
  SUBSYSTEM=="usb", ACTION=="add", ATTRS{idVendor}=="04b4", ATTRS{idProduct}=="8613", MODE="666", RUN+="/etc/fx2/load $env{DEVNAME}"
 
  SUBSYSTEM=="usb", ACTION=="add", ATTRS{idVendor}=="04b4", ATTRS{idProduct}=="8613", MODE="666", RUN+="/etc/fx2/load $env{DEVNAME}"
 +
=== Startup script ===
 +
S80_aerf2.sh
 +
#! /bin/bash -e
 +
# Load aerfx module
 +
lsmod | grep -i usbtest
 +
if [ $? -eq 0 ]; then
 +
  rmmod usbtest
 +
fi
 +
insmod /lib/modules/$(uname -r)/iCubDrivers/aerfx2/module/aerfx2.ko
 +
lsmod | grep -i usbtest
 +
if [ $? -eq 0 ]; then
 +
  rmmod usbtest
 +
fi
 +
exit 0

Revision as of 14:35, 24 November 2014

Files required to use the driver

Apart from the driver binary, some other files are required to load and use it

firmware

/etc/fx2/fx2aex.ihx

UDEV scripts

/etc/fx2/load

#!/bin/bash
exec 1>>/var/log/fx2.log
exec 2>>/var/log/fx2.log
FIRMWARE="/etc/fx2/fx2aex.ihx"
# check path
echo "$1" | grep -q '^/dev/bus/'
if [ "$?" != "0" ] ; then
  #echo "Ignoring: '$1'"
  exit 0
fi
echo 
date
echo "Trying to load: '$1', waiting for device:"
for i in `seq 100` ; do
  if [ -e "$1" ] ; then
      break
  else
      sleep 0.1
  fi
done
if ! [ -e "$1" ] ; then
  echo "Device did not apper. Aborting!"
  exit 1
fi
echo "Device exists: $1"
echo "Waiting 1s before invoking fxload..."
sleep 1
echo -n "Firmware MD5: " ; md5sum "$FIRMWARE"
/sbin/fxload -v -t fx2 -I "$FIRMWARE" -D "$1"

/etc/udev/rules.d/33-fxload.rules

SUBSYSTEM=="usb", ACTION=="add", ATTRS{idVendor}=="04b4", ATTRS{idProduct}=="8613", MODE="666", RUN+="/etc/fx2/load $env{DEVNAME}"

Startup script

S80_aerf2.sh

#! /bin/bash -e
# Load aerfx module
lsmod | grep -i usbtest
if [ $? -eq 0 ]; then
  rmmod usbtest
fi
insmod /lib/modules/$(uname -r)/iCubDrivers/aerfx2/module/aerfx2.ko
lsmod | grep -i usbtest
if [ $? -eq 0 ]; then
  rmmod usbtest
fi
exit 0