Above average nerdiness

Monthly Archives: August 2011

Installing Debian to disk on an ix2-200

Warning: This completely removes the existing filesystems from disk and kernel images from the flash that ship with the ix2-200 and leaves you with a basic Debian install. Only do this if you understand what this means and have nothing important stored on the device.

Most of the information in this post is based on Diogo Gomes’ work on the iConnect.

uBoot Parameters

The first step in installing Debian that I did was to reconfigure the uBoot environment to fix a number of issues. This is done from the uBoot prompt, which is only accessible via a serial interface.

Update the MAC address of the disconnected ethernet port on the SoC to an address from an unused range so that udev doesn’t get confused:

setenv ethaddr AA:00:00:00:00:01

Enable booting of a standard linux kernel

setenv mainlineLinux yes
setenv arcNumber 1682

Save and reset


Booting the Debian installer and completing the install

I used the published debian installer images from here copied to a ext2 formatted usb stick. I connected the usb stick to the front port of the ix2-200.

You should also have the ix2-200 connected to the internet somehow. A simple way of doing this for me was to connect to the Ethernet port of my laptop running Ubuntu and bridge it with the virtual bridge I use for running VirtualBox VMs and provides DHCP and NAT. Internet connectivity can than be used through another connection e.g. a home wireless connection. You can do this by running the following command on the laptop:

sudo brctl addif virbr0 eth0

From uBoot on the ix2-200, start the usb subsystem and load the netboot installer kernel and initial RAM disk into memory:

usb start
ext2load usb 0:1 0x01100000 /uInitrd
ext2load usb 0:1 0x00800000 /uImage

Set the boot arguments for the installer:

setenv bootargs console=ttyS0,115200n8 base-installer/initramfs-tools/driver-policy=most

Boot the installer:

bootm 0x00800000 0x01100000

You can now go through the normal debian installation almost to the end. A few tips to get you through:

  • Select eth1 for the network interface (eth0 doesn’t work).
  • I used a single RAID1 instance across a single partition on each disk with LVM and volumes on top of that.

At the last step, the installer will tell you that it can’t make the system bootable. To get around this, we need to install the uboot utilities and save the uboot images to the usb stick.

First select the ‘Execute a shell’ from the Debian installer menu, and then chroot to your fresh Debian install:

chroot /target

Install the utilities:

apt-get install mtd-utils uboot-mkimage uboot-envtools

Change to the boot directory and convert kernel and initrd files to uboot format:

cd /boot
mkimage -A arm -O linux -T ramdisk -C gzip -a 0x00000000 -e 0x00000000 -n initramfs -d initrd.img-2.6.32-5-kirkwood uInitrd
mkimage -A arm -O linux -T kernel  -C none -a 0x00008000 -e 0x00008000 -n Linux-2.6.32-5 -d vmlinuz-2.6.32-5-kirkwood uImage

Mount your usb memory stick and copy the new files to the memory stick:

mount /dev/sdXX /mnt
cp uImage /mnt/uImage-new
cp uInitrd /mnt/uInitrd-new

Exit the shell and reboot into uboot by selecting the “Finish the installation” option. At this point we should be able to now boot from disk using the uInitrd and uImage files on usb. Note that I also setup the mtd in the bootargs_console setting so we can write the kernel and initrd files to flash once we know it’s working. Replace the root value with what ever you setup during the install:

usb start
setenv bootargs_console 'console=ttyS0,115200 mtdparts=orion_nand:0x300000@0x100000(uImage),0x1000000@0x540000(uInitrd) root=/dev/mapper/'
setenv bootargs $(bootargs_console)
ext2load usb 0:1 0x00800000 /uImage-new
ext2load usb 0:1 0x01100000 /uInitrd-new
bootm 0x00800000 0x01100000

Congratulations! You should now be in your debian install.

Configuration to boot from internal flash and disk

Login and become root, and execute the following command to confirm that the nand flash has been configured correctly:

# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00300000 00004000 "uImage"
mtd1: 01000000 00004000 "uInitrd"

We can now erase and flash the uImage and uInitrd files:

# flash_eraseall /dev/mtd0
Erasing 16 Kibyte @ 300000 -- 100 % complete.
# flash_eraseall /dev/mtd1
Erasing 16 Kibyte @ 1000000 -- 100 % complete.
# nandwrite -p /dev/mtd0 /boot/uImage
# nandwrite -p /dev/mtd1 /boot/uInitrd

Reboot to get back the uBoot prompt to setup loading the kernel and initrd from flash. Replace the root value with what ever you setup during the install:

setenv mtdids 'nand0=orion_nand'
setenv mtdparts 'mtdparts=orion_nand:0x100000@0x000000(uboot)ro,0x20000@0xA0000(uboot_env),0x300000@0x100000(uImage),0x1000000@0x540000(uInitrd)'
setenv bootargs_console 'console=ttyS0,115200 mtdparts=orion_nand:0x300000@0x100000(uImage),0x1000000@0x540000(uInitrd) root=/dev/mapper/red_vg0-root'
setenv bootcmd 'setenv bootargs $(bootargs_console); nand read 0x800000 uImage; nand read 0x1100000 uInitrd; bootm 0x00800000 0x01100000'

You should now be booting Debian from flash and disk.