Building ARCH Linux distribution for iMX233-OLinuXino

Image

iMX233-OLinuXino ARCHLINUX distribution

Kiril Zyapkov is one of our early developers who received free iMX233-OLinuXino-Maxi, he uses ARCHLinux during his daily work and he made ArchLinux distribution for OLinuXino.

The distribution use OpenEmbedded Layer to generate the necessary packages. The project is at GitHub:

https://github.com/OLIMEX/archlinuxarm-olinuxino

If you browse the Github project you will notice PKGBUILD scripts, they are used by makepkg (which is part of pacman, the package manager for arch) to build the packages.

Kiril still work to create custom repo with the kernel, elftosb and imx-bootlets, now he is working on PKGBUILD for imx-bootlets, to may the install script for the kernelto add alone mmcblk0p1, and will be ready in the next days.

For these who want to test Archlinux without building the packages themself there is ready generated binary rootfs at https://docs.google.com/open?id=0B-bAEPML8fwlUnB6MTU4NVdqb1k

It works with the normal Open Embedded generated Kernel 2.6.35 which image you can download from: https://docs.google.com/open?id=0B-bAEPML8fwlWDRpMGl5TGVaNXM

Here are some documentation and useful links:

https://wiki.archlinux.org/index.php/Pacman
https://wiki.archlinux.org/index.php/Pacman_Tips
https://wiki.archlinux.org/index.php/Post_Installation_Tips

and here https://aur.archlinux.org/ is collection of many software which are not part of the repositories.
You can figure out how build system works by browsing their PKGBUILD files.
ArchlinuxARM uses the buildscripts of the original Arch, but with modifications of some packages, the repository is https://github.com/archlinuxarm/PKGBUILDs . There is scrip for rootfs generation https://github.com/archlinuxarm/PKGBUILDs/blob/master/scripts/distro-builder

Kiril is using the same script to generate rootfs-a for OLinuXino.

Short description about how to make bootable SD card with Linux file system for OLinuXino boards

(NOTE – this example is given with “sdb1 and sdb2” device but it could enumerate differently on your host, so confirm what it enumerates as before running fdisk!)

1. Insert the card reader to the Linux host.
2. Un-mount the card reader, i.e. ‘sudo umount /dev/sdb1’
3. run fdisk, ‘sudo fdisk /dev/sdb’
4. Press ‘p’ to show the partitions on the card
5. Press ‘d’ to delete a partition. Repeat to remove all partitions
6. Press ‘n’ to create a new partition
7. Press ‘p’ to select the primary partition
8. Press ‘1’ to create partition 1 on the card
9. Press Enter to start from first block
10. Type ’16MB’ to create the 16MB partitions
11. Press ‘t’ to change the newly created partition type
12. Enter ’53’ for the new partition type
13. Press ‘n’ to create a second partition, select ‘p'(primary), then ‘2’(number)
14. Press Enter to accept all default settings
15. Press ‘w’ to write the partitions to the card and exit the fdisk
16. Format the second partition on the SD card – run ‘sudo mkfs.ext2 /dev/sdb2’ command.
17. Mount the second partition on the card
18. If you do not have the mmc mounting point created yet, create one with ‘sudo mkdir /mnt/mmc’
19. Run ‘sudo mount /dev/sdb2 /mnt/mmc’ to mount the partition as the mmc card
20. Copy the supplied files – alarm-olinuxino-rootfs.tar.gz(the ARCHLINUX FS) and imx233-Olinuxino.zip(boot image) for example in your home/user directory, unzip imx233-Olinuxino.zip to imx233-Olinuxino.img
21. Enter the mounted sd card directory – cd /mnt/mmc
22. Untar the rootfs to the card ‘sudo tar -xzf /home/user/alarm-olinuxino-rootfs.tar.gz’ to put down the root filesystem.
for login use
user:
password:
23. Copy the boot image in sdb1 device using dd, i.e. type – ‘sudo dd if=/home/user/imx233-Olinuxino.img of=/dev/sdb1
24. Type ‘cd’, ‘sync’ and umount sd card – ‘sudo umount /dev/sdb2’

At this point the SD card should be ready for use.

EDIT 09/07/2012: Kiril has updated the GitHub project page with completely instructions and pre-build images: https://github.com/OLIMEX/archlinuxarm-olinuxino

Now you can download and use full functional ARCH Linux ARM distribution

Building Debian Linux distribution for iMX233-OLinuXino

Image

iMX233-OLinuXino Debian rootfs generation

If you want to skip the procedures below, the good news is that we have already pre-build Debian rootfs and you can just download it from here: https://docs.google.com/open?id=0B-bAEPML8fwlOHJkX2ZNanVfR2s

and then just read how to make your bootable SD-card as described here: https://github.com/OLIMEX/OLINUXINO/tree/master/SOFTWARE/DEBIAN/README.TXT

Otherwise if you want to go through the learning path follow these instructions:

1. Prepare empty file system – it’s good to be > 500MB, in this example we make it 1GB

$ dd if=/dev/zero of=my.img bs=1024 count=1MB

2. Format the image with the desired root fs, in this example -ext3

$ sudo mkfs.ext3 -F my.img

3. Mount the image

$ mkdir rootfs
$ sudo mount -o loop my.img rootfs/

4. Install Debian toor file system phase 1

$ sudo debootstrap –verbose –arch armel –variant=minbase –foreign squeeze rootfs/http://ftp.debian.org/debian

5. Install the packages necessary for emulation of armel with x86.
Note: If you make installation of ‘Debian squeeze’ you must install newer version of ‘qemu-user-static’ (otherwise you will see error qemu: Unsupported syscall: 341 when you generate the image in phase 2)

Only for ‘Debian squeeze’

Add these lines in /etc/apt/preferences

Package: *
Pin: release a=stable
Pin-Priority: 900
Package: *
Pin: release o=Debian
Pin-Priority: -10

add in /etc/apt/apt.conf.d/70debconf

APT::Default-Release “stable”;

add in /etc/apt/sources.list

deb http://ftp.debian.org/debian/ testing main contrib

update the list of the packages

$ sudo apt-get update

install qemu-user-static

$ sudo apt-get install -t testing qemu-user-static

install binfmt-support

$ sudo apt-get install binfmt-support

6. Start of phase 2 (this is executed on virtual armel machine). Do these commands:

$ sudo modprobe binfmt_misc
$ sudo cp /usr/bin/qemu-arm-static rootfs/usr/bin
$ sudo mkdir rootfs/dev/pts
$ sudo mount -t devpts devpts rootfs/dev/pts
$ sudo mount -t proc proc rootfs/proc
$ sudo chroot rootfs/

(this is executed on virtual armel machine)
$ /debootstrap/debootstrap –second-stage

7. To add the apt repositories, you must append these lines in /etc/apt/sources.list

deb http://security.debian.org/ squeeze/updates main contrib non-free
deb-src http://security.debian.org/ squeeze/updates main contrib non-free
deb http://ftp.debian.org/debian/ squeeze main contrib non-free
deb-src http://ftp.debian.org/debian/ squeeze main contrib non-free

8. Update the list of the packages

$ apt-get update

9. Config your language

$ export LANG=C
$ apt-get install apt-utils dialog locales

$ dpkg-reconfigure locales
$ export LANG=en_US.UTF-8

10. Installation of some important packages

$ apt-get install dhcp3-client udev netbase ifupdown iproute openssh-server iputils-ping wget net-tools ntpdate nano less

11. Config your network adapter usb11 and dhcp. Add in /etc/network/interfaces these lines

# Wireless interfaces
iface wlan0 inet dhcp
wireless_mode managed
wireless_essid any
wpa-driver wext
wpa-conf /etc/wpa_supplicant.conf

auto usb0
iface usb0 inet dhcp

12. To config the file system add in /etc/fstab these lines:

/dev/root /dev/sda2 ext3 noatime,errors=remount-ro 0 1
tmpfs /tmp tmpfs defaults 0 0

13. To config the console

$ echo ‘T0:2345:respawn:/sbin/getty -L ttyAM0 115200 linux’ >> /etc/inittab
$ sed -i ‘s/^\([1-6]:.* tty[1-6]\)/#\1/’ /etc/inittab

13. To config the host name:

$ hostname <name>

14. To add root password

$ passwd

15. Exit from the armel virtual machine

$ exit

16. TO install the modules of Linux Kernel

$ sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- INSTALL_MOD_PATH=<path_to>/rootfs modules_install

17. and unfortunately this is only the beginning 🙂

in this image we still didn’t manage to enable the TV-console, so we will try to do it later

Stanimir Bonev, Olimex Ltd

EDIT 09/7/2012: there is improvement on how to install the peripherial modules on the Debian distro: http://tech.groups.yahoo.com/group/olinuxino/message/889