Difference between revisions of "Emdebian on APF"
m (→Finalisation) |
(→Work in progress) |
||
(8 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | Embedded systems in general and Armadeus boards in particular have reached a CPU power level that allow them to now run Dekstop equivalent Linux distributions. | ||
+ | The only remaining problem was the non volatile storage medium. Indeed most embedded systems come with less than 256MBytes of FLASH and so are unable to install a "normal" Linux distribution like debian for example. | ||
+ | Problem has recently been resolved by the Emdebian project which provide size optimized debian packages. Resulting rootfs is still far from compactness of Buildroot's generated one but start to be usable on the APF configurations. | ||
+ | |||
==Requirements== | ==Requirements== | ||
− | * An APF28 with its docking board | + | * An APF28 with its docking board, |
− | * A PC running a Debian stable distribution (it can be in a chroot) | + | * A PC running a Debian stable or Ubuntu distribution (it can be in a chroot), |
− | * A microSD card. | + | * A microSD card or a 128MBytes rootfs NAND partition (256 if you want a GUI). |
==Preamble== | ==Preamble== | ||
Line 79: | Line 83: | ||
* Create a config file for multistrap: | * Create a config file for multistrap: | ||
<pre class="host"> | <pre class="host"> | ||
− | apf28/ | + | apf28/$ sudo sh -c "cat > stable.config << EOF" |
[General] | [General] | ||
arch=armel | arch=armel | ||
Line 99: | Line 103: | ||
:If you have issues with the archive keyring you can either set 'noauth=true' or download this backport: | :If you have issues with the archive keyring you can either set 'noauth=true' or download this backport: | ||
<pre class="host"> | <pre class="host"> | ||
− | apf28/ | + | apf28/$ wget http://backports.debian.org/debian-backports/pool/main/m/multistrap/multistrap_2.1.15~bpo60+1_all.deb |
− | apf28/ | + | apf28/$ sudo dpkg -i multistrap_2.1.15~bpo60+1_all.deb |
</pre> | </pre> | ||
* Build: | * Build: | ||
Line 211: | Line 215: | ||
==Issues, tips, misc...== | ==Issues, tips, misc...== | ||
− | * Sometimes | + | * Sometimes U-Boot fails to load the kernel: |
<pre class="apf"> | <pre class="apf"> | ||
BIOS> run mmcboot | BIOS> run mmcboot | ||
Line 248: | Line 252: | ||
<pre class="apf"> | <pre class="apf"> | ||
BIOS> run nfsboot | BIOS> run nfsboot | ||
+ | </pre> | ||
+ | |||
+ | ==Work in progress== | ||
+ | * Add this lines in ''rootfs/first_boot.sh'' (to remount / in rw mode at first startup): | ||
+ | <pre class="host"> | ||
+ | ... | ||
+ | mount -n proc -t proc /proc | ||
+ | +mount -n -t sysfs none /sys | ||
+ | +mount -n -o remount,rw / | ||
+ | ... | ||
+ | </pre> | ||
+ | |||
+ | * Use NAND instead of microSD. Needs Armadeus toolchain installed ! | ||
+ | <pre class="host"> | ||
+ | $ export LEB_COUNT=2047 # on APF28 | ||
+ | $ export LEB_COUNT=135301 # on APF51 | ||
+ | $ export ARMADEUS_DIR=/home/xxx/armadeus-git | ||
+ | $ sudo $ARMADEUS_DIR/buildroot/output/host/usr/sbin/mkfs.ubifs -d rootfs -e 0x1f800 -c $LEB_COUNT -m 0x800 -x lzo -o apf-emdebian-rootfs.ubifs | ||
+ | $ cp $ARMADEUS_DIR/buildroot/fs/ubifs/ubinize.cfg . | ||
+ | $ echo "image=apf-emdebian-rootfs.ubifs" >> ubinize.cfg | ||
+ | $ sudo $ARMADEUS_DIR/buildroot/output/host/usr/sbin/ubinize -o apf-emdebian-rootfs.ubi -m 0x800 -p 0x20000 -s 512 ubinize.cfg | ||
+ | </pre> | ||
+ | <pre class="host"> | ||
+ | $ cp apf-emdebian-rootfs.ubi /tftpboot/ | ||
+ | </pre> | ||
+ | <pre class="apf"> | ||
+ | BIOS> setenv board_name apf-emdebian | ||
+ | BIOS> run update_rootfs | ||
+ | </pre> | ||
+ | |||
+ | * after installation and first boot, rootfs has to be remounted in rw to be usable: | ||
+ | <pre class="apf"> | ||
+ | root@apf51:~# mount -o remount,rw / | ||
</pre> | </pre> | ||
Latest revision as of 09:35, 21 January 2013
Embedded systems in general and Armadeus boards in particular have reached a CPU power level that allow them to now run Dekstop equivalent Linux distributions. The only remaining problem was the non volatile storage medium. Indeed most embedded systems come with less than 256MBytes of FLASH and so are unable to install a "normal" Linux distribution like debian for example. Problem has recently been resolved by the Emdebian project which provide size optimized debian packages. Resulting rootfs is still far from compactness of Buildroot's generated one but start to be usable on the APF configurations.
Contents
Requirements
- An APF28 with its docking board,
- A PC running a Debian stable or Ubuntu distribution (it can be in a chroot),
- A microSD card or a 128MBytes rootfs NAND partition (256 if you want a GUI).
Preamble
This page describes how to install an Emdebian stable distribution on APF28. Emdebian is mainly a Debian without documentation (manpages,etc...), so it can fit on smaller storage devices but providing the same functionalities. One of the goals in this procedure is to use the Armadeus tools as less as possible. So you won't need to change anything in u-boot configuration and buildroot will only be used to fetch and patch the kernel. The latter could have been avoided but doing this way facilitates the choice of the kernel (2.6.35.3 or a 3.x one) and ensures all the patches are applied.
Emdebian is a work in progress and the cross-toolchains in unstable are often broken so we'll stay here in the stable branches (both Emdebian and Debian).
This procedure has been written for an APF28 but should be easily adapted for another board.
Preparation
- To avoid possible ownership issues in the generated files without sudoing (I'm a bit lazy, I agree, but I doubt God keeps an eye on me...):
$ sudo su
- Working as root directly is a really *bad* idea, so I updated this tutorial accordingly --JulienB 21:26, 11 January 2013 (UTC)
- Add emdebian tools repository to your sources.list. We'll need it to install the cross-toolchain for kernel compilation:
$ sudo echo 'deb http://www.emdebian.org/debian/ stable main' >> /etc/apt/sources.list
- Install needed packages:
$ sudo apt-get update $ sudo apt-get install multistrap $ sudo apt-get install uboot-mkimage g++-4.4-arm-linux-gnueabi (if you plan to use pre-built toolchain)
- multistrap is the Emdebian tool that will fetch the packages and build the rootfs.
- uboot-mkimage will be needed to build the final uImage.
- g++-4.4-arm-linux-gnueabi dependencies will install the whole cross-toolchain. Thanks apt :)
- Create an ext2 partition on the SD card:
# mkfs.ext2 /dev/sdc1
Building the rootfs
- Let's create a directory:
$ mkdir apf $ cd apf
Kernel
- Get an Armadeus working tree and apply configuration:
apf/# git clone git://git.code.sf.net/p/armadeus/code armadeus apf/# cd armadeus armadeus/# make apf28_defconfig
- Customise things you want to.
- Apply Armadeus patches:
armadeus/# export KDIR=$PWD/buildroot/output/build/linux-2.6.35.3 armadeus/# make $KDIR/.stamp_downloaded $KDIR/.stamp_extracted $KDIR/.stamp_patched
- Adjust KDIR depending on the kernel you chose at the preceding step.
- Copy default configuration:
armadeus/# cp buildroot/target/device/armadeus/apf28/apf28-linux-2.6.35.3.config $KDIR/.config
- Configure and compile the kernel:
armadeus/# cd $KDIR linux-2.6.35.3/# mkdir modout linux-2.6.35.3/# make INSTALL_MOD_PATH=$KDIR/modout ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- menuconfig uImage modules modules_install
- menuconfig can be omitted if you're happy with the default kernel configuration.
Now we have a kernel at $KDIR/arch/arm/boot/uImage and the modules under $KDIR/modout. Let's build the rootfs.
Multistrap
Multistrap does basically quite the same things than 'debootstrap --foreign', fetching packages from an emdebian repository, building a root tree and leaving packages unconfigured.
- Get back to the base directory:
linux-2.6.35.3/# cd ../../../../ apf28/#
- Create a config file for multistrap:
apf28/$ sudo sh -c "cat > stable.config << EOF" [General] arch=armel directory=rootfs cleanup=true noauth=false unpack=true debootstrap=Grip aptsources=Grip [Grip] packages= keyring=emdebian-archive-keyring source=http://www.emdebian.org/grip suite=stable EOF
- 'packages=' is a space separated list of additional packages.
- If you have issues with the archive keyring you can either set 'noauth=true' or download this backport:
apf28/$ wget http://backports.debian.org/debian-backports/pool/main/m/multistrap/multistrap_2.1.15~bpo60+1_all.deb apf28/$ sudo dpkg -i multistrap_2.1.15~bpo60+1_all.deb
- Build:
apf28/$ sudo multistrap -f stable.config
- Copy the kernel and the modules:
apf28/# cp $KDIR/arch/arm/boot/uImage rootfs/boot/apf28-linux.bin apf28/# cp -r $KDIR/modout/lib rootfs/
- uImage is renamed to apf28-linux.bin so that u-boot can find it.
Finalisation
We're near the end.
- Set hostname:
apf/$ sudo sh -c "echo 'apf28' >> rootfs/etc/hostname"
- Avoid some warnings:
apf/$ sudo touch rootfs/etc/fstab
- Network configuration (address,netmask,etc...) will be inherited from u-boot, but we'll need these:
apf/$ sudo echo '127.0.0.1 localhost' >> rootfs/etc/hosts apf/$ sudo echo 'nameserver 192.168.0.1' >> rootfs/etc/resolv.conf
- Add emdebian repository on the target repository for future packages installation, when run on board :
apf28/$ sudo sh -c "echo 'deb http://www.emdebian.org/grip/ stable main' >> rootfs/etc/apt/sources.list"
- The very last step will occur onboard. Create a shell script to be executed at first boot:
apf28/$ sudo cat > rootfs/first_boot.sh << EOF #! /bin/sh set -e export PATH=/usr/sbin:/usr/bin:/sbin:/bin export DEBIAN_FRONTEND=noninteractive export DEBCONF_NONINTERACTIVE_SEEN=true export LC_ALL=C export LANGUAGE=C export LANG=C mount proc -t proc /proc # Workaround configuration of dash and bash failures # See http://lists.debian.org/debian-embedded/2011/11/msg00037.html mkdir -p /usr/share/man/man1 /var/lib/dpkg/info/dash.preinst # Configure packages dpkg --configure -a # Reset root password sed -i -e 's/root:\*:/root::/' /etc/shadow # Enable login through debug console echo 'T0:23:respawn:/sbin/getty -L ttyAM0 115200 vt100' >> /etc/inittab # Self delete rm $0 sync echo 'Done! You can reset the board.' while true; do echo '.\c' sleep 1 done EOF
Note: replace ttyAM0 with the correct console device of your board, eg ttyAMA0 for APF28 3.x kernels, ttymxc2 for APF51, ttySMX0 for APF27, etc... |
- Make it executable:
apf28/$ sudo chmod +x rootfs/first_boot.sh
- Copy the rootfs on the SD:
apf28/$ sudo mkdir /mnt/sd apf28/$ sudo mount /dev/sdc1 /mnt/sd apf28/$ sudo cp -rp rootfs/* /mnt/sd apf28/$ sudo umount /mnt/sd
- Put the SD card into its placeholder, poweron the base board and interrupt the automatic boot. We need to tell the kernel it must launch first_boot.sh:
BIOS> setenv extrabootargs init=/first_boot.sh BIOS> run mmcboot
- update-alternative will complain about missing manpages. It can be ignored.
This should end-up with something like that:
Done! You can reset the board. ......
So...reset the board. To boot on emdebian, just get u-boot prompt and type:
BIOS> run mmcboot
To have it permanent:
BIOS> setenv bootcmd run mmcboot BIOS> saveenv
Issues, tips, misc...
- Sometimes U-Boot fails to load the kernel:
BIOS> run mmcboot mmc0 is current device Loading file "/boot/apf28-linux.bin" from mmc device 0:1 (xxa1) MMC0: Data timeout with command 18 (status 0xe03c2020)! ** ext2fs_devread read error - block ** Unable to read "/boot/apf28-linux.bin" from mmc 0:1 ** ## Booting kernel from Legacy Image at 40000000 ... Image Name: Linux-2.6.35.3 Created: 2012-07-02 14:05:13 UTC Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 2714300 Bytes = 2.6 MiB Load Address: 40008000 Entry Point: 40008000 Verifying Checksum ... Bad Data CRC ERROR: can't get kernel image!
Powering off/on (not just reset) solves the problem. I'm unable to say what is faulty, u-boot, hardware, other...?
- you can also boot embdebian through your network NFS shared connection:
Copy the rootfs on your share NFS folder:
apf28/# mkdir -p /tftpboot/apf28-root apf28/# cp -rp rootfs/* /tftpboot/apf28-root
For the first boot use
BIOS> setenv extrabootargs init=/first_boot.sh BIOS> run nfsboot
then after having succesfully deployed the embedebian distro:
BIOS> run nfsboot
Work in progress
- Add this lines in rootfs/first_boot.sh (to remount / in rw mode at first startup):
... mount -n proc -t proc /proc +mount -n -t sysfs none /sys +mount -n -o remount,rw / ...
- Use NAND instead of microSD. Needs Armadeus toolchain installed !
$ export LEB_COUNT=2047 # on APF28 $ export LEB_COUNT=135301 # on APF51 $ export ARMADEUS_DIR=/home/xxx/armadeus-git $ sudo $ARMADEUS_DIR/buildroot/output/host/usr/sbin/mkfs.ubifs -d rootfs -e 0x1f800 -c $LEB_COUNT -m 0x800 -x lzo -o apf-emdebian-rootfs.ubifs $ cp $ARMADEUS_DIR/buildroot/fs/ubifs/ubinize.cfg . $ echo "image=apf-emdebian-rootfs.ubifs" >> ubinize.cfg $ sudo $ARMADEUS_DIR/buildroot/output/host/usr/sbin/ubinize -o apf-emdebian-rootfs.ubi -m 0x800 -p 0x20000 -s 512 ubinize.cfg
$ cp apf-emdebian-rootfs.ubi /tftpboot/
BIOS> setenv board_name apf-emdebian BIOS> run update_rootfs
- after installation and first boot, rootfs has to be remounted in rw to be usable:
root@apf51:~# mount -o remount,rw /