Important: Please read the Qt Code of Conduct -

There is no picture in lcd

  • Hi,
    l cross compiling qt for armv7, and then write an example to test, the code below

    int main(int argc, char *argv[])
     QApplication a(argc, argv);
        MainWindow w;
    but there is no picture in lcd, l change the code below
    int main(int argc, char *argv[])
    	int fbFd = 0;
    	const char *devfile = "/dev/fb0";
    	fbFd = open(devfile, O_RDWR);
    	if (ioctl(fbFd, FBIOGET_VSCREENINFO, &vinfo) == -1) {
    		perror("Error reading variable information");
        if (fbFd == -1) {
    		perror("Error: cannot open framebuffer device");
    	if(ioctl(fbFd, FBIOPAN_DISPLAY, &vinfo)!= 0)
            return -1;
    	if(ioctl(fbFd, FBIOPAN_DISPLAY, &vinfo)!= 0)
            return -1;
        QApplication a(argc, argv);
        MainWindow w;
    	if (ioctl(fbFd, FBIOGET_VSCREENINFO, &vinfo) == -1) {
    		perror("Error reading variable information");
    	if (ioctl(fbFd, FBIOGET_FSCREENINFO, &finfo) == -1) {
    		perror("Error reading fixed information");
    	if(ioctl(fbFd, FBIOPAN_DISPLAY, &vinfo)!= 0)
            return -1;
        return a.exec();

    after compile and then download, the lcd can show picture,
    so, why we must add this code? whether there is wrong for my cross compiling?

    Edit: p3c0

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    There's not enough details:

    • What version of Qt are you using ?
    • What backend do you want to use for your application
    • What error message did you got ?
    • What hardware are you targeting ?
    • What distribution is it running ?
    • How are you starting your application on the device ?

  • @junzhang


    What is the platform plugin are you setting?
    If it is not setting, the QT_QPA_PLATFORM environment variable parameter can be used to setting or the -platform command-line can be used with the same syntax.

    Like this(for example):
    ./yourapp -platform linuxfb:fb=/dev/fb0

  • Dear Devopia53,
    how can l set my platform plugin?
    my profile is below:

    export TSLIB_ROOT=/usr/local/tslib
    export TSLIB_TSDEVICE=/dev/event0
    export TSLIB_FBDEVICE=/dev/fb0
    export TSLIB_PLUGINDIR=/usr/local/tslib/lib/ts
    export TSLIB_CONFFILE=/usr/local/tslib/etc/ts.conf
    export POINTERCAL_FILE=/etc/pointercal
    export TSLIB_CALIBFILE=/etc/pointercal
    #export QWS_SIZE=128x128
    export QWS_MOUSE_PROTO=Tslib:/dev/event0
    export QTDIR=/usr/local/qt
    export QPEDIR=/usr/local/qt
    export QWS_DISPLAY=LinuxFb:/dev/fb0
    export QT_QWS_FONTDIR=$QTDIR/lib/fonts
    export LD_LIBRARY_PATH=/usr/local/qtlib/lib:$LD_LIBRARY_PATH

  • Lifetime Qt Champion

    Using Qt 4?

  • @SGaist
    yes, qt4.8.5

  • Lifetime Qt Champion

    Did you check the permissions on the frame buffer device ?

    On a side note, if locked on Qt 4, the you should go with 4.8.7 which is the latest and last version of the Qt 4 series. Otherwise, you should go with Qt 5.

  • @SGaist
    here is my cross compile config:
    sudo ./configure --prefix=/usr/local/qt4.8.5-arm -opensource -release -shared -Declarative -importdir /opt/imports -fast -no-largefile -qt-sql-sqlite -qt3support -exceptions -xmlpatterns -no-glib -no-phonon -no-mmx -no-3dnow -no-sse -no-sse2 -svg -no-webkit -qt-zlib -qt-libtiff -qt-libpng -qt-libjpeg -make libs -make tools -nomake examples -nomake docs -nomake demo -no-nis -no-cups -iconv -no-dbus -xplatform qws/linux-arm-g++ -embedded arm -little-endian -qt-freetype -depths 16,24,32 -qt-gfx-linuxfb -qt-gfx-transformed -qt-gfx-multiscreen -no-gfx-vnc -no-gfx-qvfb -qt-kbd-linuxinput -no-kbd-qvfb -armfpa -no-mouse-qvfb -qt-mouse-linuxtp -qt-mouse-tslib -DQT_QLOCALE_USES_FCVT -DQT_NO_QWS_CURSOR -no-pch -I/usr/local/tslib/include -L/usr/local/tslib/lib -confirm-license

  • Lifetime Qt Champion

    That doesn't answer my question about the permissions of /dev/fb0 on your target.

    On a side note, never develop nor build as root. If something goes wrong there's no restriction at what can be destroyed on your system.

  • @SGaist
    / # ls /dev/fb0 -l
    crw-rw---- 1 root root 29, 0 Jan 1 00:00 /dev/fb0

    when l use Qt/qt/qt-everywhere-opensource-src-4.8.5/examples/qws/framebuffer to test, it's ok,
    your mean it's maybe to compile use "sudo"?
    l will re-compile it with no "sudo".

  • Lifetime Qt Champion

    How are you calling your application on the command line ?

  • @SGaist
    ./test_demo -qws

  • @SGaist
    l use normal user to cross compile qt5.7.0, it's still unshow anything unless l add "ioctl(fbFd, FBIOGET_FSCREENINFO, &finfo)".and it just to show one frame,
    my cross compile steps is below:

    1. download tslib1.4.tar.gz$ ./
      $ tar zxvf tslib1.4.tar.gz
      $ ./configure CC=arm-none-linux-gnueabihf-gcc CXX=arm-none-linux-gnueabihf-g++ --prefix=/usr/local/tslib --host=arm-none-linux-gnueabihf ac_cv_func_malloc_0_nonnull=yes
      $sudo make install

    2. download qt-everywhere-opensource-src-5.7.0.tar.gz
      2.1: tar zxvf qt-everywhere-opensource-src-5.7.0.tar.gz
      2.2: vim qt-everywhere-opensource-src-5.7.0/qtbase/mkspecs/linux-arm-gnueabi-g++/qmake.conf

      + QT_QPA_DEFAULT_PLATFORM = linux #eglfs 
      +QMAKE_CFLAGS_RELEASE += -O2 -march=armv7-a
      + QMAKE_CXXFLAGS_RELEASE += -O2 -march=armv7-a

      arm-linux-geneabi-xxx change to arm-none-linux-geneabi-xxx
      2.3: vim

      -prefix /opt/qt5.7.0
      -make libs
      -xplatform linux-arm-gnueabi-g++
      -skip qt3d
      -skip qtcanvas3d
      -skip qtpurchasing
      -nomake examples
      -nomake tools
      -skip qtvirtualkeyboard

      2.4: ./
      2.5: make
      2.6: sudo make install

    3. tar /usr/local/tslib and /opt/qt5.7.0

    4. for arm platform
      4.1: cp qt5.7.0.tar.gz and tslib.tar.gz to /opt
      4.2: tar zxvf qt5.7.0.tar.gz and tar zxvf tslib.tar.gz
      4.3: vim /etc/profile
      #add for qt
      export TSLIB_ROOT=/opt/tslib
      export QT_ROOT=/opt/qt5.7.0
      export TSLIB_TSDEVICE=/dev/input/event0
      export TSLIB_TSEVENTTYPE=input
      export TSLIB_CONFFILE=/opt/tslib/etc/ts.conf
      export TSLIB_CALIBFILE=/etc/pointercal
      export TSLIB_PLUGINDIR=/opt/tslib/lib/ts
      export TSLIB_CONSOLEDEVICE=none
      export TSLIB_FBDEVICE=/dev/fb0
      export QWS_MOUSE_PROTO=tslib:/dev/input/event0
      export LD_LIBRARY_PATH=/lib:/usr/lib:$QT_ROOT/lib:$TSLIB_ROOT/lib:$TSLIB_ROOT/lib/
      export QT_QPA_PLATFORM=linuxfb:tty=/dev/fb0
      export QT_QPA_FONTDIR=$QT_ROOT/lib/fonts
      export QT_QPA_GENERIC_PLUGINS=tslib
      4.4: source /etc/profile
      4.5: cd /opt/tslib/bin and then run ./ts_calibrate
      4.6: write an test example
      adb push test_qt /home/demo
      4.6: cd /home/demo and then ./test_qt

    after l run ./test_qt, there is nothing in lcd,so l write test framebuffer code to test fb driver, it's show ok,
    but if l add "ioctl(fbFd, FBIOPAN_DISPLAY, &vinfo)" in test_qt demo, it's show ok, but it just show one frame, unable to self-refresh,

    for step 4.5 and 4.6, l use another method to test, but there is still nothing in lcd.
    4.5: ./ts_calibrate -qws
    4.6: ./test_qt -qws

    note: there is no touch screen in my whole steps.

  • Lifetime Qt Champion

    What OS are you running on your target ?

  • @SGaist
    / # uname -a
    uname -a
    Linux mdm9607 3.18.20 #1 PREEMPT Mon Feb 13 10:40:15 CST 2017 armv7l GNU/Linux
    / #

  • Lifetime Qt Champion

    The distribution would be more useful.

    Also, are you running your application as root ?

    What exact message are you getting on the console when you launch the application ?

  • @SGaist
    yes, we run an application with root access.
    we test with Qt/examples/qws/framebuffer, the message is below:

    root@mdm9607:/home# ./framebuffer
    The framebuffer device was opened successfully.

    Fixed screen info:
    id: mdssfb_20000
    smem_start: 0x8fc80000
    smem_len: 155648
    type: 0
    type_aux: 0
    visual: 2
    xpanstep: 1
    ypanstep: 1
    ywrapstep: 0
    line_length: 480
    mmio_start: 0x0
    mmio_len: 0
    accel: 0

    The framebuffer device was mapped to memory successfully.

    Successfully switched to graphics mode.

    Variable screen info:
    xres: 240
    yres: 320
    xres_virtual: 240
    yres_virtual: 320
    yoffset: 0
    xoffset: 0
    bits_per_pixel: 16
    grayscale: 0
    red: offset: 11, length: 5, msb_right: 0
    green: offset: 5, length: 6, msb_right: 0
    blue: offset: 0, length: 5, msb_right: 0
    transp: offset: 0, length: 0, msb_right: 0
    nonstd: 0
    activate: 16
    height: -1
    width: -1
    accel_flags: 0x0
    pixclock: 0
    left_margin: 0
    right_margin: 0
    upper_margin: 0
    lower_margin: 0
    hsync_len: 0
    vsync_len: 0
    sync: 0
    vmode: 0

    Frame Buffer Performance test...
    Average: 395 usecs
    Bandwidth: 375.791 MByte/Sec
    Max. FPS: 2531.646 fps

    Will draw 3 rectangles on the screen,
    they should be colored red, green and blue (in that order).

    l change the Qt/examples/qws/framebuffer/main.c
    void drawRect_rgb16(int x0, int y0, int width, int height, int color)
    const int bytesPerPixel = 2;
    const int stride = finfo.line_length / bytesPerPixel;
    const int red = (color & 0xff0000) >> (16 + 3);
    const int green = (color & 0xff00) >> (8 + 2);
    const int blue = (color & 0xff) >> 3;
    const short color16 = blue | (green << 5) | (red << (5 + 6));

    short *dest = (short*)(frameBuffer)
    	  + (y0 + vinfo.yoffset) * stride
    	  + (x0 + vinfo.xoffset);
    int x, y;
    for (y = 0; y < height; ++y) {
        for (x = 0; x < width; ++x) {
            dest[x] = color16;
        dest += stride;
    }//add by junzhang
    if(ioctl(fbFd, FBIOPAN_DISPLAY, &vinfo)!= 0)
        return -1;

    there is nothing in lcd unless l add that code when l test with framebuffer example, the message is the same whether l add that code or not.

  • @SGaist
    l want to add
    if(ioctl(fbFd, FBIOPAN_DISPLAY, &vinfo)!= 0)
    return -1;
    to the code which update framebuffer in Qt,
    it's mean that if something update in Qt, it will be write data to framebuffer, so, i will add that code in the function which update framebuffer.
    it's that ok?
    if ok, pls tell which function update framebuffer. thx.

  • Lifetime Qt Champion

    You likely should check the QLinuxFbScreen class.

  • @SGaist
    thx, l found it and it's show ok.

  • Lifetime Qt Champion

    Do you mean by adding you ioctl code ?

  • @SGaist
    yes, l add inctl to refresh data to lcd.

  • Lifetime Qt Champion


    Then please mark the thread as solved using the "Topic Tools" button so that other forum users may know a solution has been found :)

Log in to reply