Some of the source files for this build are no longer available - you might try the Midge SVN

NEW! I have put up the files that can no longer be found (in fact the complete dl folder) and all the small files listed below at
see the readme

If you would like to donate, not to me , but to the Midge project go here

My "distro" was built from the files listed below - it works very well! - but you will need your own tool chain to change the ttyS0/1 baud rates - (but most things only need an ipackage

How to make and modify the Midge firmware in order to:
1) boot from a usb memory stick or hard disk
2) have a second serial port working at 9600 (or any) bps
3) suppress "terminal chatter" on ttyS0 (you still see the boot sequence)
4) have 19 LED lines as inputs or outputs

5 ) have a tool chain on your Linux PC that may be used to develop C programs for your router

These notes are based on the tutorial of IJs posted at

(my backup copy)
With much help from an anonymous contact to whom many thanks.
The objective is to create a set of instructions that can be followed
by an experimenter who, like me, may have zero knowledge of Linux at the outset.

Firmware is created that allows a Sweex Router (or clone) to boot
from a USB memory stick and to contain web pages that may
be used to send strings to the second serial port.

The baud rates of the serial ports may be changed in file serial.c before compile.
It should be possible to do this in a config file on the stick - but so far that has not worked,
please email me if you fix that.
A tool chain is created that allows C programs to be created for the Sweex on a Linux PC
I used Fedora Core 5 for the following.
Linux experts are encouraged to contact me to help improve this procedure

A. Create a folder "graham" (or what you like) in /home
and get the source of the midge firmware -

kamikaze-200602050443.tar.bz2 (6.5 MBytes)
located at

And also obtain
located at
(my backup copy here )
- 115200baud ttys0 (primary RS232 on header) and 9600baud ttyS1 (secondary RS232 - cut the pins)
(simple speed mod on the raw files from the chain - no SegeyV mods added)
serial.c - 9600baud ttys0 (primary RS232 on header) and 9600baud ttyS1 (secondary RS232 - cut the pins)
(the bootloader is always at 115200baud on ttys0)
led.c - for 19 led lines as outputs or inputs (new 5/2/07 from dl4huf - watch his site - he is still updating!)
led.h - ditto

B. Generate the midge firmware/rootfs from the source.
This will take some time (hours?), since it will retrieve lot's of
packages from various internet sites and compile them

(If you need to repeat the process save the contents of the trunk/openwrt/dl folder to avoid having to download again)

Open a terminal window and
type the following
cd /home/graham
mkdir kamikaze-200602050443

in the GUI window drag kamikaze-200602050443.tar.bz2
into the
kamikaze-200602050443 directory
cd kamikaze-200602050443
tar jxvf kamikaze-200602050443.tar.bz2

(or (in the GUI) right click - extract here)

(or just use the GUI window to make the folder kamikaze-200602050443
and use right click on
kamikaze-200602050443.tar.bz2 and "extract here" - then drag and drop)

(If this is your second time round this loop copy the /trunk/openrwrt/dl folder with all the previously downloaded contents into the newly created /trunk/openrwrt/ folder - keep the kamikaze-200602050443.tar.bz2 and the dl files on a CD - I had a crash and could not find them all on the net)

NB! Copy the 004-kernel-entry.patch and into


cd /home/graham/kamikaze-200602050443/trunk/openwrt
gmake menuconfig
In the Busybox menu leave most of the defaults but make sure you have printf, stty and httpd as follows
OpenWrt Package Selection --->
Busybox Configuration --->
Coreutils --->
[*] printf
[*] stty
Networking Utilities --->
[*] httpd
Exit Exit Save
Make everything; this will take some time,
gmake V=99
Ignore the reported errors.
It's OK if

has been made

(NB I find that some runs crash - just try again using fresh kamikaze-200602050443.tar.bz2 and the dl files)

You now have a toolchain, a kernel (not yet the finished one), lots of
packages and a rootfs.

C. Replace serial.c with the one of the modified ones
Copy the modified serial.c (for the baud rates you need) downloaded earlier into the directory
For 19 led lines as outputs or inputs copy led.c and led.h to the same directory (new 5/2/07 from dl4huf) §

D. The rest must now be done.
cd /home/graham/kamikaze-200602050443/trunk/openwrt/build_mipsel/linux-2.4-adm5120/linux-2.4.32
make menuconfig

In the menu, modify in order to have:
General setup --->
[*] Default bootloader kernel arguments
Initial kernel command string:
console=/dev/ttyS0 panic=30 root=/dev/scsi/host0/bus0/target0/lun0/part1 rw
(copy the above string into the clipboard (select it then type control-C)
In the Linux Kernel Configuration utility move down to "Initial kernel command string"
press return,
editing here is unusual - first press return, press the backspace key till the edit box is empty
paste in the string - tab till you enter the OK box

Block devices --->
<> RAM disk support (unselected)
SCSI support --->
<*> SCSI support
<*> SCSI disk support
(2) Maximum number of SCSI disks that can be loaded as modules
File systems --->
<*> Ext3 journalling file system support
<*> Second extended fs support
USB support --->
<*> Support for USB
<*> OHCI (Compaq, iMacs, OPTi, SiS, ALi, ...) support
<*> AHCI ADM5120 (USB 1.1) Host controller support
<*> USB Mass Storage support
Exit Exit Save
Replace the 3 following files with those downloaded earlier:

In drivers/net/adm5120sw.c replace
request_irq(SW_IRQ, swdrv_ProcessInt, SA_SHIRQ, dev->name, dev);
request_irq(SW_IRQ, swdrv_ProcessInt, SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev);

Recompile the kernel (still being in

Now you have also a good kernel (vmlinuz, useable with option b of

Make a flashable firmware (useable with option a of bootloader):
First compile a small utility.

In the terminal window move to the kamikaze linux kernel directory
cd /home/graham/kamikaze-200602050443/trunk/openwrt/build_mipsel/linux-2.4-adm5120/linux-2.4.32
download the C file mksyshdr.c from
(or take this copy from here)

compile it to make mksyshdr
gcc mksyshdr.c -o mksyshdr && chmod 755 mksyshdr

./mksyshdr csys vmlinuz
cat csys vmlinuz > midge-ttyS1-96-firmware.bin

You now have vmlinuz for testing in RAM and midge-ttyS1-96-firmware.bin for burning to flash

now upload the new firmware to your router

§ NB! if you go through all this again to change something you do not have to do these lines again

E. Make a root fs on a USB stick

the latest version with all the added functions here
(or make your's following the IJs instructions)

How to format a Linux 2fs USB memory stick and load the stick file sytem

F. Compile C programs on a Linux PC for the Sweex/Edimax
You now have a toolchain that can be used to
compile application programs written in C on the PC that may be transfered to run on the router.

Where you would normally write gcc write instead -

My first C program for the Sweex

On my Linux PC I created a text file graham_hello.c containing

*example hello world program
#include <stdio.h>
int main(int argc, char** argv)
/* comment */
printf("Graham says hello world \n");
return 0;
/*graham_hello.c */


I put this into a directory /home/graham/test on the PC

In a terminal window I typed
[root@localhost /]# cd /home/graham/test
[root@localhost test]# ls

To compile the program for the Sweex I typed

[root@localhost test]# /home/graham/kamikaze-200602050443/trunk/openwrt/staging_dir_mipsel/bin/mipsel-linux-uclibc-gcc -o graham_hello graham_hello.c

mipsel-linux-uclibc-gcc is the equivalent of gcc on the Linux PC
- I presume it knows where to look to find the include file stdio.h for the Sweex CPU

I copied the file graham_hello that had appeared in the directory /home/graham/test
into the bin directory of the USB memory stick

In the Hyperterminal, connected to the Sweex RS232 port, I typed graham_hello after the midge# prompt,

midge# graham_hello
Graham says hello world

(OK, I know you should not work as root, but if you use the GUI windows it lets you copy and paste without hassle.)
If you feel able to write a "This is the correct way to do it" note please send it to me for me to place here.