Thursday, January 10, 2013

Repurposing an old laptop with tinycore linux:

    low power, low cost, low noise using a compact flash card

What to do with those ancient laptops?  I always feel guitly disposing of them, knowing they cost near $3000 when new.  But what use can a pentium serve at this point?

I had a need to run a simple application to send a few commands out the serial port periodically.  I wanted this to be a low-cost, low-power, low-noise solution.  So, with this old laptop, a 16MB compact flash card I had lying around and a CF-IDE adapter I set to work.

Initially I had used FreeBSD but it required a rather large CF card due to the fact that I needed the linux-compat libraries to be included.  Then a few months later I came across tinycore linux.  Actually, microcore is what really interested me - requires 8MB and less than 32MB of RAM.  I love a challenge, so I set to work.

Tinycore wasn't really intended to be "installed" - the devs seem to prefer running from a CD or other media.   However, without a CD drive, I needed this to be installed to the CF card.  Turns out someone had already done most of the legwork for me.  Most of the instructions I list here are directly from that page, but I list here for my own history along with the steps I later used for setting it to my direct purpose.

1. download the microcore ISO file  and the grub extension.

2. partition and format the CF card, then mount the partition (/dev/sdc in my case):

# fdisk /dev/sdc

Delete the existing partition:

Command (m for help): d
Selected partition 1

Create a new partition, primary, first, full size of the card:

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1):  
Using default value 1
First sector (2048-31359, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-31359, default 31359): 
Using default value 31359

Set the partition type to 83 (linux)

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 83

Set the bootable flag for this partition:

Command (m for help): a
Partition number (1-4): 1

Write the partition table:

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

Format the partition to ext2:

# mkfs.ext2 -L TINYCORE /dev/sdc1 

3. mount the microcore ISO and copy the kernel and initramfs file to the CF card:

# cd /tmp
# mkdir tc cf
# mount /dev/sdc1 cf
# mount Core-current.iso tc
# mkdir cf/boot
# cp -a tc/boot/vmlinuz tc/boot/core.gz cf/boot

4. install the grub bootloader to the card:

# mkdir grub
# mount grub-0.97-splash.tcz grub
# mkdir cf/boot/grub
# cp -a grub/usr/lib/grub/i386-pc/* cf/boot/grub/

Next we add and edit the file cf/boot/grub/menu.lst (using vi)  and enter the following contents:

default 0
timeout 1
title tinycore
kernel /boot/vmlinuz opt=sda1
initrd /boot/core.gz

As per the aforementioned url, we need to link menu.lst to grub.conf and create a grub device mapping:

# ln -T cf/boot/grub/menu.lst cf/boot/grub/grub.conf
# echo "(hd0) /dev/sdc" >

And finally, install grub:

# grub 

grub> root (hd0,0)
root (hd0,0)
 Filesystem type is ext2fs, partition type 0x83

grub> setup (hd0)
setup (hd0)
 Checking if "/boot/grub/stage1" exists... yes
 Checking if "/boot/grub/stage2" exists... yes
 Checking if "/boot/grub/e2fs_stage1_5" exists... yes
 Running "embed /boot/grub/e2fs_stage1_5 (hd0)"...  15 sectors are embedded.
 Running "install /boot/grub/stage1 (hd0) (hd0)1+15 p (hd0,0)/boot/grub/stage2 /boot/grub/grub.conf"... succeeded
grub> quit

5. install my applications on the card, modify /opt/ to start my applications.

# mkdir cf/opt
# cp -R xxx cf/opt
# echo "/opt/xxx/start???" > cf/opt/
# chmod 755 cf/opt/
# umount cf tc grub

    This step involves creating a directory /opt in the root of the CF card and copying the files there.  Because we added the opt=sda1 bootcode to the bootloader, this directory will be mounted within the uncompressed initramfs filesystem in RAM at the /opt location.  (This also works for home=sda1, and there is also the automatically mounted /tce directory).
    I chose to use /opt because I will need to automatically start my application when the system boots.  This is most easily done by starting it via /opt/  Having /opt be persistent in the root filesystem will allow me to change this without having to deal with the "backup" solution (which could have been used if I used /tce instead and then use mydata.tgz).  But I won't be modifying files often or having files written often, so flash longevity isn't a concern for me.
    Another option would have been to have a startup script in /etc and then have that file be persistent (via /opt/.filetool.lst), but I am going for minimalistic here.

As for an IP address, tinycore uses DHCP by default so my router will offer a static IP address to it.  However, I could have just as easily added an ifconfig statement to /opt/

As a finaly note for myself, I probably could have compiled a kernel and made my own initrd image and gone even smaller or extracted the entire microcore initramfs cpio archive to the disk.  However, the advantage here is that this all took less than one hour.  Time is money.  As well, using the initramfs system ensures that everything is readonly and will not be corrupted.  Maybe in the future, remastering the initramfs to contain my application might be advantageous.
So, let's review: I have an old laptop that powers down the screen when the lid is closed a 16MB flash card that minimizes the noise (no hard disk) and power consumption (no hard disk).  Sure, a raspberry pi or a beagle board would have been a nice small solution, but why not use what I already had?

Wednesday, January 9, 2013

Creating a ffp (fonz fun plug) package for proxychains to run on the dns-323

I wanted to run an application on my dns-323 via a proxy server, specifically a SOCKS5 proxy server.  I couldn't find anyone that had build proxychains so here it is.  These instructions are for ffp 0.5.


ffp:  information about using ffp with a dlink dns-323

Using the method described in the second link above did NOT work for me.  There was an issue at the final stage, during make install where make was attempting to install proxychains.conf to a location that didn't exist.  And while I was able to manually tweak it to build correctly, that just won't work when adding to the build env because it will download the package each time.  So, instead I will create the package manually.

We need to install the following packages:
  • make
  • gcc
  • distcc
  • libtool
  • binutils
  • kernel-headers
  • automake
  • autoconf
  • patch
Each of these can be downloaded from the link listed above for packages using wget (wget ).  Then, they are installed using funpkg -i

Download proxychains, extract the contents and build:

cd /tmp
tar xvzf proxychains-3.1.tar.gz
cd proxychains-2.1
mkdir ffp
./configure --enable-static=no --prefix=/tmp/proxychains-3.1/ffp
make install
tar cvzf proxychains-3.1.tgz ffp

Now we can test installing the package:

funpkg -i proxychains-3.1.tgz

Friday, December 30, 2011

USB mounting a blackberry playbook in linux

Blackberry has decided that the playbook will not be visible as a mass storage device.  Lovely.  And, they only provide drivers for windows and mac.  Nice.  So, for us linux users?  There is a solution.  This has been blogged about by several people, but I'll summarize it here for at least my own purposes.

Basically, what we'll be doing here is having the playbook appear as a USB network card on linux and using a SMB mount.

1.  Settings -> Storage & Sharing:
  • Change "USB Connections" to "Connect to Windows"

  • Change "Network Identification" to give your playbook a network name, workgroup and a username.

  • Set "File Sharing" to ON

  • You can optionally turn ON Wi-Fi sharing so that you can use SMB mounts over Wi-Fi, but that is much slower than the USB mount we're about to cover.
  • Set a password - again, this is optional.  I didn't bother because I intend to disable file sharing when I am done.
2.  Settings -> About -> Network
  • With your playbook connected to your computer via the USB cable, the playbook should have an IPv4 address assigned to the USB NIC.  Take note of the address.  

3.  On your linux PC (one that uses gnome/nautilus in this case)
  • Open Nautilus, and from the FILE menu, select "Connect to server..."  (sorry, no screenshot, but apparently one can't take screenshots when a menu is active)
  • In the "Connect to server..." dialog:
              - select "windows share" for service type
              - enter the IP address you noted above into the "Server" field
              - set the "Share" field to "/media"
              - enter the playbook file sharing username that you set

  •  Once you click "connect" the playbook should now be mounted and visible in nautilus.

IF you prefer to do things from the command line as I do, then replace step 4 with the following:

     smbmount // /media -o leo 

Of course, replace the IP address, username and mount destination with your own.

One final point, if you would prefer to use Wi-Fi mounting, not much changes, just the IP address of the playbook, which is more likely on your local network rather than an (avahi?) network address that is used for the USB NIC.

Wednesday, December 7, 2011

Backyard Ice Rink - the tarp arrives!

The tarp has finally arrived!  20'x30' and white.  I've laid it out across the rink area, screwed in the four corners, and moved it so that it lays evenly across the area.  Here's what it looks like:

Along the boards, I simply used some extra drywall screws I had to fasten the tarp eyelets to the boards so that the wind doesn't blow it away while we wait for the deep freeze.  The screws had to be put in at an angle as shown below:

And finally, I added some extra illumination - the lighting might need to be adjusted, but here's what it looks like at night:

Monday, November 21, 2011

Backyard Ice Rink - attempt one.

Okay, so this year I've decided to attempt a backyard ice rink.  My boy has started hockey and hopefully a rink this close will spur some interest.  After a quick survey of the yard, I've determined that I can land a 20' x 30' pad that is "level enough".  (Actually, it's 28' x 18', the tarp is 30' x 20', need some extra to hold in the water). Beyond that, there's just too much slope.  So, up first is the bill of materials:

  • 20' x 30' white 6mil tarp: $51.99 ($39.99, $12 shipping)
  • boards - six  2"x10"x10': $53.34
  • boards - four  2"x10"x8': $26.68
  • stakes - four 2"x4"x8: $8.92
  • four corner brackets: $11.96
  • one box of 100x3" green deck screws: $11.49
  • subtotal: $164.38, tax: $21.37, grand total: $185.75

STEP 1: string up the box
As you can see in the image below, I have marked the four corners with stakes and run twine between the posts.  This indicates where the stakes will go.

STEP 2: insert the stakes
Here I have my box of stakes.  Rather than paying the $0.99 each for 2"x2"x4' stakes, I simply bought 2"x4"x8' and cut them down to 6 stakes per.

Next, I have lined up the boards and started pounding in some stakes - two per board.  Note: when you have misplaced you sledge hammer, the backend of an axe will suffice.

STEP 3: install the boards
Yes, that's my wife's garden I'm trampling.  She wasn't too happy, but a rink for my boy trumps the garden.   The boards are now screwed into the stakes using the 3" deck screws.  I used the green screws in hopes that they won't rust.  Two screws per stake should be enough.

STEP 4: fasten the boards to each other:
Here cut a few leftover stakes in half and screwed the adjacent boards to each other.

In the corners I used metal brackets.

STEP 5: time for coffee
 This is the finished product.  Now I'm frozen, going in to get a coffee.  And wait for my tarp to arrive.  I'll lay down the tarp once the ground is near frozen so as to not damage the grass.  Once we get some sub-zero temperatures, I'll start the flooding.

Tuesday, October 14, 2008

Building tomatoND with MLPPP for the Asus WL-520gu

Here is an attempt to recount from memory how I built tomatoND with MLPPP for the Asus WL-520gu. It may work for the Buffalo WHR-G125 as well. I may have missed a thing or two....I'll update as/if I find mistakes.

# download and untar WRT54GL source
tar xzf source/WRT54GL_v4.30.11_11_US.tgz

# download and unpackage the tomato source yielding tomato.tar and tomatoND.tar
tar xjf TomatoSource_1_19.tar.bz2

# download and unrar the tomato MLPPP patch
unrar e tomato-mlppp-1.19-mp2_src.rar

# rename WRT source folder to tomato
mv WRT54GL-US_v4.30.11_11/ tomato

# Create a symlink in /opt/brcm to tomato/tools/brcm/.
ln -s $PWD/tomato/tools/bcrm /opt/bcrm

# add the cross compiler folders to your path
export PATH

# remove files specified in tomato build README file
cd tomato/release/src/
rm -rf et et.4702 wl rts tools .model
cd router/
rm -rf busybox cron dnsmasq httpd iproute2 iptables ipupdate lib libnet libpcap mipsel-uclibc misc nas netconf ntpclient nvram others rc ses shared traceroute udhcpd upnp utils www
cd ../../..

# untar tomato source over the WRT source
tar xf tomato.tar

# untar tomatoND source over the tomato modified WRT source
tar xf tomatoND.tar

# remove .c files that have been pre-built
cd tomato/release/src/shared
rm bcmsrom.c bcmutils.c hnddma.c linux_osl.c sbutils.c sflash.c
cd ../..

# apply the MLPPP patch
patch -p1 < ../tomato-mlppp-1.19-mp2.patch

# enable MLPPP in the kernel
# set CONFIG_PPP_MULTILINK=y in both files
cd release/src/
vim linux/linux/.config
vim linux/linux/.config.old

# on my ubuntu system, make didn't like the curly bracket loops
# as a quick fix I just duplicated the sections for each loop
# (see the loops for {*.asp,*.svg} and {*.js,*.jsx}
vim router/www/Makefile

# build the source

# at some point the build will fail - the tomato_profile.h file
# gets an extra "-e " prepended to the file, just remove it
vim ./router/shared/tomato_profile.h

# make again

# your image is now in the image folder

MLPPP Tomato on the Asus WL-520gu

I picked up the Asus WL-520gu for $20 (after MIR). My hope was to run Tomato/MLPPP as is described at here: dslreports-tomato-mlppp and at However, that's only for the Linksys WRT54GL and similar devices. With help from Guspaz and dsl_ricer I was able to get it all to build, connect and run with MLPPP (though I haven't verified that it's actually working properly).

Since the dd-wrt and tomato firmware for the WL-520gu also work on the Buffalo WHR-G125, this MLPPP version *should* work on the Buffalo as well, though I don't own one and haven't tried.

DISCLAIMER: this is an account of how I got MLPPP/Tomato working on my Asus WL-520gu. I am not recommending anyone try this, and if you do, I will not be held responsible if you brick your router.

Basically, what we're going to do is flash with dd-wrt, then with basic tomato (ND version), get the router up and running, then flash with the MLPPP version. I'll describe how to build the firmware in another post. I am assuming you have a DSL modem configured to allow the router to perform pppoe negotiation.

1. Follow the steps to flash the router with dd-wrt outlined here: dd-wrt on WL-520gu. Reboot and configure to make sure it works and connects to your ISP.

2. Using a similar procedure as was done in step 1., using the asus recovery tool, flash the router with TomatoND firmware version v1.19. NOTE: you must use the ND version of Tomato. The current version is v1.21, but I used v1.19 because that is what the stable version of MLPPP is based upon. It can be found on the Tomato download page (specifically, here)

3. reboot the router and configure it appropriately to your settings. The WAN side probably won't connect via pppoe via your modem. I followed the advice in this thread to get it to connect:
I found that vlan1ports nvram variable on Tomato was set to "0 5u" I changed this as follows (from telnet login to the router):
nvram set vlan1ports="0 5"
nvram commit

4. Repeat step 2 using the MLPPP version of the tomatoND firmware that I built.

Now, step 2 may be unnecessary if you want to directly flash with the MLPPP version....I didn't try that though, so I don't know if there'd be any issue.

I use a 2write 2700HG-B modem/router. Had to configure it to bridge mode....this post was super useful (though VPI for Bell is 0, not 8).

Useful links: