I run X in this way

/usr/bin/X vt07 -retro

to have the GUI on console 7 and the gray grid as background.

On console 1 I write

while [ 1 ] ; do cat /dev/random > /dev/fb0; done

and I see the random colored pixel on screen; I can switch over all console and see the same, but when I switch on console 7, where the XServer is active, I see the same gray grid.

How can I see what I write on /dev/fb0 in the console where X is active?

If I use fbdev driver in xorg.conf I can see the random pixel also on the GUI console, but I need to use amdgpu or radeon. Are there some X options, kernel params, module params that I have to change to write over X?

I have to run a user interface program that needs X and programs that draw in predetermined areas at the same time. With kernel 3.9.6, X Server 1.14.4, and fglrx video driver these programs run and use the typical system

        fbfd = open("/dev/fb0", O_RDWR);
        if (fbfd == -1)
                perror("Error: cannot open framebuffer device");
        // Get fixed screen information
        if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo) == -1)
                perror("Error reading fixed information");
        // Get variable screen information
        if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo) == -1)
                perror("Error reading variable information");
        // Map the device to memory
        fbp = (char *) mmap(0, vinfo.yres * vinfo.pitch, PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, 0);

Now that I had to upgrade to kernel 5.11.21, X Server 1.20.11 and amdgpu driver, these programs do not draw on the console where the interface runs. I need a pointer to a buffer where I can write to draw, if it is impossible to modify the system to be able to write then I need a function that returns me a pointer where I can write via X or some other way to be able to draw freely.

  • I've updated the post with more information of what I need Jun 10, 2021 at 13:22

1 Answer 1


You cannot. In hw/xfree86/os-support/linux/lnx_init.c you will find xf86OpenConsole() which sets VT_PROCESS and KD_GRAPHICS, so you will have to go through the X server for writes while that VT is active. It happens to work with fbdev(4) because in this case you're writing directly to the same device "underneath" that's also written to by the X driver. Otherwise you'll need to talk to the X server which is probably drawing using DRI (/dev/dri/card0) via the Kernel Modesetting or card-specific driver (Intel, Radeon, etc) and has exclusive access to the hardware.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.