when directly use the frame buffer interface to control the fb0, it display noting. why ?

#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/fb.h>
#include <sys/mman.h>
#include “local_timer.h”

int main(int argc, char *argv)
int fp = 0;
struct fb_var_screeninfo vinfo;
struct fb_fix_screeninfo finfo;
long screensize = 0;
char *fbp = 0;
int x = 0, y = 0;
long location = 0;
fp = open("/dev/fb0", O_RDWR);

if (fp < 0){
	printf("Error : Can not open framebuffer device/n");

if (ioctl(fp, FBIOGET_FSCREENINFO, &finfo)){
	printf("Error reading fixed information/n");

if (ioctl(fp, FBIOGET_VSCREENINFO, &vinfo)){
	printf("Error reading variable information/n");

screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;

fbp = (char *)mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fp, 0);
if (fbp == (char *)-1) {
	printf("Error: failed to map framebuffer device to memory./n");

for(int k = 0; k < 10000; k++)
for (x = 100; x < 150; x++) {
	for (y = 100; y < 150; y++) {
		location = x * (vinfo.bits_per_pixel / 8) + y  *  finfo.line_length;

#if 1
* (fbp + location) = 255;
*(fbp + location + 1) = 0;
*(fbp + location + 2) = 0;
*(fbp + location + 3) = 0;
*(fbp + location) = 0;
*(fbp + location + 1) = 0x1f;
munmap(fbp, screensize);
return 0;

It may be because ubuntu desktop is taking hold of fb0.
After text boot via below commands, I can access it.

sudo systemctl set-default multi-user.target

sudo reboot

Note that if you want to add an entry into serial console boot menu (extlinux.conf) that you can add this to the end of the APPEND key/value pair to select text-mode only for just that boot entry (then you won’t have to set default back to graphical.target):


tanks a lots, I will try it

it works, display image with shocking speed than x11 environment. tanks to linuxdev and vickyy

I had suffered from the same problem and did the same things as mentioned(the same code#1 the same configs #2 #3).But it did not work.my bsp version is R24.2.1.
“Chenghaibo”,would you tell me which version do you make?
"vickyy ", should it be the version-problem ?Please refer to

R24.2.1 seems to have an incorrect systemd or X config which respawns X after going to multi-user.target (multi-user.target should never spawn X). There was a post here which shows how to manually disable X:

I don’t know if it will help, but you may want to test in text mode (X not running) and see what changes.