User:SDGathman

From OLPC
Revision as of 11:18, 22 November 2010 by SDGathman (talk | contribs) (Installing on SDHC)
Jump to: navigation, search

Hi! My dad bought an XO-1 via G1G1 for my daughter for Christmas. She has outgrown it, but now I use it with a USB keyboard and mouse. It has been very fun configuring a full F11 desktop to run in 256M, booting from an 8G SDHC. The process has provided the excuse to try a number of alternative applications due to lower memory requirements. Ekiga, Pidgin, terminal, firefox, claws-mail, all work beautifully. I've spent many work hours outdoors in the sun (ok, shade - I don't like sunburn) with an easily read screen. I'm waiting for a netbook with Pixel Qi display and adult keyboard. I want a foot treadle generator (easily used while seated) to charge my XO/netbook while working.

You can read more about me here:

http://gathman.org/vitae/

Running XO-1 from an SDHC Card

Version 852 of the OLPC software is a wonderful release. You can switch between sugar and Gnome desktop, and it tracks Fedora 11. However, there is hardly any room left on the 1G flash to actually use it. Back in the Fedora 9 based releases, I tried to run from an SDHC card, but a driver bug trashed the card by removing power without the proper protocol on a suspend (at least, that is what I gathered from the discussions). I was ready to try again, this time with an 8G Adata turbo SDHC.

To boot from SDHC, you need a developer key, a system image, and the SDHC card. I partitioned the card into 2 partitions. The first partition must be the root filesystem (the firmware looks there for the boot code - it could be /boot if you did some hacking). I use the second partition for swap.

Both ext3 and swap read and write the card in 8 sector (4k) blocks. Since flash drives often have 4k write blocks internally, I thought it wise to align both partitions on a 4 byte boundary:

# fdisk -H224 -S56 /dev/mmcblk0

This aligns partition 1 on a 4k boundary, and as a bonus, the swap partition is aligned on a 128k erase block boundary (in case that makes a difference). The Adata turbo claims 6Mbyte/sec write speed. I have observed peak write speeds of 5.9M, so it doesn’t seem to hurt at least. The default partition table that came on the card had 63 sectors per track (no alignment with write or erase blocks), so it may not matter. I reserved about 300M for swap:

 Disk /dev/mmcblk0: 245696 cylinders, 4 heads, 16 sectors/track
 Warning: The partition table looks like it was made
   for C/H/S=*/224/56 (instead of 245696/4/16).
 For this listing I’ll assume that geometry.
 Units = cylinders of 6422528 bytes, blocks of 1024 bytes, counting from 0
    Device Boot Start     End   #cyls    #blocks   Id  System
 /dev/mmcblk0p1          0+   1199    1200-   7526372   83  Linux
 /dev/mmcblk0p2       1200    1252      53     332416   83  Linux
 /dev/mmcblk0p3          0       -       0          0    0  Empty
 /dev/mmcblk0p4          0       -       0          0    0  Empty


http://www.usenix.org/event/fast10/tech/full_papers/boboila.pdf

There were two system images available with the 852 release, os852.img and os852.fs.tree.lzma. Both of these have the same files. os852.img is a jffs2 filesystem image, and os852.fs.tree.lzma is a tar archive compressed with lzma. I had trouble extracting the tar archive because tar on the XO-1 did not create invalid symlinks - and the absolute symlinks were of course all invalid. It turned out to be easy to use the jffs2 image instead thanks to the block2mtd driver (not included on the XO-1). After partitioning, I created

 # mke2fs -i 8192 -LOLPCRoot /dev/mmcblk0p1
 # mkswap /dev/mmcblk0p2

The OLPCRoot label is required, the boot code looks for it. On another PC, I downloaded os852.img, and then mounted it:

 # losetup /dev/loop0 os852.img
 # modprobe block2mtd block2mtd=/dev/loop0,131072
 # mkdir /mnt/olpc
 # mount -t jffs2 -r /dev/mtdblock0 /mnt/olpc

The 131072 is the 128k erase block size of the on board flash.

Now, on the olpc, I could rsync the files:

 # mkdir /mnt/f11
 # mount /dev/mmcblk0p1 /mnt/f11
 # rsync -ravH bigpc:/mnt/olpc/ /mnt/f11

I had to edit /mnt/f11/boot/olpc.fth to add rootwait:

    “ root=LABEL=OLPCRoot rootfstype=ext3 rootwait”

This waits for SDHC to initialize before attempting to mount it. You could also change the filesystem label here (and relabel the filesystem) if you wanted.

I also copied my developer key to /mnt/f11/security (optional, but allows escaping to firmware).

Then I unmounted and added the journal.

 # umount /mnt/f11
 # tune2fs -j /dev/mmcblk0p1

A reboot, and the sugar desktop came up! Sugar now has an option to switch to the Gnome desktop. I switched to Gnome.

To update with yum, I needed to enable swap, and expand /var/cache/yum. After opening a terminal:

 # swapon /dev/mmcblk0p2
 # mount -o remount,size=256M /var/cache/yum
 # yum update

I edited /etc/fstab to make swap permanent. The writes to swap are small compared to filesystem writes (except during yum update), so it wasn’t worth it to add swap manually when needed. You could get a little better performance by using a USB flash key for swap, since they would both write in parallel.

With 7.3G available, I was able to install lots of additional software, like xmms, pidgin, claws-mail, openvpn, vim-X11, vim-enhanced, gkrellm, ekiga, tigervnc. With swap enabled, I can browse the web, read email, talk on VOIP, use another desktop via VNC, chat on IM, listen to music, all simultaneously. Flash content is unusable,but javascript is fine. Thunderbird is too big (haven’t actually tried it, however), but claws-mail works great. To watch youtube, use http://tinyogg.com (HD overwhelms CPU, but standard content consumes only about 60%). The bottom line, is that 433Mhz is plenty for most tasks, barring inefficient code.