Frame buffer demo project - strange colors and garbage on the screen


I have built demo project with frame buffer and run on my Pi4 console. Got strange colors and garbage on the screen. Why and how to fix that?

Looks like it’s detecting the wrong BPP - try changing LV_COLOR_DEPTH.

I’m trying to debug this exact same thing. The 7" display is supposed to be 1024x600 but the lv_conf.h file says the max is 800x600. fset -s says mode “640x480” (which I’ve tried, same result) and 16 bits/pixel (tried that too, same result). says to take down the Raspberry Pi OS graphical interface first, which I did. This gives a single-prompt Linux system with no interference from the x-windows system. But the yellowish mess on the display shows up on both my main HDMI monitor as well as the 7" touchscreen I have on the 2nd HDMI port.

Feels like a driver issue, but a little googling says no driver is necessary. Need some new ideas here.

Hmmm. I just edited the /boot/config.txt file to comment-out the line that invokes the vc4-fkms-v3d, and now my lvgl demo works correctly on my Pi 4 “big monitor”. Nothing is showing on the 7" touchscreen. Seems like there really is a driver issue inside vcr-fkms-v3d.

Anybody know to whom I should bring this issue?

And in the “nothing’s ever easy” department, ONLY the big monitor displays correctly. I switched HDMI cables and rebooted, ran fbset -s again, got 640x480 at 32 bpp, and set lv_conf.h accordingly. 7" display is still garbage – looks like a resolution mismatch. Except for the word “Button” that displays correctly for a few seconds at the start, then disappears.

Is it command? I can’t find such one.

From the first image, it’s not a resolution issue. If it were you’d see skew lines for the edges of the boxes, or a much bigger mess.

I still believe it’s a color format issue. Could you print what is color format from the frame buffer info structs?

Without LVGL, could you also try to fill the entire fb with RED color? If you can’t do this then you really have a driver issue and the issue is outside of LVGL. (We still can help to figure it out)

If you can paint to RED it should be easy to find the issue in LVGL’s config.

This helped for my big monitor. Now picture is better:

But what is vc4-fkms-v3d and how it effects system. Is it possible to solve problem without commenting vc4-fkms-v3d?

oops, I meant fbset -s

here’s the code that produced that picture:
#include <stdio.h>
#include <linux/fb.h>
#include <unistd.h>
#include <stdlib.h>

unsigned char colours[8][4] = {
{ 0x00, 0x00, 0xFF, 0xFF }, // red
{ 0x00, 0x00, 0xFF, 0xFF }, // red
{ 0x00, 0x00, 0xFF, 0xFF }, // red
{ 0x00, 0x00, 0xFF, 0xFF }, // red
{ 0x00, 0x00, 0xFF, 0xFF }, // red
{ 0x00, 0x00, 0xFF, 0xFF }, // red
{ 0x00, 0x00, 0xFF, 0xFF }, // red
{ 0x00, 0x00, 0xFF, 0xFF }, // red

int frames[] = {0,5,10,15,20,25,30};

int columns = 640;
int lines = 480;

#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))

int frame(int c, int l){
int i;
for(i=0; i < ARRAY_SIZE(frames); i++){
// /DEBUG/ printf(“ARRAY_SIZE returns %d\n”, ARRAY_SIZE(frames));
// /DEBUG/ printf(" sizeof(s) is %d; sizeof(a[0]) is %d.\n",
// sizeof(frames), sizeof(frames[0]));
return 1;
return 1;
return 1;
return 1;
return 0;

int main(int argc, char **argv)
unsigned char pixel[3];
int l, c;
char *filename = argv[1];
FILE *f;

if (argc != 2) {
   printf("usage: sudo hw-on-fb /dev/fb0\n");
} else {
   printf ("Device : %s\n",filename);
   f = fopen(filename,"wb");

printf("Device open success \n");
    for(l=0; l<lines; l++){
        for(c=0; c < columns; c++){
                printf("frame returns nonzero\n");
                fwrite(colours[3], 1, sizeof(colours[3]), f);
                printf("frame returns zero\n");
                int colour = c/(columns/ARRAY_SIZE(colours));
                fwrite(colours[colour], 1, sizeof(colours[colour]), f);
   printf("Device open failed \n");

return 0;


lvgl demo is now working correctly on my 7" touchscreen display. I finally found the directions to properly configure it at In all, I had to (a) configure the display per adafruit’s information, (b) edit lv_conf.h to make LV_HOR_RES_MAX 800 and LV_VER_RES_MAX 480, and make LV_COLOR_DEPTH 32, and finally © edit lvgl/lv_drv_conf.h to #define USE_FBDEV 1. Then run the demo with ‘sudo ./demo’ and watch the cool animations.