Running Linux from an SD card
Contents |
Introduction
As described in the Introduction to firmware page, the Pandora is able to boot from an SD card. This tutorial explains the steps necessary to create an SD card with a copy of the Angstrom operating system which you can boot. If you do not want to run these steps manually, there also exists a utility (as a standard PND package) which can guide you through that process: Pandora SD installer
| Note: This tutorial assumes you are using Linux, and gives examples which should run on your Pandora. } |
Get a copy of the firmware
There are methods you can use to get the data off your Pandora's NAND, this topic discusses them. It is easier, however, to just extract a tar file.
- Take a look here (pandora-rootfs.tar.bz2 is what you want) and get the latest version from the official Open Pandora site. Note that this firmware version may be unstable and comes untested!
- Download this old reference image if you are having trouble with the first link.
- If the two above don't work, you can download an even older image.
- You can also copy your running firmware on the NAND to the SD partition. This is shown in its own section below.
Option 1: Use the GUI-driven SD installer tool
Instead of installing the firmware manually on the SD card (as described further below under "Option 2"), you may use the GUI-driven tool sd_installer.pnd by David Boucher, which automates the entire process. http://repo.openpandora.org/?page=detail&app=sd-install-2011-03-10
You only need the downloaded firmware tarball, the sd_installer.pnd and a suitable SD card.
Option 2: Manually install the OS on the SD card
Partition your SD card
This is an optional step.
If you want to slice your SD card into several partitions (see Setting up mutliple-partition SD cards), you can use the cfdisk command-line tool on the Pandora to create a partition table. Note that - as of Zaxxon HF5 - the Pandora firmware doesn't have a command to format FAT partitions, so if you want to use the FAT/ext2/swap - scheme, you'll have to format the first partition on another system later on (under Windows, use the Disk Management tool).
Assuming your card is in the left slot:
sudo cfdisk -z /dev/mmcblk0
WARNING: mmcblk0 will not necessarily be the left slot. It's the first card that the system recognizes, which is usually the left slot (but not if you inserted an SD into the left slot after you had one in the right slot, for example). Please make sure before you do anything dangerous.
cfdisk -z starts off with a clean partition table - if you want to see what's set up currently, use cfdisk /dev/mmcblk0.
Use only primary partitions (so you're limited to four slices).
Format SD card to ext2
You need to format your SD card to have a single ext2 partition; ext3 also works[1] and is more reliable[2]. You can have a second, swap partition, as well if you like. There are command line tools you can use as well as GUI tools.
Using the command line
Take care with using these command line tools, to be certain you are accessing the correct device. They will not ask you and will DESTROY any data on the device. This command will replace an existing partition with an empty EXT2 formatted filesystem (this includes the single FAT partition most SD cards come shipped with). Assuming /dev/mmcblk0p1 for your SD device (left slot, first partition), LABELNAME for the partition:
mkfs.ext2 -L LABELNAME /dev/mmcblk0p1
If you run into problems with formatting the SD card, try unmounting it first:
sudo umount /media/[LABELNAME of SD card]
Using a GUI tool
The GUI tools are simple enough that you shouldn't need someone to tell you how to use them. For now this is left as an exercise left for the reader (until someone wants to write up how to do it).
Copy and boot
Copy the files to your SD card
Navigate (cd) to the directory with the .tar.bz2 file you just downloaded (or made) and do:
sudo tar -xvjf <tarfile>.tar.bz2 -C <SD card>
If you're doing this on your Pandora, <SD card> is something like /media/mmcblk0p1 (first SD card slot on Pandora). On Ubuntu it would be something like /media/disk if it has no label. You can also try using GUI tools for this, but I didn't have very good luck with them.
OR copy your firmware from the NAND to the SD card
The following will ask for your password. All the operations need root permissions so I thought it would be wasteful to sprinkle sudo to everything. We will bind mount the root fs to an alternative location ("/mp"), under which other filesystems mounted under root (like the kernel virtual filesystems /proc and /sys, and your SD card.) wont be visible. This allows us to take a live copy of the NAND contents to the SD filesystem.
sudo su mkdir /mp mount --bind / /mp cp -va /mp/* /media/<SD card> umount /mp rmdir /mp exit
Set up your boot.txt
Create a new file called boot.txt (or autoboot.txt if you want to boot automatically) and copy and paste the text below. Copy that file to the root of the root of the SD card.
| If you edit the file on Windows, use an advanced text editor like Notepad++ and be sure to convert to UNIX format (in NP++: Edit -> EOL Conversion -> UNIX format). If you have DOS linebreaks, ext2load will fail with an error like "file not found" as it appends an hidden character to the uImage file name. |
boot.txt (from the official firmware site)
setenv bootargs debug root=/dev/mmcblk0p1 rw rootdelay=2 console=ttyS0,115200n8 vram=6272K omapfb.vram=0:3000K ext2load mmc 0 0x80300000 /boot/uImage-2.6.27.46-omap1 bootm 0x80300000
Note: As of Hotfix 5, your boot.txt should look like this (the uImage name has changed):
setenv bootargs debug root=/dev/mmcblk0p1 rw rootdelay=2 console=ttyS0,115200n8 vram=6272K omapfb.vram=0:3000K ext2load mmc 0 0x80300000 /boot/uImage bootm 0x80300000
Be aware though that this boot.txt assumes you have formatted your card with ext2 and loads the kernel off the SD card. If you don't want to boot from an ext2 formatted SD card, use following boot.txt
setenv bootargs root=/dev/mmcblk0p1 rw rootdelay=2 vram=6272K omapfs.vram=0:3000K ubi part boot && ubifsmount boot && ubifsload ${loadaddr}|> uImage && bootm ${loadaddr}|> && boot
Which will then tell the boot loader to look for the kernel on the internal NAND memory (note this is untested).
Both boot.txt's assume you are booting from the left SD card slot, first partition. You can change "mmcblk0p1" to "mmcblk1p1" if you want to boot from the right slot.
Setting up mutliple-partition SD cards for booting
It is possible to have several partitions on the SD card and boot from one of them. E.g. if you have three partitions on the card like this:
- Partition 1: FAT
- Partition 2: ext2 (where the rootfs should be placed)
- Partition 3: swap
You put the (auto)boot.txt file into the root of the first partition and point U-Boot to the correct locations to boot your system from the second partition. This is done by the "root" parameter of setenv to set the location of the rootfs and by the "mmc x:x" parameter of ext2load. For the above example you would need an (auto)boot.txt in the root of the FAT partition (thus it is easily editable using a Windows / Mac computer) similar to this one:
setenv bootargs debug root=/dev/mmcblk0p2 rw rootdelay=2 console=ttyS0,115200n8 vram=6272K omapfb.vram=0:3000K ext2load mmc 0:2 0x80300000 /boot/uImage bootm 0x80300000
Note: slot numbering begins at 0 (0 is left SD slot, 1 is right SD slot) and partition numbering begins at 1!
You could probably as well place the kernel (uImage) on the FAT partition's root and use the command "fatload" instead of "ext2load" to boot it like this (this is untested!):
fatload mmc 0:1 0x80300000 uimage
Boot the system
As you power up the Pandora, hold the shoulder button R. A menu should appear, allowing you to boot from the SD card. (this step isn't necessary if you chose to create an autoboot.txt instead of boot.txt). Remember that this will be an un-configured image, taking a little while longer to boot, and giving the first-run dialogue.
Access the NAND
Once you're booted into the system from SD, you may want access to the NAND rootfs. The following will let you do that.
sudo mkdir /mnt/nand sudo ubiattach /dev/ubi_ctrl -m 4 sudo mount -t ubifs ubi0:rootfs /mnt/nand
Other information
An alternative approach to using an SD card to increase the space accessible to the system is OS Extend. This allows the root filesystem to exist on more than one physical device.