Zynq design from scratch. Part 38.
Running Linaro Ubuntu on the ZedBoardOpen-source solution
To use PetaLinux in a commercial product we need to buy a license. Let's look for an open-source solution.
Linaro is a not-for-profit engineering organization that works on open-source software for the ARM architecture, including the GCC toolchain, the Linux kernel, ARM power management, graphics and multimedia interfaces
. Linaro focuses on open-source support of the ARM v7 and ARM v8 Architecture, including SoCs that contain ARM Cortex-A9, Cortex-A15, Cortex-A53 and Cortex-A57 processor(s).
We can read more about Linaro and download the software from the Linaro web page.
Where to start
Digilent has published two very informative documents called "Embedded Linux Development Guide" and "Getting Started With Embedded Linux - ZedBoard". The second document describes the Linaro Ubuntu installation. Avnet has written a document called "Ubuntu Desktop Linux" (Register and login to Zedboard.org needed). Probably the best one to use. Let's start there.
Booting Linux on ZedBoard
Booting the Zynq-7000TM All Programmable SoC (Zynq AP SoC) from an SD card, or another form of compatible memory, requires that you first place four items onto your storage device. The four required items are the Linux file system (either Linaro or BusyBox), a Linux kernel image, a BOOT.BIN file, and a compiled device tree.
The Linux file system
The ZedBoard currently supports two different Linux file systems, a BusyBox ramdisk (used by PetaLinux) and a Linaro Ubuntu distribution.
The BusyBox ramdisk is a very small file system that includes basic functionality and runs through RAM. BusyBox is non-persistent, which means it will not save any changes we make during our operating session after we power down the ZedBoard.
The Linaro file system is a complete Linux distribution based on Ubuntu. It includes a graphical desktop that displays via the onboard HDMI port. Linaro executes from a separate partition on the SD card, and all changes made are written to memory. The utility of Linaro is that it will save files even after you power down and reboot the ZedBoard. In this experiment we will use the Linaro file system.
The SD card
I will use a SanDisk SDHC 16GB card (speed grade 4). I tried first using a SanDisk Ultra card (speed grade 10) but couldn't get it work.
Connecting a SD card reader/writer to VirtualBox
1. Shutdown the VirtualBox guest operating system.
2. Connect a SD card reader with the SDcard inserted to one of the USB connectors on the host computer. Make sure the SD card reader is USB 2. VirtualBox can not handle USB 3 memory card readers (for the moment).
3. Open the Settings window in VirtualBox and select Ports->USB. Add the USB Storage device and click OK.
4. Unmount the SD card reader.
5. Start Ubuntu guest operating system.
6. Connect the SD card reader.
7. If everything works as expected, the SD card will show up in the file browser.
8. The file system is mounted in the /media/<user name> directory.
Formatting the SD card
Booting Linux on the ZedBoard from an SD card requires that we first set up the correct partitions on the SD card. We must format the first two partitions on the SD card to specific parameters. The first partition must have a FAT file system and be at least 52 MB and the second partition must have an ext4 file system and be at least 3.6GB. The second partition is only necessary when using the Linaro file system.
GParted is a free partition editor for graphically managing our disk partitions. It is used for creating, deleting, resizing, moving, checking and copying partitions, and the file systems on them. This is useful for creating space for new operating systems, reorganizing disk usage, copying data residing on hard disks and mirroring one partition with another (disk imaging).
Use the following command to install GParted.
->sudo apt-get install gparted
Use the following command to start GParted:
1. When the GParted partitioning window is displayed we select the SD card (/dev/sdb) from the GParted->Devices menu.
2. Before doing any formatting of the card we must unmount the FAT32 partition. Select the partition, right-click and choose Unmount.
3. We will start by deleting the partition. Select the partition, right-click and choose Delete.
4. To execute the command we have to click .
5. We now have a completely unallocated SD card. Let's go ahead and add two new partitions. We make the first partition about 52MB and formatted in FAT32. Don't forget to leave 4MB of free space preceding the partition. Click the new button to add a new partition.
We make the second partition 8GB (3.6GB would be enough) with ext4 file system.
6. Here is the result. Click the button to finish the partitioning.
7. The two partitions are mounted in the /media/svenand directory.
Let's do a quick check to find out if our newly formatted SD card can boot Linux on the ZedBoard. We will copy the boot files found on the original SD card, to the BOOT partition on the new SD card. Like this:
Now we can follow the instruction in part 21 to boot Linux on the ZedBoard. If this works we can continue and install the Linaro file system. If not we have to go back to the drawing board.
Downloading the Linaro file system
The first step in preparing the Linaro file system is to obtain the tarball of our preferred Linaro Ubuntu distribution. We can obtain these from Linaro at http://releases.linaro.org/ by clicking the desired version and then traversing to ubuntu/precise-images. Linaro provides several different Ubuntu builds, some of which are very lightweight and do not use a desktop. We can find a version that does contain a graphical desktop and that has been tested on the ZedBoard at: http://releases.linaro.org/12.09/ubuntu/precise-images/ubuntu-desktop.
Creating the Linaro root file system
We create a folder named linaro under /tmp and copy the zipped linaro image there.
->mkdir -p /tmp/linaro
->sudo cp linaro-precise-ubuntu-desktop-20120923-436.tar.gz /tmp/linaro/.
Unpack the disk image using the tar command:
->sudo tar zxf linaro-precise-ubuntu-desktop-20120923-436.tar.gz Here is the result.
Observe. The /tmp directory will be cleaned when rebooting the Ubuntu system.
Copy the disk image to the SD cardAfter unpacking the disk image, the root filesystem lies at /tmp/linaro/binary/boot/filesystem.dir. So the next step to do is to copy the root filesystem into the second partition of our SD Card, mounted already to /media/svenand/rootfs. A lot of files in the root filesystem are special files with special attributes, I would recommend to use rsync to do the copy, which keeps the attibutes for every file. It takes a while to copy the file to SD card, basically depended on our SD card speed.-> cd binary/boot/filesystem.dir
-> sudo rsync -a --progress ./ /media/svenand/rootfs/
To make sure all the files have been sychronized to the SD card, we need to unmount the /media/svenand/rootfs before we unplug the SD card. It may take several minutes to get everything synchronized onto the SD Card.-> sudo umount /media/svenand/rootfs/Adding device tree blob file
We need to change the bootargs defined in the device tree blob (DTB) to let the kernel use the second partition of SD card as root file system. To make our life easier, we can download a precompiled dtb file available here: devicetree_linaro.dtb
Fixing the BOOT files
We will delete the ramdisk8M.image.gz and devicetree_ramdisk.dtb files and add the devicetree_linaro.dtb file.
Prepare the ZedBoard
Once we complete these guide instructions, the SD card will have everything it needs to boot Linux on the ZedBoard. Set the jumpers on the ZedBoard as follows:
- MIO 6: set to GND (JP7)
- MIO 5: set to 3V3 (JP8)
- MIO 4: set to 3V3 (JP9)
- MIO 3: set to GND (JP10)
- MIO 2: set to GND (JP11)
- VADJ Select: Set to 1V8 (JP18)
- JP6: Shorted
- JP2: Shorted
- All other jumpers should be left untouched
Boot Linaro Ubuntu
Insert the SD Card into the ZED Board, connect a monitor to the ZED Board with an HDMI cable, connect the UART port to our computer, open a terminal for it (115200 baud rate, 8 bit, 1 stop bit, no parity, no flow control).
We power up the ZedBoard and after a few seconds the blue LED will light up. However, automatically, the boot loader (U-Boot) will still look for ramdisk by default. So, we need to stop the autoboot by pressing a key during the 3-second count down, and type the command: run sdboot_linaro to boot up the Linaro Ubuntu Desktop.
The boot process will start and after a minute or so the display will show the Linaro home screen.
Here is the Linaro Ubuntu screen.
Connect keyboard and mouse
Linaro Ubuntu has support for both a USB keyboard and a USB mouse. They will be connected to the USB OTG contact.
USB On-The-Go, often abbreviated USB OTG or just OTG, is a specification that allows USB devices such as digital audio players or mobile phones to act as a host, allowing other USB devices like a USB flash drive, digital camera, mouse, or keyboard to be attached to them.
We will start by adding a "USB MicroB to USB A" OTG adapter.
Now we can add a USB hub, a USB keyboard and a USB mouse.
The USB devices will be detected and can be used to control our Linux system.
Top Previous Next
Posted at 17:21 by svenand
November 19, 2014 12:45 PM PST
The two points that Francisco Gaspar raised are also important. Any idea as to which direction I should head in order to:
1) change the settings (i.e. MAC address). Do I need to follow, for example, this process:
2) Automate the boot process without having to press keys at boot up and type 'run sdboot_linaro'.
Probably Francisco might already have answers to these questions?
November 18, 2014 03:49 PM PST
I have uploaded the file to my blog. Go ahead and use it.
November 18, 2014 02:10 PM PST
First of all, thank you very much for taking the time to develop this blog. It is very useful.
In brief, I tried to follow the instructions in part 38 but I got an error when I tried to download: devicetree_linaro.dtb
Is seems as if the link is broken. Could you please upload the file on your blog?
|Francisco Gaspar |
May 21, 2014 12:49 PM PDT
I would also like to change the device tree, specifically I'd like to:
- Change the ethernet mac address (I have 2 boards, both with the same address which creates conflicts);
- Automate the boot process.
The second point I was able to accomplish by using the files from the other board (which I didn't configure myself and thus do not know how they were generated), but I'd like some help with the first part.
A second question: Is there any place where I can get a precompiled kernel image? I'm trying to run Linaro 14.04, but since I didn't change the zImage file it is using the old kernel image I got from the other board (running Linaro 12.11, it has kernel 3.10.0 instead of 3.10.37 as I believe 14.04 should)
April 23, 2014 01:34 PM PDT
how do you generate a dts with vivado 14.1 ?
it lacks xps_lite support and libgen is required in orger to infer .dts from .mss ?