Jump to content

Recommended Posts

Posted

Hello All

 

After a lot of hours and sleepless nights I was able to get this 5" LCD to work with the BPI-M64 module.

 

1.  Correct resolution setup + environment. 

     A. In /Boot/armbianEnv.txt set the following:

     Make sure to enter overlays= spi-add-cs1 spi-spidev  (this is for the touch panel to work)

     B.  for 180 rotation: extraargs=fbcon=rotate:2 drm_kms_helper.edid_firmware=HDMI-A-1:edid/800x480.bin video=HDMI-A-1:800x480-24@60 

          No rotation: extraargs= drm_kms_helper.edid_firmware=HDMI-A-1:edid/800x480.bin video=HDMI-A-1:800x480-24@60 

     C.  this info came from: https://askubuntu.com/questions/890231/adding-newmode-with-xrandr-800x480-60-00 

 

by the way if you dont want to see the console messages during boot you can add this to the armbianEnv.txt:

console=serial

D. Save and close.

 

E. Create a directory where the .desktop file will be contained:

    sudo mkdir -p /etc/xdg/autostart

F. Create the .desktop file and make it executable:

   Let's call this file custom-screen-resolution.desktop:

   sudo nano /etc/xdg/autostart/custom-screen-resolution.desktop

The content of the file custom-screen-resolution.desktop should look as:

 

[Desktop Entry]
Name=Custom Screen Resolution
Exec=sh -c 'xrandr --newmode "800x480_60.00"  29.50  800 824 896 992  480 483 493 500 -hsync +vsync; xrandr --addmode HDMI-1 800x480_60.00; xrandr --output HDMI-1 --mode 800x480_60.00'
Terminal=false
Type=Application
Categories=Application

 

G. reboot

H.  After O/S is loaded go to settings => display  and you be able to select the 800x480 resolution.

 

2.  With the Touch Panel I lost some hair on my head since there were many issues to overcome.

     A. I had to solder the LCD TP_IRQ Pin (22) to unused Pin (13) since Pin 22 on the BPI-M64  didnt support GPIO to IRQ...  and diving into the sources took a lot of time to figure out why, so the easiest way is to change the Pin.

         (please have a look at the attached picture.

     B.  Also there were wrong settings in the sun50i-a64-spi-add-cs1.dtbo overly, it seems that CS1 were going to the wrong Pin ( not as the BPI_M64 page shows, it should have been going to Pin 26 - PC2  but in the overlay it did go to Pin 35- PB6) 

          I really dont know why so I had to change the DTS file to:

 

/dts-v1/;
/plugin/;

/ {
        compatible = "allwinner,sun50i-a64";

        fragment@0 {
                target = <&pio>;
                __overlay__ {
                        spi0_cs1: spi0_cs1 {
                                pins = "PD0";
                                function = "gpio_out";
                                output-high;
                        };

                        spi1_cs1: spi1_cs1 {
                                pins = "PC2";
                                function = "gpio_out";
                                output-high;
                        };
                };
        };

        fragment@1 {
                target = <&spi0>;
                __overlay__ {
                        pinctrl-names = "default", "default";
                        pinctrl-1 = <&spi0_cs1>;
                        cs-gpios = <0>, <&pio 3 0 0>; /* PD0 */
                };
        };

        fragment@2 {
                target = <&spi1>;
                __overlay__ {
                        pinctrl-names = "default", "default";
                        pinctrl-1 = <&spi1_cs1>;
                        cs-gpios = <0>, <&pio 2 2 0>; /* PC2 */
                };
        };
};

 

The sun50i-a64-spi-add-cs1.dts & the sun50i-a64-spi-add-cs1.dtbo are also attached.

 Just replace the sun50i-a64-spi-add-cs1.dtbo  located at /boot/dtb/allwinner/overlay with file that I have attached here.

 

C. The next settings I have found at post here I just copy and paste so you will have all the info in one page:

 

D) Download ads7846? touch driver (compatible with xpt2046)

mkdir ds7846 
cd ds7846 
wget https://sourceforge.net/p/openipmi/linux-ipmi/ci/master/tree/drivers/input/touchscreen/ads7846.c?format=raw
mv ads7846.c?format=raw ads7846.c 


E) Create a makefile (Take note that it is TABS instead of spaces before the $(MAKE))

nano Makefile
Insert the below in without the -----
--------------------------------
obj-m := ads7846.o 
KDIR := /lib/modules/$(shell uname -r)/build 
PWD := $(shell pwd) 
all:
    $(MAKE) -C $(KDIR) M=$(PWD) modules 
clean:
    $(MAKE) -C $(KDIR) M=$(PWD) clean 
install:
    $(MAKE) -C $(KDIR) M=$(PWD) modules_install
--------------------------------


F) Exit nano and run the following

cd /usr/src/linux-headers-4.19.38-sunxi64
make scripts
make modules_prepare

sudo make
sudo make install
sudo depmod


G) Download and compile and install ads7846_device

cd .. 
git clone https://github.com/notro/fbtft_tools/
cd fbtft_tools/ads7846_device 
make 
sudo make install 
sudo depmod 


H) Load ads7846 and ads7846_device on boot

sudo nano /etc/modules-load.d/ads7846.conf 
ads7846 
ads7846_device


I) Load ads7846_device options

nano /etc/modprobe.d/ads7846_device.conf 

 

options ads7846_device model=7846 cs=1 gpio_pendown=234 keep_vref_on=1 swap_xy=0 pressure_max=255 x_plate_ohms=150 x_min=3900 x_max=200 y_min=3900 y_max=200 busnum=1

 

Note: GPIO_PENDOWN relate to the GPIO of the actual Pin number 13, With my board it is 234, If you are using other module (not BPI_M64) it could be other number,  check with your module documents or do "gpio printall" in your board to see the correct Pin number.

 

Since I use the screen in inverted mode those settings fits my needs.

 

if you will use it in normal mode you might have to switch those parameters :

swap_xy=0  or 1

x_min=3900 x_max=200 y_min=3900 y_max=200

or 

x_min=200 x_max=3900y_min=200 y_max=3900

 

I didnt really need it but you can install sudo apt-get install xinput-calibrator for fine tunning. (follow the instructions)

 

 

I hope that I didnt forget anything.

 

By the way the kernel I use is: 4.19.38-sunxi64

 

         

 

 

 

     

     

          

LCD IRQ.jpg

sun50i-a64-spi-add-cs1.dtbo sun50i-a64-spi-add-cs1.dts

LCD.png

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

Important Information

Terms of Use - Privacy Policy - Guidelines