The 1.8" TFT from Adafruit is the perfect display to attached to a Raspberry Pi.
These instructions also help with the Sainsmart display and you can find more info for both here: http://www.whence.com/rpi/
The TFT isn't 'plug & play' with the Raspberry, a patch has to be applied to the kernel to be able to interface via SPI with the ST7735R controller chip on the TFT. Once working, the display will act as a framebuffer device.
I spent two weeks trying to get it working, so I thought I would document it to help others.
###UPDATE 14th Nov 2013###
After a large number of request, I have now posted the compiled version of the kernel that supports the 1.8” TFT. Based on 2013-09-25-wheezy-raspbian.img. There are two links below, one for the Kernel the other is the instructions.
https://ozzmaker.com/downloads/1.8TFT_Kernel_3.6.11.tar
https://ozzmaker.com/download/README1.8TFT_Kernel_3.6.11.tar.txt
[wp_ad_camp_4]
Thanks go to Kamal (http://www.whence.com/rpi/) and Neil for responding to my emails & forum post, and their work on the ST7735R driver.
Thanks also go to Adafruit for their cool products.
As it takes over three hours to compile the kernel on the PI, I will show how to cross compile from another Linux PC. In my case, it is Ubuntu 12.10 running within VMWare on a Windows 7 Quad core PC. Kernel compile time is 15 mins.
Wire it up
Sainsmart wiring details are here on Kamal's page: http://www.whence.com/rpi/
You could also use a shield to make the wiring a lot easier, look here
Prepare the Raspberry Pi
-Download and install Raspbian “wheezy”.
This guide is based on 2013-02-09-wheezy-raspbian which is running 3.6.11 kernel
-Configure your Pi. E.g. Memory split, overclocking, etc..
-Update firmware and reboot. I use Hexxeh's script to update my firmware, which also needs GIT.
pi@raspberrypi ~ $ sudo apt-get update
pi@raspberrypi ~ $ sudo apt-get install git-core
pi@raspberrypi ~ $ sudo wget http://goo.gl/1BOfJ -O /usr/bin/rpi-update
pi@raspberrypi ~ $ sudo chmod +x /usr/bin/rpi-update
pi@raspberrypi ~ $ sudo rpi-update
Compile the Kernel
We will be cross compiling the kernel as compiling a kernel on the Raspberry Pi takes forever.
-Install packages used for cross compiling on the Ubuntu box.
-Get Kamal's source which has the patch for ST7735R controller and the branch for the kernel that is used in 2013-02-09-wheezy-raspbian, which is 3.6.y;
mark@ubuntu~$ cd raspberrypi-linux
mark@ubuntu~$ git checkout rpi-3.6.y+kamal-st7735fb
-Grab the current config off the Raspberry Pi.
-Copy config from the Raspberry Pi to the Ubuntu box using SCP. Replace 'raspberrypi' below with the IP address of your Raspberry Pi if hostname lookup fails.
We will then rename it once it is on the Ubuntu box
mark@ubuntu~/raspberrypi-linux$ mv config .config
-Configure .config to include the new patch and options.
You will be asked some questions for the new driver. If you are unsure of what values to use, then use these;
BCM2708 SPI controller driver (SPI0) (SPI_BCM2708) [N/m/y/?] (NEW) Y
...
ST7735 framebuffer support (FB_ST7735) [N/m/y/?] (NEW) Y
ST7735 'red tab' panel type? (FB_ST7735_PANEL_TYPE_RED_TAB) [Y/n/?] (NEW) Y
ST7735 panel has reversed RGB? (FB_ST7735_RGB_ORDER_REVERSED) [N/y/?] (NEW) N (or Y if red and blue are reversed)
ST7735 framebuffer mapping to GPIO/SPI (FB_ST7735_MAP) [Y/n/m/?] (NEW) Y
ST7735 RST gpio pin number (FB_ST7735_MAP_RST_GPIO) [-1] (NEW) 25
ST7735 D/C gpio pin number (FB_ST7735_MAP_DC_GPIO) [-1] (NEW) 24
ST7735 SPI bus number (FB_ST7735_MAP_SPI_BUS_NUM) [0] (NEW) 0
ST7735 SPI bus chipselect (FB_ST7735_MAP_SPI_BUS_CS) [0] (NEW) 0
ST7735 SPI bus clock speed (Hz) (FB_ST7735_MAP_SPI_BUS_SPEED) [4000000] (NEW) 4000000 (or 32000000 for SainSmart)
ST7735 SPI bus mode (0, 1, 2, or 3) (FB_ST7735_MAP_SPI_BUS_MODE) [0] (NEW) 0
You will need to confirm that "BCM2708 SPI controller driver" is set to Y;
CONFIG_SPI_BCM2708=y
If the above result is N or M, you will need to edit .config and change it to Y.
If you are planning on displaying the console on the TFT, then enabling these options in .config will allow you to change the font size and rotate the display later on.
CONFIG_FRAMEBUFFER_CONSOLE=y
CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y
CONFIG_FONTS=y
CONFIG_FONT_8x8=y
CONFIG_FONT_8x16=y
CONFIG_LOGO=y
-Now compile the kernel.
To enable parallel processing for a faster compile. If you have a dual core processor add -j 3 to the end of the command below. If you have quad core, add -j 6
-Create modules on the Ubuntu box which we will copy over later.
mark@ubuntu:~/raspberrypi-linux$ sudo make modules_install ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- INSTALL_MOD_PATH=../modules/
-Copy the new kernel over to the Raspberry Pi
pi@raspberrypi ~ $ sudo cp Image /boot/kernel.img
-Now copy over the new modules. First remove the unneeded directories, otherwise you will be copying over 1.9GB
The last step below is to SCP the files from from Ubuntu to the Raspberry Pi. If you have trouble SCPing into your Ubuntu box you may need to install open SSH on Ubuntu with sudo apt-get install openssh-server. This step also copies the files from my home folder 'mark'... yours would be different.
mark@ubuntu:~/raspberrypi-linux$ sudo rm -f -r ../modules/lib/modules/3.6.11+/source
pi@raspberrypi ~ $ sudo rm -f -r /lib/modules
pi@raspberrypi ~ $ sudo rm -f -r /lib/firmware
pi@raspberrypi ~ $ sudo scp -r mark@ubuntu:/home/mark/modules/lib /
-Reboot.
If everything went well, you should now have /dev/fb1.
Displaying the console on the TFT;
If you build the st7735 driver pair as built-in, add these options to the end of the line in /boot/cmdline.txt
. This will display the console on the TFT.
Some programs that work with framebuffer devices
mplayer2 = video playback
Use;
pi@raspberrypi ~ $sudo mplayer -vo fbdev2:/dev/fb1 -x 128 -y 160 -zoom file
FBI = image viewer
Use;
Links2 = web browser
Links2 uses directfb to speak to the TFT. And we need to configure directfb with our TFT details.
-Add these lines to the end of the file
geometry 128 160 128 160 16
timings 0 0 0 0 0 0 0
endmode
-Update /etc/directfbrc. If the file doesn't exist, create it.
-Add these lines to the end of the file
mode=128x160
-To run
pi@raspberrypi ~ $sudo links2 -g -mode 128x160x32k www.google.com
X Windows
Start Xwindows with;
--
-dpi 60
[wp_ad_camp_1]
Great work ! This seems a perfect fit for running MAME emulation; any ideas on how to start such a project ?
I don’t see why not. Just need a version of MAME that can use a framebuffer.
This looks promising;
http://www.mess.org/howto/sdlmame_sdlmess_framebuffer
I got mame running after a lot of messing about, so it’s possible!
– First make sure /dev/fb1 works as described so excellently here.
Note, my adafruit with HC buffer seems to work well at 60MHz setting (didn’t actually measure the clock though).
-Get advancemame debian from Shea Silvermans blog and install it. First time you run it, it creates a config file in .advance/, named advmame.rc
Open it and in the device_video section add a line:
device_video_clock 0-100/0-100/0-100
The values are a bit silly, but for this purpose it doesn’t matter.
Find the lines display_aspect and change them to 4 for x and 5 for y
Then start the mame video line setting application:
# FRAMEBUFFER=/dev/fb1 advv
It should open on your normal screen, not the lcd.
Press F5 to make a new modeline, use these parameters:
refresh 60, xpixels 128, ypixels 160. Only bgr16 mode will work
move to the bgr16 tab and press enter. A test screen should appeat on your LCD.
Press enter again, then F2 to save. Escape to exit. This modeline will have preference now.
Make sure you have a game ready in .advance/rom
#FRAMEBUFFER=/dev/fb1 advmame gamename
Enjoy! I tested with galaga namco version. Didn’t work at first (problems with the zip file format). I solved this by unzipping and (under linux!) rezipping the files.
Sound was still on my hdmi main screen, but you should be able to change that in the config file.
Some remarks: I installed libsdl1.2-debian (via apt-get). It worked also without it, but seemed slower. I think you only need libsdl-sound1.2 (the display can be done via fb driver for video and slang for text, I think). See the documentation in advancemame on sourceforge:
http://advancemame.sourceforge.net/doc-install.html#4
Galaga cpu consumption is a above 100% and sound seems a little slow.
It works much faster on mame4all, but that uses dispmanx as video driver, which works on the GPU if I’m not mistaken. Anyway, I have had no success at all with pointing that to the fb1 framebuffer.
Wow.. congrats!
It would be nice to see a video.
when i run the command sudo apt-get install gcc-arm-linux-gnueabi make git-core ncurses-dev it asks me completely different questions.. I don’t know how to reply
When I run the command sudo apt-get install gcc-arm-linux-gnueabi make git-core ncurses-dev it asks me completely different questions. I don’t know how to answer 🙁
Dummy comment to enable follow up. I forgot to enable it with the previous comment
show me the output you are getting
Ok I found those questions.. but they came after many many others and after I had many others.. I usually just pressed enter if I didn’t knew how to reply
Hello, I tried the steps mentioned above but I got errors during compiling.
ERROR: “vchi_msg_dequeue” [sound/arm/snd-bcm2835.ko] undefined!
ERROR: “vchi_bulk_queue_transmit” [sound/arm/snd-bcm2835.ko] undefined!
ERROR: “vchi_initialise” [sound/arm/snd-bcm2835.ko] undefined!
ERROR: “vchi_service_open” [sound/arm/snd-bcm2835.ko] undefined!
ERROR: “vchi_service_use” [sound/arm/snd-bcm2835.ko] undefined!
ERROR: “vchi_connect” [sound/arm/snd-bcm2835.ko] undefined!
ERROR: “vchi_service_close” [sound/arm/snd-bcm2835.ko] undefined!
ERROR: “vchi_service_release” [sound/arm/snd-bcm2835.ko] undefined!
ERROR: “vchi_msg_queue” [sound/arm/snd-bcm2835.ko] undefined!
Maybe the problem is, that my RPi is running a 3.6.11 kernel (latest rasbian, this is what /proc/config.gz on my RPi and uname tells me) and the patched kernel for the ST7735 driver is a 3.2.27. I searched a bit and it seems that there were updates in the video core driver. Is there a ST7735 patch for the new kernel series available?
pi@raspberrypi ~/src $ uname -a
Linux raspberrypi 3.6.11+ #352 PREEMPT Wed Jan 9 17:16:53 GMT 2013 armv6l GNU/Linux
The new kernel belongs to the updated bootloader:
pi@raspberrypi ~/src $ dpkg -S /boot/kernel.img
raspberrypi-bootloader: /boot/kernel.img
I didn’t found a source package for the new kernel. So maybe I would be able to compile the 3.2.27 modules (either by disabling snd_bcm2835 or enabling bcm2835_vchi which I tried but didn’t found an option in .config) At least I fear that the old 3.2.27 kernel won’t run with the updated videocore driver.
I think the initial step of updating the firmware brought me the 3.6.11 kernel.
Is there any help?
Ok, I finally managed it. Important: If you use raspbian 2012-12-16 DON’T UPDATE THE FIRMWARE! (don’t use rpi-update). The firmware is already new enough for the driver.
I had to set up a new raspbian-wheezy 2012-12-16 (on a slooowww 2gb sd-card) and did all steps except rpi-update. This keeps me the 3.2.27 kernel. (apt-get update; apt-get upgrade is o.k.)
Then I had to do a small modification. First I use menuconfig:
klaus@LittlX:~/src/raspberrypi-linux$ sudo make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- menuconfig
The st7735 driver is in:
Device Drivers -> Graphics support -> Support for frame buffer devices
And then the driver has to be build as an module (don’ use ‘y’, use ‘M’ instead)
ST7735 LCD panel framebuffer support
[*] ST7735 ‘red tab’ panel type?
ST7735 framebuffer mapping to GPIO/SPI
(25) ST7735 RST gpio pin number
(24) ST7735 D/C gpio pin number
(0) ST7735 SPI bus number
(0) ST7735 SPI bus chipselect
(4000000) ST7735 SPI bus clock speed (Hz)
(3) ST7735 SPI bus mode (0, 1, 2, or 3)
Do the rest steps mentioned. it should work!
I’ve got an old pi running on kernel 2.x. Is there a possibility to update it only to 3.2.27 . apt-get upgrade leaves me 3.6.
hi, in your nice trutorial you are swapping from user mark@ubuntu to pi@ubuntu…
and all my tries to run this line “pi@raspberrypi ~ $ sudo scp -r pi@ubuntu:/home/pi/modules/lib /”failed…even with ip adress and my user instead of ubuntu&pi i get time out…i copied it over usb device maybe i made mistakes there…or whatever happened.
and when i run “pi@ubuntu:~/raspberrypi-linux$ sudo make modules_install ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- INSTALL_MOD_PATH=../modules/” i get a mass of new questions?? more than at the first make?
and where can i kill the programmer/developer of the vi texteditor this is the worst piece of crap ive ever seen in my entire life, and yes i used linux bevor and i cant deal with this s***
i didnt get fb1….only stuck with fb0 so i will try this again..and now startx even doesnt work anymore?
best regards ben
I have changed all the @ubuntu to mark@ubuntu. My mistake sorry.
For this;
“pi@raspberrypi ~ $ sudo scp -r username@ubuntu:/home/pi/modules/lib /”
You may have to install SCP server;
Look at these;
http://ubuntuforums.org/showthread.php?t=1392857
http://www.linuxquestions.org/questions/ubuntu-63/cant-connect-via-scp-599896/
It should still work even if you copy them using a SD card.
And this;
“pi@ubuntu:~/raspberrypi-linux$ sudo make modules_install ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- INSTALL_MOD_PATH=../modules/” i get a mass of new questions?? more than at the first make?”
This usually happens if you try and compile a second time without resetting your source.
You can reset with this;
Make clean
make mrproper
You then start again by copying over .config from the raspberry pi. (The step above that has “Grab the current config off the Raspberry Pi.” )
Good luck!
hi, thanks mwilliams03 for your advices , i started from scratch seemed to be my own mistake by moving the wrong lib folder to the raspberry pi…now it works with fbi 😀 but my raspberry is blue and not pink!took a color screen test picture and yes my red&blue is swapped any ideas? did i forget the yes at red tab panel?
best regards ben
Thanks to Kamal Mostafa he told me what to do, you have to edit your local st7735fb.c in your git hub clone folder.
{ ST7735_CMD, ST7735_MADCTL},
{ ST7735_DATA, 0xc8}, //this make 0xc0
this was because the display (HY 1.8 SPI TFT haydooz..cheapest on ebay) is SRGB changed or wrong way conected.
thanks Kamal Mostafa you are the man!
best regards Ben
Hi, Great tuto! I have not my Raspberry Pi (I must receive it tomorrow) and I have ordered it with this screen.
However, I have some questions:
– Why do we need to do that? Touching the Kernel, just for a display ?
– Do we need a breadboard to use this screen ? (I’m a noob in electrinics)
– What do mean the lines “”mark@ubuntu:~/raspberrypi-linux$” ?
– Can I do all that stuff without my pi, just with the SD Card ?
– I planed to use that screen to display information from the tty/command line/scripts I wrote, is it possible ? I saw you have “raspberrypi login : _”, what is it ? your tty ?
Sorry for my bad English,
Thank you in advance for your answer, thank you for your tutorial.
In order;
-Because the Raspberry wheezy Distro doesn’t include a driver for this display
-no, not for this screen. You can wire right to the GPIO ports on the Pi
-This is just the user prompt on my Ubunto box. I show the user prompt in all the commands so you can work out what PC I run the command from.
-You will need your Pi and SD card to do this.
-yes it is possible to display on tty, I even see the boot screen on mine. Look for fbterm and fbcon. More info here; http://www.whence.com/rpi/
Thank you for your quick answers 😀
I didn’t understand that “Replace ‘raspberrypi’ below with the IP address of your Raspberry Pi if hostname lookup fails.”
Where do we have to replace ‘raspberrypi’ ?
If “sudo scp pi@raspberrypi:.config .” fails.. then try with IP address. Eg
“sudo scp pi@192.168.1.10:.config .”
Thank you for the awesome writeup! had to use kamal’s page for the pinout to my sainsmart device, but it works great!
Thanks for the great article! I could able to build the kernel and my lcd is working. But I couldnt change resolution from 128×160 to 160×128, I mean my screen x axis is longer than y axis.
If I could use it 160×128 it will be more better I think. (I will be wide screen)
And ideas?
you need to rotate the image.
Is it the terminal you want to rotate?
i have fixed that with changing -r parameter’s value in /sbin/fbterm-login script’s command : exec /usr/bin/fbterm -r 1 — /bin/login < /dev/$2
Thanks for the great article! I could able to build the kernel and my lcd is working. But I couldnt change resolution from 128×160 to 160×128, I mean my screen x axis is longer than y axis.
If I could use it 160×128 it will be more better I think. (It will be wide screen)
Any ideas?
I don’t suppose there’s a way to get an existing image? I can’t compile one due to some network complications.
I don’t suppose there’s a way to get someone’s existing image? I can’t compile one due to some complicated network issues.
sorry..I don’t have one and I’m not of aware of one.
Instead, can you tell me of an alternate way to copy the modules?
pi@raspberrypi ~ $ sudo scp -r mark@ubuntu:/home/pi/modules/lib /
My problem is that my Raspberry pi can’t connect to Ubuntu, but the Ubuntu can copy files over to the Pi.
Have you installed SSH on the ubuntu host?
sudo apt-get install openssh-server
Also try to SCP on the local ubuntu box to itself. Eg scp localhost
Or try setting up a NFS share on the ubuntu host and than mount this on the Pi… A lot more steps are involved.
Goo info here; http://blog.retep.org/2012/07/07/using-nfs-to-provide-extra-disk-to-a-raspberry-pi/
Unfortunately none of these options seem to work for me. I suspect it’s because I’m running Ubuntu inside VMWare on my Mac, since I don’t have access to a standalone Ubuntu machine. Is there anything else I can do? This is the only step I can’t get passed.
Sorry if this is a double post, but I wasn’t sure if my first comment got through due to a network outage.
So I was able to get a connection on the to the VMWare Ubuntu by using a bridged connection, however when trying to do this step:
sudo scp -r mark@ubuntu:/home/pi/modules/lib /
I get the error that /home/pi/modules/lib doesn’t exist. (Making sure the correct username and IP are in place.) Indeed, that folder doesn’t exist anywhere on Ubuntu after following all these steps. Is it supposed to? Or are we supposed to copy the main /lib/modules folder? (The one with “3.2.27+ folder)
I had the same issue, as I also run Ubuntu within VMware. Bridged connection fixed it.
So, if you follow the instructions;
Everything is done from the home folder… for me, I created a user called pi on my ubuntu box, /home/pi/ , which is show via ‘~’ below;
You download the source and then CD into the source directory;
~/raspberrypi-linux/$
You than build the kernel and modules from within this directly.
These commands;
sudo mkdir ../modules
make modules_install ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- INSTALL_MOD_PATH=../modules/
Places the modules one level back. Eg ~/modules/.
The full path for me is /home/pi/modules/lib
Maybe you have a different username and you need to change that in the path of the SCP command?
Remember, when you need to start all over again, just do these two commands to reset the kernel source;
Sudo make mrproper
Sudo make clean
You can then start again from the step
sudo mkdir ../modules
Thanks for clearing up the confusion. I was able to compile everything successfully while creating the modules and being able to copy them over. I didn’t get errors, warnings, or anything alarming.
However, it didn’t seem to work. I don’t have /dev/fb1 listed on my Pi, just fb0. On the startup sequence, I do see that it’s loading kernel modules st7735fb, spi-bcm2708, and st7735fb_map. My SainSmart screen is solid white, and I did double check the connection per Kamal’s chart. I also followed his settings about reversing the RGB and using 32000000 for the clock speed.
What else do I need to do to diagnose what the issue might be?
I don’t know what to say.. maybe recheck the wiring?
Or, try compiling as modules to see if it works that way;
You will have to change these to ‘m’;
BCM2708 SPI controller driver (SPI0) (SPI_BCM2708) [N/m/y/?] (NEW) m
…
ST7735 framebuffer support (FB_ST7735) [N/m/y/?] (NEW) m
And edit these two files; instructions are above in the blog;
/etc/modprobe.d/raspi-blacklist.conf
/etc/modules
I got mine working,
Now I am trying to use another spi device which is connected to spidev0.1 (CE1) pin.
I can use both TFT module and nRF24L01+ wireless module together but they are not working pretty well.
Sometimes the wireless module fails to transmit and the TFT screen hangs while wireless module is transmitting.
Do I have to do something special to make them work together without any problems?
Interrupt? Threads?
Any ideas?
Thanks
Hi,
I don’t have another linux machine to cross compile, but I am happy to leave my pi compiling overnight. Is there some instructions for just compiling on the Pi ? Sounds a lot easier for us newbs who are struggling.
Cheers,
Texy
It is a lot easier to compile right on the Pi.
After doing this step;
git clone –depth=1 git://github.com/kamalmostafa/raspberrypi-linux.git
do;
cd raspberrypi-linux
sudo zcat /proc/config.gz > .config
make oldconfig;
make <– will take a few hours
make modules_install
sudo cp Image /boot/kernel.img
reboot
The start back again from the instructions above at;
sudo vi /etc/modprobe.d/raspi-blacklist.conf
Thanks for the quick reply. Never mind the compiling – its taking ages just to ‘git clone’ – and it failed the first time. Lets hope it doesn’t fail again.
Cheers,
Texy
Hi,
still struggling with the git clone. Keep getting this:
pi@raspberrypi /home/shares/public/TFT $ sudo git clone git://github.com/kamalmostafa/raspberrypi-linux.git
Cloning into ‘raspberrypi-linux’…
remote: Counting objects: 2640506, done.
remote: Compressing objects: 100% (446606/446606), done.
Receiving objects: 100% (2640506/2640506), 699.49 MiB | 931 KiB/s, done.
remote: Total 2640506 (delta 2176484), reused 2625226 (delta 2168094)
error: index-pack died of signal 94)
fatal: index-pack failed
Any idea’s?
Texy
no sure. put GIT_TRACE=1 before get to get more detailed logging
Hi again,
so I think the git clone worked last night. not sure what was different. in the folder it creates there is only a hidden .git folder with other folder inside -= is that correct?
Anyway, I move to the raspberrypi-linux directory, type in the zcat command and get this :
/home/shares/public/TFT/raspberrypi-linux $ sudo zcat /proc/config.gz > .config
-bash: .config: Permission denied
????
Texy
OK scrub that last message. I don’t think the git clone worked properly. I now have done a successsfull clone and am now ‘making’. There was a whole lot of questions asked during the make oldconfig stage !!! Not sure I answered correctly for ll of them, lets hope so.
Cheers,
Texy
ok.. let me know how you go
Hi Mark,
my Pi is still compling….after 5 hours, lol.
Question = regarding the SPI mode choice – above you have 0 as the answer, but in this forum post :
http://www.raspberrypi.org/phpBB3/viewtopic.php?t=28696&p=262909#p262002
3 is used. Which is correct ? – I used the 0 above as I only found the forum thread since I started compiling.Thanks,
Texy
I never notice that that person used 3 in that post…
0 is the correct choice. I have only ever used 0.
I just read that it takes over 10 hours to compile on a rpi………………
Hmmm, maybe it doesn’t matter if its set to 0 or 3 – in this post, you have said that you used 3 :
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=64&t=12897#p222127
Texy
Well shortly after my last post the pi appeared to crash – i,m ssh’ing into the pi and it lost connection. If I go to the next step ‘make modules_install’ I get an error message :
/home/shares/public/TFT/raspberrypi-linux# make modules_install
cp: cannot stat `/home/shares/public/TFT/raspberrypi-linux/modules.builtin’: No such file or directory
make: *** [_modinst_] Error 1
So it looks like I’m gonna need to start again ;-/
Surely someone who who has successfully compiled the kernel can dropbox the file for us 😉 ?
Texy
In the mean time….I am loading ubuntu on an old laptop. I have also set up ubuntu on my vista laptop using virtuallbox, but I have a problem with installing arm-linux-gnueabi and ncurses :
as it can’t find the package arm-linux-gnueabi and it want to install libncurses5-dev instead of ncurses-dev ????
Texy
yep.. thats fine; you should get a line saying this;
Note, selecting ‘libncurses5-dev’ instead of ‘ncurses-dev’
Thanks Mark. I,ve been battling this for most of the weekend. Nearly there, but a big learning process, plus installing ubuntu on the old laptop has taken time. Can’t get wifi working on it, so hard wired it, etc.I think I got the kernel.img file more or less right, but made errors copying the modules and firmware folders, so I,m basically going to start again from scratch. I was using a very recent raspbian distro in any case and i,m not sure the tweaks we are trying are fully compatible?
Then again, your very first instructions are effectively upgrading to latest with the rpi-update. Can you confirm that the procedure you outline would still work with recent raspbian distro’s? What’s the latest you have proven?
Texy
I have only tried it with 2012-10-28-wheezy-raspbian.img.
If I have time this weekend, ill try with the latest distro
okay… I tested 2013-02-09-wheezy-raspbian which is running 3.6.11 kernel.
There are some changes in the install and I have updated the instructions above.
When grabbing the source, you need to do this;
git clone git://github.com/kamalmostafa/raspberrypi-linux.git
git checkout rpi-3.6.y+kamal-st7735fb
And before you compile the kernel, you need to confirm that SPI_BCM2708 has Y. As shown in the instructions above.
I hope this helps.
Thanks for your continued support Mark – we will get there in the end!
One thing I struggled with, and I,m sure I will tonight when I next get chance to get this going, is permissions using scp when you need to copy from the Ubuntu PC to the Pi. Despite the fact I entered the correct password, it said I didn’t have permission. Sorry, I can’t remember if it was
mark@ubuntu:~/raspberrypi-linux$ scp arch/arm/boot/Image pi@raspberrypi:.
or
pi@raspberrypi ~ $ sudo scp -r mark@ubuntu:/home/pi/modules/lib /
or both!!
If I understand those commands correctly, they both copy from the PC to the Pi, however one line is ‘giving’ , whilst the other line is ‘taking’.
Another question – how easy is it to change the SPI bus speed after the process is finished (and proven to work at the default 4mhz). If I wanted to push my particular display, to see if will work at up to 32Mhz as Kamal did?
Thanks,
Texy
OK – its all working now – brilliant !!!!
My question regarding changing the PCI clock still stands though.
It’s fantastic that you’ve been able to sharethis tutorial Mark – thankyou again. There are a few gotcha’s for linux newbs like myself. The very last command when you scp using the pi to take from the Ubuntu PC – as you can see from the comments above, if you don’t create a user called pi on the PC before you start then the /home/pi/ bit is invalid. Also you could just add bits about adding the ssh server installation. Don;t take this as critisim, just an as suggestions for improvement.
Cheers,
Texy
Good news.
And all good points. I’ll update the page.
Ok – here’s another. I have reason to believe that there already is a .config folder on the Pi and it may be overwritten by this procedure. I could be wrong but after I got the display working I then went into the GUI but found no task bar. One suggestion to fix this was to copy some files or other to the ~/.config folder. Of course there was no .config directory, but there is a .config file. I think it got lost……
Apologies if I just got the procedure wrong, and it’s not the instructions that are wrong, lol.
Texy
thanks Text!.. I have updated all instructions with all your recommendations.
As to changing the speed, I think you will need to re-compile the kernel. In saying that, after a few goes at doing it on a faster computer.. you will be able to do it in 15 minutes.
…I emailed kamal whilst I was waiting for your reply and got this :
Yes, it is possible to change the SPI speed without recompiling the driver. Add this kernel boot parameter to /boot/cmdline.txt as follows: “st7735fb_map.spi_speed_hz=8000000”. Only values that are multiples of 4000000 are valid (other values will just get silently rounded down to the next multiple).
So that may be useful.
Cheers
Texy
interesting.. thanks. I’ll give that a go
Hi, its me again….if you ever get it working be aware of sudo apt-get update and than upgrade…did it..and now my display doesnt work anymore cant load st7735fb is in the booting process….gues ive to recompile it 🙁
The first thing I did once I had got it working is made a backup of the sd card. Considering the amount of time and effort involved in getting it compiled etc, it seemed the obvious thing to do, but its easy to say in hindsight….;=)
Texy
Yes, can confirm as I have just found the same.
Texy
i just made it again..with all new upgrades..
Thanks for the brilliant walk through. I’ve gone through it and got the /dev/fb0 and /dev/fb1 appearing and on turn on it shows the colour wheel the pi initially displays on a normal HDMI out. I can get it to display pictures and mplayer video via ssh commands but not links2 (get a lot of error messages, but I don’t care about that).
If I add the ‘fbcon=map:10 fbcon=rotate:1 fbcon=font:ProFont6x11’ text to the end of /boot/cmdline.txt then the colour wheel turns into the boot text, as required, but it doesn’t lead to the prompt, the screen just goes black. I cannot change the orientation or the text font either, it seems to be fixed. Conversely when I issue a halt command over ssh the flashing underscore appears momentarily before the display goes white (to signify the pi is off). And the /sbin/fbterm-login stuff doesn’t work at all. Is con2fbmap a way around this? I can’t figure out how to use it though and really I want to be able to see the prompt for a project I’m doing.
Alternatively, how might one go about piping Python output to the display?
Thanks for any help you can render. If it helps to guide a response I’d consider myself a competent novice.
Hi
I have actually removed the fbterm instructions…. fbcon should do what you want. I use this.
To be able to rotate the display or change the font size, it has to be enabled in the kernel before compiling;
CONFIG_FRAMEBUFFER_CONSOLE=y
CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y
CONFIG_FONTS=y
CONFIG_FONT_8x8=y
CONFIG_FONT_8x16=y
CONFIG_LOGO=y
Regarding python, I use pygame to display to the TFT via the frame buffer. You just need to specify the framebuffer device at the start of the program;
os.environ[“SDL_FBDEV”] = “/dev/fb1”
Thanks very much, I’ve got it displaying images using pygame! Took a bit of time to sort out the Python3.2 version but its all a learning experience. The pi shows the mouse arrow when outputting to fb1, is there a way to remove that? Or is this more of a pygame issue, in which case I’ll go ask elsewhere. Took me a moment to realise I need to use sudo to give Python access to /dev/fb1 but then it worked fine.
Though it is not important for what I want to do you might want to know the links2 error I get, in case there is an easy fix and someone else wants to use links2. It displays in the terminal some DirectFB stuff and then gives an FBDev/Mode error as follows :
(*) FBDev/Mode: Setting 640×480 LUT8
(*) FBDev/Mode: Switched to 128×160 (virtual 128×160) at 16 bit (LUT8), pitch 256
(!) [ 2745: 0.000] –> Caught signal 11 (at 0xb6f36000, invalid permissions) <–
(!!!) *** WARNING [still objects in 'Layer Region Pool'] *** [../../../lib/fusion/object.c:241 in fusion_object_pool_destroy()]
(!!!) *** WARNING [still objects in 'Layer Context Pool'] *** [../../../lib/fusion/object.c:241 in fusion_object_pool_destroy()]
It might as well be written in Welsh for all the sense it makes to me but hopefully it is of some use to you.
good to hear.
Yeh, links2 is a bit fiddly… I don’t use it as I couldn’t get rid of the scroll bars, which took up a lot of room.
For the mouse, use this;
pygame.mouse.set_visible(0)
Got a follow on question you can hopefully help with. I use the 2013-02-09-wheezy-raspbian image, so as to follow the guide as closely as possible. Upon installation the wireless works perfectly and I can use wired and wireless connections simultaneously. However, after doing all the stuff to create /dev/fb1 upon reboot the wireless stops working, doesn’t appear in the drop down menu of the wireless manager 2013-02-09-wheezy-raspbian has by default. No amount of wpa_supplicant.conf editing resolves this and I have to resort to using wicd. Unfortunately wicd doesn’t allow simultaneous connections, connecting the wired cuts the wireless and vice versa.
Why would the fb configuration alter network protocols? Is there any additional steps I could do in the fb setup procedure which would avoid this problem? I don’t know if it is just the type of wireless USB stick I use, a variety of problems are documented on line in regards to particular USB wireless sticks having just this problem, or whether it happens to everyone but few people use two connections.
it should still be working. did you do;
“make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- oldconfig”
before compiling, open up .config file and check what wireless drivers you have selected to be installed.
I have the same problem. I am using a DWA-131 wireless setup.
try this:
Confirm that you can see your USB with;
lsusb
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 7392:7811 Edimax Technology Co., Ltd EW-7811Un 802.11n Wireless Adapter [Realtek RTL8188CUS]
if you see then edit interfaces file;
sudo nano /etc/network/interfaces
It should like something like this;
auto lo
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
auto wlan0
iface wlan0 inet dhcp
wpa-ssid “ssid”
wpa-psk “password”
(your ssid and password need to have the quotes around them)
reboot
thanks Mark but no luck, I get the following
cannot find device wlan0
Bind socket interface: No such device
Failed to bring up wlan0
I am able to see it in lsusb though.
great work !
How can I rotate the display from 128×160 to 160×128 ?
Used as console, fbcon command are ok, but for the video?
regards
claudio
For video, I don’t think there is a way to rotate the video in Maplyer without re-encoding. The Pi may not be able to handle this.
I rotated and re-sized my videos first on my windows PC with Freemake video converter, which is free and a easy to use.
If I do not cross compile and just compile using my Raspberry Pi, should I still be seeing a /dev/fb1?
Everything executed properly except that when I go into /dev I see only fb0.
It says I have a 3.2.27+
What could have gone wrong?
The latest instructions are based on kernel 3,6,x.. or 2013-02-09-wheezy-raspbian.img.
And yes, you should get /dev/fb1 even if you compile on your Pi.
I was finally able to get it working. I was following your advice before
“It is a lot easier to compile right on the Pi.
After doing this step;
git clone –depth=1 git://github.com/kamalmostafa/raspberrypi-linux.git
do;
cd raspberrypi-linux
(git checkout rpi-3.6.y+kamal-st7735fb)
sudo zcat /proc/config.gz > .config
make oldconfig;
make <– will take a few hours
make modules_install
sudo cp arch/arm/boot/Image /boot/kernel.img
reboot"
I did not do the make modules_install step this time and everything started working.
I haven't repeated it to make sure that it was the problem I was running into, but if anyone else is having trouble with those instructions should try that and I hope it works for them.
Hi Mark
First of alll, awesome job with documenting all details and replying to everyone and helping them out. I have a bunch of issues which I was hoping to get helped with:
I’m trying to cross complie using ubuntu but running into several errors. Some I’ve been able to solve but some are unsolvable and I am unable to proceed.
1. when I do “KG@ubuntu~/raspberrypi-linux$ sudo scp pi@raspberrypi:config .” it gives me an error saying can’t scp because of “host key verification failed”. It asks me to use ssh-keygen to delete known_hosts which I did and then scp works fine.
2. When I configure .config to include new path and options by using the command “KG@ubuntu~/raspberrypi-linux$ make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- oldconfig”, it gives several errors along the way but eventually executes the command, but unfortunately ends up in errors too. To start with, as soon as I execute the above command, it tells me “make: /usr/bin/arm-linux-gnueabi-oldconfiggcc: Command not found”. Then it continues to execute the command and takes me to questions starting “Support for frame buffer devices (FB) y/n/m”. I answer the questions as per your instructions – however keep in mind that it never asks me this question “BCM2708 SPI controller driver (SPI0) (SPI_BCM2708) [N/m/y/?] (NEW)”. Anyhow, I continue answering all the questions after which it executes some more and finally spits out this error
“/bin/sh: 1: /usr/bin/arm-linux-gnueabi-oldconfiggcc: not found”
“make[1]: *** [kernel/bounds.s] Error 127”
“make: *** [prepare0] Error 2”
But I went into .config and manually entered “y” for BCM2708 SPI controller driver. Also changed the rotation and other things you recommend to y.
Then I actually started the cross_compile where it asked me a bunch of questions again which I said “y” and it ended the compile in a minute saying
“make[1]: Target `__build’ not remade because of errors.
“make: *** [scripts] Error 2
“make: Target `_all’ not remade because of errors.
Any idea which step I might have made a mistake? Sorry for the long post, but I am new to ubuntu & pi – so there is a learning curve. Let me know if i should email you my .config file.
Thanks
KG
1.
This will happen every time you rebuild the raspberry pi. Not a big issue, just delete the key as you did.
2.
Did you do install the arm compiler on your Ubuntu box? ‘sudo apt-get install gcc-arm-linux-gnueabi make git-core ncurses-dev”
Can you see it installed installed;
sudo find / -name arm-linux-* -print
When you enter the command to make oldconfig.. Are you entering a space between arm-linux-gnueabi- and oldconfig?
If the command above works, you should only be asked for new changes to the Kernel. Eg the TFT drivers. (There could also be a possibility that there is a couple of new drivers in your kernel source.)
If you are ask a lot of questions and any of the steps above, like over 30… then something went wrong and you might as well stop.
BTW;
If you want to reset your source to compile again do this;
make clean deletes compiled objects
make mrproper deletes config files
sudo rm –f –r ../modules delete modules
Then copy back the .config from your vanilla Pi install. As the above commands would delete it.
Maybe when you copy it over from the Pi, keep a copy in your Ubuntu home folder.
Mark
Hey Mark
What can I say, your instructions were spot on! Turns out I wasn’t leaving a space between gnueabi- and oldconfig. I got confused from your instructions since oldconfig was in a different line. I should have just copy-pasted your commands instead of trying to type them verbatim. Everything works now and I can see fb1 and also was able to display images on my TFT – got the mplayer working as well. Only thing I’d like to point out is when I copied to pi from ubuntu, instead of my username@ubuntu, I had to type in my laptop’s ip address. Everything else worked pretty much like you said. Thanks once again. This was great.
Next, I’d like to use the spi master-slave interface and drive two displays at once (with half the image in each of them). Given my limited knowledge of linux, I don’t think it’ll be easy to pull it off – any chance you know how to get started with this? Out of curiosity, what is your next project with the pi these days?
Thanks once again,
KG
Good to hear.
I see what you mean, I have made the field bigger. So now the space is a lot clearer.
I don’t know about getting multiple devices running via SPI, but what you are trying to do would be a great idea. Please let me know if you get it working.
There two things I’m working on now;
-trying to get a 3.2” TFT with touchscreen working. No luck so far
-Balancing robot, which uses a gyroscope and accelerometer
I’ll post in my blog when I get them working.
Hi again Mark.
I can get the fbcon to display on the TFT, but only in portrait mode – I cannot get it to display landscape. I assume thats what the fbcon:rotate=1 is meant to do. I,ve tried other values and also the format fbcon=rotate:1 (as suggested by Kamal), but that doesn’t work either.
Any idea’s?
Thanks,
Texy
Ah, just read though other comments and its seems that I need to enable rotation before compiling.I’ll give it another go 😉
Texy
So the end result of following these instructions will result in a a TFT LCD module working with a Raspberry Pi? Nice! I’ve seen other TFT LCD modules on RPi, but their frame rates were incredibly poor. These instructions ensure a smooth frame rate for native resolution?
Notro has done a lot of work for the TFT displays on the PI.
https://github.com/notro/fbtft/wiki
The answer from Notro;
That depends on the display size and bus (serial/parallel).
With drivers from this project: https://github.com/notro/fbtft/wiki
* ~25 fps on an ITDB02-28 with 8-bit parallel bus, 320×240, 150kB video memory
* ~22 fps on an Adafruit 2.2″ with 9-bit SPI @32MHz, 176×220, 75kB video memory (9-bit is slower than 8-bit due to extra transfer buffer preparation)
* ~60 fps on a Sainsmart 1.8″ with 8-bit SPI @32MHz, 128×160, 40kB video memory
The project is still young, so there’s hasn’t been done much with regards to performance.
.
.
And I would agree with him
Thanks for the reply! I purchased a SainSmart 1.8″ 128×160 LCD module recently, and am eager to get the ball rolling; so it looks like I made the right decision in which LCD to procure. Now I wait for it to arrive!
There is also talk of native LCD components in the future from the Raspberry Foundation. That’d be pretty cool.
Love it! Works on an adafruit 1.8inch with a HC type buffer. I’m quite comfortable at 60MHz SPI clock (haven’t tried any higher yet).
I am having some trouble with Xwindows though. After the kernel build the pi crashes (locks up) when it starts lightdm or basically anything X. Tried remove and re-install x11-common but nothing helps. Maybe it’s because I came from 3.6.11+?
Is there a way to compile your framebuffer device as a module on ‘any’ kernel instead as part-of-the-kernel? I don’t mind if I have to compile the whole kernel (i.e. use that compile system) but I would like to try it on the latest and greatest…
In the end I would like to make micro MAME arcade machine, based on the arcadie for iphone.
Play space invaders and donkey kong 🙂
When I first got it working, I had it running as a module.
.
.
Choose these options when compiling;
ST7735 framebuffer support (FB_ST7735) [N/m/y/?] (NEW) m
ST7735 panel is ‘red tab’ type? (FB_ST7735_PANEL_TYPE_RED_TAB) [Y/n/?] (NEW) y
ST7735 framebuffer mapping to SPI0.0 (FB_ST7735_MAP) [N/m/y/?] (NEW) m
ST7735 RST gpio pin number (FB_ST7735_MAP_RST_GPIO) [-1] (NEW) 25
ST7735 D/C gpio pin number (FB_ST7735_MAP_DC_GPIO) [-1] (NEW) 24
ST7735 SPI bus number (FB_ST7735_MAP_SPI_BUS_NUM) [0] (NEW) 0
ST7735 SPI bus chipselect (FB_ST7735_MAP_SPI_BUS_CS) [0] (NEW) 0
ST7735 SPI bus clock speed (Hz) (FB_ST7735_MAP_SPI_BUS_SPEED) [4000000] (NEW) 4000000
ST7735 SPI bus mode (0, 1, 2, or 3) (FB_ST7735_MAP_SPI_BUS_MODE) [3] (NEW) 3
Then follow these extra steps;
-sp-bcm2708 is blacklisted, we need to comment it out so it loads at boot.
sudo vi /etc/modprobe.d/raspi-blacklist.conf
#blacklist spi-bcm2708
Now set the order in which the modules are loaded.
sudo vi /etc/modules
-Add these three lines to the bottom of the list;
st7735fb
spi-bcm2708
st7735fb_map
-Reboot.
Would love to see the MAME cabinet once finished!
Thanks for the module compile info. Would you also have a diff so I can see what you actually patched/added? The kernel sources are a bit much to dig through…
Thanks!
Frank
I was thinking: Is there a patch to the kernel involved? As far as I now understand it, the st7735fb is part of the video subsystem. I used to compile video drivers in the past (for a USB stick dvb-T tuner). I only needed the video4linux git, point it to the kernel headers, compile and voila, a perfect kernel module. If the same where applied here (in the process removing all the unneccessary video drivers, you would only need the linux headers and the make would be much shorter.
Thing is, it only works if nothing in the kernel itself needs patching…
Cheers,
Frank
So I’ve attempted this four times now, and am very close to getting it working. Everything appears to compile just fine, but I run into issues when it’s time to do “pi@raspberrypi ~ $ sudo scp -r mark@ubuntu:/home/mark/modules/lib /”. I’m using Ubuntu in a virtual environment (VirtualBox), and I can’t find my IPV4 address for the virtual machine. So what I did to copy the files was “sudo scp -r /home/eric/modules/lib pi@192.168.1.2:/home/pi/Desktop”. From there, I then moved directories into /lib. I reboot and whatnot, and the LCD displays the boot gradient image, but not the console! Any ideas?
I am also missing /dev/fb1…
So it seems that I do have /dev/fb1 (didn’t see it before). On my root I have /modules and /firmware, and inside of /lib is /3.6.11+; still, only the gradient appears, not the console. If anyone has any input, I’d greatly appreciate hearing about it.
The gradient image indicates that it is working…. but you have no /dev/fb1 this is strange.
Have you tried to get the console going with adding this to in /boot/cmdline.txt;
fbcon=map:10 fbcon=rotate:1 fbcon=font:ProFont6x11
I had the issue you had when first using VMWare. I was unable to from the Ubuntu to Pi.
Try changing your virtual image network settings to “Bridged networking”. Then do an ifconfig in ubuntu to get the IP address.
I heeded your advice with the networking and managed to get that settled. Thanks for that! I’ll give this whole tutorial a fresh go tomorrow; we’ll see how it goes then.
I finally got it working! Just one issue: red and blue are inversed. Ha ha! No worries, I can fix that. But cool, it works! 😀
I get just the grandient and not the console. fbi to show images works great though. I’m using ubuntu on a real machine, not vmware. Any idea/tips what I could be missing for the console to work?
Try this.
If you build the st7735 driver pair as built-in, add these options to the end of the line in /boot/cmdline.txt. This will display the console on the TFT.
fbcon=map:10 fbcon=rotate:1 fbcon=font:ProFont6x11
I have this in /boot/cmdline.txt :
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
fbcon=map:10 fbcon=rotate:1 fbcon=font:ProFont6x11
Still, I only get the gradient when booting. but fbi with images works fine. Maybe I failed at some step in the kernel building. Is there some way to verify that the st7735 driver pair was built-in ? I compiled the kernel more than once but this always happens.
If run this:
sudo zcat /proc/config.gz | grep SPI_BCM2708
I get:
CONFIG_SPI_BCM2708=y
That means it was built in right?
check for the st7735fb driver;
sudo zcat /proc/config.gz | grep 7735
Is there any way to display the xorg Desktop on the TFT? If so, how is it achieved?
good to hear. try this;
FRAMEBUFFER=/dev/fb1 startx
Yeah, I saw that just a few moments ago here: http://www.youtube.com/watch?v=elHCGuDMlkg. Thanks for everything!
Everything is working great on the console and in x11, but there’s one thing I want to do which isn’t working as I had hoped. I’m using the Allegro 5 graphics library and I’d like to launch a program I made using said library from the console, but whenever I do, it doesn’t display the program, just the console. Then, when I press ESC (to close the program I wrote), it returns to normal, which means that it launched successfully, but the display wasn’t pushed to the LCD. Any ideas how this could be done?
As a matter of fact, the program runs fine once I plug my composite cables into my TV from my Pi. So I just need to “transfer” the display to the LCD.
I have never used Allegro 5 before.
I have only been able to display on the TFT with SDL in c and Pygame in Python.
For both, I had to set the environment variable first.
For pygame;
os.environ[“SDL_FBDEV”] = “/dev/fb1”
For SDL in c;
SDL_putenv(“SDL_FBDEV=/dev/fb1”);
Maybe you have to do something similar?
Hmm. Quite possibly. I’ll check with their official forum. If that doesn’t work, I guess I’ll begin learning SDL! Ha ha. Thank you.
As it turns out, Allegro does not have anything to assign it to a framebuffer. So I’ll (attempt to) write my own! 😛
Sorry for the late response mwilliams03.
Here’s the output of `sudo zcat /proc/config.gz | grep 7735` :
CONFIG_FB_ST7735=y
CONFIG_FB_ST7735_PANEL_TYPE_RED_TAB=y
CONFIG_FB_ST7735_RGB_ORDER_REVERSED=y
CONFIG_FB_ST7735_MAP=y
CONFIG_FB_ST7735_MAP_RST_GPIO=25
CONFIG_FB_ST7735_MAP_DC_GPIO=24
CONFIG_FB_ST7735_MAP_SPI_BUS_NUM=0
CONFIG_FB_ST7735_MAP_SPI_BUS_CS=0
CONFIG_FB_ST7735_MAP_SPI_BUS_SPEED=4000000
CONFIG_FB_ST7735_MAP_SPI_BUS_MODE=0
Does this mean it was built in?
Sorry for brevity and typo’s, (sent from my phone).
Reblogged this on SainSmart.
Helped me alot and very clear. Thank you for taking the time to write this.
First, I’d like to begin by saying thank you for taking the time in making this guide. It was a huge help and has taken me one step closer to completing my project. There are a few things I would like to incorporate into this, such as a tactile button switch to turn the screen off and back on, a toggle if you will. From what I understand, I need a relay to do this. Using the relay I would wire the 5v power for the display to the relay and use that to switch it on and off using the tactile button switch. Is this the best way to go about doing this or is there another way I could accomplish this through programming? Thank you very much for your time! -W
There is a way to do this through programming, you could use a transistor connected to one of the GPIO pins. When the pin is set high, it will allow current to pass through. When it is set low it will not allow current through. I plan to write up a post regarding the usage of a transistor to turn the display on and off soon.
Thank you for your reply. After some experiments I got both the relay and the transistor methods working, but opted to use the transistor method due to space and the smaller amount of parts. It was a great learning experience, just as following this tutorial has been. I have one more question. I noticed Adafruit has a new 2.2 TFT in stock (http://www.adafruit.com/products/1480) and I am interested in using this as well. It looks like it uses a different driver ILI9340 and I see you use source code from Kamal Mostafa’s git hub repository for the ST7735R. Would it be difficult to modify this procedure to accommodate the new larger 2.2 TFT?
For the 2.2″ from adafruit, I used Notro’s drivers. https://github.com/notro/fbtft/wiki
The wiki has a lot of information
Sorry about the double post, but I just ran into a problem. The screen works fine and I can toggle it on and off through the terminal by setting the pin 1 and 0 respectively. The problem I have is when I run a script using wiring pi, in the beginning of the script (to make sure it is initially turned on) I will write wiringpi2.digitalWrite (pin,1) to set the pin to high. Whenever I use this command it turns the screen all white. Any help with this issue would be greatly appreciated. Thank you for your time. -W
You are only using this for the back light right?
can you past in the code specific to setting the pin high.
Thank you for the quick reply, but as I went to recreate the error it seems that it is working just fine now. Weird. It seems that is happens randomly. Perhaps it is a problem with my display. Could it being underpowered have an effect on the display as to turn the screen white?
Thank you for the tutorial ,it help me alot making adafruit 1.8 tft display works with raspberry.
i was able to use the screen with a python script to display texts and images,but i’m wondering how to use the touch panel?
is there a certain module that needs to be loaded so the panel would be recognized like we do for the tft_device with modeprob?
thanks in advance
Your welcome.
I have yet to see a 1.8″ with a touch screen. What model do you have?
not really sure if it actually have a touch panel,i’m working on this project for a client remotely and he asked me to write some code for a raspberry pi which include displaying messages on a 1.8″ TFT screen ,he also wants to incorporate a touch gesture for one of the features,the display is 1.8″ adafruit tft screen,to tell you the truth i’m not a hardware kind of guy ,so it would be great if you can help point us to the right direction and may suggest an alternative display if this one doesn’t do the job
thanks alot 🙂
I have the 1.8″ from Adafruit and it doesn’t include touch.
The sainsmart 3.2TFT includes touch;
http://www.amazon.com/SainSmart-Display-Touch-Adapter-Arduino/dp/B008FWSG3S/ref=sr_1_1?ie=UTF8&qid=1378204086&sr=8-1&keywords=sainsmart+3.2+tft
I have the above screen working, including touch. See my other post;
https://ozzmaker.com/2013/05/23/raspberry-pi-with-a-3-2-tft-with-touch-control/
I’m about to post a blog entry on how to code for the touch component of the TFT.
thank you for your quick reply ,we’ll get a new display if the client still wants the touch gesture.
looking forward for your post about coding for the touch panel on TFT displays .
Hey again we got a new display from adafruit ,its a 2.8″ 18-bit color TFT LCD with touchscreen breakout board .
it have 8 data pins and 4 pins for control input plus 4 for the touch panel.
any ideas on how to wire it with the pi and get it to work?
can we wire the data io pins and control inputs pins to the pi’s gpio pins of our choice and when loading the model specify whereeach pin goes?
2.8″ with touch – similar to this one?
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=93&t=53144
Texy
here is the link for the display
http://www.adafruit.com/products/335
Thank you so much for this excellent tutorial. Everything works fine except the shutdown -h. Issuing “sudo shutdown -h now” triggers the shutdown but then reboots again. How can i fix that problem?
Thank you for help.
Try “sudo halt”
I already did without success…
I extracted some lines from /var/log/syslog (with the command: “$ grep -A 20 shutdown /var/log/syslog”) after the system ought to halt:
Oct 20 22:52:49 cam1 shutdown[2168]: shutting down for system halt
Oct 20 22:52:52 cam1 init: Switching to runlevel: 0
Oct 20 22:52:54 cam1 ifplugd(eth0)[1535]: Exiting.
Oct 20 22:52:59 cam1 ifplugd(lo)[1574]: Exiting.
Oct 20 22:52:59 cam1 ntpd_intres[1978]: ntpd exiting on signal 15
Oct 20 22:52:59 cam1 ntpd[1956]: ntpd exiting on signal 15
Oct 20 22:53:10 cam1 kernel: imklog 5.8.11, log source = /proc/kmsg started.
Oct 20 22:53:10 cam1 rsyslogd: [origin software=”rsyslogd” swVersion=”5.8.11″ x-pid=”1834″ x-info=”http://www.rsyslog.com”] start
Oct 20 22:53:10 cam1 kernel: [ 0.000000] Booting Linux on physical CPU 0
Oct 20 22:53:10 cam1 kernel: [ 0.000000] Initializing cgroup subsys cpu
Oct 20 22:53:10 cam1 kernel: [ 0.000000] Linux version 3.6.11+ (sascha@Sascha-HPNotebook) (gcc version 4.7.2 20120701 (prerelease) (crosstool-NG linaro-1.13.1-2012.07-20120720 – Linaro GCC 2012.07) ) #1 PREEMPT Sat Sep 14 19:17:46 CEST 2013
Oct 20 22:53:10 cam1 kernel: [ 0.000000] CPU: ARMv6-compatible processor [410fb767] revision 7 (ARMv7), cr=00c5387d
Oct 20 22:53:10 cam1 kernel: [ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
Oct 20 22:53:10 cam1 kernel: [ 0.000000] Machine: BCM2708
Oct 20 22:53:10 cam1 kernel: [ 0.000000] cma: CMA: reserved 16 MiB at 17000000
Oct 20 22:53:10 cam1 kernel: [ 0.000000] Memory policy: ECC disabled, Data cache writeback
Oct 20 22:53:10 cam1 kernel: [ 0.000000] On node 0 totalpages: 98304
Oct 20 22:53:10 cam1 kernel: [ 0.000000] free_area_init_node: node 0, pgdat c0557c44, node_mem_map c0602000
Oct 20 22:53:10 cam1 kernel: [ 0.000000] Normal zone: 768 pages used for memmap
Oct 20 22:53:10 cam1 kernel: [ 0.000000] Normal zone: 0 pages reserved
Oct 20 22:53:10 cam1 kernel: [ 0.000000] Normal zone: 97536 pages, LIFO batch:31
How do you rotate startx display?
Hi there,
FYI : I installed 2013-07-26-wheezy-raspbian.img . Run on OSX 10.8.5. TFT display from Sainsmart ST7735R. Do you have any suggestion what should I do??
I’m running into an error.
When I run this command :
sudo apt-get install gcc-arm-linux-gnueabi make git-core ncurses-dev
I got this error:
Reading package lists… Done
Building dependency tree
Reading state information… Done
Note, selecting ‘libncurses5-dev’ instead of ‘ncurses-dev’
E: Unable to locate package gcc-arm-linux-gnueabi
and when I run this command:
make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- -k
I got this error :
/bin/sh: 1: /usr/bin/arm-linux-gnueabi-gcc: not found
make[1]: *** [kernel/bounds.s] Error 127
make[1]: Target `__build’ not remade because of errors.
make: *** [prepare0] Error 2
HOSTCC scripts/genksyms/parse.tab.o
CC scripts/mod/empty.o
/bin/sh: 1: /usr/bin/arm-linux-gnueabi-gcc: not found
make[2]: *** [scripts/mod/empty.o] Error 127
HOSTCC scripts/mod/mk_elfconfig
make[2]: Target `__build’ not remade because of errors.
make[1]: *** [scripts/mod] Error 2
HOSTCC scripts/kallsyms
HOSTCC scripts/pnmtologo
HOSTCC scripts/conmakehash
HOSTCC scripts/bin2c
HOSTLD scripts/genksyms/genksyms
make[1]: Target `__build’ not remade because of errors.
make: *** [scripts] Error 2
make: Target `_all’ not remade because of errors.
Hi
Firstly many thanks on the hard work and for making the compiled kernel freely available. I am finding it impossible to download the entire kernel, it keeps stopping at around 24 – 28MB. I’ve tried different browsers and download managers with no success.
Very frustrating and a shame no-one can see your work. Is there some other way I can get hold of the download?
Sorry for your trouble.
I’ll try and get it fixed.
You get get the file from here;
https://www.mediafire.com/?v0y2qnfa6jx32fe
Thanks a lot Mark, brilliant! I really wasn’t looking forward to trying to compile it on the PI.
Thanks for the guide – A matter of interest, is it possible to connect more than one screen with one Pi? How many can you put? Is it possible to show as different display rather than cloned” screen?
Apparently yes you can have an extended screen on two small screen, which seems fine for SBS3D http://cassettepunk.com/blog/2013/11/12/view-master-video-player-hacking/
Yep — I also wrote a HOWTO for converting an FBTFT display driver to SBS3d. See http://cassettepunk.com/blog/2013/11/21/howto-convert-an-spi-framebuffer-driver-to-stereoscopic/ for details.
thank you for all of your great contributions!
I wonder if this can be applied on the 3rd and 4th screen?
My idea is to use 4 screens to display 4 different graphics.
Yes, the same approach can be extended to as many displays as you have spare GPIO lines (to control the chip select lines for each display). And you can gang displays together arbitrarily. If you can follow the HOWTO and understand the approach it’s taking, you should be fine to hack up the driver for more displays.
ok, slightly off topic, but would like to know if the LCD from the Nokia N810 (AM 800x480x16) could be used with the RPi? It is a great screen, but unfortunately the hardware has become a bit outdated.
Any thoughts?
Hi,
before i start “Clone my raspberrypi-linux repo” i have to run “uname -a” so i can find out my based branch.
I typed it in and i have the Linux raspberrypi 3.10.19+.
The manual of Kamal Mosafa says that you have select the rpi-3.2.27+kamal or the rpi-3.6.y+kamal. But my rpi is completly different.
Does anybody know which i have to select?
Regards
Patrick
kamal’s drivers are based off the Raspian image. What are you using? OpenElec?
Is there a way to use your patch on the latest XBMC for Raspberry PI? How?
I’m not sure about the above patch. But, I think Notro has been able to get his version working with XBMC
I guess I got ahead of myself with the XBMC…. I got your patch to work up to a point, with the latest Wheezy, but get and error when entering: to start X;
“FRAMEBUFFER=/dev/fb1 startx”
command.
The gif, of the robot, appeared with the command pior to this one, but other than that I only see the boot up sequence, via the 1.8 TFT, then the TFT goes blank, with the exception of a “-” without the quotes.
Hi,
thanks a lot for your tutorial! I followed your instructions and all worked out well!
I wonder if you have managed to use the SD slot on the lcd-board?
Greetz!
Murmel
No sorry
when i want start the “startx” with FRAMEBUFFER=/dev/fb1 startx, then comes a white – on the LCD Display and thats it… why? (sorry for my english)
Hello
In your desctibed that you could use CS 0 or CS1.
But can anybody tell me how i can use CS1 instead of CS0?
Thanks for your help!
Best Regards,
Patrick
*you described,
sry for mistake
Hi,
I’ve downloaded the 1.8TFT kernel and followed the instructions on README. But TAR process is stopped with unspecified error message. I’m using firmware 3.12.26+ on the Pi. Could that be the reason? if so, how to overcome?
Have any one got this working on a 4.0.x or 4.1.x kernel with device tree. Raspberry Pi3 B .
Can spi_bcm2835 driver
Hi,
The link to the Kernel instructions leads to a page not found error, could you please update the link?
The links have now been fixed
I had trouble finding this Image. So, I thought I’d provide a link. http://downloads.raspberrypi.org/raspbian/images/2013-05-25-wheezy-raspbian/
Sorry wrong image i meant http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/ .
Hello,
I am currently attempting to make a wearable headset using a PI4b. I would like to use the sainsmart 1.8″ TFT for the primary display.
My question is: is this method still viable on the newest raspbian versions? If so, are there any special/different steps needed to make it work?
I have almost no experience with coding outside of math languages (matlab) so if you have a solution can you make it as “barney style” as possible for me? I tried to install different a patch for the same type of project but if froze my os during boot-up. So I had to re-image my sd card…
thank you!