I love my little Linksys NSLU2. It's sold as a NAS device which uses USB hard drives, but under the hood it's a Linux box. There's a community of hackers dedicated to exapnding the capabilities of this little NAS, making it a full-blown Linux box. I run Debian Linux on mine, which has been upgraded to 64 MiB of RAM. It's currently used as a file, DNS, DHCP and web server; it's hosting this site. In the past I've also used it as a mail and news server. Anything you can do on a big Linux box you can do on the NSLU2 - bearing in mind the limited RAM, processing power and lack of screen of course.
As I use mine as a public web server, I want to make sure it stays on all the time. As shipped, the NSLU2 can't restart itself after a power failure. There are a few ways to achive this that others came up with. This page details my solution, which builds on their work and adds a few features.
I wanted to be able to shut my NSLU2 down without it immediately coming back up when power returned, but still wanted it to recover after power failure if it had been on. That wasn't possible with the existing solution - they always switched on whenever the power was applied. By using the AVR's ADC to monitor the 3.3V power supply I was able to achive that and implement a few other modes of operation.
The modes are:
The two most useful modes of operation are Recover Previous State and installing a switch to switch between Switchoff and Absolutely Always On - that will provide your NSLU2 with an on/off switch while still allowing for a clean shutdown. If you install the switch you might want to remove the existing power button so an accidental knock doesn't cause a shutdown then power-up sequence.
The hardware is just an Atmel ATtiny13, with an optional resistor to help you sleep better at night. I used one in an an 8-pin DIP package, which just fits in the case, though the package doesn't really matter as it'll be wired up directly, dead-bug style.
|1||Linksys mode select||optional|
|2||3.3V Sense||connect via 10k resistor to +3.3V pin of J2|
|3||Button||connect to non-grounded pin of push-button|
|4||GND||GND on 5V input jack|
|5||Absolutely Always On mode select||optional|
|6||On After Power Loss mode select||optional|
|7||Switchoff mode select||optional|
|8||Vcc||+5V on 5V input jack|
The mode select pins can be shorted to ground to select that mode. This can be done with a switch while running, or by permanently soldering a wire link in place. Only one mode select pin should be grounded at once; if more than one is grounded the mode selected depends on the ordering in the code, which may not be what you expect. If no mode select pin is grounded, the mode is Recover Previous State.
The 10k resistor between pin 2 and the 3.3V supply is optional. It was there during development to guard against a software error setting the pin as an output and thus shorting the 3.3V supply to ground or +5V. There should be no such software errors now, but it might help you sleep better at night knowing a bug in some random guy's code or a cosmic ray can't flip the right (or wrong) bit and fry your slug.
Fuses must be set for 128kHz internal RC osciallator and BOD set to 4.3V.
The code was written in C using Atmel's AVRStudio and is released under the the GNU GPL, V3+. It should compile on anything with GCC for the AVR, though the Makefile will need some tweaking.
You can either download the source and build it yourself, or just download and flash the hex file.
HomeEmail: tim (at) my surname without the initial 'a' (dot) org