分类: LINUX
2011-08-08 01:28:49
Here's one way to make a Debian root filesystem for the Sim.One.
I prepare the root filesystem on some fast host, then transfer it to the Sim.One to complete the installation.
Create the base system on some other computerPrepare the mediaHere, I'm using a USB pendrive, whose single partition appears as /dev/sda1; If you use an SD card, it'll be /dev/mmcblk0p1 instead. Although the final filesystem is under 128MB, you'll need a 256MB device to be able to create it.
mkfs -t ext2 -b 1024 -m 0 /dev/sda1Don't periodically check already-clean volumes because it is time-consuming
tune2fs -c 0 -i 0 /dev/sda1Make the new medium visible on your host computer
mkdir /mnt/sda1Dump an initial filesystem onto the medium, up to the point where you need to run native programs on a real ARM processor
debootstrap --arch armel --foreign squeeze /mnt/sda1 http://ftp.debian.org/debianChange directory into the new root filesystem
cd /mnt/sda1Zap some configurations that were copied from the host system
echo simone > etc/hostnameCreate missing devices in the static /dev
mknod dev/ttyAM0 c 204 16Install the kernel modules into the root filesystem. If you have compiled your own kernel you can use:
cd ~/linux-simone/linux-2.6.36or if you downloaded the kernel image you should fetch its modules tarball and unpack it into the Debian root filesystem:
cdIf you don't need the modules, you will at least need to cd out of /mnt/sda1 so that you can unmount it.
Now unmount the storage and wait for the prompt to return before unplugging it
umount /mnt/sda1Complete the installation on the Sim.OneBoot the base systemNow move the pendrive to one of the Sim.One's USB sockets and boot it into a single-user shell, talking to it over the serial port at 57600 baud.
The following settings are for a USB pendrive. If your root filesystem is on an SD card, use root=/dev/mmcblk0p1 instead.
First load a Debian EABI kernel. Here is my setup to fetch it from a file called "uImage" on a tftp server:
SIM.ONE> set ipaddr 10.0.0.51alternatively, you can write the image to flash memory:
SIM.ONE> set ipaddr 10.0.0.51Just this once, we want it to boot into a single-user shell:
SIM.ONE> set bootargs console=ttyAM0 root=/dev/sda1 rootwait mmc_core.use_spi_crc=0 init=/bin/shWhen you get the shell prompt on the Sim.One, set up the environment and install the core packages. On an SD card, this step takes just under an hour. On USB pendrive under half an hour. It's time to take a break!
debootstrap/debootstrap --second-stageThis is the point at which maximum filespace is used: 218428 KB.
If, during this step, you get I/O errors from the USB storage or "USB disconnect" messages on the console, it may be that you are using Sim.One hardware before v1.4 and have not set it to access the RAM in 16-bit mode. Fetch u-boot-*-16bit.bin from the Downloads page
wget http://sim1.googlecode.com/files/u-boot-1.1.6-simone-20091201-16bit.binand program it with the "download" utility as described on the wiki page at the section "EP9307 loader" -> "Programming the U-Boot loader into Flash".
Clean up after debootstrapapt-get cleanSet the dateIf the real-time clock is not set correctly, you might like to do so now. Here we set it to 12:45 on the 1st March 2011
date 030112452011Create kernel module indicesIf you installed the modules (above) from your own kernel compilation, you will need to build the module index files before kernel module loading will work. The module tarballs should have had this step performed already, but you can do it anyway to make sure; it takes about 4 minutes.
depmod -aCreate basic configurationsFilesystem mount table
cat > etc/fstab << \EOFArrange for a login shell to be started on the serial port
cat >> /etc/inittab << \EOFand allow root logins on it
echo ttyAM0 >> /etc/securettyIf this filesystem is for personal use, you probably want to set a root password at this point.
passwdFor the distribution instead, we clear the root password
passwd -d rootArrange for the audio modules to be loaded at system startup
echo snd-soc-simone >> /etc/modulesConfigure the network to set up the loopback interface and to have the ethernet auto-configure with DHCP
cat >> /etc/network/interfaces << \EOFRemove a bogus directory that was created during the installation of udev
rm -r /dev/.udevNow boot into the proper system
exec /sbin/initand log in as root
simone login: rootSet up the software package management system. You might prefer to use a local mirror such as ftp.it.debian.org - see for a complete list - and for the latest in multimedia you might also like to add deb squeeze main
cat > /etc/apt/sources.list << \EOFAdding these package lists makes a new high-water mark for filesystem size of 229519KB.
Save spaceInstall localepurge to save 30 MB of multi-language message translations. Press Enter at "Do you want to continue?" and go ahead with "No locales" when it asks: Tab Enter Tab Enter.
apt-get install localepurge # Filesystem size -> 246360KBRemove downloaded copies of packages (again!)
apt-get cleanIf you like, you can remove the documentation, leaving the directory structure so that future apt-get install operations won't fail due to missing directories. I don't do this in the standard distribution.
find /usr/share/man ! -type d -print0 | xargs -0 rmRemove pointless backups, log files and temporary files
rm /usr/share/info/dir.oldIf you're making a system to distribute, you can also remove the downloaded package lists
rm /var/cache/apt/* /var/lib/apt/lists/*All done. Close down and celebrate.
haltThe final size of the filesystem without the package lists is 109330 Kbytes. Removing the documentation leaves about 70MB.