NSLU2-Linux
view · edit · print · history

This describes how to get your Slug taking to an APC UPS with APCUPSD. I was using OpenSlug 2.7 and an APC BackUPS? XS1200? UPS which was plugged in to a USB hub.

USB Setup

First you will need to check that your USB configuration is correct and you can see the UPS when it has been plugged in and turned on.

Details are at <<http://www.apcupsd.com/manual/USB_Configuration.html>>(approve sites)

Take a look at what USB devices the Slug can see.

'cat /proc/bus/usb/devices'

You should see an output with an entry for your UPS. Something like this.


T: Bus=01 Lev=02 Prnt=03 Port=03 Cnt=02 Dev#= 5 Spd=1.5 MxCh?= 0
D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS?= 8 #Cfgs= 1
P: Vendor=051d ProdID?=0002 Rev= 1.06
S: Manufacturer=American Power Conversion
S: Product=Back-UPS XS 1200 FW:8.g1 .D USB FW:g1
S: SerialNumber?=BB0100009999?
C:* #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr?= 24mA
I: If#= 0 Alt= 0 #EPs?= 1 Cls=03(HID ) Sub=00 Prot=00 Driver=(none)
E: Ad=81(I) Atr=03(Int.) MxPS?= 6 Ivl=10ms


The most important line is the 'I:' line where it says 'Driver=(none)' If you are like me then you will have to install the HID kernel module

'ipkg install kernel-module-usbhid' 'modprobe usbhid'

Now if you do 'cat /proc/bus/usb/devices' you should get...


T: Bus=01 Lev=02 Prnt=03 Port=03 Cnt=02 Dev#= 5 Spd=1.5 MxCh?= 0
D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS?= 8 #Cfgs= 1
P: Vendor=051d ProdID?=0002 Rev= 1.06
S: Manufacturer=American Power Conversion
S: Product=Back-UPS XS 1200 FW:8.g1 .D USB FW:g1
S: SerialNumber?=BB0100009999?
C:* #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr?= 24mA
I: If#= 0 Alt= 0 #EPs?= 1 Cls=03(HID ) Sub=00 Prot=00 Driver=usbhid
E: Ad=81(I) Atr=03(Int.) MxPS?= 6 Ivl=10ms


You'll notice that now it says 'Driver=usbhid' Now you can be sure that the UPS is communicating on the USB level.

<<Note if you want the 'usbhid' driver to load at startup you will have to put 'modprobe usbhid' in one of the system startup files.>>

Building APCUPSD from source. (I used 3.12.3 28 April 2006)

You will need some sort of NSLU2 development environment setup. I use native but you can pick the one that you like best.

<<don't compile as root!>>

I used these basic configure options to compile APCUPSD.

'./configure --prefix=/usr/local --sbindir=/sbin --enable-usb --enable-pthreads' 'make' 'su - ' 'make install'

Configure the '/etc/apcupsd/apcupsd.conf' file with proper settings. See <<http://www.apcupsd.com/manual/Configuration_Examples.html>>(approve sites) for help

These are the configs I used


     UPSCABLE usb
     UPSTYPE usb
     DEVICE
     LOCKFILE /var/lock
     UPSCLASS standalone
     UPSMODE disable

Load apcupsd on system startup.

The 'make install' does not know how to handle Openslug so you will have to put the startup scripts for apcupsd in place by hand. They are located under `/usr/local/src/apcupsd-3.12.3/platforms/unknown'

Testing that the UPS is communicating with the NSLU2

'apcaccess status'

Test the wall feature by removing the USB cable from the Slug. You should see

'Warning communications lost with UPS lost.'

and when you put the cable back in...

'Communications with UPS restored.'

At the same time, it sends the same message to the system log and to the temporary EVENTS file

(/etc/apcupsd/apcupsd.events).

If this works then you should do a Power Fail Test.

Now if you are a worrier then I suggest you do a complete system backup before doing the power fail test. While the EXT3? filesystem on the Slug is resilient there is a chance that the power fail test will cause your Slug to unexpectantly shutdown and you may damage the filesystem.

To do the Power Fail test just pull the power plug from the UPS. The UPS should go in to battery mode and keep the power to your Slug. You will also messages from 'apcupsd' that it has detected a power failure.

'Warning power loss detected on UPS NSLU2'

'Power failure on UPS NSLU2. Running on UPS batteries.'

Wait a few seconds to make sure the UPS can handle the load and then plug the UPS back in. You will see a power restore message.

'Power has returned on UPS NSLU2...'

See the following Web page for further UPS tests you can do. <<http://www.apcupsd.com/manual/Testing_Apcupsd.html>>(approve sites)

Take a look at the '/etc/apcupsd/apcupsd.conf' file regarding shutdown sequence configurations. Make changes to suit your needs.

Stay tuned for 'Network Monitoring (CGI) Programs' and other fasinating subjects.


Device nodes

Note from Jelle: I had to add the nodes manually by running the make-hiddev script, as pointed out in http://www.apcupsd.com/manual/USB_Configuration.html#SECTION000101400000000000000(approve sites):

"Apcupsd accesses USB UPSes? via the hiddev device nodes. Typically these are located in /dev/hiddevN, /dev/usb/hiddevN or /dev/usb/hiddev/hiddevN (where N is a digit 0 thru 9). Some distributions (some Debian releases, possibly others) do not provides these device nodes for you, so you will have to make them yourself. Check /dev, /dev/usb, and /dev/usb/hiddev and if you cannot find the hiddevN nodes, run (as root) the examples/make-hiddev script from the apcupsd source distribution. "

view · edit · print · history · Last edited by rwhitby.
Based on work by Hillary, marceln, hgfjf5, Poutnik, yaasel, Eddie, ST, dfgdgaw, Gerbil, dsafsfd, PatrickSchneider, and jelle.
Originally by mrkzander.
Page last modified on September 23, 2006, at 10:40 PM