qwertyuiopzxcvbnm
Posts: 13
Joined: Fri May 01, 2015 7:23 pm

Bare-metal SPI Display using GPU

Thu Nov 05, 2015 9:54 pm

I am interested in using an SPI Display with the Rasperry Pi in assembly(such as the PITFT from Adafruit). I think I could work out how to get it working using the CPU, but is there a way of getting the GPU to output screen data over SPI? And what would this involve?

ghans
Posts: 7438
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: Bare-metal SPI Display using GPU

Fri Nov 06, 2015 7:33 am

What do you expect from involving the GPU ? Do you need 3D acceleration ?

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

qwertyuiopzxcvbnm
Posts: 13
Joined: Fri May 01, 2015 7:23 pm

Re: Bare-metal SPI Display using GPU

Fri Nov 06, 2015 7:56 am

I would want to use the GPU to free up power on the CPU for processing. I was under the impression that it would take up quite a bit of CPU time to run the screen off it. Am I wrong in thinking that? Would the CPU still be able to carry out processor intensive tasks without much loss of speed?
And to answer your question, no, I'm not planning on using 3D graphics.

ghans
Posts: 7438
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: Bare-metal SPI Display using GPU

Fri Nov 06, 2015 9:17 am

I think you will be fine . If Linux and fbtft managed it with around 50 17 % CPU usage on the single-core models , so should you.
Getting the GPU involved will complicate things extremely.

ghans
Last edited by ghans on Tue Dec 12, 2017 8:31 am, edited 1 time in total.
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

User avatar
ab1jx
Posts: 403
Joined: Thu Sep 26, 2013 1:54 pm
Location: Heath, MA USA
Contact: Website

Re: Bare-metal SPI Display using GPU

Sat Sep 30, 2017 3:24 pm

I was looking for a way to do exactly the same thing. On a single core Zero Adafruit's userspace tftcp uses about 17% CPU. The only workaround I see is that whatever you write to the tft stays there until you write something else so it doesn't need continuous updates, certainly not 30 times per second.

LdB
Posts: 582
Joined: Wed Dec 07, 2016 2:29 pm

Re: Bare-metal SPI Display using GPU

Sat Sep 30, 2017 4:23 pm

Eric is already working on the SPI to bring it under the MESA driver so it becomes accelerated. His blog has the video of his talk about displays.

Around 1:57:45
https://www.youtube.com/watch?v=F3uRpOI ... Mby&t=6447

So watch that space he is likely to do something going forward.

User avatar
ab1jx
Posts: 403
Joined: Thu Sep 26, 2013 1:54 pm
Location: Heath, MA USA
Contact: Website

Re: Bare-metal SPI Display using GPU

Sun Oct 01, 2017 3:05 am

Actually after some Googling for ILI9341 commands it seems these are quite common, sold by several companies. You can find the bare display on Aliexpress for about $12 delivered (possibly without the touch part). Adafruit did some valid work on them, they sell them for Arduinos too. So it's good to buy at least 1 from Adafruit but if I get this working the way I want I'll probably pick up a few more through Aliexpress. There's now an spidev Linux kernel driver.

There is mention that the display also has an 18 bit color mode, 6 each for rgb. Not sure if it's worth using but I never liked rgb565 or whatever. There's a ton of documentation out there. Some of the ILI9341 commands used in the Adafruit code I can't find documented as to what they do.

Can the GPU access the GPIO? I would think that could be a bottleneck since the SPI is really a few pins of the GPIO. If the CPU has to relay everything that doesn't sound like much of a speedup.

User avatar
bitbank
Posts: 214
Joined: Sat Nov 07, 2015 8:01 am
Location: Sarasota, Florida
Contact: Website

Re: Bare-metal SPI Display using GPU

Sun Oct 01, 2017 4:02 pm

The fbtft and fbcp programs are generalized to work with any program which outputs to a framebuffer and translate that into a reasonable way to talk to an SPI connected LCD. The performance hit is because fbcp constantly copies the entire framebuffer to the virtual framebuffer created by fbtft (even if nothing changes on the display). This is very wasteful if your code can specify when and where you want to draw on the display. I wrote a simpler and faster way to access SPI LCD displays (https://github.com/bitbank2/SPI_LCD). It requires your code to explicitly call functions to draw text, pixels and bitmaps. If your app doesn't need to do frequent updates to the display, you'll use very little CPU. This task doesn't make any sense for a GPU to do.
The fastest code is none at all :)

User avatar
Ultibo
Posts: 98
Joined: Wed Sep 30, 2015 10:29 am
Location: Australia

Re: Bare-metal SPI Display using GPU

Mon Oct 02, 2017 2:16 am

Given that the focus of this forum is on bare metal development and all of the solutions presented so far focus on Linux :roll: , here is an Ultibo example of rendering OpenGL ES on the GPU and outputting the result on an SPI display (HX8357 TFT LCD) completely without Linux.

https://github.com/ultibohub/Asphyre/tr ... ySPIAndGPU

This uses the Asphyre/PXL framework which has been ported to Ultibo and makes doing OpenGL ES a lot more friendly, but you could also do the same with standard GLES functions and direct access to the TFT framebuffer.

Just to show it can be done without that L word ;)
Ultibo.org | Make something amazing
https://ultibo.org

Return to “Bare metal”

Who is online

Users browsing this forum: No registered users and 5 guests