2. Quick start guide

This document will guide you from importing the virtual machine to debugging an Hello World! example on a customized Linux distribution you will generate with OpenEmbedded/Yocto toolchain.

2.1. Install

The development environment is provided as a virtual disk (to be used by a VirtualBox virtual machine) which you can download from this page:

Important

Compute the MD5SUM value of the zip file you downloaded and compare it to the golden one you find in the download page.

Uncompress the file, and you will get a .vdi file that is our virtual disk image. The environment contains the SDK for all the boards provided by Architech, ZedBoard included.

2.1.1. Download VirtualBox

_images/vdi_virtualbox_logo.png

For being able to use it, you first need to install VirtualBox (version 4.2.10 or higher). You can get VirtualBox installer from here:

https://www.virtualbox.org/wiki/Downloads

Download the version that suits your host operating system. You need to download and install the Extension Pack as well.

Important

Make sure that the extension pack has the same version of VirtualBox.

Install the software with all the default options.

2.1.2. Create a new Virtual Machine

  1. Run VirtualBox
_images/vdi_open_virtualbox.png
  1. Click on New button
_images/vdi_new_virtual_machine.png
  1. Select the name of the virtual machine and the operating system type
_images/vdi_virtual_machine_name.png
  1. Select the amount of memory you want to give to your new virtual machine
_images/vdi_virtual_machine_memory.png
  1. Make the virtual machine use Architech’s virtual disk by pointing to the downloaded file. Than click on Create.
_images/vdi_hard_drive.png

2.1.3. Setup the network

We need to setup a port forwarding rule to let you (later) use the virtual machine as a local repository of packages.

Note

The virtual machine must be off

  1. Select Architech’s virtual machine from the list of virtual machines
_images/vdi_machine_listed.png
  1. Click on Settings
_images/vdi_click_settings.png
  1. Select Network
_images/vdi_network.png
  1. Expand Advanced of Adapter 1
_images/vdi_network_nat_advanced.png
  1. Click on Port Forwarding
_images/vdi_network_nat_port_forwarding.png
  1. Add a new rule
_images/vdi_network_nat_port_forwarding_rule_add.png
  1. Configure the rule
_images/vdi_network_nat_port_forwarding_rule_added.png
  1. Click on Ok

2.1.4. Customize the number of processors

Building an entire system from the ground up is a business that can take up to several hours. To improve the performances of the overall build process, you can, if your computer has enough resources, assign more than one processor to the virtual machine.

Note

The virtual machine must be off

  1. Select Architech’s virtual machine from the list of virtual machines
_images/vdi_machine_listed.png
  1. Click on Settings
_images/vdi_click_settings.png
  1. Select System
  2. Select Processor
  3. Assign the number of processors you wish to assign to the virtual machine
_images/vdi_change_number_of_processors.png

2.1.5. Create a shared folder

A shared folder is way for host and guest operating systems to exchange files by means of the file system. You need to choose a directory on your host operating system to share with the guest operating system.

Note

The virtual machine must be off

  1. Select Architech’s virtual machine from the list of virtual machines
_images/vdi_machine_listed.png
  1. Click on Settings
_images/vdi_click_settings.png
  1. Select Shared Folders
  2. Add a new shared folder
_images/vdi_add_shared_folder.png
  1. Choose a directory to share on your host machine. Make sure Auto-mount is selected.
_images/vdi_new_shared_folder.png

Once the virtual machine has been booted, the shared folder will be mounted under /media/ directory inside the virtual machine.

2.1.6. Install VBox Additions

The VBox addictions add functionalities to the virtual machine such as better graphic driver and more. It is already installed in the SDK but is important re-install it to configuring correctly the virtual machine with your operating system.

  1. Starts the virtual machine
_images/vbStart.png

2. Click on the virtual box menu to the voice Devices and select Insert Guest Additions CD Images.... A message box will appear at the start of the installation, click on run button

_images/messagebox_vboxadditions.jpg
  1. To proceed are required admin privileges, so insert the password architech when asked
_images/messagebox_sudo.jpg
  1. Then a terminal will show the installation progress. When finished, press Enter key
_images/terminal_vboxadditions.jpg
  1. Before to use the SDK, it is required reboot the virtual machine

2.2. Build

Important

A working internet connection, several GB of free disk space and several hours are required by the build process

  1. Select Architech’s virtual machine from the list of virtual machines inside Virtual Box application
_images/vdi_machine_listed.png
  1. Click on the icon Start button in the toolbar and wait until the virtual machine is ready
_images/vbStart.png
  1. Double click on Architech SDK icon you have on the virtual machine desktop.
_images/splash0.jpg
  1. The first screen gives you two choices: ArchiTech and 3rd Party. Choose ArchiTech.
_images/splash1.jpg
  1. Select ZedBoard as board you want develop on.
_images/splashscreen_board_selection.jpg
  1. A new screen opens up from where you can perform a set of actions. Click on Run bitbake to obtain a terminal ready to start to build an image.
_images/splash3.jpg
  1. Open local.conf file:
  Host    select
gedit conf/local.conf
  1. Go to the end of the file and add the following lines:
  Host    select
EXTRA_IMAGE_FEATURES_append = " tools-debug debug-tweaks"
IMAGE_INSTALL_append = " tcf-agent gdbserver"
or
EXTRA_IMAGE_FEATURES_append = " tools-debug debug-tweaks"
IMAGE_FEATURES_append = " eclipse-debug"

This will trigger the installation of a features set onto the final root file system, like tcf-agent and gdbserver.

  1. Save the file and close gedit.
  2. Build core-image-minimal-dev image by means of the following command:
  Host    select
bitbake core-image-minimal-dev

At the end of the build process, the image will be saved inside directory:

  Host    select
/home/architech/architech_sdk/architech/zedboard/yocto/build/tmp/deploy/images/zedboard
  1. Setup sysroot directory on your host machine:
  Host    select
sudo tar -xzf /home/architech/architech_sdk/architech/zedboard/yocto/build/tmp/deploy/images/zedboard/core-image-minimal-dev-zedboard.tar.gz -C /home/architech/architech_sdk/architech/zedboard/sysroot/

Note

sudo password is: “architech

2.3. Deploy

Warning

The following instruction will make you overwrite your SD card content, it will be lost forever! If you have important data on it, make sure you do a backup of your data on the SD card before catching up with the next steps.

Create two partitions on the SD card you mean to use to boot the board. The first one has to be a FAT16 (name it boot), 64MB will be more than enough. Create the second partition as an EXT2 (name it rootfs), make it big enough to fill the free space on the disk size.

Run this command:

  Host    select
mkdir -p /home/architech/Documents/zedboard

to create the directory that will be used to save a few files you need to download from the Internet:

Now, we assume that the first partition of the SD card gets mounted (in your SDK virtual machine) under:

  Host    select
/media/boot

while the second partition gets mounted under:

  Host    select
/media/rootfs

Warning

If that’s not the case for your configuration, please find out which are the proper mounting points for those two partitions on your system and replace them in the following instructions.

Ok then, we can finally deploy bootloader and kernel on the first partition of the SD card:

  Host    select
cp /home/architech/Documents/zedboard/BOOT.BIN /media/boot/
cp /home/architech/Documents/zedboard/uEnv.txt /media/boot/
cp /home/architech/Documents/zedboard/devicetree.dtb /media/boot/
cp /home/architech/architech_sdk/architech/zedboard/yocto/build/tmp/deploy/images/zedboard/uImage /media/boot/

and the root file system on the second partition of the SD card:

  Host    select
sudo rm -rf /media/rootfs/*
sudo tar -xzf /home/architech/architech_sdk/architech/zedboard/yocto/build/tmp/deploy/images/zedboard/core-image-minimal-dev-zedboard.tar.gz -C /media/rootfs/

Important

sudo password is architech

Make sure everything has been written on the SD card:

  Host    select
sync

and unmount the SD card from your system.

2.4. Boot

Make sure that ZedBoard boot mode (JP7-JP11) and MIO0 (JP6) jumpers are set like in the following picture:

_images/board_boot_switches.png

Insert the SD card you just prepared inside socket J12.

Connect the external power adapter to ZedBoard connector J20 and move switch SW8 to the “On” position.

And now proceed by setting up the serial console.

On ZedBoard there is an USB-UART port (J14) labeled UART

_images/board-uart.jpg

which you can connect, by means of a micro-USB cable, to your personal computer.

Note

Every operating system has its own killer application to give you a serial terminal interface. In this guide, we are assuming your host operating system is Ubuntu.

On a Linux (Ubuntu) host machine, the console is seen as a ttyACMX device and you can access to it by means of an application like minicom.

Minicom needs to know the name of the serial device. The simplest way for you to discover the name of the device is by looking to the kernel messages, so:

  1. clean the kernel messages
  Host    select
sudo dmesg -c
  1. connect the mini-USB cable to the board already powered-on
  2. display the kernel messages
  Host    select
dmesg
  1. read the output
  Host    select
[29629.785374] usb 3-2: >new full-speed USB device number 4 using xhci_hcd
[29629.806908] usb 3-2: >New USB device found, idVendor=04b4, idProduct=0008
[29629.806915] usb 3-2: >New USB device strings: Mfr=1, Product=2, SerialNumber=4
[29629.806919] usb 3-2: >Product: Cypress-USB2UART-0123456
[29629.806922] usb 3-2: >Manufacturer: 2012 Cypress Semiconductor
[29629.806925] usb 3-2: >SerialNumber: 0201258B0816
[29629.858654] cdc_acm 3-2:1.0: >This device cannot do calls on its own. It is not a modem.
[29629.858705] cdc_acm 3-2:1.0: >ttyACM0: USB ACM device
[29629.859345] usbcore: registered new interface driver cdc_acm
[29629.859347] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters

As you can see, here the device has been recognized as /dev/ttyACM0.

Now that you know the device name, run minicom:

  Host    select
sudo minicom -ws

If minicom is not installed, you can install it with:

  Host    select
sudo apt-get install minicom

then you can setup your port with these parameters:

  Host    select
+-----------------------------------------------------------------------+
| A -    Serial Device      : /dev/ttyACM0                              |
| B - Lockfile Location     : /var/lock                                 |
| C -   Callin Program      :                                           |
| D -  Callout Program      :                                           |
| E -    Bps/Par/Bits       : 115200 8N1                                |
| F - Hardware Flow Control : No                                        |
| G - Software Flow Control : No                                        |
|                                                                       |
|    Change which setting?                                              |
+-----------------------------------------------------------------------+
        | Screen and keyboard      |
        | Save setup as dfl        |
        | Save setup as..          |
        | Exit                     |
        | Exit from Minicom        |
        +--------------------------+

If on your system the device has not been recognized as /dev/ttyACM0, just replace /dev/ttyACM0 with the proper device.

Once you are done configuring the serial port, you are back to minicom main menu and you can select exit.

Give root to the login prompt:

Board

zedboard login: root

and press Enter.

Note

Sometimes, the time you spend setting up minicom makes you miss all the output that leads to the login and you see just a black screen, press Enter then to get the login prompt.

2.5. Code

The time to create a simple HelloWorld! application using Eclipse has come.

Note

Before to start remember to copy the cross-toolchain libreries to sysroot

sudo cp -r /home/architech/architech_sdk/architech/zedboard/toolchain/sysroots/armv7a-vfp-neon-poky-linux-gnueabi/* /home/architech/architech_sdk/architech/zedboard/sysroot
  1. Return to the Splashscreen, which we left on ZedBoard board screen, and click on Develop with Eclipse.
_images/splash4.jpg
  1. Go to File→ New→ Project..., in the node “C/C++” select C Project and press next button.
_images/eclipse-newprj1.jpg
  1. Insert HelloWorld as project name, open the node Yocto Project ADT Autotools Project and select Hello World ANSI C Autotools Project and press next button.
_images/eclipse-new-project.jpg
  1. Insert Author field and click on Finish button. Select Yes on the Open Associated Perspective? question.
_images/eclipse-author.jpg
  1. Open the windows properties clicking on Project→ Properties and select Yocto Project Settings. Check Use project specific settings in order to use the pengwyn cross-toolchain.
_images/eclipse-properties.jpg
  1. Click on OK button and build the project by selecting Project→ Build All.

2.6. Debug

Use an ethernet cable to connect the board (connector J11) to your PC. Configure your workstation ip address as 192.168.0.100. Make sure the board can be seen by your host machine:

  Board    select
ifconfig eth0 192.168.0.10
  Host    select
ping 192.168.0.10

If the output is similar to this one:

  Host    select
64 bytes from 192.168.0.100: icmp_req=1 ttl=64 time=0.946 ms
64 bytes from 192.168.0.100: icmp_req=2 ttl=64 time=0.763 ms
64 bytes from 192.168.0.100: icmp_req=3 ttl=64 time=0.671 ms
64 bytes from 192.168.0.100: icmp_req=4 ttl=64 time=0.793 ms

then the ethernet connection is ok. Enable the remote debug with Yocto by typing this command on ZedBoard console:

  Board    select
/etc/init.d/tcf-agent restart

On the Host machine, follow these steps to let Eclipse deploy and debug your application:

  • Select Run→ Debug Configurations...
  • In the left area, expand C/C++Remote Application.
  • Locate your project and select it to bring up a new tabbed view in the Debug Configurations Dialog.
_images/debugform.jpg
  • Insert in C/C++ Application the filepath (on your host machine) of the compiled binary.
  • Click on New button near the drop-down menu in the Connection field.
  • Select TCF icon.
_images/tcf1.jpg
  • Insert in Host Name and Connection Name fields the IP address of the target board. (e.g. 192.168.0.10)
_images/tcf2.jpg
  • Then press Finish.
  • Use the drop-down menu now in the Connection field and pick up the IP Address you entered earlier.
  • Enter the absolute path on the target into which you want to deploy the cross-compiled application. Use the Browse button near Remote Absolute File Path for C/C++Application: field. No password is needed.
_images/remotepath.jpg
  • Enter also in the path the name of the application you want to debug. (e.g. HelloWorld)
_images/debug2.jpg
  • Select Debugger tab
_images/gdb.jpg
  • In GDB Debugger field, insert the filepath of gdb for your toolchain
  Host    select
/home/architech/architech_sdk/architech/zedboard/toolchain/sysroots/i686-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-gdb
  • In Debugger window there is a tab named Shared Library, click on it.
  • Add the libraries paths lib and usr/lib of the rootfs (which must be the same used in the target board)
  Host    select
/home/architech/architech_sdk/architech/zedboard/sysroot/lib
/home/architech/architech_sdk/architech/zedboard/sysroot/usr/lib
  • Click Debug to login.
  • Accept the debug perspective.

Important

If debug does not work, check on the board if tcf-agent is running and gdbserver has been installed. You can ignore the message “Cannot access memory at address 0x0”.