Module: Xilinx::Provision::CableDriver
- Defined in:
- lib/xilinx/provision/cable_driver.rb
Overview
Drives the setup of the USB cable driver needed to talk to Xilinx boards.
Class Method Summary collapse
-
.build(target_path) ⇒ Object
Builds the cable driver.
-
.build_prerequisites ⇒ Object
Installs the packages needed to build the cable driver.
-
.configure_udev ⇒ Object
Sets up the udev daemon to allow non-root access to the USB cable.
-
.git_url ⇒ Object
The URL printed when no ISE installation is found.
-
.path ⇒ Object
The path to the driver file.
-
.setup ⇒ Object
Performs all the setup needed for the USB cable driver.
-
.udev_rules ⇒ Object
Rules for the udev daemon to allow non-root access to the USB cable.
Class Method Details
.build(target_path) ⇒ Object
Builds the cable driver.
Assumes the build requirements have been installed by build_prerequisites.
Args:
target_path:: directory that will contain the driver
Returns the command’s output.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/xilinx/provision/cable_driver.rb', line 53 def self.build(target_path) target_path = File. target_path Dir.mktmpdir do |temp_dir| Dir.chdir temp_dir do output = `git clone -q #{git_url} 2>&1` return output if $CHILD_STATUS.to_i != 0 Dir.chdir 'usb-driver' do output = `make all 2>&1` return output if $CHILD_STATUS.to_i != 0 FileUtils.cp 'libusb-driver.so', target_path end end end nil end |
.build_prerequisites ⇒ Object
Installs the packages needed to build the cable driver.
Returns a false value for success, and a string containing error output if the build goes wrong.
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/xilinx/provision/cable_driver.rb', line 34 def self.build_prerequisites if File.exist?(`which apt-get`.strip) # The literal `apt-get ...` doesn't use Kernel.` and can't be stubbed. output = Kernel.`( 'apt-get install -y git-core libusb-dev build-essential fxload 2>&1') $CHILD_STATUS.to_i == 0 ? nil : output else "Unsupported OS / distribution\n" end end |
.configure_udev ⇒ Object
Sets up the udev daemon to allow non-root access to the USB cable.
70 71 72 73 |
# File 'lib/xilinx/provision/cable_driver.rb', line 70 def self.configure_udev Xilinx::Provision::Udev.add_rules udev_rules, '71-xilinx-usb-cable' nil end |
.git_url ⇒ Object
The URL printed when no ISE installation is found.
88 89 90 |
# File 'lib/xilinx/provision/cable_driver.rb', line 88 def self.git_url 'git://git.zerfleddert.de/usb-driver' end |
.path ⇒ Object
The path to the driver file.
83 84 85 |
# File 'lib/xilinx/provision/cable_driver.rb', line 83 def self.path File. '../libusb-driver.so', Xilinx::Provision::Impact.path end |
.setup ⇒ Object
Performs all the setup needed for the USB cable driver.
Returns a false value in case of success, or a string with error information if something goes wrong.
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/xilinx/provision/cable_driver.rb', line 17 def self.setup if output = build_prerequisites return "Error while obtaining driver prerequisites:\n#{output}" elsif output = build(path) return "Error while building driver:\n#{output}" elsif output = configure_udev return "Error while configuring cable driver udev rules\n#{output}" elsif output = Xilinx::Provision::Udev.reload_rules return "Error while loading cable driver udev rules\n#{output}" end nil end |
.udev_rules ⇒ Object
Rules for the udev daemon to allow non-root access to the USB cable.
Returns an array of rules to be written to a udev file.
78 79 80 |
# File 'lib/xilinx/provision/cable_driver.rb', line 78 def self.udev_rules ['ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="03fd", MODE="666"'] end |