Unable To Use TFT ILI9341 With Pi And Resin


#1

I’m trying to use my TFT with resin but I can’t get it to work. I followed this guide to set it up https://www.raspberrypi.org/forums/viewtopic.php?f=91&t=111817 (last comment). Using that guide I got it to work perfectly on Raspbian by editing the config.txt and cmdline.txt, just those 2 files because I can’t use touch because my screen is not detecting touch input, but I can’t get it to work on Resinos, I swapped back to my Raspbian SD thinking that the screen might have died but it worked. Am I doing anything wrong?


#2

We are using a bunch of Raspberry Pi TFT screens for demos with resin.io, so fundamentally it should work. Tomorrow I will check with the screens we use with the info in forum post you linked to.

One thing I can think of is that current Raspbian and current resinOS is using different kernel versions and thus different device tree overlays). The forum post mentions the 4.4.x kernel for the Raspberry Pi and the the rpi-display overlay. The current version of resinOS is on an earlier kernel, but I think it should already include that overlay… Will check this as the first thing.

In the meantime, what exact TFT module are you using? (for example we usually work with PiTFT Plus 2.8"). Which Raspberry Pi version you work with?


#3

Hi, yes I saw that blog post. I’m using this tft screen that I bought from ebay: http://m.ebay.com/itm/401087406846?_mwBanner=1#shpCntId

I am completely sure that the screen works (at least eith the latest Raspbian) and I know that in my unit the touch sensor is damaged but I don’t need it.

Edit:

Raspbian V: 2016-09-23 with Pixel (although this worked before Pixel) Kernel: (I’m not sure, I think that 4.4)

And this are the additions I made to try to make the screen work:

cmdline.txt

fbcon=map:10 fbcon=font:VGA8x8 logo.nologo

config.txt

# TFT display and touch panel
#dtoverlay=rpi-display,rotate=0,speed=10000000,xohms=100,debug=4
dtoverlay=rpi-display
dtparam=rotate=90
dtparam=speed=10000000
dtparam=xohms=100
dtparam=debug=4

I’m not sure if I’m missing anything else.


#4

Checked out the 1.24.1 resinOS release, and that does not have the rpi-display overlay included, so I’m guessing that’s the main issue, why it doesn’t work what you are trying. I’ve checked out the info on rpi-display, it seemed pretty generic, and similar to putft28-resistive overlay which included with the current version, and the hardware also uses ILI9341.

Seems like all is needed is enabling this other overlay with the right parameters, for example:

dtoverlay=pitft28-resistive,rotate=90

This was enough for me to get the TFT screen working. Note, that the dtparm values can be put together in one line with the dtoverlay, as your example shows above as well (just commented out, the 2nd line of the config.txt you show).

You can also set all this remotely, by adding a RESIN_HOST_CONFIG_variablename Fleet or Device configuration, for example in this case would be RESIN_HOST_CONFIG_dtoverlay with the value pitft28-resistive,rotate=90. See more details in the docs.

Test

To test it, I used a very simple setup.

  • Started from a new application, downloaded the OS image, burned it on an SD card

  • Set a Fleet Configuration with the name RESIN_HOST_CONFIG_dtoverlay with valuepitft28- resistive,rotate=90 (rotation is 90 degrees, set to the angle I had the display at)

  • Created a new git repo with Dockerfile.template such as this:

FROM resin/%%RESIN_MACHINE_NAME%%-debian:latest

WORKDIR /usr/src/app
ENV INITSYSTEM on

RUN apt-get update && \
    apt-get install -yq --no-install-recommends \
     fbi wget \
    && apt-get clean && rm -rf /var/lib/apt/lists/*

ENV DEFAULTIMAGE https://upload.wikimedia.org/wikipedia/commons/thumb/6/64/2008_inside_the_National_Portrait_Gallery,_London.jpg/320px-2008_inside_the_National_Portrait_Gallery,_London.jpg

CMD wget "${IMAGE-$DEFAULTIMAGE}" -O image.jpg && \
    fbi -d /dev/fb1 -T 1 --noverbose image.jpg && \
    while : ; do echo "idling..."; sleep 600; done

It installs fbi, the framebuffer image viewer, downloads an image from the internet and displays it (controllable over the IMAGE environment variable.

git-commit this one file, and push it to the application.

  • Attach the TFT to the Pi, and boot it up from the SD card. After some configuration resin will set the values defined above in config.txt, and starts the application. Here’s the result I got for these two settings (the fleet config and the Dockerfile.template)

I am not 100% sure that your TFT works exactly the same, but it might worth a try.

Overlays

For reference, here are all the overlays included in host OS 1.24.1:

hifiberry-amp-overlay.dtb
hifiberry-dac-overlay.dtb
hifiberry-dacplus-overlay.dtb
hifiberry-digi-overlay.dtb
i2c-rtc-overlay.dtb
iqaudio-dac-overlay.dtb
iqaudio-dacplus-overlay.dtb
lirc-rpi-overlay.dtb
pi3-miniuart-bt-overlay.dtb
pitft22-overlay.dtb
pitft28-resistive-overlay.dtb
pps-gpio-overlay.dtb
rpi-ft5406-overlay.dtb
w1-gpio-overlay.dtb
w1-gpio-pullup-overlay.dtb

We are adding the latest device tree overlays to the resinOS upgrade in the near future, so should have all standard ones hopefully soon.


#5

Ok thanks, I’ll give it a try


#6

Nope, that didn’t worked but I got it working by sideloading the overlay.


#7

Good to hear it works now! :thumbsup: Sideloading means dropping the file on the SD card as well and using it that way? Maybe it is indeed a different overlay than the pitft28 series. Hope to get the new set of overlays into resinOS very soon, to cut down such issues.


#8

Yes, I downloaded the overlay from GitHub and pasted it in the overlays folder of the SD card, and this time I configured it from the web.


#9

Brilliant! :checkered_flag: That’s a clear path for improvement, once the new device tree overlays are included, won’t need any editing of the card. :blush:

Are you working on any particular project, or just experimenting with the hardware?


#10

Right now I’m experimenting but I have a personal project, I want to make a desktop clock. https://github.com/iGerli/clockOS/wiki


#11

Very cool, thanks for sharing! Would definitely love one of these on my bedside table! :first_quarter_moon_with_face:

Not sure if you’ve seen the resin-electronjs project by @curcuz, maybe good for some inspiration! :pen_fountain: That project has a framebuffer branch with the changes required to run on the TFT screen (it needs to pull in the latest changes from master, but maybe there would be a way to combine the code into a single codebase).


#14

I’m planning to use that project by @curcuz, I haven’t seen that branch, I’m going to try to update it if necessary.

Edit: Updated it in my copy of it, I’ll try to fork it and update it


#15

@imrehg do you know if ResinOS syncs automatically with time servers?


#16

Yes, it does, here’s the relevant info in the docs: Time Management