Vontar X3 TV box LED DTB fix

Hello All!
I have a Vontar X3 TV box and when installing CE I used the standard sml_s905x3_4g_1gbit.dtb file and everything works fine except for the system LED. It is swapped: when CE is runnijg, ir is OFF, and after the shutdown from CE menu it becomes ON.
But the android firmware lights this LED correctly.
I’ve looked over .dtb files from Android and CE and that is what I’ve seen:
Android:

	gpioleds {
		compatible = "gpio-leds";
		status = "okay";

		sys_led {
			label = "sys_led";
			gpios = <0x68 0x0b 0x00>;
			default-state = "on";
		};

CoreELEC:

	gpioleds {
		compatible = "gpio-leds";
		status = "okay";

		sys_led {
			label = "sys_led";
			gpios = <0x44 0x0b 0x01>;
			linux,default-trigger = "default-on";
		};
	};

As you can see, the last number in gpios section differ: in Android it is 0x00 (GPIO_ACTIVE_HIGH) while in CoreELEC it is 0x01 (GPO_ACTIVE_LOW).

So my assumption is I have to change it somehow. I’ve tried to change it in CoreELEC->Hardware menu but it seems that setting changes only linux,defaultrigger entry, which is not what I need.

So my question is: What is my best strategy to change the .dtb?
I tried to dump and compile .dtb file from my running instance of CE, but .dts file I got differs absolutely from the stock sml_s905x3_4g_1gbit.dtb, and bescides dtc compiler gives too much warning when compiling my decompiled .dts file. So I am afraid it will not work.
So what should I do to change only one entry in .dtb?

Also I have found one more difference in Android and CoreELEC DTBs describing what I believe is this LED’s GPIO:
Android

		ao-bank@ff800014 {
			reg = <0xff800014 0x08 0xff800024 0x14 0xff80001c 0x08>;
			reg-names = "mux\0gpio\0drive-strength";
			gpio-controller;
			#gpio-cells = <0x02>;
			phandle = <0x68>;
		};

CoreELEC

		ao-bank@ff800014 {
			reg = <0x00 0xff800014 0x00 0x08 0x00 0xff800024 0x00 0x14 0x00 0xff80001c 0x00 0x08>;
			reg-names = "mux\0gpio\0drive-strength";
			gpio-controller;
			#gpio-cells = <0x02>;
			phandle = <0x45>;
		};

As you can see reg entry differs, there are several additional zeros in CoreELEC.
Should I also change this entry too?

EDIT: It looks like I’ve got it why there are additional zeros: in Android #size-cells = <0x01>; while in CoreELEC #size-cells = <0x02>;

So looks like the last question is answered.

You will need to create a autostart.sh and read your dtb.img and modify the values if needed.

Like something about fdtget -t x /flash/dtb.img /gpioleds/sys_led gpios
Then modify only the last value from 0x00 to 0x01 and reboot.

There are some samples here in forum.

Thank you!

Some minor questions:

  1. So, I will need to make this fdtget/fdtput on every boot?
    Or it is just a one time action?
  2. what should be my fdtput command if fdtget -t x /flash/dtb.img /gpioleds/sys_led gpios gives me
    44 b 1?

fdtput -t x /flash/dtb.img /gpioleds/sys_led gpios "44 b 0" ?

Yes, something like this, you need to test.
Best is to make the script more smart and check if it’s already modified.
If not, modify and reboot device. If yes, do nothing and continue booting.

I can’t get it working.
after
fdtput -t x /flash/dtb.img /gpioleds/sys_led gpios "44 b 0"

fdtget return only “44”. Looks like fdtput ignores everything after the space… is there any manual?

Never mind, I got it. The quotation marks in a value were superfluous

It Wroks! Thanks a lot!
Now I have my LED working correctly!
Should I share this solution with other Vontar X3 owners somehow?

1 Like

They have the topic here with your solution, they can come here. Share your script here and mark it solved.

I am not too much experienced with bash, so it may look a little awkward, but anyway here is the script.

#!/bin/bash
GPIO=`fdtget -t x /flash/dtb.img /gpioleds/sys_led gpios`
GPIO_ACTIVE_FLAG=`echo $GPIO| awk 'END {print $NF}'`
if [[ "$GPIO_ACTIVE_FLAG" == "0" ]]; then
  echo "SYSTEM LED GPIO IS CORRECT"
  exit 0
else
  echo "Changing System Led GPIO_ACTIVE flag"
  GP=`echo $GPIO | sed '$s/\w*$//'`
  GPIO=$GP"0"
  mount -o remount,rw /flash
  fdtput -t x /flash/dtb.img /gpioleds/sys_led gpios $GPIO
  sync
  mount -o remount,ro /flash
fi

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.