Raspberry Pi with fbtft enabled

Hi all

I’m trying to get a small Adafruit 1.5" 128x128 OLED to run as a second display (to show playback details, channel tuned in PVR etc.). I’ve got it running in Raspbian with a stock Pi Foundation kernel (which includes fbtft support) but the OSMC kernel doesn’t seem to include fbtft support? Is there a simple way I can add this?

Hi Steve

Is the FBTFT module merged in Raspbian’s kernel? I know it’s been an out of tree module for some years.

If you can confirm what kernel you are using on Raspbian (output of uname -a) I am sure we can get this included


Thanks Sam

Yes - current stock Raspbian “2018-06-27-raspbian-stretch” includes it.

A “sudo modprobe fbtft_device name=pioled” works fine with no additional code added. I think there was a change to the way Linux handled video output that meant the fbtft approach was unlikely to be a long-term solution so it was moved to staging?

However it’s still very useful - and because so many portable game solutions use little TFT/OLED screens driven by SPI using fbtft (and fbcpy) I guess the Raspbian team continue to include it?

Output of uname -a :

“Linux raspberrypi 4.14.52-v7+ #1123 SMP Wed Jun 27 17:35:49 BST 2018 armv7l GNU/Linux”

There are a couple of Kodi addons that use SDL and pygame to drive neat little status displays using fbtft as a way of talking to SPI ‘second displays’.

Hi Steve,

This should be added now. As the standard boiler plate goes:

  1. Login via the command line
  2. Edit the file /etc/apt/sources.list
  3. Add the following line: deb http://apt.osmc.tv stretch-devel main
  4. Run the following commands to update: sudo apt-get update && sudo apt-get dist-upgrade && reboot
  5. Your system should have have received the update.

Please see if the issue is resolved.

I also recommend you edit /etc/apt/sources.list again and remove the line that you added after updating. This will return you to the normal update channel.



1 Like

Thanks Sam - will try it and get back to you.

1 Like

Sam - followed your instructions but get the same error.

sudo modprobe fbtft_device name=pioled
modprobe: ERROR: could not insert 'fbtft_device': Invalid argument

uname -a returns
Linux osmc 4.14.34-3-osmc #1 SMP PREEMPT Mon Jul 16 02:39:26 UTC 2018 armv7l GNU/Linux


Sam - it works thanks and the pioled can be enabled with fbtft support at boot.

Unfortunately the add-on I want to use GitHub - vitalogy/script.kodisplay is proving tricky - it requires SDL and pygame. Have got about 98% of the way there but it fails. There is a fault installing pygame but it completes.


13:00:20.580 T:1687155456   ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <class 'pygame.error'>
                                            Error Contents: Unable to open a console terminal
                                            Traceback (most recent call last):
                                              File "/home/osmc/.kodi/addons/script.kodisplay/kodisplay.py", line 202, in <module>
                                              File "/home/osmc/.kodi/addons/script.kodisplay/kodisplay.py", line 101, in __init__
                                            error: Unable to open a console terminal
                                            -->End of Python script error report<--
13:00:20.585 T:1925474816   DEBUG: ------ Window Init (DialogNotification.xml) ------
13:00:20.677 T:1687155456    INFO: Python script stopped

It runs fine in stock raspbian - but I’ve hit the limit of my abilities…

Suspect I’ll have to use a second Pi and KodiDisplayInfo to remotely connect instead.

(The aim is to have a neat small OLED or TFT screen that shows Kodi status separate to the main video output. Tuned Live TV channel, File playing etc. Kodisplay is much neater and better implemented than Kodi Display Info, but the latter runs over http whereas the former needs to run on the same box I think)

Hi Steve,

I wonder if stopping Kodi (sudo systemctl stop mediacenter) lets you start PyGame on the screen from the command line.

I would also check permissions on /dev/fb1. chown osmc:osmc on /dev/fb1 might be all that’s needed for this to work; but it’s unclear if PyGame is trying to open /dev/fb1 (presumably your fbtft display) or trying to open /dev/fb0.


Thanks Sam will give that a go. In the Add on config I’ve set the fbtft as/dev/ fb1

If you run ls -l on /dev/fb0 and /dev/fb1 respectively, there will probably be different permissions.
Do let me know if this is the case. We probably want to adjust our udev rules to handle this properly.


I’m actually not clear how I start a Kodi add-on from the command line… The add-on needs pygame but I don’t know how to test it outside of Kodi.


osmc@osmc:~$ sudo systemctl stop mediacenter
osmc@osmc:~$ ls -l /dev/fb0
crw-rw---- 1 root video 29, 0 Jul 17 13:14 /dev/fb0
osmc@osmc:~$ ls -l /dev/fb1
crw-rw---- 1 root video 29, 1 Jul 17 13:14 /dev/fb1

They look to have the same permissions?

They do indeed, so that doesn’t seem to be the issue.

Try this demo here:

Stop Kodi: sudo systemctl stop mediacenter

Run: python modified_012_text.py (not tested, but should work).
If you get the same error, output of strace python modified_012_text.py | paste-log would be interesting.


I get :

osmc@osmc:~$ python modified_012_text.py
Traceback (most recent call last):
  File "modified_012_text.py", line 86, in <module>
  File "modified_012_text.py", line 41, in flytext
    screen = pygame.display.set_mode((320,240))
pygame.error: Unable to open a console terminal 

Ah - stderr isn’t being captured with your command line options - I did something different to capture stderr rather than stdout

https://paste.osmc.tv/zaweqiritu is a better log

There’s a lot of it - I wonder if I haven’t installed pygame properly?

open("/dev/tty", O_RDWR)                = 5
ioctl(5, VT_GETSTATE, 0x7ea4cf88)       = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(5, KDGKBMODE, 0x7ea4cf88)         = -1 ENOTTY (Inappropriate ioctl for device)

That’s odd.

I think that could be the problem. These ioctls are trying to get keyboard inputs associated with the TTY, but I’m not sure that should be happening at all when (presumably) doing this via SSH.

From: Re: [pygame] How to prevent mouse initialization in Pygame

FB_OpenKeyboard in SDL_fbevents[1] is called unconditionally during
Framebuffer video initialization.[2] You can see there that most of
the logic to find a keyboard device is guarded by a check that
geteuid() == 0. (I.e. that the user is root.) The only fallback for
when not root is to try to open /dev/tty. If it fails to find a
keyboard device it can use it aborts. I hope that helps back up what
has been gleaned from the strace and maybe gives some clues.

This might help: python - Pygame headless setup - Stack Overflow and tell Pygame to stop trying to incorrectly set up the TTY.


Hmm - odd. I’ve tried a couple of changes in the test python code incorporating the suggestions made in the links and they don’t seem to help.

Also Kodisplay errors on startup in Kodi - as per previous log - which isn’t related to SSH?

Odd that it runs in Kodi under Raspbian OK - though pygame was already installed in Raspbian - and I was running with different users as well I guess?

Correct – it’s also strange that it doesn’t work in Kodi.
Did you install via pip? Might be worth checking the Raspbian version versus what you’ve installed under OSMC.

Did you try running PyGame (with Kodi stopped) as root (sudo)?


Kodisplay is a Kodi add-on - so I installed via the Zip installer option within Kodi Add-ons.

I installed pygame and its various dependencies via a couple of routes - and not convinced it’s 100% healthy.

sudo python modified_012_text.py gives me identical errors


There was a hard-coded resolution in modified_012_text.py that was larger than my display and thus gave an error because it couldn’t open a screen the right size even when I ran as root…

With sudo python modified_012.text.py it runs and I get text on my display, without sudo I get pygame.error: Unable to open a console terminal

This is a root permissions thing isn’t it? I wonder if my raspbian account has root and therefore doesn’t give the console output issue?

Possibly. Maybe osmc user needs to be in tty group?

Could try sudo chmod 777 /dev/tty* temporarily