Ondrej 'SanTiago' Zajicek, firstname.lastname@example.org
This text is obsolete. it is much better to use Linux kernel from OpenWRT and use debootstrap to install Debian
I got device "Mikrotik Routerboard 532" (rb532), which is board with MIPS CPU IDT 79RC32H434 (which has integrated network card and serial port), 32 MB RAM, two on-board via-rhine network cards, two miniPCI connectors, on-board 128 MB of NAND Flash and Compact Flash connector.
I would like to install Debian Sarge (arch: mipsel) on 256 MB CF disk. Because kernels of Debian installer don't have support of this specific board (especially CF driver), i had to prepare my kernel. I got plain vanilla Linux 2.4.32 (here) and patch for rb532 from Mikrotik (here). But i need some toolchain.
I installed Debian packages toolchain-source, toolchain-source-gdb (and several, but not all 'recommended' packages) and dpkg-cross on my Debian Sarge i386 workstation. I found bug in toolchain-source - i file /usr/bin/tpkg-install-libc there is wget downloading packages from testing instead of stable (or maybe better sarge). I corrected it and executed:
tpkg-install-libc mipsel-linux tpkg-make mipsel-linux cd binutils-... dpkg-buildpackage -rfakeroot cd .. cd gcc-... dpkg-buildpackage -rfakeroot cd ..
And installed created Debian packages.
Then i patched kernel with Mikrotik's patch. There were two rejects, but they weren't important. Then i edited Makefile to change ARCH, and CROSS_COMPILE to have:
ARCH = mips CROSS_COMPILE = mipsel-linux-
In Makefile i also changed: "HOSTCC = kgcc" to "HOSTCC = gcc", "CC = $(CROSS_COMPILE)kgcc" to "CC = $(CROSS_COMPILE)gcc" and in arch/mips/Makefile i changed: "tool-prefix = mipsel-linux-uclibc-" to "tool-prefix = mipsel-linux-" (originals are some strange settings from Mikrotik's patch)
Here is patch which sets ARCH and CROSS_COMPILE and repairs several Mikrotik's breakage.
Now i configure kernel with:
$ cp config.mipsel .config $ make menuconfig
I chose wanted options (.config of my last kernel compilation for rb532 is here), especially this options i compiled directly into kernel:
Ramdisk is needed to put initrd of Debian installer to it. (several platform-specific options were already set from config.mipsel)
When i tried this i found devfs is needed because used initrd.gz from Debian Sarge installer supposed it. Adding of this options:
This option have some collision with MTD (during compilation), so i disabled MTD and YAFFS (this can be used to access buildin NAND Flash, which i don't need for installation).
Then compilation was executed:
$ make vmlinux $ mipsel-linux-strip vmlinux
Then i took some initrd.gz with Debian installer (from here). cdrom/initrd.gz doesn't support network installation (or i coldn't find it in installation menu), cobalt/netboot/initrd.gz is usable, the last one (sb1-swarm-bn/netboot/initrd.gz) i didn't try.
initrd.gz and kernel options was integrated to kernel:
$ echo "root=/dev/ram0 ramdisk_size=8192" >kernel.params $ mipsel-linux-objcopy --add-section kernparm=kernel.params vmlinux $ mipsel-linux-objcopy --add-section initrd=initrd.gz vmlinux
Then i configured DHCP and TFTP server, put vmlinux to TFTP root, connected serial terminal (set to 115200 kb/s, 8N1) to rb532 and booted rb532. In boot menu i choosed Ethernet boot and DHCP. Installation started and proceeded (in low-memory mode) up to step where it wanted to partition a harddisk. parted failed (because kernel oopsed during parted scanning of CF). I entered shell, tried to use parted from command line (but without success), tried to use fdisk (but it wasn't installed), so i cancelled installation, remove CF from rb532 and put it to USB CF reader (on my workstation), where i use fdisk to make two primary paritions, one with size of 4 MB and type 27 (in hexadecimal) (this partition should contain raw ELF image of Linux kernel, which will be started by RouterBOOT (bootloader integrated in rb532)), the other is standard partition for Linux. Then i restarted installation of Debian, did no-problem steps. instead of proceed with partitioning i entered shell:
# mke2fs -j /dev/discs/disc0/part2 # tune2fs -c 0 -i 0 -m 2 /dev/discs/disc0/part2 # mkdir /target # mount /dev/discs/disc0/part2 /target # exit
Then i tried to continue with next step after partitioning, but Debian installer didn't allowed to skip partitioning. So i entered shell (found that /target is unmounted):
# mount /dev/discs/disc0/part2 /target # /usr/sbin/debootstrap --arch mipsel sarge /target ftp://your-mirror-of-debian-mipsel/debian
This installated Debian base packages. After that there are two important steps - installation of kernel to first partition and preparation of console. Both steps can be done from shell before reboot or from another computer with USB CF reader.
For first step you need compiled and stripped kernel (vmlinux), integrate boot options:
$ echo "root=/dev/cfa2" >kernel.params $ mipsel-linux-objcopy --add-section kernparm=kernel.params vmlinux # dd if=vmlinux of=/dev/cfa1 # or another place in case of USB CF reader variant.
In second step edit /etc/inittab, remove lines starting getty on virtual terminals and add line for starting getty on console (which is on serial port):
t0:23:respawn:/sbin/getty -L console 115200 vt100
After two final steps there is working Debian Sarge on rb532, controllable through serial console. Now just tune some details (empty /etc/fstab, /etc/network/interfaces and empty root passwd) and package selection.
When i wanted kernel with modules, i found i have some problem with modversion - symbols in kernel wasn't generated correctly. I disabled modversion and everything worked.
When i wanted to do 'make dep', it failed in directory 'arch/mips/rb/rb100'. I removed line 'export-objs = prom.o' from 'arch/mips/rb/rb100/Makefile' and everything worked.
When i wanted to compile madwifi (version 20050522) for that kernel, i tried three targets (mips-le-elf, mips1-le-elf, mipsisa32-le-elf), all have problem with collisions between gcc arguments. I choosed mips-le-elf and removed '-mips1' from 'hal/public/mips-le-elf.inc' and everything worked.
When i wanted to compile ipv6 support, it failed with missing 'dev_get_by_flags' symbol. Mikrotik's patch disabled export of that symbol for no apparent reason. After revertion of that it worked.
Here Is patch for RB 500's watchdog support.
Another useful information about installation of Linux on rb532: