Skip to content

Instantly share code, notes, and snippets.

@bchanudet
Last active December 31, 2023 13:47
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save bchanudet/a14dcfcd5b8a42f0d32f6645fd6f2a02 to your computer and use it in GitHub Desktop.
Save bchanudet/a14dcfcd5b8a42f0d32f6645fd6f2a02 to your computer and use it in GitHub Desktop.
Framebuffer on ST7735s (1.44inch LCD HAT)

Enable modules in Kernel

In raspi-config

Enable SPI under "Interfacing options"

Add modules

$ sudo nano /etc/modules

Append two modules (in two lines) :

spi-bcm2835
fbtft_device

Create FBTFT configuration

# /etc/modprobe.d/fbtft.conf
options fbtft_device name=adafruit18_green gpios=reset:27,dc:25,cs:8,led:24 speed=40000000 bgr=1 fps=60 custom=1 height=128 width=128 rotate=180

Check /dev/fb1 is present

  1. Reboot you Raspberry Pi

    $ sudo reboot
    
  2. Once rebooted, check if new fb device is present

    $ sudo ls /dev # /dev/fb1 must appear
    $ sudo apt-get install fbset # framebuffer utility
    $ sudo fbset -i -fb /dev/fb1 # should return information of screen.
    

Change options in /boot/config.txt

Add or modify the following options in the file:

dtoverlay=pwm-2chan,pin=18,func=2,pin2=13,func2=4
hdmi_force_hotplug=1
hdmi_cvt=128 128 60 1 0 0 0
hdmi_group=2
hdmi_mode=1
hdmi_mode=87
display_rotate=1

#disable uart to boost boot speed
enable_uart=0
start_x=0

Then reboot:

$ sudo reboot

Synchroneous copy between fb0 and fb1

In order to display console and other things on the screen.

Compile fbcp

$ sudo apt-get install cmake
$ git clone https://github.com/tasanakorn/rpi-fbcp
$ cd rpi-fbcp/
$ mkdir build
$ cd build/
$ cmake ..
$ make
$ sudo install fbcp /usr/local/bin/fbcp

Test it

$ fbcp

Right now you should see the content of the screen on the pHAT screen.

Launch automatically at startup

Edit the file /etc/rc.local. Add before the exit 0 line:

fbcp&

References

@bchanudet
Copy link
Author

Hi @tomohgee, that would mean that the fbtft configuration didn't work. Are you sure you're using an ST7735S controller and not another? Among the forks of this Gist, there is this one by @GautamBose that seems to have been modified to accommodate a ST7735R controller. The last letter is actually quite important!

If you indeed use a ST7335S, then maybe something else went wrong. This gist is 2 years old now, I would expect something not working anymore. But if so, you should find some information in the syslog I think?

@tomohgee
Copy link

tomohgee commented Nov 20, 2020

I did manage to get fb1 to show up, but my screen is still white.
I am sure, that its the S version.

@Martenz
Copy link

Martenz commented Nov 24, 2020

I did manage to get fb1 to show up, but my screen is still white.
I am sure, that its the S version.

Exactly the same issue ... Amazon says S .. but still white screen and no way to see fb1 also for me..

@jbrandes
Copy link

I am having the same problem with no luck. I'm doing everythign right i think.I'm following all the tutorials which more or less say the same thing. Still a white screen.

@badjano
Copy link

badjano commented Feb 28, 2021

I got it working, but the screen goes blank after some time and won´t go back on.
Also couldn´t make it 128 x 128, it stays at 720 x 480

Edit: I got some info from my seller, he sent me this link:
https://www.waveshare.net/wiki/1.44inch_LCD_HAT?spm=a2g0s.imconversation.0.0.3d073e5fTM9i7J&file=1.44inch_LCD_HAT

you can translate it using chrome

@badjano
Copy link

badjano commented Feb 28, 2021

I just noticed your cmake command is missing some arguments:

#1.3inch LCD HAT
cmake -DSPI_BUS_CLOCK_DIVISOR=20 -DWAVESHARE_ST7789VW_HAT=ON -DDMA_TX_CHANNEL=5 -DDMA_RX_CHANNEL=6 -DBACKLIGHT_CONTROL=ON -DSTATISTICS=0 ..
#1.44inch LCD HAT
cmake -DSPI_BUS_CLOCK_DIVISOR=20 -DWAVESHARE_ST7735S_HAT=ON -DDMA_TX_CHANNEL=5 -DDMA_RX_CHANNEL=6 -DBACKLIGHT_CONTROL=ON -DSTATISTICS=0 ..

mine had a channel error, which made me change 5 to 7 and 6 to 1

@Jakob2222222
Copy link

On my Zero 2w is this error: make
[ 50%] Building C object CMakeFiles/fbcp.dir/main.c.o
/home/jakob/rpi-fbcp/main.c:9:10: fatal error: bcm_host.h: No such file or directory
9 | #include <bcm_host.h>
| ^~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/fbcp.dir/build.make:76: CMakeFiles/fbcp.dir/main.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/fbcp.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment