Where to get parts ?!

Where do you go for basic electronic parts in the USA!? like discrete components and small chips — in single quantities, i.e. without having to bulk order them?

Back in India (and I think in most South Asian countries) most major cities have streets/bazaars full of electronic component shops (not consumer electronics, but components, semiconductors,…). It’s a electronics hobbyists heaven to find a street full of shops like that. So frustrating not to find something like that here in the USA, and RadioShack just doesn’t do it for me. But here’s my bookmark of some online shops:


Choosing a Microcontroller

As I went about choosing what is the good microcontroller to get started on, here’s my shortlist:

8/16 bit:


Slug – Tips

Reducing Memory

Given that it has only 32MB of RAM, NSLU2 runs Asterisk as is very well, but if you want to add more daemons you might need to miser down on the memory.

Dropbear consumes only 2.4MB vs 8.2MB of SSH (who would’ve ever thought I’d be concerned about savings of 6MB of memory!)

Install dropbear:

apt-get install dropbear

Edit the /etc/default/dropbear configuration file:


Remove sshd and start dropbear:

update-rc.d -f ssh remove
/etc/init.d/dropbear start

Here is a comparison of memory usage:

NSLU2:~# ps -eo comm,pid,%mem,vsize | grep dropbear
dropbear 1743 root 1.7 1916
dropbear 1884 root 3.4 2440

NSLU2:~# ps -eo comm,pid,%mem,vsize | grep sshd
sshd 1808 root 3.5 5148
sshd 1904 root 7.6 8216

Asterisk: If you’re running Asterisk, you might want to replace your modules.conf with minimal one found here Slimming Asterisk, it’ll prevent hoards of asterisk modules from loading.

Reducing Disk Writes

If your using a flash drive, you’ll definitely want to reduce the number of disk writes to the drive.

1. Mount with ‘noatime’ parameter, this will stop the kernel from writing the access time every time the file accessed.

/dev/sda1 / ext3 defaults,noatime,errors=remount-ro 0 1

2. Disable syslogd MARK entries
Disable syslogd MARK entries by adding this line to /etc/default/syslogd. You don’t need this if you’re using Debian 5.0.1 (Lenny) – it uses rsyslogd (instead of syslogd) and MARK entries are disabled by default (the “ModLoad immark” is commented out in /etc/rsyslog.conf).

SYSLOGD=”-m 0″

3. Log files are sync’d immediately to the filesystem the moment they are written to. To prevent immediate sync’ing, dash out all entries in /etc/default/syslogd. It will still write to the log files, just that they won’t get sync’d immediately.

4. Move samba caching to a ramfs
On doing a “find /var -mmin -10 -ls” I found some files that were being written to regularly by samba. Moved this to a small ramfs, by adding this line in /etc/fstab:

none    /var/cache/samba    ramfs    maxsize=512    0    2

5. Set swappiness value to zero (default is 60):

echo 0 > /proc/sys/vm/swappiness

or set this in /etc/sysctl.conf:

vm.swappiness = 0

6. Tune disk writes. Set the following in /etc/sysctl.conf:

vm.dirty_background_ratio = 5              # default = 5
vm.dirty_ratio = 50                                # default = 10
vm.dirty_writeback_centisecs = 500        # default = 500
vm.dirty_expire_centisecs = 3000           # default =3000

Spinning Down the Drive

After trying a couple of different ways to do this (hdparm, scsi-stop, etc), I found I had the best luck with the sg_start utility (from sg3_utils package):

Get the packages:

sudo apt-get install sg3-utils libsgutils1

Example command to spin down:

sg_start –stop –pc=2 /dev/sdb

Very useful. Besides using it for the slug, I also use it to force spin down my external drive after unmounting it and just before I pull the USB cable – so that I don’t get that horrible “clunk” noise in the drive.


Some other things you might want to put into your Linux on Slug:

1. Enforce file system check
Given that the NSLU2 is headless, you definitely don’t want to be left helpless, should it ever go into maintenance mode asking you to do fsck. So enforce fsck, add the following in /etc/default/rcS:


2. Power Button
The default setup causes the power button to reboot. I changed it to shutdown:

ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -h now

De-Underclocked Slug

Following the instructions at Overclocking the Slug, I decided to overclock my NSLU2 today, and pulled out my soldering iron.
It seems you’re not really overclocking it… but restoring it to its normal/full speed of 266MHz. For some reason these units shipped configured to run at 133MHz, done via a pull down resistor (R83) – which one simply has to de-solder.

In doing this I didn’t realize just how tiny they’d be (the last time I soldered something was more than 15yrs ago). Less than 1mm away from the adjacent resistor. Next time, I’ll just snip it off with a pair of nail-clippers like some sluggers have done.

In that end… I have a 266MHz server, 32MB RAM, with Debian on a 2GB flash (with Asterisk, ssh, lighttpd, ruby,… with still 1GB free space left!). Costing only $70 and only 10w of power – can be kept on 24×7 with no sweat (contrast that with at least 200w Intel/AMD based server costing at least $400).

One thing I got out of this exercise… is that I found out that I needed reading glasses 8-|.

My Slug :-)

Got my NSLU2 today. It’s small, less than 5w, no moving parts, no fan. Specs: 266MHz ARM processor (XScale IXP420 ARMv5TE), 32MB SDRAM, 8MB Flash, 2GB USB Flash.

First thing I did was to replace the Linksys firmware with Linux. The possibilities for use of this thing are endless: as a print server, file server, internet radio, file downloads, etc. At 5w you don’t have to worry about wasting energy (compared with a 70w laptop or a 300w desktop), and can run it 24×7 without fear of damaging it.

I installed Debian/NSLU2 – Debian/ARM running on NSLU2.

The instructions for installing Debian/NSLU2 were pretty straight forward and worked with no problem.

FYI, pullout locations: for JTAG, GPIO, USB ports.

RedBoot Bootloader

Here’s some tips I got about accessing the firmware’s Redboot bootloader. That is, before you do anything you might want to make sure you can get to RedBoot bootloader’s command prompt on the NSLU2. By default RedBoot listens on, so you’ll need to add a route to that first.

First turn off the NSLU2 and execute this in a terminal:

sudo route add eth0
sudo arping -f; telnet 9000

Then turn on the NSLU2. The above telnet will wait…

[spari@localhost ~]$ sudo arping -f; telnet 9000
ARPING from eth0

The moment it connects and returns the RedBoot prompt, hit Control-C (you will have less than 2 seconds to do that!):

[spari@localhost ~]$ arping -f; telnet 9000
ARPING from eth0
Unicast reply from [00:31:41:59:26:54] 5.134ms
Sent 12 probes (12 broadcast(s))
Received 1 response(s)
Connected to (
Escape character is ‘^]’.
== Executing boot script in 1.430 seconds – enter ^C to abort

Embedded Systems

Like many who got onto the IT bandwagon, I never got to utilize what I was trained in – electrical engineering. After a career of high-level application development (i.e. in the IT Industry), I’ve taken the plunge, into the embedded world – back to my roots.

It really is an exciting and much more challenging area to be in – compared with drudgery of enterprise software development (“fatware”) – where you don’t care about efficiency, you just slap on more memory, disk, cpu’s.

I have to thank the Slug for getting me into the world of embedded systems: embedded Linux, embedded hardware, ARM processors, 8-bit microcontrollers.

Surprisingly very little has changed since the Zilog Z80 (years ago) in terms of how they work. What has changed is that the CPU and all its peripheral components (RAM, EEPROM, Flash, USART, ADC, DAC, clock circuitry) have been all compressed into a single unit – the microcontroller (uC or MCU), the size of thumbnail, less than $2, consuming less than 1W (compare that with $200 and 40W of CPU used in PCs – I know it’s an unfair comparison, but today’s MCUs (especially ARM chips) where like the CPUs of 15 years back).