arthur-liberman / linux_openvfd

FD628 and similar compatible LED controller driver for linux
GNU General Public License v3.0
21 stars 27 forks source link

Auto switch to wrong controller #6

Closed kruzer closed 2 years ago

kruzer commented 3 years ago

Hi, I have a strange problem with the driver, it seems to switch to wrong controller after changing display type. my box: rk3318 (H96 Max) system: Armbian - Linux rk3318-box 5.10.37-rockchip64 controller: FD6551 my openvfd.dts:

/dts-v1/;
/plugin/;
/ {
   fragment@0 {
      target-path = "/";
      __overlay__ {
         openvfd {
            compatible = "open,vfd";
            dev_name = "openvfd";
            status = "okay";
         };
      };
   };
};

driver parameters are set with /etc/modprobe.d/openvfd.conf

options openvfd vfd_gpio_clk="4,0x16,0"
options openvfd vfd_gpio_dat="4,0x15,0"
options openvfd vfd_gpio_stb="4,0x14,0"
options openvfd vfd_chars="0,4,3,2,1"
options openvfd vfd_dot_bits="0,1,3,2,4,5,6"
options openvfd vfd_display_type="0x02,0x00,0x00,0x06"

after module is loaded, last lines from dmesg shows:

OpenVFD: display.type = 2, display.controller = 6, pdata->dev->dtb_active.display.flags = 0x00
OpenVFD: Select FD6551 controller
OpenVFD: SW I2C interface intialized (address = 0x0000 (N/A), MSB mode, pull-ups off)

and OpenVFDService correctly prestents time on display, but after trying to check another display type:

./OpenVFDService -dt [N]

driver switches to another controller

OpenVFD: Select FD628 controller
OpenVFD: SW SPI 3-wire interface intialized (LSB mode)

And display stops working, until driver module is reloaded, am I doing something wrong?

Jeebus678 commented 2 years ago

@kruzer hey, can you elaborate on how you got this setup? I have the same controller but am having no luck…

kruzer commented 2 years ago

I don't remember exactly, but I've done it in a standard linux way. Built openvfd driver on the box, I've created modprobe config in file /etc/modprobe.d/openvfd.conf like in the example above. my /boot/armbianEnv.txt:

verbosity=1
bootlogo=false
overlay_prefix=rockchip
fdtfile=rockchip/rk3318-box.dtb
rootdev=UUID=de2057ff-2fc6-418c-b583-7a1e2dbe8219
rootfstype=ext4
console=both
overlays=rk3318-box-cpu-hs rk3318-box-emmc-ddr rk3318-box-emmc-hs200 rk3318-box-led-conf1 rk3318-box-wlan-ap6334
user_overlays=openvfd mymali
usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u

I've created openvfd.dts :

/dts-v1/;
/plugin/;
/ {
   fragment@0 {
      target-path = "/";
      __overlay__ {
         openvfd {
            compatible = "open,vfd";
            dev_name = "openvfd";
            status = "okay";
         };
      };
   };
};

and managed to convert it to /boot/overlay-user/openvfd.dtbo now the demo is working (apart form "cycle characters" which does nothing)

kruzer@rk3318-box ~/D/linux_openvfd (master)> ./OpenVFDService -t -dt 1
Display type 0x00000001
Initializing...
Process ID = 5080
Brightness loop from 0 to 7
Clear display
Original test codes:
 Test chart, seq of nr from:0 to 76
 Bit sequence
 Bit sequence 2
 Bit sequence 3
Jeebus678 commented 2 years ago

How did you manage to read the values from /etc/modprobe.d/vfd.conf? I keep getting Failed to verify VFD configuration file, attempt using device tree as fallback., i've ever tried giving it permissions but nothing works.

arthur-liberman commented 2 years ago

Check your file formatting. It needs to be a simple ascii (non-UTF8) text file. You can run cat /etc/modprobe.d/vfd.conf to print it into the cli.

Jeebus678 commented 2 years ago

I tried writing it as ASCII and then modprobe from new. Same error. Here is my service file. Note: I placed my file in /root/.config/vfd.conf instead of /etc/modprobe.d/

[Unit]
Description=openvfd
Wants=network-online.target

[Service]
Type=simple
Environment="OPTS=-12h"
ExecStartPre=/bin/sh -c ". /root/.config/vfd.conf; /sbin/modprobe openvfd vfd_gpio_clk=$vfd_gpio_clk vfd_gpio_dat=$vfd_gpio_dat vfd_gpio_stb=$vfd_gpio_stb vfd_chars=$vfd_chars vfd_dot_bits=$vfd_dot_bits vfd_display_type=>ExecStart=/root/linux_openvfd/OpenVFDService $OPTS &
ExecStop=/usr/bin/killall OpenVFDService
ExecStopPost=-/sbin/rmmod openvfd

[Install]
WantedBy=multi-user.target
Jeebus678 commented 2 years ago

@kruzer did you manage to solve your original problem? I got the driver set up and running successfully but it seems I ran into the same problem as you.

kruzer commented 2 years ago

Yes, after this patch https://github.com/kruzer/linux_openvfd/commit/1d83779bb9d525e6593b97f7e893cccc73080d4d it is working ok for me.

arthur-liberman commented 2 years ago

That patch is wrong, as it prevents changing other parameters relevant to the display type. Your [N] in -dt needs to be a 32bit hex value that includes all of the relevant fields.