Jump to content

Recommended Posts

Posted

When I run pygame for any significant length of time on legacy kernel it crashes with a kernel timeout error.  I haven't been able to get past this, and from what I tell, it should be fixed in later kernels.  So, I'm trying my hand with the mainline kernel, and I have two hurdles I haven't been able to pass yet.

 

I'm using an Orange Pi Zero, hardware Ethernet, mainline distro, with a 2.4" SPI TFT LCD.  Frame buffer is /dev/fb0 created with

     modprobe fbtft_device custom name=fb_ili9341 gpios=reset:1,dc:0,led:3 speed=48000000 rotate=90 busnum=0 txbuflen=65536

 

Whenever I create a display I get an error that it cannot open mouse.  The following toy world program:
 

#! /usr/bin/env python
import pygame
screen = pygame.display.set_mode((320, 240))
while 1:    
  pass

returns:

Traceback (most recent call last):
File "./bar", line 5, in <module>
  screen = pygame.display.set_mode((320, 240))

pygame.error: Unable to open mouse

Using the same hardware with the legacy distro does not give the same error.

 

On larger programs I'm also getting a slew of ALSA messages too, but I'm not sure how critical they are.  I'm hoping they're informational, but I'll look at them closer when I get past the mouse error.  I'll include them here to be complete in case they are critical to the main issue:

  Reveal hidden contents

 

 

I know mainline is experimental and not supported, but since I've hit a dead-end on legacy I thought I'd work on this distro before moving to other systems.  Please hit me up with any suggestions, or share the laugh with me if I'm doing something really dumb.

Posted

If I might ask a rather broad question -- has anyone got an il9341 2.4" TF display to work with mainline kernel on an orange pi zero? 

 

I can get the device to register with modprobe, and the backlight becomes active, but I haven't been able to get anything else happen to the display.  I'm wondering just how far in over my head I am.

Posted

Yes it work fine for me. This are my fbtft options:

name=fb_ili9341 gpios=dc:0,led:3,reset:1 speed=16000000 busnum=1 rotate=0 bgr=1

 

I think your problem is busnum. In OPIZero the SPI bus=0 is connected to a SPI flash you should use bus 1.

 

 

 

 

 

Posted

Thanks for the lead!  But when I use busnum 1 I get an error modprobe: ERROR: could not insert 'fbtft_device': Invalid argument

 

Using busnum 0 executes with no terminal messages, the backlight turns on and the screen is all white, and dmesg looks good.

  Reveal hidden contents

 

But I can't get any pygame programs to work even if I add os.putenv('SDL_FBDEV','/dev/fb0') before pygame.init().  Argh!

Posted

Hi ldiaz,

 

Would you mind giving some more information about how you set up an LCD to work with the Orange Pi Zero? it would be most appreciated!

 

I'm trying to set up a Waveshare Spotpear 3.5" LCD; I would really like to set up an Adafruit 2.8 capacitive touch screen, but that is for later.

 

Here are some questions:

  1. What armbian distribution are you using?
  2. What LCD did you use?
  3. What GPIOs on the Orange Pi did you use and how do they match with the LCD?
  4. Did you make any modifications to script.bin.? 
  5. Did you download any drivers or other packages?
  6. Did you user overlays?
  7. Did you have to modify any other files to get it to work?

Thank you very much,

Rod

 

 

Posted

rlsten -- do you want info for legacy?  I've got my 2.4" working well on that, but pygame won't run for long periods without throwing an error.  That's why I'm moving up to the newer mainline environment with the current kernel.  For legacy I did not need to make script.bin changes, only had to add python-pygame package, and no overlay work.

Posted

Touch is possible, but not something I did in any of my projects.  There are additional pins on the display for touch that will need to be connected, and if you use x windows the display may need to be calibrated.  

Posted

Hi

  • Im using main-line/dev version not legacy.
  • The GPIO are those of the SPI1 interface + some extra for additional signals required. in my case gpios=dc:0,led:3,reset:1.
  • For display only its not needed to install any overlay only notro's fbtft.
  • In case that what to use the touch screen then you need to use a device tree overlay using with spidev and spi-add-cs1 overlays. (attached my version)
  • For touch you need and additional CS GPIO defined in spi-add-cs1 and one more for IRQ from the touch screen. I picked "PA7".

 

regards,

touch.dts

Posted

@ldiaz - you had to install notro's fbtft in mainline?  I've been trying to get things to work with the fb included in the distro.  Since I could get the backlight to respond with modprobe and the messages looked like it created a good /dev/fb0 I thought it was okay as-is.

 

If you added notro's fbtft, would you tell me specifics on what you added (which src/bin's you downloaded and installed)?

Posted

The fbtft is included in main-line build you don't need to download or install anything else. As you say the once ftft_device is activated if wiring is correct the screen works with out problem in /dev/fb0. X windows also works with out problem.

 

For touch screen you need to load the overlay I posted.

 

 

 

 

Posted

Sorry for hijacking your thread.

This option was working ok for me for 3.5 inch raspberry lcd on legacy kernel but for mainline it doesn't work : (My /etc/modprobe.d/fbtft.conf)

options fbtft_device custom name=fb_ili9486 gpios=dc:18,reset:2 speed=16000000 busnum=1 txbuflen=32768 rotate=270

I also have a "fbtft.conf" file /etc/module-load.d/ which contains : fbtft_device .

it used to work ok in legacy but in kernel I get onlt white screen and the screen does not initialize.

modprobe fbtft_device custom name=fb_ili9486 gpios=dc:18,reset:2 speed=16000000 busnum=1 txbuflen=32768 rotate=270  gives me error : ERROR: could not insert 'fbtft_device': Invalid argument

 

can you please help me why this is not working in mainline kernel ?

Best regards.

Posted

You are not hijacking the thread at all! Your experience is very close to mine, and I started this thread.

 

In your case, have you tried to use busnum=0?  Modprobe completes without errors for me with busnum 0 works, but not busnum 1.

Posted

@A-P There is no more detail in dmesg about the error?

 

It's very strange that @glow solution to busnum=0 works as OPIZERO has no pins to connect to SPI0 bus in the GPIO header. Check this:

 

Orange-Pi-Zero-Pinout-banner2.jpg?fit=12

 

Busnum=1 will use the pins for SPI1: SPI1_CLK,SPI1_MISO,SPI_MOSI and SPI1_CS.

 

For other needed pins (this will depend on the screen) you need to select the GPIOS manually. Be aware of the mapping:

Orange-Pi-Zero-pinout.jpg

Check your wiring to verify it is correct with fbtft parameters. What errors are shown in dmesg?

 

For checking that thet SPI1 works well you can use the spi-dev overlay simply puting this in /boot/armbianEnv.txt:

overlays= <other overlays> spi-spidev  

param_spidev_spi_bus=1

after reboot /dev/spi*  files should be present.

 

Posted

@ldiaz I'm not sure how to explain my results with busnum -- my zero does not have spi flash on it (the space for the chip on the back is empty).  Does your zero have spi flash memory?

Posted

@glow. Mine has a spi flash.  But the fact is that H2+ gpios for SPI0 are not accesible in the GPIO header, so in any case you need to connect the display to the SPI1 not the 0. As you have done here:

  Quote

pin

21 - miso

15 - led

23 - sck

19 - mosi

13 - dc

11 - reset

24 - cs

06 - gnd

01 - vcc

Expand  

 

  Try the overlay spi-dev  with busnum=1 as I commented in my previus post. Then try to load the driver for the display with modprobe.

 

  Quote

overlays= <other overlays> spi-spidev  

param_spidev_spi_bus

Expand  

 

Posted

I'm comfortable in nix environments, but overlays are new to me.  I last recall using 'overlays' on a heathkit with 4k ram, but that's a different story.

 

I've verified my pin connections - they are identical to yours.   Since I'm new to overlays I followed your earlier message and  added the following to the end of /boot/armbianEnv.txt

     overlays= <other overlays> spi-spidev
     param_spidev_spi_bus=1

 

After reboot there are no /dev/sp* devices.  (there weren't any before the reboot either, perhaps the /dev/spi* devices are specifically tied to spi memory, and not the spi bus???  at no time do I have an /dev/spi* entry)

 

modprobe fbtft_device custom name=fb_ili9341 gpios=dc:0,led:3,reset:1 speed=16000000 busnum=1 rotate=0 bgr=1 generates an error

modprobe: ERROR: could not insert 'fbtft_device': Invalid argument and dmesg shows:

[  112.942447] fbtft: module is from the staging directory, the quality is unknown, you have been warned.
[  112.949365] fbtft_device: module is from the staging directory, the quality is unknown, you have been warned.
[  112.951171] spi spi0.0: spi-nor spi0.0 10000kHz 8 bits mode=0x00
[  112.951279] fbtft_device: spi_busnum_to_master(1) returned NULL
[  112.957422] fbtft_device: failed to register SPI device

 

if I then change busnum=0 in modprobe it works and dmesg shows

[  144.264907] fbtft_device: module is from the staging directory, the quality is unknown, you have been warned.
[  144.266482] spi spi0.0: spi-nor spi0.0 10000kHz 8 bits mode=0x00
[  144.266595] spi spi0.0: Deleting spi0.0
[  144.267381] fbtft_device: GPIOS used by 'fb_ili9341':
[  144.267390] fbtft_device: 'dc' = GPIO0
[  144.267396] fbtft_device: 'led' = GPIO3
[  144.267402] fbtft_device: 'reset' = GPIO1
[  144.267419] spi spi0.0: fb_ili9341 spi0.0 16000kHz 8 bits mode=0x00
[  144.282605] fb_ili9341: module is from the staging directory, the quality is unknown, you have been warned.
[  144.635818] Console: switching to colour frame buffer device 30x40
[  144.637480] graphics fb0: fb_ili9341 frame buffer, 240x320, 150 KiB video memory, 16 KiB buffer memory, fps=20,
 spi0.0 at 16 MHz

 

I have another brand new zero so my next step is use it with another display and a fresh mainline image and see if I get the same results.

 

I remember my excitement when I used the same hw with a legacy image and it worked like a charm.  Too bad the programs would crash after running for a substantial period of time.

Posted

overlay is nothing special is only hardware definition SPI o IC2 have not hw discovery mechanims. Try spi-dev overlay without loading the driver and check if spi1 devices are created.

 

My wiring is the following:

display      ZERO GPIOS
VCC       -  3.3 V pin 1
GND       -  GND pin 25 (any GND would do as they internaly connected)
CS      -  SPI1 CS0 pin 24
RESET     -  GPIO1 pin 11
DC      -  GPIO0 pin 13
MOSI       -  SPI1 MOSI pin 19
SCK      -  SPI1 SCLK pin 23
LED      -  GPIO3 pin 15
MISO      -  SPI1 MISO pin 21

 

SPI port are fixed pins, you must configure only DC/RESET/LED according to your wiring.
name=fb_ili9341 gpios=dc:0,led:3,reset:1 speed=16000000 busnum=1 rotate=0 bgr=1

 

 

 

Posted

@ldiaz

by adding :  overlays= <other overlays> spi-spidev and param_spidev_spi_bus=1 to armbianEnv.txt I have /dev/spi1.0 .

but fbtft options still give me error wih busnum=1 and the screen dos not work.

As I said before same options and the way I load fbtft_device works in legacy kernel but in mainline itdoes not work. so pin numbers and options are correct.

Any help ?

Posted

@A-P Honestly I have not tested the ili9486 you are using but the li9341 that @glow is ussing. However they should work both. I think the best way to trouble shoot this is:

1. Could you share your screan pinout and wiring to the OpiZero?

2. Could you share dmesg after modprobe of the driver?

3. what is on your armbianEnv.txt?

 

Regards,

Posted

Dear @ldiaz

The ili9487 is 3.5 inch HAT raspberry pi lcd. pinout for raspberry pi is as below :

 

PIN NO. SYMBOL DESCRIPTION
1, 17 3.3V Power positive (3.3V power input)
2, 4 5V Power positive (5V power input)
3, 5, 7, 8, 10, 12, 13, 15, 16 NC NC
6, 9, 14, 20, 25 GND Ground
11 TP_IRQ Touch Panel interrupt, low level while the Touch Panel detects touching
18 LCD_RS Instruction/Data Register selection
19 LCD_SI / TP_SI SPI data input of LCD/Touch Panel
21 TP_SO SPI data output of Touch Panel
22 RST Reset
23 LCD_SCK / TP_SCK SPI clock of LCD/Touch Panel
24 LCD_CS LCD chip selection, low active
26 TP_CS Touch Panel chip selection, low active

 

according to raspberry pi to orange pi transfrom pinout formula Reset pin for orange pi is GPIO2 and DC pin is GPIO18.

 

Output of dmesg :

  Reveal hidden contents

 

armbianEnv.txt  contents :

verbosity=1
logo=disabled
console=both
disp_mode=1920x1080p60
overlay_prefix=sun8i-h3
rootdev=UUID=4f5d3473-9def-435f-8591-83a518b0cb35
rootfstype=ext4
extraargs="fbcon=map:8"
extraargs="fbcon=rotate:2"

 

the only doubt I have is contents of /lib/modules/4.10.11-sun8i/kernel/drivers/video/fbdev/core/ which is different from 3.4.113 kernel. in mainline I only have : fb_sys_fops.ko  syscopyarea.ko  sysfillrect.ko  sysimgblt.ko.  but in 3.4.113I have a fbtft directory which has kernel files for every lcd type like :

fb_bd663474.ko  fb_ili9325.ko  fb_ra8875.ko   fb_ssd1331.ko    fb_tinylcd.ko
fb_hx8340bn.ko  fb_ili9340.ko  fb_s6d02a1.ko  fb_ssd1351.ko    fb_tls8204.ko
fb_hx8347d.ko   fb_ili9341.ko  fb_s6d1121.ko  fb_st7735r.ko    fb_upd161704.ko
fb_hx8353d.ko   fb_ili9486.ko  fb_ssd1289.ko  fbtft_device.ko  fb_watterott.ko
fb_ili9320.ko   fb_pcd8544.ko  fb_ssd1306.ko  fbtft.ko         flexfb.ko

 

Can you please check your /lib/modules/4.10.11-sun8i/kernel/drivers/video/fbdev/core/ directory and tell me if yours have different contents.

Thanks.

 

Posted

@A-P if you connect the screen to the PIZero as a Hat it sure SPI1 as SPI pins are those of this interface.  SP1 CS=0. Also DC, RST/DC seems correctly mapped.

 

The relevant part of the dmsg is this:

[  308.268459] fbtft: module is from the staging directory, the quality is unknown, you have been warned.
[  308.281149] fbtft_device: module is from the staging directory, the quality is unknown, you have been warned.
[  308.284168] m25p80 spi0.0: spi-nor spi0.0 10000kHz 8 bits mode=0x00
[  308.284388] fbtft_device: spi_busnum_to_master(1) returned NULL
[  308.291574] fbtft_device: failed to register SPI device
[  418.056146] fbtft_device: module is from the staging directory, the quality is unknown, you have been warned.
[  418.058972] m25p80 spi0.0: spi-nor spi0.0 10000kHz 8 bits mode=0x00
[  418.059177] fbtft_device: spi_busnum_to_master(1) returned NULL
[  418.066383] fbtft_device: failed to register SPI device

it seems the spi_busnum=1 is not activated / registered as present. This, in principle, could be accomplished by inserting this in the armbianEnv.txt

overlays=spi-spidev
param_spidev_spi_bus=1

As regards current location of drivers mine are here:

root@orangepizero:~# ls /lib/modules/4.11.5-sun8i/kernel/drivers/staging/fbtft/

fb_agm1264k-fl.ko  fb_hx8347d.ko  fb_ili9163.ko  fb_ili9340.ko fb_ili9486.ko  fb_s6d02a1.ko  fb_ssd1306.ko  fb_st7735r.ko  fb_tls8204.ko  fb_upd161704.ko  fbtft_device.ko

fb_bd663474.ko   fb_hx8353d.ko  fb_ili9320.ko  fb_ili9341.ko fb_pcd8544.ko  fb_s6d1121.ko  fb_ssd1331.ko  fb_st7789v.ko  fb_uc1611.ko   fb_watterott.ko  flexfb.ko

fb_hx8340bn.ko   fb_hx8357d.ko  fb_ili9325.ko  fb_ili9481.ko fb_ra8875.ko   fb_ssd1289.ko  fb_ssd1351.ko  fb_tinylcd.ko  fb_uc1701.ko   fbtft.ko

 

But I'm using 4.11 kernel version. It should not be relevant if the module system is propperly configured.

 

Hope It can be useful

 

 

 

 

 

 

Posted

I used different hardware, including a brand new opi zero that looks to have spi flash but it behaves the same;  Briefly, using a mainline image, apt-get update/install, and install python-pygame.  After modprobe using bus 0 the backlight on the display lights up, but nothing I do after that shows up on the display.. It remains white. My goal is to get pygame to display (I don't want to X windows), and I'm not interested in input at this time.  I only want to display information.

 

I've tried to add the overlay information as suggested to armbianEnv in /boot, tried busnum 1 (error) as well as 0 (creates /dev/fb0), and tried con2fbmap.  When using legacy pygame scripts work.  I'll retry the suggestions made by @ldiaz  to be sure I haven't overlooked anything.  Hopefully I'll find a step I overlooked and it'll start working.

Posted

Thank you @ldiaz, By adding overlays=spi-spidevparam_spidev_spi_bus=1 it worked .

Now can you please tell me a step-by-step guide how to enable touch  ? touch screen chip is xpt2046 and pinout is like the one I sent you before.

Again thanks for your time.

Posted

I thank you too @ldiaz.  Like @a-p I added overlays=spi-spidevparam_spidev_spi_bus=1 to armbianEnv and when I modprobe (using busnum=1 l like you said ) I got a console window on my display.  Progress! 

 

I appreciate your sticking with us on this.  I was about to give up. 

Posted

This is not directly relevant, but I wanted mention something as a follow up.  My immediate goal is to use the display as output (no input needed).  When I tried running my pygame programs I got the following message and my pygame programs would not run.

 

pygame.error: Unable to open mouse

 

Since I don't care about a mouse [at this time] I added a line after the device identifier and it seems to be working:

os.putenv('SDL_FBDEV','/dev/fb0')
os.putenv('SDL_MOUSEDEV', '/dev/null')   # workaround for unable to open mouse error

pygame.init()

 

If this is really dumb, please let me know.  For now, I'm back to being a kid in a candy shop.

Posted

I want to start by saying how much I appreciate the efforts of @glow, @ldiaz, and @A-P on this topic. Thanks to you, I have been able to get a Waveshare Spotpear 3.5(A) Touchscreen working with Legacy on both the Orange Pi Zero and the Orange Pi Zero Plus 2.

 

The Waveshare Screen has the identical pin outs and uses the same driver (ili_9486) as the screen used by @A-P, and his settings, supplemented by @ldiaz's additions to armbianEnv.txt regarding SPI Bus Number 1, worked for my screen as well. The only difference was in armbianEnv.txt, I had to use extraargs="fbcon=0". I don't know what controls the creation of the framebuffers in /dev, but I only had fb0.

 

Next, I will try to get the touch functionality working. My screen uses the same drivers as the one used by @ldiaz; earlier you attached the file you used to activate touch (touch.dt); my question is, where does this file go?

 

Finally, I apologize for asking this question, but on the LCD, I get a tty login screen, the same as I get using SSH. I can't open a desktop environment from this console (startx says command not found). Can someone explain what I have to do to have the LCD open to a desktop environment. I have xfce and lightdm already installed.

 

Thanks very much!

Posted

Hi,

   @glow I have not test any pygame in the zero as I use kivy that requires X windows for working on armbian so here I can't be very useful.

   

   As @A-P is interested in make also touch working a was able also to do it in the past with a Orange Pi Zero with XPT2046. This are the steps.

 

  1. You need to be sure that you have the module module for ADS7846 available in your build. If I remenber well its installed by default.
  2.  Add to your armbianEnv.txt another std overaly it is call spi-add-cs1. This will add an adtional line for CS of the toch screen in the pin 26 that is what is compatible with your screen (TP_CS).
  3. Need to compile the dts I provided but for your screen you nee to change "PA7" to "PA1" in the ads7846_pins section of the file. The compilation is done with a DTC compiler (I think is installed by default). this way:
./dtc -@ -I dts -O dtb -o /boot/overlay-user/ads7846-touch.dtbo touch.dts

# it will show some warnings. if dct is not available you can get an complie it by:
#git clone -b dt-overlays8 https://github.com/pantoniou/dtc
#sudo apt-get install -y flex bison
#cd dtc
#make
  1. Finally you need to add to you armbianEnv.txt this line: user_overlays= ads7846-touch
  2. Reboot.
  3. The dts has the possibility to tweak parameters for sensibility, dimension,etc.... This version is the default ported from raspberry Pi.

  Thats it!

 

 

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines