RaspberryPi 3 with PiTFT 3.5" Restive Touch & ElectronJS

Hi All,

I recently got my hands on a PiTFT display. Its this model ( https://www.adafruit.com/product/2097 ) - 3.5" 480x320 Restive Touch.

My Goal : Create a small interface to display / pilot some of the applications I’m running through resin on this Pi. Since I’m not a coding expert, I’ve headed the nodeJS / JS way as this is a language I have the most knowledge off. And also happens to be the language the app running on my resin Pis is dev’d in.

Initially I was looking into getting it to work with WPE. https://github.com/resin-io-playground/resin-wpe
But upon recommendation, I’ve changed my mind to use ElectronJS instead. Starting off with getting the boilerplate operational. => https://github.com/resin-io/resin-electronjs/

So To start simple, I’ve set the Env. Variable URL_LAUNCHER_URL to a URL. To display that page onto the PiTFT. It works on the HDMI screen I also connected, but the PiTFT stays turned on, but blank (white screen).

I’ve looked also at Adafruit’s FAQ, trying out their recommendations : https://learn.adafruit.com/adafruit-pitft-3-dot-5-touch-screen-for-raspberry-pi/faq?view=all

In my config.txt I have :
dtparam=spi=on
dtparam=i2c1=on
dtparam=i2c_arm=on
dtoverlay=pitft35r,rotate=90,speed=42000000,fps=20
gpu_mem=160

I tried several variations of settings in the config.txt but couldn’t figure out anything that worked.
In my console on resin I a have :

29.11.17 11:17:59 (+0800) Systemd init system enabled.
29.11.17 11:17:59 (+0800) systemd 215 running in system mode. (+PAM +AUDIT +SELINUX +IMA +SYSVINIT +LIBCRYPTSETUP +GCRYPT +ACL +XZ -SECCOMP -APPARMOR)
29.11.17 11:17:59 (+0800) Detected virtualization 'other'.
29.11.17 11:17:59 (+0800) Detected architecture 'arm'.
29.11.17 11:17:59 (+0800) Set hostname to <0578e5e>.
29.11.17 11:18:02 (+0800) hostname: No address associated with hostname
29.11.17 11:18:02 (+0800) xauth:  file /root/.Xauthority does not exist
29.11.17 11:18:02 (+0800) xauth: (stdin):1:  bad display name "0578e5e:0" in "add" command
29.11.17 11:18:02 (+0800)
29.11.17 11:18:02 (+0800)
29.11.17 11:18:02 (+0800) X.Org X Server 1.18.4
29.11.17 11:18:02 (+0800) Release Date: 2016-07-19
29.11.17 11:18:02 (+0800) X Protocol Version 11, Revision 0
29.11.17 11:18:02 (+0800) Build Operating System: Linux 4.4.26-v7+ armv7l Raspbian
29.11.17 11:18:02 (+0800) Current Operating System: Linux 0578e5e 4.9.50 #2 SMP Wed Nov 1 16:03:39 UTC 2017 armv7l
29.11.17 11:18:02 (+0800) Kernel command line: 8250.nr_uarts=0 bcm2708_fb.fbwidth=1824 bcm2708_fb.fbheight=984 bcm2708_fb.fbswap=1 vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000  dwc_otg.lpm_enable=0 console=null root=/dev/mmcblk0p2 rootfstype=ext4 rootwait vt.global_cursor_default=0
29.11.17 11:18:02 (+0800) Build Date: 11 November 2016  11:59:59AM
29.11.17 11:18:02 (+0800) xorg-server 2:1.18.4-2+rpi1 (https://www.debian.org/support)
29.11.17 11:18:02 (+0800) Current version of pixman: 0.33.3
29.11.17 11:18:02 (+0800)       Before reporting problems, check http://wiki.x.org
29.11.17 11:18:02 (+0800)       to make sure that you have the latest version.
29.11.17 11:18:02 (+0800) Markers: (--) probed, (**) from config file, (==) default setting,
29.11.17 11:18:02 (+0800)       (++) from command line, (!!) notice, (II) informational,
29.11.17 11:18:02 (+0800)       (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
29.11.17 11:18:02 (+0800) (==) Log file: "/var/log/Xorg.0.log", Time: Wed Nov 29 03:18:02 2017
29.11.17 11:18:02 (+0800) (==) Using system config directory "/usr/share/X11/xorg.conf.d"
29.11.17 11:18:11 (+0800) [212:1129/031811.431368:WARNING:audio_manager.cc(295)] Multiple instances of AudioManager detected
29.11.17 11:18:11 (+0800) [212:1129/031811.431845:WARNING:audio_manager.cc(254)] Multiple instances of AudioManager detected
29.11.17 11:18:12 (+0800) [235:1129/031812.174771:ERROR:sandbox_linux.cc(343)] InitializeSandbox() called with multiple threads in process gpu-process.
29.11.17 11:18:15 (+0800) [212:1129/031815.374899:ERROR:object_proxy.cc(583)] Failed to call method:org.freedesktop.NetworkManager.GetDevices: object_path= /org/freedesktop/NetworkManager: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.NetworkManager was not provided by any .service files
29.11.17 11:18:15 (+0800) [212:1129/031815.375035:WARNING:wifi_data_provider_linux.cc(183)] Failed to get the device list

I probably missed something simple somewhere. I’m looking forward to your feedbacks!

Hi,
I believe the overlay you need is named differently. Can you instead try with this name?

dtoverlay=pitft35-resistive,rotate=90,speed=42000000,fps=20

Thanks Floion,

Just tried, now the difference is that the PiTFT screen is dark.
The console seems to be identical.

Can you change the config.txt settings to these:

disable_overscan=1
dtparam=spi=on
dtoverlay=pitft35-resistive,rotate=90,speed=32000000,fps=60

?

OK, so just tried. The end result is the same. My webpage displays on the HDMI monitor, and PiTFT stays dark.

This time though, during the booth process, HDMI monitor displayed the resin splash in the top-right corner. Not sure it has much of a link, but just sharing in case it matters.

To recap, current content of my config.txt :

disable_overscan=1
dtparam=spi=on
dtoverlay=pitft35-resistive,rotate=90,speed=32000000,fps=60
gpu_mem=160

Okay, I missed some settings on my previous post.

Can you add so that it’s similar to this:

hdmi_force_hotplug=1
hdmi_cvt=480 320 60
hdmi_group=2
hdmi_mode=87

and also

disable_overscan=1
dtparam=spi=on
dtoverlay=pitft35-resistive,rotate=270,speed=32000000,fps=60

?

You can also keep

dtparam=i2c1=on
dtparam=i2c_arm=on

Okay, some really good progress now :slight_smile:
Now the splash appears on both the HDMI monitor and the PiTFT. Once the Pi is booted though, the webpage displays on the HDMI monitor (it’s in the 480x320 resolution) but the PiTFT is black.

almost!

Recap of the content of my config.txt

hdmi_force_hotplug=1
hdmi_cvt=480 320 60
hdmi_group=2
hdmi_mode=87

disable_overscan=1
dtparam=spi=on
dtoverlay=pitft35-resistive,rotate=270,speed=32000000,fps=60

dtparam=i2c1=on
dtparam=i2c_arm=on

gpu_mem=160

Do you want dual screen to work? What happens now if you unplug hdmi and reboot?

Not necessarily Dual Screen. It’s good if it works - but not a must. Priority is to have the PiTFT work :slight_smile:

If I reboot without HDMI it’s the same, splash on PiTFT then black.

Right. And one more time, apparently the speed param is wrong. Can you try with:

dtoverlay=pitft35-resistive,rotate=90,speed=25000000,fps=20

I also see I wrote rotate 270 before. I meant it to be 90

Same thing. No noticeable difference aside of the rotation.

Quick update, on the latest one, here is what I have in the console at the end. Slightly different from what I had at the start.

29.11.17 17:36:53 (+0800) [179:1129/093653.792300:WARNING:audio_manager.cc(295)] Multiple instances of AudioManager detected
29.11.17 17:36:53 (+0800) [179:1129/093653.793073:WARNING:audio_manager.cc(254)] Multiple instances of AudioManager detected
29.11.17 17:36:54 (+0800) [202:1129/093654.966049:ERROR:sandbox_linux.cc(343)] InitializeSandbox() called with multiple threads in process gpu-process.
29.11.17 17:36:55 (+0800) [179:1129/093655.807793:ERROR:backend_impl.cc(1033)] Critical error found -8
29.11.17 17:36:55 (+0800) [179:1129/093655.808336:ERROR:entry_impl.cc(1039)] No file for c103001e
29.11.17 17:36:55 (+0800) [179:1129/093655.809533:WARNING:storage_block-inl.h(131)] Failed data load.
29.11.17 17:39:06 (+0800) [179:1129/093906.550286:ERROR:object_proxy.cc(583)] Failed to call method:org.freedesktop.NetworkManager.GetDevices: object_path= /org/freedesktop/NetworkManager: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.NetworkManager was not provided by any .service files
29.11.17 17:39:06 (+0800) [179:1129/093906.550469:WARNING:wifi_data_provider_linux.cc(183)] Failed to get the device list

There is this critical error that wasn’t there before.

I’ve browsed a little and found this : https://www.raspberrypi.org/forums/viewtopic.php?t=138757
Not totally related but I went ahead and used the resin terminal to do the following :

$ cd /boot/
$ mkdir overlays
$ cd overlays
$ wget https://www.dropbox.com/s/npjc52s2z6ifk55/pitft35r-overlay.dtb?dl=0 -O pitft35r-overlay.dtb
$ wget https://raw.githubusercontent.com/adafruit/Adafruit-PiTFT-Helper/master/adafruit-pitft-helper
$ chmod +x adafruit-pitft-helper
$ sudo mount /dev/mmcblk0p1 /boot
$ sudo ./adafruit-pitft-helper -t 35r -u /data/

And the console got me this for the helper process:

Type = 35r
Homedir = /data/
[PITFT] Checking init system...
Found systemd
/boot is mounted
[PITFT] Updating X11 default calibration...
[PITFT] Updating X11 setup tweaks...
grep: /data//.profile: No such file or directory
Adding 'export FRAMEBUFFER=/dev/fb1'
[PITFT] Updating TSLib default calibration...
[PITFT] Updating SysFS rules for Touchscreen...
Would you like the console to appear on the PiTFT display? [y/n] y
[PITFT] Updating console to PiTFT...
Updating /boot/cmdline.txt
sed: can't read /etc/kbd/config: No such file or directory
[PITFT] Updating /etc/modules...
Adding stmpe_ts
[PITFT] Updating /boot/config.txt...
[PITFT] Success!
[PITFT] Notes:
Please don't run rpi-update, or you'll have to re-install a kernel
with PiTFT support.  For more info, see:
https://learn.adafruit.com/adafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-pi/faq

I then rebooted the Pi, and the result was the the HDMI output was off. And the PiTFT was now displaying my webpage as set in the env.variables.

This is what the adafruit script added to my config.txt
# — added by adafruit-pitft----helper Wed Nov 29 10:00:37 UTC 2017
[pi1]
device_tree=bcm2708-rpi-b-plus.dtb
[pi2]
device_tree=bcm2709-rpi-2-b.dtb
[all]
dtparam=spi=on
dtparam=i2c1=on
dtparam=i2c_arm=on
dtoverlay=pitft35-resistive,rotate=270,speed=25000000,fps=20
# — end adafruit-pitft-helper Wed Nov 29 10:00:37 UTC 2017 —

So nothing extra from what he already had. I’m no expert, but could it be that the resin image has some files missing to support that particular screen ?

Only issue with that, is that it won’t always be here. Just did a reboot and it’s back to like before …

How were you adding to config.txt before? Have you always used the webterminal or did you ssh to the host OS?

Are you using an image from resin.io or from resinos.io?

I was editing the file manually. Inserting the SD card in my pc.

The image is from resin.io
Created an app for rpi3 and downloaded the default one.

App code is the ElectronJS boilerplate straight from GitHub.

So I guess my next move now is to figure how I can have the files needed (are these called drivers?) for this display into the resin base image I’m using.

Again, this it totally unknown territory for me, any hints appreciated :slight_smile:

I would just say to try on a fresh install and add to config.txt just the above settings that the adafruit helper added.

You can modify the confg.txt on the SD card as you did or you can try like https://resin.io/blog/updating-config-txt-remotely/

I would first say you modify it directly on the SD card and see if you get it to work consistently

Ok, so I’ve restarted from scratch.

0- Loaded files from git (https://github.com/resin-io/resin-electronjs) into my git folder, resin push to master etc.
1- DL a fresh image from the resin dashboard
2- Edit manually the config.txt and added the following :

dtparam=spi=on
dtparam=i2c1=on
dtparam=i2c_arm=on
dtoverlay=pitft35-resistive,rotate=270,speed=25000000,fps=20
gpu_mem=160

3- Changed the env variable to
URL_LAUNCHER_URL = file:////usr/src/app/data/index.html
(the default page)

Source: https://github.com/resin-io/resin-electronjs

4- Boot Up.

So while the splash displays on the PiTFT, as soon as the app runs, screen is ON but blank. So identical behaviour as before.
Also, I pluged-in HDMI to verify and there there is proper display of the app Hello World page.


So I do believe some kind of something to drive the PiTFT 3.5 is missing somewhere.
Any ideas ?

Hey @xyala,

I think that the only missing thing here is configuring the xserver to use the correct framebuffer device. My configuration to get resin-electronjs running on a PiTFT 3.5’’ Resistive Touch was:

  1. DL a fresh image from resin dashboard
  2. Set Device Configuration variable
    RESIN_HOST_CONFIG_dtoverlay
    to
    pitft35-resistive,speed=25000000,fps=20
  3. Set Device Configuration variable
    RESIN_HOST_CONFIG_gpu_mem
    to
    160
  4. Edit app/start.sh by prepending FRAMEBUFFER=/dev/fb1 startx ...
  5. Commit and push changes

After that I was able to see the hello world message and unicorn (not the full ascii art since it’s trimmed due to screen size) on the TFT screen.

Ok I see. Makes sense actually.

do you have the full line you use for 4, the … starx … ?

I’m going to try this as soon as I touch down ! (Not sure it’s a good idea to take out the RPI on the plane haha)

Thanks !