| Version 11 (modified by divx118, 2 years ago) |
|---|
Building a Debian rootfs for gen8
Some general info:
This guide will probably work for other distros. You will need to install SDE angstrom which can be retained from archos and atleast booted angstrom one time. To get me started I used some guidelines from http://www.dev.katlea-studio.com/. To make this guide complete I am using some copy/paste from his guide. I am running Ubuntu 10.04 so commands or dependencies that need to be installed are based on that. Also note that I own an A101IT so all the tests are done on that. I am using qemu with a virtual machine to install the distro. I know it isn't perfect, but it is a very easy way to get started.
1) Creating a work directory
We need a place on or host PC where we can get our work done. I am using /usr/src/debian. First make the dir and then make run the chown command so you get full read/write access as normal user. If it isn't stated otherwise in this guide I assume you run the commands that are mentioned in this directory.
$ sudo mkdir /usr/src/debian $ sudo chown <your login> /usr/src/debian $ cd /usr/src/debian
2) Installing Qemu on your host PC
$ sudo apt-get install qemu $ sudo apt-get install qemu-kvm-extras
3) Create an image disk to use with qemu
First we will have to create an image disk where we can later install debian on. The command below will create a 2 Gb image which will be enough for debian with lxde desktop. If you want a bigger image just adjust the count accordingly. For example making a 3Gb image use count=3072. This is however not so important right now, you can also do it later when we make the final rootfs.img that we put on the archos. The only thing you have to think about is that your image will be large enough for your emulator and the things you want to install to get an initial image to get it working on the archos.
$ dd if=/dev/zero of=debianlxde.img bs=1M count=2048
We don't need to format the image, this will be done by the debian installer.
4) Download boot image and kernel for your virtual machine
You can find the following kernel (vmlinuz-2.6.32-5-versatile) and initrd (initrd.img-2.6.32-5-versatile) on http://people.debian.org/~aurel32/qemu/armel/
$ wget http://people.debian.org/~aurel32/qemu/armel/initrd.img-2.6.32-5-versatile $ wget http://people.debian.org/~aurel32/qemu/armel/vmlinuz-2.6.32-5-versatile
Then we also need the net installer from debian (initrd.gz). http://ftp.de.debian.org/debian/dists/squeeze/main/installer-armel/current/images/versatile/netboot/
$ wget http://ftp.de.debian.org/debian/dists/squeeze/main/installer-armel/current/images/versatile/netboot/initrd.gz
5) Installing debian on our debianlxde.img
Now we are going to install debian on our earlier created debianlxde.img. Like mentioned above we are using the net installer, so you should be connected through the internet.
$ sudo qemu-system-arm -M versatilepb -kernel ./vmlinuz-2.6.32-5-versatile -initrd ./initrd.gz -hda ./debianlxde.img -m 256 -append "root=/dev/ram"
Before you will open a window in which will appear the debian net installer. Follow the onscreen instructions and install debian. The installer is idiot proof :) so if in doubt use the default option. Important is that you make a note of your username, password and the root password you use. In my case I used the following:
user: debian password: debian root password: debianroot
This all will take some time, so please be patient. When the installer is completed it will reboot in the emulator, that is the moment you can close your qemu window and move on to the next step.
6) Installing the GUI and some basic apps
We now start qemu with the normal initrd.
$ sudo qemu-system-arm -M versatilepb -kernel ./vmlinuz-2.6.32-5-versatile -initrd ./initrd.img-2.6.32-5-versatile -hda ./debianlxde.img -m 256 -append "root=/dev/sda1 m=256M"
Qemu will start again and now with a debian command prompt. Login with the credentials you used in the installer, in my case user debian with password debian. Get root to install a GUI.
$ su
Enter your root password, in my case it was debianroot. Update the installer and install the lxde GUI.
$ aptitude update $ aptitude install lxde
Please note this will take some time to complete, so again be patient.
After that I installed the following apps that I think are usefull in a first startup. ssh server, onscreen keyboard, battery moonitor and the network manager wicd.
$ aptitude install openssh-server $ aptitude install matchbox-keyboard-im $ aptitude install xbattbar $ aptitude install wicd $ shutdown now
I don't recommend installing more apps, because that can also easily be done on your archos. After the shutdown now debian will shutdown and you can close the qemu window.
7) Adjusting the debianlxde.img
Because we installed debian with a different kernel then we have on our archos to run angstrom we need to adjust the image a bit. Before we can modify the image we have to mount it to a directory so we can access the files. We also need some old files from the angstrom image so we need to mount that to.
First we create two directories so we can mount the images in them.
$ mkdir ./debianlxde $ mkdir ./angstrom
Connect shutdown your archos and connect it to your PC. Start it up in recovery by holding the minus button and shortly press the power button. Keep the minus button presses until the white recovery screen appears. Go to recovery --> repair system and then start USB.MSC The A101IT mounts under /media/A101IT on ubuntu. Change this path to what yours needs to be in the following commands.
Because we are going to replace the rootfs.img from angstrom, we will rename it first so we don't overwrite it in the next steps.
$ mv /media/A101IT/rootfs.img /media/A101IT/rootfs.angstrom
Now we mount the image to our directory.
$ sudo mount -o loop /media/A101IT/rootfs.angstrom ./angstrom
We also have to mount our debianlxde.img, but that is a bit more work, because the net installer in debian creates also a swap partition in the image file. So we need to determine wich partition we need to mount in the image. I found a nice tutorial for this here http://www.andremiller.net/content/mounting-hard-disk-image-including-partitions-using-linux
$ parted ./debianlxde.img
and we get the following
parted debian_2G_first.img WARNING: You are not superuser. Watch out for permissions. Warning: Unable to open /usr/src/debian/debianlxde.img read-write (Permission denied). /usr/src/debian/debianlxde.img has been opened read-only. Warning: Unable to open /usr/src/debian/debianlxde.img read-write (Permission denied). /usr/src/debian/debianlxde.img has been opened read-only. GNU Parted 2.2 Using /usr/src/debian/debianlxde.img Welcome to GNU Parted! Type 'help' to view a list of commands. (parted)
Now type the following at the prompt "unit" --> "B" --> "print" and the last "quit" to exit parted. You should see something like this
Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) unit Unit? [compact]? B (parted) print Model: (file) Disk /usr/src/android/debian_2G_first.img: 2147483648B Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 1048576B 2003828735B 2002780160B primary ext3 boot 2 2004876288B 2146435071B 141558784B extended 5 2004877312B 2146435071B 141557760B logical linux-swap(v1) (parted) quit
The biggest is the ext3 partition and that is the one that we want. Notice the start offset "1048576B" which we need to declare in the mount loop command. To mount the debianlxde.img we do the following
$ sudo mount -o loop,offset=1048576B ./debianlxde.img ./debianlxde
8) Making the final image file
Like we did before
$ dd if=/dev/zero of=debianlxdefinal.img bs=1M count=2048
But now we have to format the image to ext3
mkfs.ext3 -F debianlxdefinal.img
Make a directory to mount and mount it
mkdir ./debianlxdefinal sudo mount -o loop ./debianlxdefinal.img ./debianlxdefinal
Copy all the files from the mounted debianlxde.img to the new debianlxdefinal.img
$ sudo cp -rp ./debianlxde/* ./debianlxdefinal
Copy over some files we need from angstrom use -p option to preserve attributes.
$ sudo cp -p ./angstrom/boot/* ./debianlxdefinal/boot $ sudo cp -rp ./angstrom/lib/modules/2.6.29-omap1 ./debianlxdefinal/lib/modules
9) Getting the wifi driver to work and load at startup
Well I assume you have build your driver according to Generation 8 specific developer resources, but we will also need tiwlan_loader to load the firmware, ini file and calibration file. I compiled that from http://omappedia.com/index.php?title=Wilink_Linux&redirect=no If someone knows a way to build it from archos sources please add the info to the wiki. The firmware.bin is obtainable from TI.
We are going to add a folder in the root of the rootfs where we will copy our needed files for the wlan. To succesfully load the firmware we will also need the tiwlan.ini and wlanconf.nvs (calibration file). However we will use a shortcut and copy them over from archos android on startup. We could do that for the rest of the files too, but it is more fun building stuff yourself :). Assuming your files are in the work directory (in my case /usr/src/debian), we will do the following.
$ sudo mkdir ./debianlxdefinal/wifi $ sudo cp ./firmware.bin ./debianlxdefinal/wifi $ sudo cp ./tiwlan_loader ./debianlxdefinal/wifi $ sudo cp ./tiwlan_drv.ko ./debianlxdefinal/wifi
The wifi can then be loaded on your device as follows. Following command is to run on the archos booted in debian
$ sudo cp /media/data/misc/wifi/tiwlan.ini /wifi $ sudo cp /media/data/misc/wifi/wlanconf.nvs /wifi $ sudo insmod /wifi/tiwlan_drv.ko $ sudo /wifi/tiwlan_loader -i /wifi/tiwlan.ini -f /wifi/firmware.bin -e /wifi/wlanconf.nvs
But we will make a startup script for that later, because we are not done yet with our rootfs.img (debianlxdefinal.img).
10) Battery monitor
I have chosen for xbattbar monitor, because you can make a script for it to pass the right values to xbattbar. I made the following little script xbattbar.sh to read the values.
#!/bin/sh # # xbattbar.sh # # This script will get the right values for the battery status and send it to xbattbar # xbattbar should be started as follows to use this script: # xbattbar -a -t 6 -s /usr/bin/xbattbar.sh # -a means always on top -t <#> specifies the thickness of the bar ACONLINE="off" AC=$(cat /sys/class/power_supply/ac/online) #echo "ac = $ac" if [ $AC = "1" ]; then ACONLINE="on" fi BAT=$(cat /sys/class/power_supply/battery/capacity) echo "battery=$BAT" echo "ac_line=$ACONLINE"
We copy this script to /usr/bin in the debianlxdefinal.img
$ sudo cp ./xbattbar.sh ./debianlxdefinal/usr/bin
Then we also make sure it starts automaticly when X is started so we will make a file named "xbattbar.desktop" with the following inside.
[Desktop Entry] Encoding=UTF-8 Name= Xbattbar Comment=run battery monitor xbattbar Exec=xbattbar -a -t 6 -s /usr/bin/xbattbar.sh
Then we copy this file to /home/debian/.config/autostart assuming your username is debian else you have to replace it with the username you used.
sudo cp ./xbattbar.desktop ./debianlxde/home/debian/.config/autostart
We have one problem with this, because capacity values aren't updated in /sys/class/power_supply/battery/capacity on debian. We need to run the batteryd from archos android to do that, more on this when we get to the startup script.
11) Enable autologin
Because I have my USB host port broken on my A101IT and I haven't figured out how to start the onscreen keyboard at the login screen yet. I am using for now automatic login. To enable that we copy /usr/share/defaults.conf to /etc/gdm/gdm.conf and edit that file.
$ sudo cp ./debianlxdefinal/gdm/defaults.conf ./debianlxdefinal/etc/gdm/gdm.conf $ sudo gedit ./debianlxdefinal/etc/gdm/gdm.conf
Now we change at line 48 AutomaticLoginEnable?=false to AutomaticLoginEnable?=true and at line 49 we fill in our username, in my case debian.
gdm.conf
... [daemon] # Automatic login, if true the first attached screen will automatically logged # in as user as set with AutomaticLogin key. AutomaticLoginEnable=true AutomaticLogin=debian ...
More to come...

