Home > Community > Blogs > System Design and Verification > xilinx zynq 7000 virtual platform frequently asked questions virtualbox edition
 
Login with a Cadence account.
Not a member yet?
Create a permanent login account to make interactions with Cadence more conveniennt.

Register | Membership benefits
Get email delivery of the System Design and Verification blog (individual posts).
 

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

Xilinx Zynq-7000 Virtual Platform Frequently Asked Questions: VirtualBox Edition

Comments(0)Filed under: ESL, embedded software, System Design & Verification, Ubuntu, Virtual Machine, virtual platforms, virtual prototypes, system design, Xilinx, VirtualBox, Zynq-7000, FAQ, Xilinx SDK, NAT, Zynq virtual platform, port forwarding, VBoxManage, network address translation, Eclipse

The use of virtual machine technology offers great ease of use benefits. Since the virtual platform for the Xilinx Zynq-7000 Extensible Processing Platform has been available as a virtual machine appliance, I have seen it run by many people who would probably not be able to install and configure a traditional installation using the Cadence InstallScape installer or the Virtual System Platform command line installation program. Today, I would like to share the top 3 most frequently asked questions related to using the Xilinx Zynq-7000 Virtual Platform as a VirtualBox Appliance.

The first question covers networking, the second is a remedy for when the virtual machine will not start, and the third explains how to shrink the virtual disk.

For this article the host is the native operating system installed on a computer and the guest is the operating system installed inside a virtual machine.

How can I login to the virtual machine and do other networking tasks like remote debugging?

A common networking mode used by virtual machines is Network Address Translation (NAT). NAT is the simplest way of accessing an external network from the guest operating system. The VirtualBox documentation explains that NAT is like placing a router between the guest and the host machine which translates the network traffic between the guest operating system running in the virtual machine and the external network. The disadvantage of NAT is that like any private network behind a router, the virtual machine is not accessible from the outside. This makes NAT a poor solution for a server, but most of the time embedded software developers doing code, compile, run, and debug tasks do not require server capabilities.

Although NAT is a good configuration for a virtual machine there are times when it's useful to access the virtual machine from the outside. Two examples are remote login and remote debugging. These use cases can be handled using the port forwarding features of VirtualBox.

Port forwarding means VirtualBox will listen for network traffic on specified ports, and when traffic arrives it forwards the traffic to the same or a different port number in the guest operating system.

The first example is remote login. Consider a situation where a software developer uses the Xilinx SDK on a Windows machine to edit and compile the embedded software for Zynq. After the compilation is done the software can be tested on a virtual platform running on a Linux guest in VirtualBox. The software could be copied using scp and the simulation could be started by using ssh to connect to the virtual Linux machine and launch the simulation. The Remote System Explorer perspective in Eclipse can also be used to browse the guest file system. Remote login using ssh requires port forwarding. To setup port forwarding for ssh look in the Network settings as shown below.

Then click the Port Forwarding button to set up the rules for port forwarding. The screenshot below shows two rules for port forwarding. The first one says to forward packets for host port 2222 to port 22 on the guest machine. Now ssh requests for the host machine on port 2222 will be sent to the guest on the normal port 22. There are many programs that can do ssh from the host including PuTTY, Tera Term, and the Xilinx SDK.

 

Of course, for ssh to work an ssh server must be running in the guest. To add it use:

$ sudo apt-get install openssh-server

Another use case is to use the Xilinx SDK or a command line gdb to connect and debug a program running in a virtual platform simulation in the guest machine from the host machine. This configuration uses a network connection between gdb and the virtual platform simulation, so the port which is used must be forwarded from the host machine to the guest so the connection can be made. The screenshot above also shows a rule to forward port 7777 on the host to port 7777 in the guest. In this case the port numbers are the same. If there is a simulation waiting for a gdb connection on port 7777 in the guest, and either an Eclipse debug configuration is set up to use a remote debugging connection on localhost port 7777 or a gdb target remote command is given with localhost:7777, the debugging session will connect.

More details about how to configure the virtual platform and the Xilinx SDK for remote debugging are provided in the Zynq Virtual Platform User Guide.

Why doesn't my virtual machine start?

A more fundamental problem occurs when the virtual machine will not start up. Below is a screenshot from a user who hit the problem after importing the virtual appliance and trying to start it.

The Zynq Virtual Platform appliance has the hardware virtualization boxes checked as shown in this screenshot.

If a particular computer doesn't support hardware virtualization (maybe it's old) I thought it might be possible to uncheck these boxes and then start successfully. This was unsuccessful for those who tried it and would probably be too slow anyway to be useful. The solution is to enable the virtualization instructions in the BIOS (or get a better computer). For some reason, some computers have this disabled by default even when the CPU supports virtualization. Users who enabled virtualization in the BIOS were able to start the virtual machine. Each computer's BIOS is different in how the options are named, but hopefully they not too hard to find. There are lots of similar things that can be found by searching the topic. One user sent this link as a useful description (even though it's not specifically about VirtualBox).

How can I shrink the size of the virtual disk?

The Zynq Virtual Platform uses a 20 GB disk that grows dynamically as more data is added to it. This means it starts small (only a few GB to save download time) and as it is used it takes up more room. Unlike a physical disk, if data is removed from the file system in the guest machine, the size of the disk file on the host machine doesn't shrink by the same amount. In fact, it never shrinks, it only grows bigger. It is possible to shrink the disk file so it takes up less room on the host and also helps make the virtual machine smaller if it needs to be shared with other users. VirtualBox has a VBoxManage command that can be run on the host machine to shrink, or compact, the disk file. The procedure is a little tricky, so I wouldn't recommend it every day, but it's useful when needed.

Although VBoxManage looks straight forward, the trick is to understand that it will only compact the data that is all zeros on the disk. Because of this the unused parts of the disk must be set to zero so the compaction will actually compact. Without zeroing the unused space the compaction will cause little or no change in the file size.

To zero the unused space I use a program called zerofree to do the job. It is installed in the Zynq Virtual Platform in /usr/sbin/zerofree. The hard part is making zerofree do its job. If you just run it inside the running system it will not do anything because the file system is mounted with write permission. To succeed the file system needs to be mounted as read-only. Here is what happens if you just run zero free on a running system:

The easiest way is to drop into single-user mode by typing:

$ sudo init 1

Then you will see a menu like this:

 

You can select netroot or arrow down and select root.

Then run the following commands to stop various services that prevent the file system from being mounted read-only.

# service rsyslog stop
# service network-manager stop
# killall dhclient

Now mount the file system as read-only and run zerofree:

# mount -n -o remount,ro /dev/sda1
# zerofree /dev/sda1

Halt the system and you are all set to run VBoxManage to shrink the disk.

With the virtual machine stopped find the disk image you want to compact and find and run VBoxManage command something like this:

VBoxManage.exe modifyhd <filename> --compact

After the compaction completes the file should be smaller and the virtual machine can be restarted.

Hopefully, this information answers the most frequently asked questions in an easy to understand way. Much of the information is available by searching, but there are also many dead-ends out there with information that did not work for me. As always, please share the tips and tricks you use to run virtual platforms using virtual machines.

Jason Andrews

Comments(0)

Leave a Comment


Name
E-mail (will not be published)
Comment
 I have read and agree to the Terms of use and Community Guidelines.
Community Guidelines
The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.