Linaro has emerged as a great place to find well tested toolchains, Linux kernels, and evaluation builds for Ubuntu and Android. Everything is focused on the ARM Architecture which is great news for me since almost all of the projects I work on also involve ARM processors.
Last year I looked up a presentation by Christian Reis, the Linaro VP of Engineering, titled, The Weird World of Linux on ARM. For me, ARM is the primary architecture I work with. Although I run Linux on multiple x86 machines for software development, I recall only one time I compiled a Linux kernel and tried to debug a broken device driver on the x86 architecture. The diversity of the ARM ecosystem and the popularity among Cadence customers has made the ARM architecture the focus of most of my work. It didn't actually occur to me that Linux on ARM was weird at all since I have very little x86 experience.
One of the challenges of a Virtual Platform developer is access to software to use in testing new models. While I find embedded Linux very interesting, there is not always time to spend on actual software development and creating new software to run on a new model. The good news is there is no shortage of information and open source software available. The challenge is that it all takes time to find, learn, build, and use. Linaro is a great place because it provides easy access to various useful and time saving components.
During testing of the Cadence Virtual Platform for the Xilinx Zynq-7000 EPP I was looking for more software to try and decided to check out some of the Linaro deliverables, I decided to try some of the Ubuntu Oneiric images on the Virtual Platform. As the first step I started with the Linaro Nano image, a small image with basic console and networking.
Today, I'll explain the steps to run the Nano image on the Virtual Platform for the Xilinx Zynq-7000 EPP.
The first step is to get the Nano image from the Linaro Downloads page.
Click the rightmost column on the Nano row to get the image, the filename I downloaded was linaro-o-nano-tar-20120123-1.tar.gz
I extracted the file and changed directory to binary/boot/filesystem.dir
Here I can see the root file system that I want to use.
To start with I made a new image file, 256 Mb, that can be used by the SD Card model present in the Virtual Platform.
$ dd if=/dev/zero of=linaro-nano.img bs=1024k seek=256 count=0
Since this is just a test image there is no need to partion the image, I'll just use a single partion for the entire SD card image.
Next, make a file system on the image, I used an ext2 file system:
$ /sbin/mkfs.ext2 linaro-nano.img
Then mount the image somewhere on the host machine so the file system data can be loaded. I made a temporary directory called t/ in /mnt
$ sudo mount -t ext2 -o loop linaro-nano.img /mnt/t
Copy the data from the downloaded Nano image onto the SD card image that is mounted on the host machine:$ cd /mnt/t
$ cp -r ~/Downloads/binary/boot/filesystem.dir/* .
Finally, unmount the image and it's ready to run.
$ sudo umount /mnt/t
I put the image in SD Card slot 1. This is an SD card model, not a real SD card, but in the Virtual Platform configuration file I specify the image to use for SD card 1 in the sd_card1 section:sd_card1
The last thing is to set SD card 1 as the root file system on the Linux kernel command line. This is done via the Linux Device Tree.
For the Virtual Platform, I edit the default zynq-ep107.dts device tree source file and specify the SD card as the root file system. Since we are attaching it to SD card 1 the device node is /dev/mmcblk1
Here is the device tree source file for the kernel command line
bootargs = "console=ttyPS0,115200 root=/dev/mmcblk1 rootwait rw earlyprintk ip=:::::eth0:dhcp";
Then rebuild the device tree using the device tree compiler, dtc from the scripts/dtc directory of the Linux kernel source tree.
% dtc -I dts -O dtb -o zynq-ep107.dtb zynq-ep107.dts
Make sure the .cfg file for the simulation has in the loader section INITRDFILE "" to make sure no ramdisk image is used as a root file system. Without this a default ramdisk image file could boot.
Run the simulation as normal and the result is a shown below, a running system with the latest Xilinx Zynq Linux kernel and the Linaro Nano image.
If you haven't looked at the Linaro website take some time to see what's there. A lot can be learned from the Wiki.