I’m trying to work with framebuffer on Jetson Nano.
I have written following C-program:
#include <linux/fb.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <unistd.h> // For close
#include <sys/mman.h> // For mmap
#include <string.h> // For memset
#define FBDEV "/dev/fb0"
int main() {
int fbfd= open(FBDEV, O_RDWR);
if (fbfd < 0) {
printf("Error in opening FrameBuffer: %d\n", fbfd);
exit(fbfd);
}
struct fb_var_screeninfo vinfo;
ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo);
int fb_width= vinfo.xres;
int fb_height= vinfo.yres;
int fb_bpp= vinfo.bits_per_pixel;
int fb_bytes= fb_bpp / 8;
int fb_data_size= fb_width * fb_height * fb_bytes;
char *fbdata= mmap(0, fb_data_size,
PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, (off_t)0);
memset(fbdata, 0, fb_data_size);
for (int offset=0; offset < fb_data_size; offset= offset + 4) {
fbdata[offset + 0]= 125;
fbdata[offset + 1]= 125;
fbdata[offset + 2]= 0;
fbdata[offset + 3]= 0;
}
munmap(fbdata, fb_data_size);
close(fbfd);
printf("Width: %d\n", fb_width);
printf("Height: %d\n", fb_height);
printf("BPP: %d\n", fb_bpp);
printf("Bytes: %d\n", fb_bytes);
}
Compile it with gcc main.c
. And this program works fine! The color of the screen is changing.
Now, I’m trying to do a Qt program. I have written a simple programm:
pod@rover:~/Projects/RotateFB$ cat main.cpp
#include <QApplication>
#include <QWidget>
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
QWidget window;
window.resize(320, 240);
window.setWindowTitle("Simple Window");
window.show();
return app.exec();
}
And a pro-file:
pod@rover:~/Projects/RotateFB$ cat RotateFB.pro
######################################################################
# Automatically generated by qmake (3.1) Mon Mar 24 12:53:39 2025
######################################################################
TEMPLATE = app
TARGET = RotateFB
INCLUDEPATH += .
QT += widgets
# The following define makes your compiler warn you if you use any
# feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
# Input
SOURCES += main.cpp
Building: qmake
and make
.
In regular X-session program works fine. But I fail to run it in framebuffer. I’m trying to do:
pod@rover:~/Projects/RotateFB$ ./RotateFB -platform linuxfb
QPainter::begin: Paint device returned engine == 0, type: 3
QPainter::setCompositionMode: Painter not active
QPainter::begin: Paint device returned engine == 0, type: 3
QPainter::setCompositionMode: Painter not active
QPainter::setCompositionMode: Painter not active
QPainter::setCompositionMode: Painter not active
But nothing happens.
I need some advice. How can I run Qt program on Jetson Nano framebuffer?