Thursday, January 9, 2014

Bare Metal Qt 5.2 on BeagleBone Black Ubuntu - Part 1

Overview

This part will guide you through the steps to create a working cross compile platform for the Beaglebone. I will try to keep it generic enough that you could use any toolchain and target distro, but this is my target:
  • BeagleBone Black Rev A6
  • Saucy Ubuntu 13.10 with Kernel 3.8.13-bone32 (12/13/2013) installed to eMMC
  • CircuitCo LCD7 Rev A3
See Part 2 for configuring and building Qt. 

Downloads

Download these files while you read the instructions below...


Setup Generic Virtual Machine

Follow these instructions to create and setup a vanilla Ubuntu VM. If you already have a VM or are going to use your host Ubuntu install, proceed to the "Install Compiler Prerequisites" section.
  1. Install Virtual Box
  2. Create a new Virtual Machine
    1. Enter a name, such as "Ubuntu Qt Builder"
    2. Change Type to "Linux", if it hasn't automatically done so.
    3. Change Version to "Ubuntu (64 bit)"
    4. Specify memory size, at least 1.5 Gb for better compiling performance.
    5. Create a new virtual hard drive (ignore size recommendation for now)
    6. Select VDI
    7. Select Dynamically allocated
    8. Set size to at least 40 Gb (it's dynamic, so why limit yourself)
    9. Once the virtual machine is created, change the advanced settings
      1. Click the Settings button and then select "System" from the list on the left
      2. Click the "Processor" tab and change the Processors to something greater than 1
      3. Select "Display" from the list on the left
      4. Max out the video memory
      5. Select "Storage" from the list on the left
      6. Click on the empty CD drive under the Storage Tree
      7. Under the attributes section, click the CD symbol and select "Choose a Virtual CD/DVD disk file"
      8. Point it to your Ubuntu ISO.
      9. Adjust other virtual machine settings as desired.
  3. Start the virtual machine and perform the Ubuntu Install
  4. After the install completes, reboot the virtual machine. Don't forget to hit enter to "eject" the boot CD when it prompts.
  5. Let it install the 200+ updates
  6. After another reboot, install Guest Additions by clicking on the Devices menu of the running VM, and then selecting "Install Guest Additions..." (You may have to do this again after Ubuntu installs future updates)

Install Compiler Prerequisites

Since we are running a 64 bit host OS, we need to install the 32 bit libraries to run some of the build tools. We also need the Linaro headers. Follow these instructions to install both of these required packages
  1. Open a new Terminal or xterm window
  2. Type the following to install the Linaro headers and 32 bit compatibility libraries
> sudo apt-get install lsb                          
> sudo apt-get install ia32-libs                       

Extract Qt Source

Perform this step to expand the source tarball into your home directory. It will reside under the tarball directory of "qt-everywhere-opensource-src-5.2.0". This can be done in a new terminal window, while the prerequisites are being installed.

> cd                                                   
> tar -zxf qt-everywhere-opensource-src-5.2.0.tar.gz   

Now we create a couple of folders for our shadow builds. This helps keep the main source folder clean of configuration files and binaries.

> mkdir qt-5.2-host                                    
> mkdir qt-5.2-target                                  


Extract Linaro Toolchain

I chose to use the Linaro toolchain because it came highly recommended and the Ubuntu cross compile chain does not include a g++ binary, which will be required to compile Qt.

Issue these commands to extract the Linaro toolchain, change the directory name, and move it to a global location:

> tar -Jxf gcc-linaro-arm-linux-gnueabihf-4.8-2013.04-20130417_li nux.tar.xz                                                       
> mv gcc-linaro-arm-linux-gnueabihf-4.8-2013.04-20130417_linux \ 
 linaro                                                          
> sudo mv linaro /usr/local                                      
  

Conclusion

You should now have a working Ubuntu virtual machine that is:

  • Up-to-date
  • Has necessary host utilities installed
  • Contains a folder, in the home directory, with the Qt source
  • Has the Linaro toolchain installed under /usr/local/linaro


Continue on to Part 2 for the configuration and building of Qt.

12 comments:

  1. Have you managed to get it working using SGX? For me Qt is a bit useless without QtQuick2. I also compiled it on my machine seems like fb works fine (but qtquick needs openGL)

    ReplyDelete
    Replies
    1. I haven't been working on this.....too many other things. But I hope to get to it soon. It looks like it is getting closer:
      https://groups.google.com/forum/#!topic/beagleboard/qQTC7C8g0I8

      Delete
  2. Hi,

    Im using "qt-everywhere-opensource-src-4.8.6", cross compiler "angstrom-2011.03-i686-linux-armv7a-linux-gnueabi-toolchain-qte-4.6.3".

    I cross compiled Qt source successfully.
    Even the Qt libraries are transferred into Beaglebone black.

    But when I execute my binary in the board it showing an error stating "bash: ./Test:No such files or directory"

    I tried to set the library path. Still it is not executing.
    Can i know the reason for this?

    Thank you.

    ReplyDelete
    Replies
    1. At first, try write a console applications with Qt Creator.
      1 - Only empty main() , without any Qt classes.
      2 - With using basic classes, like QString.
      Also, command ldd -v exetubable_file shows required libraries.

      Delete
  3. When I type "sudo apt-get install ia32-libs" I get the following: "Package ia32-libs is not available, but is referred to by another package.
    This may mean that the package is missing, has been obsoleted, or
    is only available from another source
    However the following packages replace it:
    lib32z1 lib32ncurses5 lib32bz2-1.0

    Any idea what the issue is?

    ReplyDelete
    Replies
    1. Sorry for the delayed response, but I did not see this error until I switched to Ubuntu 14.04 LTS today.

      I ran ldd on /usr/local/linaro/bin/arm-linux-gnueabihf-cpp and found that libstdc++.so.6 was missing. I installed it by running:

      sudo apt-get install libstdc++6:i386

      I haven't tried to compile yet, but Qt Creator seemed happy with the Compiler link.

      See http://askubuntu.com/questions/107230/what-happened-to-the-ia32-libs-package for insight.

      Delete
    2. You will also need libncurses5:i386 for gdb....

      Delete
  4. Hi Louis
    Thank you for your detailed guide.
    I'm very new to all of this.
    I have to run an Angstrom distribution on the BBB since I'm using a Waveshare LCD Cape. With another distribution, the touchscreen is not working at all. So i tried to do your guide with this distribution installed on my BBB.
    At the end, when I want to run any test file, I get this error:

    -sh: ./xyz: No such file or directory

    Could you please help me?

    ReplyDelete
  5. Hello Unknown :)

    You can try running 'ldd xyz' to see if the program is a valid executable for the platform you are running on. If not, you may have compiled for the wrong target or the cross compile did not work.

    ReplyDelete
    Replies
    1. Thanks for your fast reply!
      The angstrom distribution doesn't know the ldd command. If I do ldd on the Ubuntu host it says that it's not an executable, of course because I compiled it for ARM, right?
      I try to use Ubuntu also for the BBB now. Is there an easy way to export the properties of the LCD Cape, etc from Angstrom and import them on a Ubuntu distribution?

      Delete
    2. No problem!

      Yes, you are correct about the binary being an ARM executable. One more thing to try on Angstrom is to ensure that the Qt libraries are installed in the exact same path that you passed to the configuration script. LDD makes this much easier, otherwise you are just shooting in the dark. Most likely you are missing an OS dependency somewhere.

      If you want to switch to embedded Ubuntu, you should be able to find the appropriate LCD cape driver file (device tree overlay) in the Angstrom filesystem. It probably won't work directly on Ubuntu because the kernels have to be very close, if not exactly the same. In this case you would have to find the source *.dts file and compile it for your embedded Ubuntu kernel.

      Delete
    3. I realized that you can install the ldd command for Angstrom. The error stays the same when I check the file with ldd:
      ..No such file or directory..

      What do you mean by "Qt libraries are installed in the exact path.."? Do I have to install Qt on the BBB? Isn't it just enough if I copy the binaries from the Qt build on the host to the BBB?

      I also cant find any .dts files on the Angstrom distribution. And even when I look at the slots of the cape manager (bone_capemgr), there is no "special" slot loaded. Its just two default ones.

      Delete