ReleaseEngineering/Mozpool/How To Create a Panda Android Image Suitable For Mozpool
Mozpool uses build artifacts to deploy Android and B2G on to SD cards. The SD card must be pre-populated with a preseed image which contains a MBR partition table and the u-boot loader.
Capturing the Android Artifacts from a SD Card
If you have installed Android on an SD card, you can extract the system, userdata, and boot artifacts using tar.
- Start by inserting the SD card into the reader on the capturing host.
- Create the mount points.
mkdir -p /tmp/boot/ /tmp/system/ /tmp/data/
- Check dmesg to determine the device filename (eg this is typically either /dev/sdX or /dev/mmcblkX)
dmesg
- Some OSes auto mount SD cards upon insertion. Check the mounted filesystems and mount the boot, system and userdata partitions to the correct mount points.
sudo mount -t vfat /dev/mmcblk0p1 /tmp/boot sudo mount -t ext4 /dev/mmcblk0p2 /tmp/system sudo mount -t ext4 /dev/mmcblk0p5 /tmp/data
- Using Tar to extract the artifacts. Although android uses several partitions, only 3 are needed for mozpool to deploy at working Android image. It is critical to use sudo here. Not using it can result in bootable but unstable images due to clobbered file ownership and permissions.
sudo tar -jcpsf system.tar.bz2 -C /tmp system sudo tar -jcpsf userdata.tar.bz2 -C /tmp data sudo tar -jcf boot.tar.bz2 -C /tmp boot/uInitrd boot/uImage
This will produce 3 tarball artifacts.
- system - Android mounts this as /system within the init startup phase and contains all the Android OS components
- userdata - Android mounts this as /data. It contains apps and configuration data
- boot - This is contains only 2 file, the Android linux kernel (uImage) and the initrd ram disk image (uInitrd). The boot loader and boot loader scripts are provided in the preseed image and should not be captured in the boot artifact.
Capturing Android Artifacts from an image file
This process is similar to the previous steps but is used when extracting Android artifacts from an Android SD Card image file which is typically created using dd.
- Setup loopback device to file
sudo losetup /dev/loop0 android.img
- Setup partitions
sudo partx -a /dev/loop0
- Create mount points
sudo mkdir -p /tmp/boot /tmp/system /tmp/data
- Mount boot, system and data filesystems
sudo mount -t vfat /dev/loop0p1 /tmp/boot sudo mount -t ext4 /dev/loop0p2 /tmp/system/ sudo mount -t ext4 /dev/loop0p5 /tmp/data/
- Extract filesystems to artifacts
sudo tar -jcpf boot.tar.bz2 -C /tmp boot/uImage boot/uInitrd sudo tar -jcpf system.tar.bz2 -C /tmp system/ sudo tar -jcpf userdata.tar.bz2 -C /tmp data/
Once the artifacts are captured, see Adding New Android Images to Mozpool section for uploading instructions.
Adding New Android Images to Mozpool
This process describes uploading the Android artifacts to puppetmaster for distribution and updating mozpool with the new image name. In this example, we use panda-android-4.0.4_v3.0. You should select something different based on hardware type (panda, tegra, etc), OS (b2g, android, etc), OS version and image version.
- Login to a Releng Distinguished Puppetmaster and create a new directory under /data/bmm/artifacts. This new directory should match the name and version of the Android image being uploaded.
mkdir -p /data/bmm/artifacts/panda-android-4.0.4_v3.0
- Copy the 3 Android artifacts to the newly created directory
scp boot.tar.bz2 system.tar.bz2 userdata.tar.bz2 root@releng-puppet2.srv.releng.scl3.mozilla.com:/data/bmm/artifacts/panda-android-4.0.4_v3.0
- Run puppetmaster-fixperms as root
sudo puppetmaster-fixperms
- Create new mozpool pxe config. The easiest way is to login to any of the mozpool production servers and use the pxeconfig tool.
pxe-config --active -m "Fennec-testing Android Image from bug 958710" -c - add panda-android-4.0.4_v3.0
- This will accept a pxe config from stdin. Copy and paste pxe config to terminal then Ctrl+D. Example pxe config (spacing and newlines are important here). Make sure android_image is set to the correct image name:
default panda-live prompt 0 timeout 10 label panda-live kernel panda-live/uImage initrd panda-live/uInitrd append console=ttyO2,115200n8 rw fixrtc vram=48M omapfb.vram=0:24M mem=1G@0x80000000 text earlyprintk=ttyO2 fetch=http://%IPADDRESS%/squashfs/precise-panda-live-build.2012120602.squashfs boot=live mobile-imaging-url=http://%IPADDRESS%/scripts/android-second-stage.sh android_image=panda-android-4.0.4_v3.0 syslog-server=%IPADDRESS% live-noconfig dhcp
- Add new image to mozpool database. You must connect to the mozpool production mysql and execute the following SQL statements.
insert into images (name, boot_config_keys, can_reuse, hidden, has_sut_agent) values ("panda-android-4.0.4_v3.0", "[]", 1, 0, 1);
- Last, create a mapping between the new image and the pxe config.
insert into image_pxe_configs(image_id, hardware_type_id, pxe_config_id)
select images.id, hardware_types.id, pxe_configs.id from images, hardware_types, pxe_configs
where images.name = 'panda-android-4.0.4_v3.0' and hardware_types.type = 'PandaBoard' and pxe_configs.name = 'panda-android-4.0.4_v3.0';