(→Syncing the full image to the SD card) |
(→Syncing the full image to the SD card) |
||
| Line 67: | Line 67: | ||
You want to perform the following on the device itself, not to any of the partitions on it: | You want to perform the following on the device itself, not to any of the partitions on it: | ||
| - | dd if=${ | + | dd if=${IMAGE}-${STAMP}-mrstnand/${IMAGE}-${STAMP}-sda.bin of=/dev/sdb bs=10M |
The above will take a while. Go get coffee. Once it has completed, you can eject the SD card and boot your Aava device to the new image. | The above will take a while. Go get coffee. Once it has completed, you can eject the SD card and boot your Aava device to the new image. | ||
These are some of the notes that we keep and use to make our development easier at Intel. Feel free to edit/modify/correct as needed.
Contents |
You can find which build image you may want by navigating to the MeeGo Build Download page. The build image is consistently named with a sequential magic build number stamped in the middle.
For example, in meego-handset-ia32-aava-mtf-1.0.80.13.20100803.2-mrstnand.tar.bz2, 1.0.80.13.20100803.2 is the build number. To simplify the commands later, we export that value, and the base image name, to two environment variables. We are doing some wget/sed trickery to automatically grab the most recent image produced. You can hardcode to a specific version by changing STAMP to point to a specific version.
export IMAGE=meego-handset-ia32-aava-mtf export STAMP=$(wget -qO - http://repo.meego.com/MeeGo/builds/trunk/ | sed -ne 's,^.*<a href="\(1\.0\.80\.[^/]*\).*$,\1,p' | tail -n 1) echo "Found stamp: ${STAMP}"
You can then perform the following:
cd wget http://repo.meego.com/MeeGo/builds/trunk/${STAMP}/handset/images/${IMAGE}/${IMAGE}-${STAMP}-mrstnand.tar.bz2 tar xvf ${IMAGE}-${STAMP}-mrstnand.tar.bz2
The above will create a directory called ${IMAGE}-${STAMP}-mrstnand which contains the filesystem that will eventually end up on the SD card.
Its easiest to work with the image file system on a development system, and then write to the SD card.
Due to how some of the images are created, the start sector is non-deterministic and must be calculated for each image created.
cd
VALUE=($(echo -ne "u b\np\nq\n" | parted ${IMAGE}-${STAMP}-mrstnand/${IMAGE}-${STAMP}-sda.bin | grep ext3\$))
OFFSET=${VALUE[1]/B}
The following snippet will mount the image to the aava-image directory, unmounting that directory if it already exists and is mounted, or creating it if it doesn't yet exist.
[ ! -e aava-image ] && mkdir aava-image || { mount | grep -q aava-image && sudo umount aava-image ; }
sudo mount -o loop,offset=${OFFSET} ${IMAGE}-${STAMP}-mrstnand/${IMAGE}-${STAMP}-sda.bin aava-image
You will now have the Aava image mounted on your local filesystem under the directory aava-image.
sudo mic-chroot aava-image
At this point you are now chroot'd into the MeeGo image, and you can install / modify the image as you want.
NOTE: Make sure you exit the chroot environment before you try and rsync or dd the updated image to your SD card. Failure to do so may result in an incomplete transfer occurring and an unusable MeeGo OS image.
NOTE: If yum doesn't exist (some images had zypper installed instead of yum) then you first need to install yum:
zypper install yum
You can then use yum to install new packages
yum install rsync nano perf openssh-server screen gdb abrt{,-plugin-{logger,ccpp}} yum-utils strace
Once booted, if you ssh into the MeeGo system the ssh'd user won't have access to the DBus session, or various environment variables configured within the X environment. To work around this, you can launch a screen session from within X.
Install an application launcher that kicks off a screen session:
cat << EOF > /usr/share/applications/screen.desktop [Desktop Entry] Name=Screen Exec=/usr/bin/screen -dmS meego Icon=moblin-xterm Type=Application EOF
To leverage the above, once you have booted the SD image on a MeeGo device, you will see an application called 'Screen'. You can launch that application, and then ssh into the device and run:
screen -dr
to attach to the screen session. From there you can then run MeeGo applications which require access to the display and DBus under the MeeGo user session.
Don't forget to exit mic-chroot!
exit
dd or rsync as appropriate. If you haven't transferred the image to your SD card previously, you will need to dd the entire image to the SD card. If you have already dd the image and are now just installing an update, you can use rsync to transfer only those files that have changed -- which can be MUCH faster.
The first time you use an SD card or a new image, you need to install the entire image to the SD card. You can use the dd command for this.
NOTE: the following assumes sdb is your SD card. See Finding your SD card for information on finding the correct device for your SD card.
You want to perform the following on the device itself, not to any of the partitions on it:
dd if=${IMAGE}-${STAMP}-mrstnand/${IMAGE}-${STAMP}-sda.bin of=/dev/sdb bs=10M
The above will take a while. Go get coffee. Once it has completed, you can eject the SD card and boot your Aava device to the new image.
You don't have to always start with the fresh image. You can remount the file system environment and mic-chroot back into it to perform additional updates:
VALUE=($(echo -ne "u b\np\nq\n" | parted ${IMAGE}-${STAMP}-mrstnand/${IMAGE}-${STAMP}-sda.bin | grep ext3\$))
OFFSET=${VALUE[1]/B}
mount -o loop,offset=${OFFSET} ${IMAGE}-${STAMP}-mrstnand/${IMAGE}-${STAMP}-sda.bin aava-image
mic-chroot aava
yum update
When you are done, you MUST exit the mic-chroot environment. If you don't, your source filesystem will be mixed with host files when transferring to the SD card.
exit
Just exit -- DO NOT unmount aava-image.
Next we will mount the SD card:
mkdir aava-sd mount /dev/sdb1 aava-sd
NOTE: Replace sdb1 with the appropriate device ID on your system for the SD card; you want to mount the first partition and not the device itself.
And now we can rsync to push file system changes to the SD card:
rsync -avprl aava-image/ aava-sd/
Once the above has completed, unmount both filesystems:
unmount aava-{image,sd}
You can now eject the SD card and boot on your Aava system.
You can frequently run something like the following to find your SD card device.
Insert the SD card, wait a few seconds, and then run:
dmesg | grep -A 1 "Assuming drive cache"
You will see something like:
sd 19:0:0:0: [sdb] Assuming drive cache: write through sdb: sdb1
In the above, 'sdb' is the drive you want.
The MeeGo images for handset default to ~1.5G. If you have a large SD card (4G, 8G, etc.) you can't leverage that space by default. To do that, you can perform the following steps.
NOTE: Before beginning, make sure the image is not mounted.
First, make the "drive" larger. Below we grow it by 2G (2048 * 1M). We resize the image by seeking to 2047M into the file, and writing 1M of zeros.
dd if=/dev/zero of=${IMAGE}-${STAMP}-mrstnand/${IMAGE}-${STAMP}-sda.bin bs=1M seek=2047 count=1
Now, use parted on the file to grow the partition to the full file size:
VALUE=($(echo -ne "u b\np\nq\n" | parted ${IMAGE}-${STAMP}-mrstnand/${IMAGE}-${STAMP}-sda.bin | grep ext3\$))
OFFSET=${VALUE[1]/B}
parted ${IMAGE}-${STAMP}-mrstnand/${IMAGE}-${STAMP}-sda.bin
(parted) rm 1
(parted) mkpart primary ext3 ${OFFSET}b -1
(parted) q
Finally, mount the partition and resize it:
mount -o loop,offset=${OFFSET} ${IMAGE}-${STAMP}-mrstnand/${IMAGE}-${STAMP}-sda.bin aava-image
resize2fs $(mount | sed -ne 's,^\([^ ]*\) .*aava-image.*$,\1,p')
NOTE: The last command just finds the loop back device that was used to mount the file to the aava-image directory.
You can now mic-chroot into the image:
mic-chroot aava-image
Verify you have more space:
df