pygame displaying on /dev/fb0

I have a ili9341 2.4" TFT display wired to SP1 on my BeagleBone Black and it’s working fine when I run fbi to display images, or mplayer to play movies.

I’m unable to get pygame to display on it. I’m trying to get my clock.py[1] to work and all I get is:

pygame 1.9.4.post1
Hello from the pygame community. https://www.pygame.org/contribute.html
Driver: fbcon failed.
Driver: directfb failed.
Driver: svgalib failed.
Traceback (most recent call last):
File “./clock.py”, line 142, in
clock = pyclock()
File “./clock.py”, line 38, in init
raise Exception(‘No suitable video driver found!’)
Exception: No suitable video driver found!

/opt/scripts/tools/version.sh is here[2]. There are no messages in dmesg.

This worked a couple of years ago. Any ideas how to get this pup running again?

—Mark

[1] https://github.com/MarkAYoder/BeagleBoard-exercises/blob/master/displays/ili9341/fb/pygame/clock.py

[2]

git:/opt/scripts/:[ef16ffa8c27225005cc2b2c974a83da3dee6c1ef]
eeprom:[A335BNLT0A5A1513BBBK3586]
model:[TI_AM335x_BeagleBone_Black]
dogtag:[BeagleBoard.org Debian Buster IoT Image 2020-08-31]
bootloader:[microSD-(push-button)]:[/dev/mmcblk0]:[U-Boot 2019.04-00002-gc9b3922522]:[location: dd MBR]
UBOOT: Booted Device-Tree:[am335x-boneblack-uboot-univ.dts]
UBOOT: Loaded Overlay:[AM335X-PRU-RPROC-4-19-TI-00A0]
UBOOT: Loaded Overlay:[BB-ADC-00A0]
UBOOT: Loaded Overlay:[BB-BONE-eMMC1-01-00A0]
kernel:[4.19.94-ti-r50]
nodejs:[v10.21.0]
/boot/uEnv.txt Settings:
uboot_overlay_options:[enable_uboot_overlays=1]
uboot_overlay_options:[disable_uboot_overlay_video=1]
uboot_overlay_options:[uboot_overlay_pru=AM335X-PRU-RPROC-4-19-TI-00A0.dtbo]
uboot_overlay_options:[enable_uboot_cape_universal=1]
pkg check: to individually upgrade run: [sudo apt install --only-upgrade ]
pkg:[bb-cape-overlays]:[4.14.20200814.0-0~buster+20200814]
pkg:[bb-wl18xx-firmware]:[1.20200813.1-0~buster+20200813]
pkg:[kmod]:[26-1]
pkg:[librobotcontrol]:[1.0.5-git20200715.0-0~buster+20200716]
pkg:[firmware-ti-connectivity]:[20190717-2rcnee1~buster+20200305]
groups:[debian : debian adm tty kmem dialout cdrom floppy audio dip video plugdev users systemd-journal input bluetooth netdev i2c gpio admin spi iio docker tisdk weston-launch xenomai cloud9ide pwm eqep remoteproc]
cmdline:[console=ttyO0,115200n8 bone_capemgr.uboot_capemgr_enabled=1 root=/dev/mmcblk0p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 lpj=1990656 rng_core.default_quality=100 quiet]
dmesg | grep remote
[ 67.629755] remoteproc remoteproc0: wkup_m3 is available
[ 67.697686] remoteproc remoteproc0: powering up wkup_m3
[ 67.697720] remoteproc remoteproc0: Booting fw image am335x-pm-firmware.elf, size 217168
[ 67.697999] remoteproc remoteproc0: remote processor wkup_m3 is now up
[ 69.600373] remoteproc remoteproc1: 4a334000.pru is available
[ 69.602641] remoteproc remoteproc2: 4a338000.pru is available
dmesg | grep pru
[ 69.600373] remoteproc remoteproc1: 4a334000.pru is available
[ 69.600538] pru-rproc 4a334000.pru: PRU rproc node pru@4a334000 probed successfully
[ 69.602641] remoteproc remoteproc2: 4a338000.pru is available
[ 69.602818] pru-rproc 4a338000.pru: PRU rproc node pru@4a338000 probed successfully
dmesg | grep pinctrl-single
[ 0.925809] pinctrl-single 44e10800.pinmux: 142 pins, size 568
dmesg | grep gpio-of-helper
[ 0.939434] gpio-of-helper ocp:cape-universal: ready
lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
END

I'd expect it to use fbcon..

But why didn't it pick it up...

Regards,

Yup, I think before it would grap fbcon, but not now.

–Mark

Are you running it as sudo?

https://learn.adafruit.com/pi-video-output-using-pygame/pointing-pygame-to-the-framebuffer

Jon

Yes, I’ve tried it with and without sudo. Same results.

–Mark

Have you checked the output of the following command?

“**fbset -i -fb /dev/**fb0

Have you tried to force the video driver to fbcon as an environment variable such as:
SDL_VIDEODRIVER="fbcon"

I suppose you could try to force it in your pygame code as such:
os.putenv(‘SDL_VIDEODRIVER’, ‘fbcon’)

Cheers,

Jon

Was it with v4.14.x before? i wonder if the new tinydrm driver in
v4.19.x is causing a fun issue?

Regards,

I tried the 4.14 and 5.6 kernels, but no luck.

–Mark

Have you tried running it as root? Not ‘sudo’ but su to root and try it there. It could still be a permission issue.

Cheers,

Jon

Just a thought, is your user part of the ‘video’ group? I would suspect it is since you were able to run the fbi stuff but it wouldn’t hurt to check.

Cheer,

Jon

su gives the same results.

Good idea, but I’m in group video.

If you run 'lsmod" does the fbcon module show in the output?

If not, try to load it manually:

modprobe fbcon

Does this show an error?

Check

bone$ lsmod
Module Size Used by
fb_ili9341 16384 3
fbtft_device 49152 0
fbtft 45056 2 fbtft_device,fb_ili9341
pru_rproc 28672 0
irq_pruss_intc 20480 1 pru_rproc
pruss 16384 1 pru_rproc
pm33xx 16384 0
wkup_m3_ipc 16384 1 pm33xx
wkup_m3_rproc 16384 1
remoteproc 57344 3 pru_rproc,wkup_m3_rproc,wkup_m3_ipc
virtio 16384 1 remoteproc
virtio_ring 28672 1 remoteproc
pruss_soc_bus 16384 0
usb_f_acm 16384 2
u_serial 20480 3 usb_f_acm
usb_f_ncm 28672 2
uio_pdrv_genirq 16384 0
usb_f_mass_storage 53248 2
uio 20480 1 uio_pdrv_genirq
usb_f_rndis 32768 4
u_ether 20480 2 usb_f_ncm,usb_f_rndis
libcomposite 65536 18 usb_f_acm,usb_f_ncm,usb_f_mass_storage,usb_f_rndis
spidev 20480 0

bone$ sudo modprobe fbcon
sudo: unable to resolve host ece434: No address associated with hostname
modprobe: FATAL: Module fbcon not found in directory /lib/modules/4.19.94-ti-r50

Are you sure there is a fbcon module?

https://www.kernel.org/doc/html/latest/fb/fbcon.html#a-configuration

... seems to imply it may not have been built for the standard release BBB
kernels.

There is a fbcon module as is referenced in the pygame script you listed from Adafruit. I would suspect that none of the drivers listed in the script (‘fbcon’, ‘directfb’, ‘svgalib’) would be loadable on your system. From what I have gathered, fbcon is enabled by enabling the Framebuffer console feature in the kernel as in the .config. I’m not 100% sure how to do this with the BB kernel.

When my BBBlue was still alive (R.I.P.), I did connect a ili9341 display to it and had to run the following to get a QT app to run on the screen:

<qt_program> -platform linuxfb:fb=/dev/fb0

This is the example I followed which was posted by Jason.
https://gist.github.com/jadonk/0e4a190fc01dc5723d1f183737af1d83

Perhaps something similar would work for the BB Black and pygame.

Cheers,

Jon

It's enabled:

│ ┌───────────────────────────────────────────────────────────────────────┐ │
  │ │ [*] Framebuffer Console support
     │ │
  │ │ -*- Map the console to the primary display device
     │ │
  │ │ [*] Framebuffer Console Rotation
     │ │
  │ │ [ ] Framebuffer Console Deferred Takeover │

Regards,

In my config, BBAI running 4.14 kernel, I found two instances of fbcon:
$ sudo find / -name fbcon

/sys/devices/virtual/graphics/fbcon
/sys/class/graphics/fbcon

The framebuffer console seems to be attached to the console layer.

$ cat /sys/class/vtconsole/vtcon1/bind
1
$ cat /sys/class/vtconsole/vtcon0/bind
0

Info on fbcon:
https://www.kernel.org/doc/html/latest/fb/fbcon.html

Not sure if this helps at all.

Cheers,

Jon

Jon:
Well… su does give different results than sudo. I tried su again and it works!

So, how can I set permissions so I don’t have to su or sudo?

–Mark

p.s. Thanks for all the suggestions.

I now have it working with sudo. I just added https://github.com/MarkAYoder/BeagleBoard-exercises/blob/a531dca3a5f52813623bd40ea42bc733decfc70d/displays/ili9341/fb/pygame/clock.py#L26

I needed to set SDL_NOMOUSE to 1.

–Mark