question

stnz avatar image
stnz asked

Venus 2.85, Raspberry Pi, 3.5" TFT and framebuffer assignment

Hello,

Short question, is the Venus OS GUI somehow hardcoded to run on specific framebuffer device number and how to change that? Or any other idea what I'm doing wrong with RB3+, a 3.5" SPIO TFT display and Venus 2.85?

In every other article and blog the TFT seems to show up as /dev/fb1, but I'm getting this:

root@raspberrypi2:~# cat /proc/fb
0 simple
1 BCM2708 FB
2 fb_ili9486

So, the TFT seems to be sitting at /dev/fb2 and in theory works fine there, but the GUI doesn't work.

After a lot of experimenting I have the screen running ok for console and calibration, basically with the settings below but the GUI never shows up. I see the console boot messages and a root prompt on the screen, but nothing else. Removing the headless file doesn't change anything, so I assume it's just trying to draw on wrong fb device.

config.txt:

[all]
dtparam=spi=on
hdmi_force_hotplug=1
dtoverlay=tft35a, rotate=270
display_default_lcd=1

cmdline.txt:

dwc_otg.lpm_enable=0 fbcon=map:2 console=tty1 consoleblank=300
Venus OSRaspberry Pi
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

4 Answers
Kevin Windrem avatar image
Kevin Windrem answered ·

There is code in /opt/victronenergy/gui/start-gui.sh that looks for fb0 and uses that. You might play around with that and see if you can move the GUi to fb2. I don't know if that will work however.

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

stnz avatar image
stnz answered ·

Oo, thanks. Will take a look and report back. :)

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

stnz avatar image
stnz answered ·

Meh, no. Actually that code only seems to check the resolution from fb0 and set that to a variable, not actually start the GUI on it. So it's hardcoded somewhere else.

I assume the solution would be to get the framebuffer device order correct, but I cannot figure out how..

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

kivanov avatar image
kivanov answered ·

I have the same screen - cheap 3.5 inch LCD SPI screen based on xpt2046.

Seems that /dev/fb0 is hardcoded in the binary: /opt/victronenergy/gui/gui

I managed to get this working with a very dirty hack:

If you have set all driver and console stuff and have the screen showing the serial console, you can try the following:


First check the actual framebuffer device created by the driver:

root@raspberrypi2:~# dmesg | grep graph
[    3.157670] graphics fb2: fb_ili9486 frame buffer, 480x320, 300 KiB video memory, 32 KiB buffer memory, fps=33, spi0.0 at 16 MHz

root@raspberrypi2:~# ls -alh /dev/fb*
fb   fb0  fb1  fb2  
root@raspberrypi2:~# cat /proc/fb
0 simple
1 BCM2708 FB
2 fb_ili9486    #this one is the display set by the driver, so we need to output console to it and also to force the GUI to output there as well

Then, did the bellow:

mv /dev/fb0 /dev/fb9
ln -s /dev/fb2 /dev/fb0
export TSLIB_TSEVENTTYPE=INPUT
export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_TSDEVICE=/dev/input/touchscreen0
export TSLIB_CALIBFILE=/etc/pointercal
export TSLIB_CONFFILE=/etc/ts.conf
export TSLIB_PLUGINDIR=/usr/lib/ts
export QWS_MOUSE_PROTO=tslib:/dev/input/touchscreen0

Then, run

/opt/victronenergy/gui/gui

and check whether the Victron GUI will show up on the screen.


Then you can proceed the actual calibration process, etc. (that the variables above are for). I finally added the above lines to /opt/victronenergy/gui/start-gui.sh.

The more elegant solution would be using udev, but I did not manage to set it up.

5 comments
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

jeroen avatar image jeroen ♦ commented ·

Can you try just adding '-display Linuxfb:/dev/fb2' as an argument for the gui in start-gui.sh?

I am not sure that tslib is needed at all. What happens if the touchscreen0 is used directly (which is the default if it exists)?

0 Likes 0 ·
kivanov avatar image kivanov jeroen ♦ commented ·

Hi Jeroen, yes your suggestion actually works, just tried it:

[root@raspberrypi2:~]# chmod -x /opt/victronenergy/gui/start-gui.sh
[root@raspberrypi2:~]# sync
[root@raspberrypi2:~]# reboot

# just after rebooting:
[root@raspberrypi2:~]# uptime
 12:47:43 up 0 min,  load average: 4.61, 1.20, 0.40
[root@raspberrypi2:~]#
[root@raspberrypi2:~]# /opt/victronenergy/gui/gui -display Linuxfb:/dev/fb2
Reloading input devices: "LinuxInput:/dev/input/event0"
"using /etc/venus for runtime features"
                                        "running on raspberrypi2"
                                                                  Connecting to deprecated signal QDBusConnectionInterface::serviceOwnerChanged(QString,QString,QString)
                                                                                                                                                                        Creating settings
.....................
..........................

tslib is not needed for this particular case, but I included just in case if it is needed for the screen calibration part.

I have already set up the screen calibration and doing the test above (without having the start-gui script to load the mentioned variables, all of the set-before features of the screen (touch and calibration) is working as expected.

Thanks a lot for your input. It is good to have some help for the gui executable and the cli options that we can supply to it if possible.


0 Likes 0 ·
kivanov avatar image kivanov kivanov commented ·

Using the solution suggested by @Jeroen, we can edit the /opt/victronenergy/gui/start-gui.sh and change the variable multistring in the else section of the if case (that checks for headfull operation) like this:

#multistring="Multi: LinuxFb: "
multistring="Multi: LinuxFb:/dev/fb2 "

I think it is also advisable to swap /dev/fb0 with /dev/fb2 - there are two places that check the device (whether framebuffer device is already present in the system), but even without altering this, it is working.

0 Likes 0 ·
wildmustango avatar image wildmustango kivanov commented ·

@kivanov Wow! This is a great and clean solution. I struggled to get it working with another workaround using a program called fbcp from https://github.com/tasanakorn/rpi-fbcp This piece of software copies primary framebuffer to secondary framebuffer. So, I modified it to accept another framebuffer via argument, you can have a look at my GitHub page https://github.com/wild-mustango/VenusOsTFT35 where I have posted a tutorial to get this cheap TFT 3.5" touchscreens working.

Definitely I will update my tutorial using your solution.

Many thanks for posting it.

P.S.: Sorry, I'm not able to set links correctly, don't know why since I'm using the hyperlink button.

0 Likes 0 ·
kivanov avatar image kivanov wildmustango commented ·

Hi @wildmustango, great tutorial, especially the hw mod for screen blanking.

I decided to do this (screen blanking) with e simple push on-off button on my box panel (in which the r-pi will be), which will control the 5V power pin coming from the r-pi header, based on the pinout scheme of the display.
https://cdn.awsli.com.br/945/945993/arquivos/MPI3501-3.5inch-RPi-Display-User-Manual-V1.0.pdf

When I need it I will just push the button, do what I need, then switch it off.

The original idea discussed here: https://github.com/goodtft/LCD-show/issues/200

0 Likes 0 ·