Jump to content

Recommended Posts

Posted

@L Jumadi there are 2 components: the module in kernel space and the service in user space. You don't need to use make module / module-install / service-install because the command `make install` documented in README.md will do these 3 commands for you.

 

Now, if it's trying to install the module in `/lib/module/6.7.12/build` instead of `/lib/module/6.7.12-edge-sunxi64/build`, that's probably because you ran some make command in the `/lib/module/6.7.12-edge-sunxi64/build` directory which caused the kernel configuration to be updated. Unless you are familiar with building kernel, you should stay away from the `/lib/module/6.7.12-edge-sunxi64/` directory. You just build the module from another directory (such as /home/user/tm16xx). To revert to your kernel configuration (so installing out of tree modules won't use `/lib/module/6.7.12`, you can remove your Linux header package and reinstall it.

 

Whatsoever, we can focus on the next steps since you have been able to build and probe the module. Before checking the service, you need to get sure the the drivers initialize the device properly. You can have a look at kernel messages after loading the module, like this:

 

```

rmmod tm16xx

 

# clear previous kernel logs

dmesg -c > /dev/null

 

modprobe tm16xx

# you should see all LEDs ON

 

# check probe logs 

dmesg

```

 

Posted (edited)

@Jean-Francois Lessard thanks, Im building from home, but maybe messed up using sudo make . About service-install I read other forum also so I thought it needed :) Ok next step I already do (all need sudo) dmesg result:

 

[  189.603677] tm16xx 1-0024: Failed to set brightness: -6
[  189.604464] tm16xx 1-0024: Failed to write display data: -6
[  189.604545] tm16xx 1-0024: Display initialized successfully

 

Sure no LED lights :) (Im already turn off liberman overlay to test your driver, I guess its already enough)

I'm modifiying your tanix-tx6-allwinner-h6.dtso as Im use in liberman, its same as transpeed

 

sda-gpios = <&pio 8 11 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>; /* PI11 */
scl-gpios = <&pio 8 12 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>; /* PI12 */

 

rest all same, then make overlay .. rename result to tm16xx.dtbo put at /boot/overlay-user and also edit /boot/armbianEnv.txt . Usually I use armbian-add-overlay dtsfile.dts  that auto make dtbo copy and edit it :)

 

Edit I include my liberman config here to help, seems many other than gpio setting needed:

                compatible = "open,vfd";
                dev_name = "openvfd";
                openvfd_gpio_clk = <&pio 8 11 0>;
                openvfd_gpio_dat = <&pio 8 12 0>;
                vfd_gpio_chip_name = "0300b000.pinctrl";
                openvfd_chars = [02 01 02 03 04];
                openvfd_dot_bits = [00 01 03 02 04 05 06];
                openvfd_display_type = <0x03000000>;
                status = "okay";

 

 

 

 

Edited by L Jumadi
add liberman fdt
Posted

Im aleady try to convert my vfd.conf and edit gpio section as your last change, make overlay no error also but dmesg result still same as I post before

Posted (edited)

@L Jumadi It looks like you should reverse the pin configuration of the data and clock pins

 

Your openvfd config:

```

openvfd_gpio_clk = <&pio 8 11 0>; // this is the clock ping

openvfd_gpio_dat = <&pio 8 12 0>; // this is the data pin

```

 

Should become:

```

sda-gpios = <&pio 8 12 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>; // this is the data pin

scl-gpios = <&pio 8 11 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>; // this is the clock pin

```

 

You can also try setting gpio flags to 0 such as in your openvfd config. It would become:

```

sda-gpios = <&pio 8 12 0>; // this is the data pin

scl-gpios = <&pio 8 11 0>; // this is the clock pin

```

 

Edit: I have added a check in tm16xx.c to report "Failed to initialize display" instead of "Display initialized successfully" when it fails to set brightness or to write display data. This won't fix your issue per se but at least it will add clarity when looking at dmesg.

Edited by Jean-Francois Lessard
Posted

Thanks for your patience, Im not carefull then just expect the order of configuration is same :) Now my LED display 8888 already at boot.. then I guess it all okay (No other LED than the number and dot) btw the dot not on also, later will check how to turn it on, or blink thanks

Posted

@L Jumadi that is great news! It means driver has initialized the display device properly. Displaying 8888 is expected when device gets probed. It's the display service that will then set the time and LEDs on the display from user space.

 

But before you start the service, you can check that segment and digit mappings are well configured by running `display-utils -c`. Please read Check your display configuration of README.md to know how to check and adjust these mappings.

 

Once mappings are good, you can start the service by using `systemctl start display`.

 

 

Posted (edited)

@Jean-Francois Lessard Already test and find correct segment and digit but seems it start from 2nd digit, so echo 1234

will display only 123 from 2nd digit, cant fill first digit unless on 1st boot all 4 digit show. And seems my dts segment mapping different from what I read from cat /sys/class/display/segments

Edit: Segment fixed after edit the correct one and make overlay again but digit still from 2nd

 

Just fyi: display-utils and display-services on /usr/sbin of mine not correct attributes  all empty) maybe faulty install on me

Edited by L Jumadi
fixed
Posted

@Jean-Francois Lessard here I copy paste it :

/dts-v1/;
/plugin/;

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/leds/common.h>

&{/} {

    display-client {
<------>compatible = "i2c-gpio";
<------>sda-gpios = <&pio 8 12 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>; /* PI12 */
<------>scl-gpios = <&pio 8 11 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>; /* PI11 */
<------>i2c-gpio,delay-us = <5>;
<------>#address-cells = <1>;
<------>#size-cells = <0>;

<------>display-controller@24 {
<------><------>compatible = "fdhisi,fd650";
<------><------>reg = <0x24>;

<------><------>tm16xx,digits = [01 02 03 04];
<------><------>tm16xx,segment-mapping = [00 01 02 03 04 05 06];

<------><------>#address-cells = <2>;
<------><------>#size-cells = <0>;

<------><------>led@2,0 {
<------><------><------>reg = <2 0>;
<------><------><------>function = LED_FUNCTION_ALARM;
<------><------>};
<------><------><------>
<------><------>led@2,1 {
<------><------><------>reg = <2 1>;
<------><------><------>function = LED_FUNCTION_USB;
<------><------>};

<------><------>led@2,3 {
<------><------><------>reg = <2 3>;
<------><------><------>function = "play";
<------><------>};

<------><------>led@2,2 {
<------><------><------>reg = <2 2>;
<------><------><------>function = "pause";
<------><------>};

<------><------>led@2,4 {
<------><------><------>reg = <2 4>;
<------><------><------>function = "colon";
<------><------>};

<------><------>led@2,5 {
<------><------><------>reg = <2 5>;
<------><------><------>function = LED_FUNCTION_LAN;
<------><------>};

<------><------>led@2,6 {
<------><------><------>reg = <2 6>;
<------><------><------>function = LED_FUNCTION_WLAN;
<------><------>};

<------>};
};
};

Posted (edited)

@L Jumadi there is something weird about this open vfd configuration `openvfd_chars = [02 01 02 03 04];` and the resulting conversion in device tree for my driver. Grid index 02 is used twice. LEDs should not use the same grid index as the digits. There might be some special handling of this case in the OpenVFD driver (to be confirmed by reviewing OpenVFD code).

 

The controller typically use an array of 5 grids (indexed from 0 to 4) where each grid has 7 segments. There are 4 grids used for the digits, where the segments are turned on or off to represent a specific number. For example, the number 8 has all segments on and the number 1 has only the 2 segments on (the ones on the right).

 

The display assembly then uses the remaining grid to control the various icons (the LEDs) by mapping one segment to each of these icons.

 

In your device tree `tm16xx,digits = [01 02 03 04];` maps the digits to grid indexes 1, 2, 3, 4 and LEDs also uses the grid index 2 for the LEDs:

```

led@2,[SEGMENT] {

    reg = <2 [SEGMENT]>;

    /* ... */

};

```

 

I would start by commenting out the LEDs configuration in the device tree and then confirming which grid indexes are used for the digits by following Test alternative digits ordering. For example, you could try grid indexes "0 1 2 3" and check if it still starts from the 2nd digit.

 

Once the correct grid indexes for the digits are found, you can update the `tm16xx,digits` accordingly, uncomment the LEDs configuration and change the LED grid index to the one that is not used in the digits. For example, if using digit indexes "0 1 2 3", the led grid index should be 4. Or if digits indexes are "1 2 3 4", led grid index should be 0.

 

Edit:

Looking at fd650 controller datasheet, it supports only 4 grids, so they will be indexed from 0 to 3. There is no need to test digit indexes over 3. 

 

It would also mean that your display has no LED icons as all grids are used for the digits.  You can then completely remove the LEDs definition in the device tree.

 

If your display has icons, its likely that you need to configure a different controller by changing the compatible string in the device tree. Both "fdhisi,fd655" and "fdhisi,fd6551" are pretty similar to fd650 but supports a 5th grid (so grid indexes goes from 0 to 4). The main difference between fd655 and fd6551 is the number of brightness levels supported (3 for fd655 and 8 for fd6551).

 

Edited by Jean-Francois Lessard
Posted

@L Jumadi I've had a look at some pictures of the Tanix TX6 and it doesn't look to have icons such as other displays found on amlogic and rockchip TV boxes.

 

I have also reviewed the OpenVFD source code and I have found that it hardcoded a special case for the fd650 controller which uses an 8th segment as the time separator icon.

 

So, I have updated the tm16xx driver's code to enable the 8th segments on fd650 controller to be used as an icon. You can pull the latest version from GitHub and rebuild / reinstall the driver.

 

Your device tree should now be updated like this:

```

/dts-v1/;

/plugin/;

#include <dt-bindings/gpio/gpio.h>

#include <dt-bindings/leds/common.h>

&{/} {

 display-client {

  compatible = "i2c-gpio";

  sda-gpios = <&pio 8 12 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>; /* PI12 */

  scl-gpios = <&pio 8 11 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>; /* PI11 */

  i2c-gpio,delay-us = <5>;

  #address-cells = <1>;

  #size-cells = <0>;

  display-controller@24 {

   compatible = "fdhisi,fd650";

   reg = <0x24>;

   tm16xx,digits = [00 01 02 03];

   tm16xx,segment-mapping = [00 01 02 03 04 05 06];

   #address-cells = <2>;

   #size-cells = <0>;

   led@1,7 {

    reg = <1 7>;

    function =

"colon";

   };

  };

 };

};

```

 

Note that I am not totally sure about which digit the time separator uses. Since your openvfd config is `openvfd_chars = [02 01 02 03 04];` and the first index (02) is for the icons, it should be digit 2, but it seems that OpenVFD somehow adds +1 to fd650 grid indexes. So the above device tree uses 1 as the colon grid index but you may have to test with different values between 0 and 3.

 

Thanks for your time in testing my driver and allowing me to make it better!

Posted (edited)

@Jean-Francois Lessard as I remember, I already try 0 1 2 3 via command but got error when include 0 in the number (forgot the error seems like its not supported). As I ever mention my display have no other icon, and to make it more complicated it is Tanix tx3 mini (picture outside same with it), which usually use amlogic chip :P

Now the reason why Im testing your driver: It seems yours starting early at booting than the liberman (but maybe its me that cant configure it properly) so I can see 2 stage display like android one which display boot when on and time after all ready. Which then Im ask wether I can change (customize via config or other) the display right after the display initialization (than the default 8888, maybe change to boot or hi :)

Will try your new code and dt and report after this :)

 

Edited by L Jumadi
clarify meaning :)
Posted

Make fdt success as usual but when try reinstall driver got error. I reinstalled header.. trying make success but when make install error permission denied. so sudo make install error:

No rule to make target 'arch/arm64/tools/gen-cpucaps.awk', needed by 'arch/arm64/include/generated/asm/cpucap-defs.h'.  Stop.

then I re-read your read.me no need make just make install, I try make clean and make install same permision denied then sudo make install same as above without creating tm16xx.ko

I try to make and move tm16xx.ko manually then reboot, dmesg said:

[   10.187780] tm16xx: version magic '6.7.12 SMP mod_unload aarch64' should be '6.7.12-edge-sunxi64 SMP mod_unload aarch64'

I dunno whats wrong, as I try re-make liberman and modules_install still ok

Posted

Your kernel header configuration didn't had the right release version when the driver was built. Maybe the driver was built successfully prior of reinstalling the kernel headers.

 

1. Make sure your kernel headers configuration are restored 

```

cat /lib/modules/$(uname -r)/build/include/config/kernel.release

```

Make sure it shows 6.7.12-edge-sunxi64

If not, you should reinstall the kernel headers.

 

2. Rebuild the tm16xx driver

First make sure to clean the build so it will recompile the driver. Otherwise make may not detect that your kernel header configuration has changed since last build.

In your tm16xx source code directory:

```

make clean

```

Then you can build the driver. Let's proceed step by step instead of using `make install`.

```

make module

```

then install the driver

```

sudo make module-install

```

and probe the driver

```

sudo rmmod tm16xx

sudo modprobe tm16xx

```

 

3. While not related to building the driver, you should be able install the service without permission denied error by using this command :

```

sudo make service-install

```

 

Posted

@Jean-Francois Lessard thanks, with your help now I know which file to check.. dunno maybe because my header using old version. Step I do: kernel header reinstalled

cat /lib/modules/$(uname -r)/build/include/config/kernel.release  correct -> 6.7.12-edge-sunxi64

I try sudo make install it error like I describe before, then I re-check

cat /lib/modules/$(uname -r)/build/include/config/kernel.release  wrong -> 6.7.12

 

reinstalled header again, check kernel.release correct and try make clean then make module --> success

then I wrong type make module-install without sudo error permission denied, redo correct sudo make module-install error because build directory gone, recreate it and check kernel.release still correct, so I re-try with correct order

make clean, make module ==> success, sudo make modules-install error:

 

Entering directory '/usr/src/linux-headers-6.7.12-edge-sunxi64'
make[3]: *** No rule to make target 'modules.order', needed by '//lib/modules/6.7.12-edge-sunxi64/modules.order'.  Stop.

 

But accidentally I check /lib/modules/6.7.12-edge-sunxi64/updates seems tm16xx.ko re-created so I try reboot

It seems modules loaded correctly as LED power on 8888 awhile then blank .. dmesg said Display initialized successfully

trying sudo display-utils -c its correct display 1234 and colon, so I try starting display.service but status is failed

I try manually display-service as root it error:

/usr/sbin/display-service: line 68: echo: write error: Invalid argument

I check its the line number mentioned:

echo timer > /sys/class/leds/display::colon/trigger

Maybe there is error on my installation before but sure the driver already correct :) .. thanks

 

Posted

After trial error I change the error line with

echo heartbeat > /sys/class/leds/display::colon/trigger

then it successfully display time with colon heartbeating :P

 

Sure will be nicer if we can change 1st time appearance than 8888, but I already satisfied with current stage

Posted

@L Jumadi Great news, I am glad the 8th segment icon works! Thanks for your feedback.

 

I've reviewed the Makefile and I have removed an unused BUILD_DIR variable that was deleted in the clean target. I guess that your system somehow defined this variable to your build folder and that it caused the problem you were experiencing with the headers.

 

Let's get into the display service since we now have a confirmed working driver. As you saw, the display service is simply a bash script. It relies on existing other kernel features to manages the icons.

 

The line causing the problem 

```

echo timer > /sys/class/leds/display::colon/trigger

```

is configuring the basic timer trigger to make the colon blink every half second (more details in Kernel documentation).

 

My guess is that the kernel module providing this timer trigger has not loaded properly (maybe because of an issue you have with `make service-install`). Here are the commands that you can launch manually:

```

# load the modules for the current session

modprobe -a ledtrig_timer ledtrig_netdev tm16xx

 

# save the dependencies on other modules for next boots

 echo "softdep tm16xx pre: ledtrig_timer ledtrig_netdev" > /etc/modprobe.d/tm16xx.conf 

```

Posted

Trying it rightaway give error:

modprobe: WARNING: Module ledtrig_timer not found in directory /lib/modules/6.7.12-edge-sunxi64

maybe my armbian version or sunxi version not provide it :P

Posted

The idea behind 8888 is to turn on all LEDs for quick visual diagnostic when the driver is loaded, which I think is pretty useful.

 

If you want something else to be shown during boot, you can create a simple service unit file and make it execute early in the boot process but just after the driver is loaded. It can then contain a simple command like

```

echo "boot" > /sys/class/leds/display/value

```

 

Or something fancier with something like:

```

display-utils -t "boot b**t b//t b00t"

```

 

Or you can even make your own script that animates text!

Posted

You can check which led trigger modules are already built for your distribution:

```

ls /lib/modules/$(uname -r)/kernel/drivers/leds/trigger/

```

If you don't have ledtrig-timer but you have ledtrig-transient, that would make it for the colon (see kernel doc about transient led trigger).

 

Otherwise, you can reach out your distribution maintainers to add these modules. In last resort you could modify the display service to update the time every half second and making the colon blinks.

 

Posted (edited)

You can try something like this for your the systemd unit file (I have not tested it):

```

[Unit]

Description=Set LED display value to "boot" after tm16xx module loads

After=systemd-modules-load.service

ConditionPathExists=/sys/class/leds/display/value

 

[Service]

Type=oneshot

ExecStart=/bin/sh -c 'echo "boot" > /sys/class/leds/display/value'

 

[Install]

WantedBy=sysinit.target

```

 

And enable it like this (rename set-boot-display.service to the name of you unit file):

```

sudo systemctl enable set-boot-display.service

sudo systemctl start set-boot-display.service

```

 

Edit:

Save this file as `set-boot-display.service` in `/etc/systemd/system/`,

Edited by Jean-Francois Lessard
Posted (edited)

ls /lib/modules/$(uname -r)/kernel/drivers/leds/trigger/ Error: No such file or directory

Before I found the trigger with

cat /sys/class/leds/display::colon/trigger

which result:

none usb-gadget usb-host kbd-scrolllock kbd-numlock kbd-capslock kbd-kanalock kbd-shiftlock kbd-altgrlock kbd-ctrllock kbd-altlock kbd-shiftllock kbd-shiftrlock kbd-ctrlllock kbd-ctrlrlock usbport disk-activity disk-read disk-write mtd nand-disk [heartbeat] cpu cpu0 cpu1 cpu2 cpu3 activity default-on panic mmc0 mmc1 mmc2 stmmac-0:00:link stmmac-0:00:100Mbps stmmac-0:00:10Mbps

 

thanks for service suggestion, will try and experiment with it.. hope can display early as I am still not so familiar with systemd

 

Edited by L Jumadi
Posted

cat /sys/class/leds/display::colon/trigger will only show loaded modules. Your distribution should come with a set of additional loadable modules. There is no much option to make a led blink on a constant timing with the options you have right now.

Posted

@Jean-Francois Lessard already try your service then try to boot.. it display 8888 longer than a blink boot after followed by time display. So I stick to 8888 only better :) at least have displaying something long before the time. Dunno on Android the led display is faster show when device just like to power on, Its Android base on Linux also with even older kernel, lol. Maybe many unused service or other at kernel loading removed, but after that Android longer loading than armbian

Posted

About /lib/modules/$(uname -r)/kernel/drivers/leds/trigger/ I already investigate as Im building the images myself I can check trigger config is modules but seems the image created not include all modules, I will report the creator, thanks

Posted

About early LED show seems its on generic LED can be set at u-boot

but maybe thats not using any driver just signal one or few individual led :)

Maybe Android version using that way also, sure manufacture worker did it and not publish as opensource

Posted

There is a post on the rk3318 tvboxes forum with a kernel dump and something that did not went good with work queues: https://forum.armbian.com/topic/26978-csc-armbian-for-rk3318rk3328-tv-box-boards/?do=findComment&comment=203586

 

I did take a little look into the code, but could not spot anything wrong.

By the way @Jean-Francois Lessard wasn't it simpler to use .led_set_brightness_blocking in place of .led_set_brightness and let the led core do the job with the work queues?

Posted (edited)

@jock I've replied to the other thread. I will review usage of workqueue later, but I think it may be related to something else. Since this is the workqueue that is writing to hardware device (i2c or spi), I guess that the kernel dump warning may appear when the cpu is hogging while accessing the hardware interface, such as i2c/spi interface misconfiguration or having multiple drivers trying to access the same interface (such as running OpenVFD at the same time).

 

To answer your question about async led_set_brightness, the workqueue is used to manage concurrency issues. Using sysfs, you can set the individual led on/off or changing display/value but they are all dumped together on every write to the controller. A workqueue can only be scheduled one at a time (other schedule calls will be ignored if already scheduled), so it will pickup all the changes that happened concurrently once it's executed.

 

Plus I have experienced cases where set brightness coming from ledtrig_timer (and/or ledtrig_netdev) were called from an irq/sortirq context, therefore causing kernel panic if writing directly to the device (ref related commit).

 

Edit:

Kernel dump should be solved as well as some other minor improvements: https://forum.armbian.com/topic/26978-csc-armbian-for-rk3318rk3328-tv-box-boards/?do=findComment&comment=204448

Edited by Jean-Francois Lessard
Posted (edited)

hi @Jean-Francois Lessard

Searching further how to early change display, I found using this udev rules can change it quick after your 8888 displayed, better than systemd :)

 

ACTION=="add", SUBSYSTEM=="module" KERNEL=="tm16xx", RUN+="/bin/sh -c 'echo \"bo
ot\" > /sys/class/leds/display/value'"

 

Edit:  Should be faster using modprobe install option but dunno why its never executed on armbian tough its correct config

 

Maybe then seaching how to make your driver load earlier :)

Edited by L Jumadi
Posted

Ok after long search..  I found that your softdep solution prevent my install option, so I just do it all on install option in /etc/modprobe.d/tm16xx.conf 

 

install tm16xx /sbin/modprobe -q ledtrig_timer; \
                        /sbin/modprobe -q ledtrig_netdev; \
                        /sbin/modprobe -i tm16xx; \
                        echo boot > /sys/class/leds/display/value

Now it display boot imediately so my eyes cant catch up if 8888 ever show :P

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines