Raspi: Can't write to framebuffer?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
TyrelHaveman
Member
Member
Posts: 40
Joined: Thu Sep 20, 2007 11:20 pm
Location: Bellingham, WA
Contact:

Raspi: Can't write to framebuffer?

Post by TyrelHaveman »

Hey again guys,

I've been running into some bumps trying to write an OS for Raspberry Pi. Note I'm using (and thus writing for) a Pi 2 Model B, in case that matters.

I've started communicating with the GPU via the "mailbox" and I can get it to send me an address for a framebuffer. When I do so, the screen goes blank (previously showing the rainbow thing). So things SEEM to work okay. But...

I can't write any pixels to it.

In one example, I have requested a 640x480x32-bit frame buffer, and I was given one by the GPU of the appropriate size, pitch, etc, at address 0xFDACE000.

So I start writing some pixels within the region right after 0xFDACE00. But it doesn't work. I see nothing on the monitor and if I read back that memory address, I always get zero. This is from my serial log:

Code: Select all

[INFO:Framebuffer]: Initialized 1228800-byte framebuffer at 640x480x32bpp (pitch 2560) at FDACE000. Virtual offset is 0.
[INFO:Framebuffer]: Setting pixel (100,100) at 0xFDB0C990 to (255, 0, 255)
[WARNING:KernelMain]: Unable to set pixel, value was 0x0
[INFO:Framebuffer]: Setting pixel (101,100) at 0xFDB0C994 to (255, 0, 255)
[WARNING:KernelMain]: Unable to set pixel, value was 0x0
[INFO:Framebuffer]: Setting pixel (102,100) at 0xFDB0C998 to (255, 0, 255)
[WARNING:KernelMain]: Unable to set pixel, value was 0x0
I've double-checked that the addresses I'm writing the pixels to are correct (you can do the calculations of the pixels shown in my log to see).

Why isn't it letting me change the pixels? This has been driving me crazy for a week.

Code for framebuffer is here: framebuffer.cpp

Code that is calling it to set pixels is here: kernel.cpp (Line 113)

Thanks for any help you can provide.
User avatar
mark3094
Member
Member
Posts: 164
Joined: Mon Feb 14, 2011 10:32 pm
Location: Australia
Contact:

Re: Raspi: Can't write to framebuffer?

Post by mark3094 »

I have attached an archive of old code that I was playing with a few years ago, for the RPi Model B. I was able to get the FrameBuffer working and displaying text (or rather, drawing characters).
Hopefully some of the code in there will be useful, but it may be different on the RPi-2.

I stopped working with the Raspberry Pi (in favour of x86) as there were parts that were 'closed-source' at the time. Most notably, it was very difficult to write USB drivers for it.
Attachments
RPi Framebuffer.rar
(7.36 KiB) Downloaded 31 times
Post Reply