To begin with, I have to apologise for a big delay between this post and my previous one. Fractured arm slowed me down a lot but did not stop me completely, so I am back:)


This post will conclude my Ultra96 training and will cover the PetaLinux labs. There are three main things I learnt from this module:

1. How to configure and build a PetaLinux image for Ultra96 V2;

2. How to include custom applications in the PetaLinux build;

3. How to create a simple IoT application with MQTT protocol and connect it to IBM Bluemix.


Minimal Ultra96 PetaLinux - Lab 1


  • Use the Xilinx tool chain in conjunction with the Ultra96 board USB JTAG to program new boards that have never been programmed or boards that can no longer boot up due to software problems;
  • Setup and configure a minimal PetaLinux system using the PetaLinux tools;
  • Boot a minimal PetaLinux image;



This was not the first time I was configuring and building PetaLinux. This time, however, the process was much more structured than before. Everything covered in the instructions could also be found in the UG1144 document by Xilinx. That document is huge though; therefore, having concise notes saves you a lot of time.

Unexpectedly, I got stuck when trying to prepare my SD card. I did not have a USB SD card reader and was trying to use the built-in reader on my laptop. My VM could not see the device at all.

Having spent some time searching for a solution, I came across this guide:

What it suggests is to create a .vmdk virtual machine disc image out of your SD card and mount to the VM. Eventually, SD card appears as /dev/sdb disc. After that, I was able to format the partitions as required and put the image files. Very important step is to call sudo sync whenever you change the contents of the disc (SD card in this case) for changes to actually take place outside the VM. The downside of this approach is that you must restart the VM if the SD card was ejected and inserted back. Overall, getting a USB card reader would have been a much simpler option but this one works, too:)


Updating Fully Featured PetaLinux - Lab 2


  • Create PetaLinux systems that load from SD Card


In the first lab, we used the basic ZynqMP when creating the PetaLinux project. This time, we replaced the standard template with Ultra96-specific BSP. It supports the SPI interface required for the Click Mezzanine with the sensor to work in the future exercises. I

n the lab manual it is advised to verify if SPI Slave Select signals are enabled in the HW design. They were supposed to be selected by default. However, this was not the case in my project. I had to modify ZynqMPSoC block configurations and regenerate the .hdf file.


This time, we covered more steps for PetaLinux configuration and this is likely to be the optimal procedure you would use for your designs:

  1. Create a PetaLinux project and use a BSP as source;
    1. petalinux-create -t project -n <project name> -s <path to BSP>
  2. Configure PetaLinux with your HW design;
    1. petalinux-config --get-hw-description=<path to .hdf file>
  3. Configure kernel (add SPI support in this case);
    1. petalinux-config -c kernel
  4. Configure and include various files and applications outside of the PetaLinux kernel;
    1. petalinux-config -c rootfs
  5. Include correct Device Tree file customized for your design;
    1. It should be placed in <project_name>/project-spec/meta-user/recipes-bsp/device-tree/files/
  6. Package your PetaLinux boot files;
    1. petalinux-package --boot --fsbl zynqmp_fsbl.elf --u-boot u-boot.elf --pmufw pmufw.elf --fpga system.bit
  7. And finally build the image;
    1. petalinux-build

Having completed all the steps above I ended up with a working version of PetaLinux that launched on my Ultra96. I was able to login as root and see the system boot information.

Connect with Ultra96 Using Wi-Fi


     • Connect your Ultra96 to a wireless LAN (WLAN);

     • Interact with the internet using various networking protocols;


This was a short to show how to quickly connect Ultra96 to your WiFi network. When Ultra96 boots, it creates a WiFi hotpsot to which you can connect from your machine. Once connected, there is dedicated web-interface at where details of your WiFi network can be entered and saved. The board will then connect automatically.

You can then check what IP address was allocated to your Ultra96 using ifconfig and use SSH later on to interact with PetaLinux. I also used wget to check if the Internet connect actually works.

Creating PetaLinux Applications using Xilinx SDK


     • Develop PetaLinux user applications meaning;

     • Read and manipulate the LSM6DSL Sensor using Ultra96.


In this lab we finally get to develop a custom application for PetaLinux and debug it on hardware. We proceed as in the previous modules (Hardware and Software). The difference is that Linux should be selected as the OS platform when creating a new project in the Xilinx SDK.

The application code is provided with the tutorial files and simply reads temperature data from the LSM6DSL sensor that is plugged in the Ultra96 using the Click Mezzanine. Communication happens over SPI.

On the other hand, debugging interface is quite different from the previous exercises. The application loading and debugging will be happening remotely. To achieve that we need to set up a tool called Linux TCF Agent. IP address noted in the last lab is required. The Port field should be set to 1534.



Then create new Run/Debug settings and launch Debug on Hardware. This will switch you to the Debug view of the Xilinx SDK.



The first time I did this I got an error message that the program file cannot be downloaded. I tried to reset the debug session several times. It did not resolve the issue so I had to restart the SDK and repeat all the steps from scratch to make the debug session work.



Otherwise, debug process is identical to whatever was covered in Hardware and Software modules.

IoT Application: Log Sensor Data to IBM™ Bluemix


     • Collect sensor data from SPI Sensors.

     • Use the MQTT IoT protocol to send data to servers.

     • Create JSON formatted information that IoT applications often use.

     • Setup your own IBM™ Bluemix© Quickstart cloud service.


I never expected that connecting your device to an IoT server would be this simple. I never used IBM Cloud before and only worked with the AWS IoT Core previously. I really enjoyed the quickstart feature where you only need to type in your device name to see the data it is ending. This is done via the link:

Obviously, there is work to do on the Ultra96 side. We need a working MQTT client to handle communications with the IBM Cloud. Again, the application code was provided and only the device name needs to be changed. There is a great tutorial that covers step by step how to integrate MQTT with your application:

When application is loaded and Ultra96 is connected to the network, temperature data from the LSM6DSL sensor is plotted in the IBM Cloud web interface.



Embed an Application Using Ultra96 PetaLinux


     • Create and install a custom application into the Ultra96’s PetaLinux file system.

     • Compile a custom C application using a Makefile.


In the final lab I learnt how to add my application to the PetaLinux build. To do that, we need to use a different PetaLinux command option:

petalinux-create -t apps --template c --name lsm6dsl-sensor –enable

As you can see, the same command is used as for creating a new project. However, the -t option is changed to apps. The LSM6DSL application is used again as example. You will find your application listed in the bitbake file (<path_to_petalinux_directory>/2018_3/support_documents/v2/lab6/<project_name>/project-spec/meta-user/recipes-core/images) once the command above is executed successfully.



It is important to modify your application bitbake file (<path_to_petalinux_directory>/2018_3/support_documents/v2/lab6/<project_name>/project-spec/meta-user/recipes-apps/<app_name>), too, to point it to correct sources and Makefile. You also need to specify the installation folder in the root file system by setting a parameter: FILES_${PN} += "/home/petalinux/*"

Finally, PetaLinux can be rebuilt so that the application is included.

The application can be run by logging in the PetaLinux:

  1. cd /usr/bin
  2. ./lsm6dsl-sensor



So this is it, the training material is over. I can safely say that I learnt a ton - the courses provided me with the fundamentals for all three development aspects: hardware platform, baremetal applications and finally Linux applications. I think Hardware and Software modules were very close to ideal in terms of level of detail when explaining the concepts. There was a bit of material overlap between the two but that did not spoil anything. I wish the PetaLinux module had more labs though. As of now, it was the shortest module from the three, which, in my opinion, is a bit unfair as there is a lot to grasp to get started with PetaLinux properly and be able to work with it independently without relying fully on the template projects.


I am very grateful to the element14 community and rscasny specifically for the ongoing support and encouragement, and the sponsors of Path 2 Programmable for such a great learning opportunity!