Setting-up QtCreator to cross compile for iMX6 series

From ESS-WIKI
Revision as of 03:39, 30 September 2020 by Zhengguang.yang (talk | contribs) (RK3399 Qt5Creator)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Prerequisites

All operations in this guide are based on Ubuntu 18.04 LTS 64bit only.
First please install Ubuntu 18.04 LTS 64bit* with minimum 2GB memory.

Installing required packages

Please login and perform the following commands:

$ sudo apt-get install build-essential
$ sudo apt-get install qtcreator
$ sudo apt-get install qt5-default
$ sudo apt-get install qt5-doc
$ sudo apt-get install qt5-doc-html qtbase5-doc-html
$ sudo apt-get install qtbase5-examples

Installing cross toolchain

Please download cross compiler toolchain first. Then execute the following command to unzip the cross compiler tool to the /opt directory

$ sudo tar -zxf rk3399_risc_toolchain.tar.gz -C /opt


Working within QtCreator

Starting the QtCreator

$ qtcreator
  1. The QtCreator's main window shows up.
    RTENOTITLE
  2. Check QtCreator's version by using "Help" -> "About Qt Creator".
    RTENOTITLE

Configuring the Cross-Compiler Options

  1. Bring up the options dialog using "Tools" -> "Options..."
  2. Select the "Devices" page on the left, and click "Add..."
  3. Select "Generic Linux Device" and click "Start Wizard".
    RTENOTITLE
  4. Specify proper settings and click "Next>"
    RTENOTITLE
  5. Click "Finish"
  6. Device test finished successfully. Click "Close".
    RTENOTITLE

    If device test failed, please go back to specify proper settings.
    RTENOTITLE
    (It is necessary to set a blank password at least, null password does not work.)

    RTENOTITLE
    (It means device's IP is incorrect or some network issues occured.)
  7. Click "Apply"
  8. Select the "Build & Run" page on the left, switch to "Compilers" tab, drop down "Add" menu and choose "GCC-->C++".
  9. Name the compiler as "RK G++"
  10. Click "Browse..." to select "/opt/rk3399_risc/buildroot/output/rockchip_rk3399/host/bin/aarch64-buildroot-linux-gnu-g++"
  11. Click "Apply"
    RTENOTITLE
  12. Switch to the "Debuggers" tab
  13. Click "Add"
  14. Name the debugger as "RK GDB"
  15. Click "Browse..." to select "/opt/rk3399_risc/buildroot/output/rockchip_rk3399/host/bin/aarch64-buildroot-linux-gnu-gdb"
  16. Click "Apply"
    RTENOTITLE
  17. Switch to the "Qt Versions" tab.
  18. Check if the "Qt 5.12.2 (host)" is auto detected in "Manual" item ?
    RTENOTITLE
    If not, click "Add..." to choose the proper qmake.
  19. Click "Apply"
  20. Switch to the "Kits" tab.
  21. Click "Add".
  22. Name the kit as "RK toolchain"
  23. Specify the correct "Device Tpye", "Compiler", "Debugger" and "Qt version"
  24. Click "Browse..." to select "/opt/rk3399_risc/buildroot/output/rockchip_rk3399/host/aarch64-buildroot-linux-gnu/sysroot" as sysroot
  25. Click Apply
    RTENOTITLE
  26. Click OK to finalize the configuration.
  27. Invoke the options dialog again to make sure the "iMX6 toolchain" is default kit.

Creating the Project

  1. Bring up "New" dailog using "File" -> "New File or Project..."
  2. Select "Applications" -> 'Qt Widgets Application"
  3. Click "Choose..."
    RTENOTITLE
  4. Use "Hello" as name
  5. Create in "/mnt/sda1/work/qt/qt_PJ"
  6. Click "Next"
    RK3399 Qt Project local.png
  7. Check "RK toolchain"
  8. Click "Next".
    RK3399 Qt Project toolchain.png
  9. Use default settings for "Class Information"
  10. Click "Next"
    RK3399 QT Project last.png
  11. Use default settings for "Project Management"
  12. Click "Finish"
    RK3399 Qt Project last2.png
  13. Double click "Hello.pro" to switch to editor window
  14. In new project it is necessary to add following two lines into qt project file.
    target.path = .
    INSTALLS += target
    RK3399 Qt Project code002.png
  15. Press "Ctrl+S" to save file.
  16. Double click "mainwindow.ui" to switch to Design mode
  17. Drag & drop one Label widget on main form, use property editor on the right side to change text and font size
    RTENOTITLE
    RK3399 Qt Project code003.png
  18. Save all project files using "File" -> "Save All"

Building the Project

  1. Switch to "Projects" mode
  2. Check if "build configuration" is set to "Debug".
    RK3399 Qt debug setting.png
  3. Check if "Files to deploy" is correct
    RK3399 Qt run setting.png
  4. Switch to "Edit" mode
  5. Click "Build" using context menu of project "Hello"
    RK3399 Qt build start.png
  6. The green "Build" bar means no error occured.
    RK3399 Qt build status.png
  7. Press "Alt+4" to show "Compile Output".
    RK3399 Qt build output.png

Deploying the Application

  1. Click "Deploy" using context menu of project Hello
    RK3399 Qt deploy start.PNG
  2. The green "Deploy" bar indicates no error occured.
    RK3399 Qt deploy output.png

Debugging the Application

  1. Click debug icon to start debugging.
    RK3399 Qt debug start.png
  2. Press "Alt+3" to show "Application Output"
    RK3399 Qt debug output.png
  3. The "Hello" shows up on primary display.
    RK3399 Qt result show.png
  4. Click "stop" to stop debugging.
    RK3399 Qt debug stop.png
  5. The deafult desktop returns back.
    RK3399 Qt default Desktop.png