This page walks through the DebWrt project in small steps. It is written with hands on in mind. What you need is a Debian GNU/Linux computer. Other hardware will be emulated.

Have a Command Line Interface. When you type

ls -ld /usr/src

you should see

drwxrwsr-x 27 root src 4096 dec  5 11:26 /usr/src

Check bash

echo $[4*6]

should print 24

Check if you are allowed to do sudo

sudo echo $[6*7]

should print 42

Using the sudo power

sudo addgroup ${LOGNAME} src

Will most likely show

Adding user `accountname' to group `src' ...
Adding user accountname to group src
Done.

Now is is user ${LOGNAME} allowed to write in the directory /usr/src

Some more information, for reference ( no need to execute )

stappers@inertia:~
$ echo ${LOGNAME} # print user name
stappers
stappers@inertia:~
$ LANG=C sudo delgroup ${LOGNAME} src
Removing user `stappers' from group `src' ...
Done.
stappers@inertia:~
$ LANG=C sudo delgroup ${LOGNAME} src
/usr/sbin/delgroup: The user `stappers' is not a member of group `src'.
stappers@inertia:~
$ LANG=C sudo addgroup ${LOGNAME} src
Adding user `stappers' to group `src' ...
Adding user stappers to group src
Done.
stappers@inertia:~
$ LANG=C sudo addgroup ${LOGNAME} src
The user `stappers' is already a member of `src'.
stappers@inertia:~
$ 

The command id should show now uid=1000(stappers) gid=1000(stappers) groups=0(root),4(adm),20(dialout),24(cdrom),25(floppy),27(sudo),29(audio),40(src),44(video),46(plugdev),106(vde2-net),118(kvm),1000(stappers), otherwise logout and login to fetch your new group membership.

Emulated hardware

buy hardware with care

sudo aptitude install qemu

When you now do

which qemu-system-mipsel

you should see

/usr/bin/qemu-system-mipsel

Debian kernel for test drive

cd ~
mkdir testdrive
cd testdrive
wget http://ftp.nl.debian.org/debian/pool/main/l/linux-2.6/linux-image-2.6.32-5-4kc-malta_2.6.32-29_mipsel.deb
dpkg -x linux-image*deb .
file boot/vmlinux*

that last line should show something like

boot/vmlinux-2.6.32-5-4kc-malta: ELF 32-bit LSB executable, \
 MIPS, MIPS32 version 1 (SYSV), statically linked, \
 with unknown capability 0xf41 = 0x756e6700, not stripped

The actual start

qemu-system-mipsel -M malta -nographic -kernel boot/vmlinux-2.6.32-5-4kc-malta

Should see lines like

   .
   .
   .
[    0.560000] PCI: Enabling device 0000:00:0a.1 (0000 -> 0001)
[    0.564000] scsi0 : ata_piix
[    0.568000] scsi1 : ata_piix
[    0.568000] ata1: PATA max UDMA/33 cmd 0x1f0 ctl 0x3f6 bmdma 0x1040 irq 14
[    0.572000] ata2: PATA max UDMA/33 cmd 0x170 ctl 0x376 bmdma 0x1048 irq 15
[    0.580000] pcnet32.c:v1.35 21.Apr.2008 tsbogend@alpha.franken.de
[    0.580000] PCI: Enabling device 0000:00:0b.0 (0000 -> 0003)
[    0.580000] pcnet32: PCnet/PCI II 79C970A at 0x1020, 52:54:00:12:34:56 assigned IRQ 10.
[    0.588000] eth0: registered as PCnet/PCI II 79C970A
[    0.588000] pcnet32: 1 cards_found.
   .
   .
   .
[    0.740000] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)

Now you known:

  • Serial port works
  • IDE Controller is seen as a SCSI device
  • Network Interface Card is detected
  • That Kernel panic is this time expected

To stop qemu-system-mipsel do in another terminal

kill -HUP $( ps -ef | awk '$8 ~ /qemu-.*-mipsel/ { print $2 }' )

That kernel did serve it's purpose.

cd ~ ; rm -rf testdrive/  # to cleanup
which svn

Should report /usr/bin/svn, otherwise sudo aptitude install subversion.

Go to the directory where the DebWrt source should go

cd /usr/src

That place is the linux kernel source. Another good reason for not under /home, it that there will be pathnames without username in further bugreports.

A simple write permission check

touch removeme ; rm removeme

should be silent. Other verify the output of ls -ld /usr/src and id.

Now download debwrt by

svn checkout https://svn.debwrt.net/debwrt/trunk debwrt

You might see output like

Known fingerprint of the https server {{{ 15:dd:03:49:ee:63:0f:1c:a8:e3:8e:24:20:cc:1c:25:24:75:c4:ce }}}

A    debwrt/openwrt/openwrt-deliver.mk
 U   debwrt
Checked out revision 175.

You have a new directoy, please enter it by

cd debwrt

A ls will show

config  Config.in  debian  LICENSE  Makefile  openwrt  README  rules

You are about to build debwrt, and you need build dependencies.

sudo aptitude install  build-essential libncurses5-dev

And even more build dependencies

sudo aptitude install zlib1g-dev gawk flex unzip git-core

The next step is a quatum leap, visit, read and do MakeMenuconfigMalta

Welcome back!

The next step is starting the build process. The command is

make

Give your build host time to do much work, including several source downloads.

Several minutes later ( expect a half hour)

A succesfull build finishes with

Make DebWrt completed

DEBWRTVERSION : angel - 2.0-1 - [ 29 January 2011 (r156) ]
TARGET_ARCH   : mipsel
BOARD         : malta
SUB_BOARD     : le_Default
LINUX_VERSION : 2.6.36.2 (default)

Typing

make board

should report

Board    : malta
Sub-Board: le_Default

Find kernel

file build/openwrt-malta-le_Default-trunk-default/build_dir/linux-malta_le/vmlinux.elf

should report

build/openwrt-malta-le_Default-trunk-default/build_dir/linux-malta_le/vmlinux.elf: \
 ELF 32-bit LSB executable, MIPS, MIPS32 rel2 version 1 (SYSV), statically linked, \
 with unknown capability 0xf41 = 0x756e6700, stripped

Testdrive your new kernel

qemu-system-mipsel -M malta -nographic -kernel \
 build/openwrt-malta-le_Default-trunk-default/build_dir/linux-malta_le/vmlinux.elf

You should see these lines

   .
   .
   .
PCI: Enabling device 0000:00:0a.1 (0000 -> 0001)
scsi0 : ata_piix
scsi1 : ata_piix
ata1: PATA max UDMA/33 cmd 0x1f0 ctl 0x3f6 bmdma 0x1040 irq 14
ata2: PATA max UDMA/33 cmd 0x170 ctl 0x376 bmdma 0x1048 irq 15
physmap platform flash device: 00400000 at 1e000000
physmap-flash physmap-flash.0: map_probe failed
pcnet32: pcnet32.c:v1.35 21.Apr.2008 tsbogend@alpha.franken.de
PCI: Enabling device 0000:00:0b.0 (0000 -> 0003)
pcnet32: PCnet/PCI II 79C970A at 0x1020, 52:54:00:12:34:56 assigned IRQ 10
pcnet32: eth0: registered as PCnet/PCI II 79C970A
pcnet32: 1 cards_found
   .
   .
   .
VFS: Cannot open root device "(null)" or unknown-block(0,0)
Please append a correct "root=" boot option; here are the available partitions:
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)

To stop qemu-system-mipsel do in another terminal

kill -HUP $( ps -ef | awk '$8 ~ /qemu-.*-mipsel/ { print $2 }' )

DISK

Now we gonna create a disk

dd if=/dev/zero of=/usr/src/debwrt/tile bs=1M count=2048

you get output like

2048+0 records in
2048+0 records out
2147483648 bytes (2.1 GB) copied, 26.1691 s, 82.1 MB/s

and now have a file that has the size of two gigabyte

Swap space 128Megabyte

echo $[2048-128]

shows 1920

Next you need fdisk that uses libparted

sudo fdisk -v

should show something like

GNU Fdisk 1.2.4

otherwise do sudo aptitude install gnu-fdisk

We will run fdisk to partition our disk. These commands / keystrokes where used:

sudo fdisk /usr/src/debwrt/tile
u
n
p

+1920MB
n
p


t
2
82
w

to see this:

GNU Fdisk 1.2.4
Copyright (C) 1998 - 2006 Free Software Foundation, Inc.
This program is free software, covered by the GNU General Public License.
  
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
  
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.

Using /usr/src/debwrt/tile
Command (m for help): u
Changing display/entry units to sectors
Command (m for help): n
Partition type
   e   extended
   p   primary partition (1-4)
p
First sector  (default 32s):
Last sector or +size or +sizeMB or +sizeKB  (default 4194303s): +1920MB
Command (m for help): n
Partition type
   e   extended
   p   primary partition (1-4)
p
First sector  (default 3750016s):
Last sector or +size or +sizeMB or +sizeKB  (default 4194303s):
Command (m for help): t
Partition number (1-2): 2
Hex code (type L to list codes): 82
Changed type of partition 2 to 82 (Linux swap)
Command (m for help): w

Writing all changes to /usr/src/debwrt/tile

Listing the partition table with fdisk -l /usr/src/debwrt/tile will show

Disk /usr/src/debwrt/tile: 2 GB, 2147483648 bytes
4 heads, 32 sectors/track, 32768 cylinders
Units = cylinders of 128 * 512 = 65536 bytes

               Device Boot      Start         End      Blocks   Id  System 
/usr/src/debwrt/tile1               1       29297     1874992   83  Linux
/usr/src/debwrt/tile2           29298       32768      222080   82  Linux swap

Listing the partition table in sectors with fdisk -lu /usr/src/debwrt/tile will show

Disk /usr/src/debwrt/tile: 2 GB, 2147483648 bytes
4 heads, 32 sectors/track, 32768 cylinders, total 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes

               Device Boot      Start         End      Blocks   Id  System 
/usr/src/debwrt/tile1              32     3750015     1874992   83  Linux
/usr/src/debwrt/tile2         3750016     4194303      222080   82  Linux swap

Further preparation of our virtual disk. It uses loop device technique.

For the swap partition

sudo losetup --find --show --offset $[3750016*512] tile

may show

/dev/loop6

where the 6 is more likely to be 0

sudo mkswap /dev/loop6

gives

Setting up swapspace version 1, size = 227471 kB
no label, UUID=a31d5609-3a58-4c26-8078-4c7641e3d7df

Release of the swap partition

sudo losetup --detach /dev/loop6

For the data partition

sudo losetup --find --show --offset $[32*512] tile

may show

/dev/loop6

where the 6 is more likely to be 0

LANG=C sudo mkfs -t ext3 /dev/loop6 1874992

gives

mke2fs 1.41.3 (12-Oct-2008)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
117360 inodes, 468748 blocks
23437 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=482344960
15 block groups
32768 blocks per group, 32768 fragments per group
7824 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912

Writing inode tables: done                            
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
sudo tune2fs -c 0 -i 0 /dev/loop6

gives

tune2fs 1.41.3 (12-Oct-2008)
Setting maximal mount count to -1
Setting interval between checks to 0 seconds

Mounting the data partion

sudo mkdir -p /mnt/target
sudo mount /dev/loop6 /mnt/target
df /mnt/target

gives

/dev/loop6             1845484     35564   1716172   3% /mnt/target

Copying debwrt root filesystem in the data partion with these commands

$ sudo bash
# ( cd build/rootfs-mipsel-angel-2.0-1/ && tar c . ) | ( cd /mnt/target && tar x )
exit
$ df /mnt/target

looks at my build host like this

stappers@inertia:/src/src/debwrt
$ sudo bash
root@inertia:/src/src/debwrt
# ( cd build/rootfs-mipsel-angel-2.0-1/ && tar c . ) | ( cd /mnt/target && tar x )
root@inertia:/src/src/debwrt
# exit
exit
stappers@inertia:/src/src/debwrt
$ df /mnt/target
Bestandssysteem     1K-blokken  Gebruikt Beschikbr Geb% Aangekoppeld op
/dev/loop6             1845484    341108   1410628  20% /mnt/target
stappers@inertia:/src/src/debwrt
$ 

We are ready with the disk preparation, let it go.

sudo umount /mnt/target
sudo losetup --detach /dev/loop6

No output, both commands are silent (when no errors occure)

First debwrt start

Now we gonna start qemu again, now with much more parameters. Recognice -hda which takes the disk that was prepared.

qemu-system-mipsel -M malta -nographic \
  -kernel /usr/src/debwrt/build/openwrt-malta-le_Default-trunk-default/build_dir/linux-malta_le/vmlinux.elf \
  -hda /usr/src/debwrt/tile -parallel none -m 256 \
  -net user -net nic,model=pcnet \
  -append "root=/dev/sda1 probe_mask=0x3f init=/sbin/init root_delay=10"

This time there should no kernel panic expect to see

   .
   .
   .
ata1.00: ATA-7: QEMU HARDDISK, 0.12.5, max UDMA/100
ata1.00: 4194304 sectors, multi 16: LBA48
ata2.00: ATAPI: QEMU DVD-ROM, 0.12.5, max UDMA/100
ata2.00: configured for UDMA/33
ata1.00: configured for UDMA/33
scsi 0:0:0:0: Direct-Access     ATA      QEMU HARDDISK    0.12 PQ: 0 ANSI: 5
sd 0:0:0:0: [sda] 4194304 512-byte logical blocks: (2.14 GB/2.00 GiB)
sd 0:0:0:0: [sda] Write Protect is off
scsi 1:0:0:0: CD-ROM            QEMU     QEMU DVD-ROM     0.12 PQ: 0 ANSI: 5
sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
 sda: sda1 sda2
sd 0:0:0:0: [sda] Attached SCSI disk
EXT3-fs: barriers not enabled
kjournald starting.  Commit interval 5 seconds
EXT3-fs (sda1): mounted filesystem with writeback data mode
VFS: Mounted root (ext3 filesystem) readonly on device 8:1.
Freeing prom memory: 956k freed
Freeing unused kernel memory: 212k freed
INIT: version 2.88 booting
EXT3-fs (sda1): using internal journal
pcnet32 0000:00:0b.0: eth0: link up

Welcome to the DebWrt post installation!

Press ctrl-d for normal boot. Use vim.tiny to edit files.

Note that both telnetd and sshd are running on: 192.168.1.1 and on 192.168.1.20.

Second stage install instructions:
sshd (859): /proc/859/oom_adj is deprecated, please use /proc/859/oom_score_adj instead.

  /debootstrap/debootstrap --second-stage  ;
  rm -rf /var/cache/apt/archives  ;
  mkdir -p /var/cache/apt/archives/partial  ;
  echo "deb http://ftp.nl.debian.org/debian squeeze main" >>/etc/apt/sources.list
# OR
- echo "deb http://ftp.debian.org/debian sid main" >>/etc/apt/sources.list
- for Lenny: dpkg-reconfigure dash

 Don't execute these lines, these are a reminder for myself(amain) when preparing an DebWrt release:
- rm -rf /lib/modules/*
- rm -rf /lib/firmware/*

root@debwrt:/# 

Finish the installation by copy and paste these four lines

/debootstrap/debootstrap --second-stage  ;
rm -rf /var/cache/apt/archives  ;
mkdir -p /var/cache/apt/archives/partial  ;
echo "deb http://ftp.nl.debian.org/debian squeeze main" >>/etc/apt/sources.list

from and to the serial port.

This is what you can expect:

/debootstrap/debootstrap --second-stage  ;
I: Installing core packages...
   .  ( several minutes the line )
I: Unpacking required packages...
I: Unpacking libacl1...
I: Unpacking libattr1...
I: Unpacking base-files...
   .
   . ( about an half hour )
   .
I: Configuring update-inetd...
I: Configuring openbsd-inetd...
I: Configuring telnetd...
I: Base system installed successfully.
root@debwrt:/#   rm -rf /var/cache/apt/archives  ;
root@debwrt:/#   mkdir -p /var/cache/apt/archives/partial  ;
root@debwrt:/#   echo "deb http://ftp.nl.debian.org/debian squeeze main" >>/etc/apt/sources.list
root@debwrt:/#  

Now find out if your debwrt system survives a restart

reboot
root@debwrt:/# reboot
INIT: Switching to runlevel: 6
INIT: Sending processes the TERM signal
Stopping internet superserver: inetd.
Saving the system clock.
   .
   .
   .
Starting internet superserver: inetd.
Starting NTP server: ntpd.
Starting periodic command scheduler: cron.

Debian GNU/Linux squeeze/sid debwrt ttyS0

debwrt login: 

Now login as root with password debwrt

debwrt login: root
Password:
Linux debwrt 2.6.36.1 #21 SMP Sun Dec 12 20:26:41 CET 2010 mips

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
root@debwrt:~#

Okay now you have something that works. Use it for further tweaking or use the experience you have now for other hardware.

Further reading

Last modified 7 years ago Last modified on Apr 4, 2011, 7:15:53 PM