[A20-SOM204] Boot from eMMC using bootloader in SPI Flash and legacy kernel

Started by Titomax, November 07, 2019, 07:05:01 PM

Previous topic - Next topic

dpierleo

Hi selfbg,

thank you for your help.

1. I am able to see the device under /sys/class/backlight directory so everything works well.

2. I can export four GPIO I need (PI06, PI07, PI14, PI15) but I cannot export PI10 and PI11. I receive a message "busy" when I am trying to export them. I think it is because PI10 and PI11 are used in EVB for green and yellow leds that I do not need in my custom board. Is there any way to disable a20-som204-evb:green and a20-som204-evb:yello by a new overlay?

3. I made all you told me and I edit my custom overlay lcd-olinuxino-7.dts as follows:

/dts-v1/;
/plugin/;

/ {
 compatible = "allwinner,sun7i-a20";
 description = "Enable LCD-OLinuXino-7";

 fragment@0 {
 target = <&i2c2>;
 __overlay__ {
 status = "okay";

 ft5x@38 {
 compatible = "edt,edt-ft5306";
 reg = <0x38>;
 touchscreen-size-x = <800>;
 touchscreen-size-y = <480>;

 interrupt-parent = <&pio>;
 interrupts = <7 7 2>;

 touchscreen-inverted-x;
 touchscreen-inverted-y;

 irq-gpios = <&pio 7 2 0>;
 wake-gpios = <&pio 8 1 1>;
 };
 };
 };
};

But when I execute command:

armbian-add-overlay lcd-olinuxino-7.dts
I receive the following error:

Compiling the overlay
dtc: livetree.c:521: get_node_by_phandle: Assertion `(phandle != 0) && (phandle != -1)' failed.
/usr/sbin/armbian-add-overlay: line 81:  3366 Aborted                dtc -@ -q -I dts -O dtb -o ${temp_dir}/${fname}.dtbo $1
Error compiling the overlay

Where is the error?

Thank you in advance for your help

dpierleo

Hi,

can anyone help me with my previous post?

I use sun7i-a20-olimex-som204-evb-emmc.dtb and I would like to modify some feature using overlay:

1) I would like to use PI10 and PI11 as GPIO.

2) I would like to use capacitive touch screen with ft5x_ts driver.

Issue in point 1:

in device tree source sun7i-a20-olimex-som204-evb.dts (inherited by sun7i-a20-olimex-som204-evb-emmc.dtb) I can see:

leds {
 compatible = "gpio-leds";

 stat {
 label = "a20-som204-evb:green:stat";
 gpios = <&pio 8 0 GPIO_ACTIVE_HIGH>;
 default-state = "on";
 };

 led1 {
 label = "a20-som204-evb:green:led1";
 gpios = <&pio 8 10 GPIO_ACTIVE_HIGH>;
 default-state = "on";
 };

 led2 {
 label = "a20-som204-evb:yellow:led2";
 gpios = <&pio 8 11 GPIO_ACTIVE_HIGH>;
 default-state = "on";
 };
 };

Could I remove led1 and led2 using an overlay? How? In this way I could use PI10 and PI11 as GPIO.

Issue in point 2:

I edited my custom overlay lcd-olinuxino-7.dts as follows:

/dts-v1/;
/plugin/;

/ {
 compatible = "allwinner,sun7i-a20";
 description = "Enable LCD-OLinuXino-7";

 fragment@0 {
 target = <&i2c2>;
 __overlay__ {
 status = "okay";

 ft5x@38 {
 compatible = "edt,edt-ft5306";
 reg = <0x38>;
 touchscreen-size-x = <800>;
 touchscreen-size-y = <480>;

 interrupt-parent = <&pio>;
 interrupts = <7 7 2>;

 touchscreen-inverted-x;
 touchscreen-inverted-y;

 irq-gpios = <&pio 7 2 0>;
 wake-gpios = <&pio 8 1 1>;
 };
 };
 };
};

But when I execute command:

armbian-add-overlay lcd-olinuxino-7.dts
I receive the following error:

Compiling the overlay
dtc: livetree.c:521: get_node_by_phandle: Assertion `(phandle != 0) && (phandle != -1)' failed.
/usr/sbin/armbian-add-overlay: line 81:  3366 Aborted                dtc -@ -q -I dts -O dtb -o ${temp_dir}/${fname}.dtbo $1
Error compiling the overlay

I believe if I solve these two issues, I can reach my final goal.

Please, could anyone help me?

Thank you in advance

selfbg

Quote from: dpierleo on December 16, 2019, 05:43:42 PM1) I would like to use PI10 and PI11 as GPIO.

You can do this without the overlay. Do the following as root:

echo leds >  /sys/bus/platform/drivers/leds-gpio/unbindThis will release the gpio control.

The export and use them (See here):
# Export PI10
echo 266 > /sys/class/gpio/export

# Export PI11
echo 267 > /sys/class/gpio/export

Optionally if you want to use them only as outputs, you can also toggle the by:
echo 1 > /sys/class/leds/a20-som204-evb\:green\:led1/brightness
echo 0 > /sys/class/leds/a20-som204-evb\:green\:led1/brightness

echo 1 > /sys/class/leds/a20-som204-evb\:green\:led2/brightness
echo 0 > /sys/class/leds/a20-som204-evb\:green\:led2/brightness

The DTS overlays doesn't support deletion of nodes. (For now).


selfbg

Quote from: dpierleo on December 16, 2019, 05:43:42 PM2) I would like to use capacitive touch screen with ft5x_ts driver.


Guess this is some dtc bug. Try updating it:
wget http://ftp.debian.org/debian/pool/main/d/device-tree-compiler/libfdt1_1.5.1-1_armhf.deb
dpkg -i libfdt1_1.5.1-1_armhf.deb

wget http://ftp.debian.org/debian/pool/main/d/device-tree-compiler/device-tree-compiler_1.5.1-1_armhf.deb
dpkg -i device-tree-compiler_1.5.1-1_armhf.deb

dpierleo

Hi selfbg,

thank you so much for your support.

Quote from: selfbg on December 20, 2019, 12:57:20 PMGuess this is some dtc bug. Try updating it

The point (2) is now ok. With updated version of dtc, the overlay is compiled well. I am about to try system with the right capacitive display.

For the point (1) I have three questions:

(a) During the boot process, where can I put the commands to unbind leds and to export pins that you suggested to me? In the rc.local? I guess that it is important to run these commands as soon as possible because otherwise we could have a moment of conflict where PI10 and PI11 are set as output (because the device tree sets those pins as leds) and the other device is also output on the same nodes.

(b) Can I unbind only some leds (not all)?

If I do:

echo leds >  /sys/bus/platform/drivers/leds-gpio/unbind
all three leds are unbound. How can I unbind only two of the three leds?
I tried changing "leds" with the name of single led but that does not work (single led is unrecognized).

(c) basically I would like to obtain the same thing I obtained with following FEX code:

[gpio_para]
gpio_used = 1
gpio_num = 17
gpio_pin_1 = port:PH00<0><default><default><default>
gpio_pin_2 = port:PI02<0><default><default><default>
gpio_pin_3 = port:PG00<0><default><default><default>
gpio_pin_4 = port:PG01<0><default><default><default>
gpio_pin_5 = port:PG02<0><default><default><default>
gpio_pin_6 = port:PG03<0><default><default><default>
gpio_pin_7 = port:PG04<0><default><default><default>
gpio_pin_8 = port:PG05<0><default><default><default>
gpio_pin_9 = port:PI10<0><default><default><default>
gpio_pin_10 = port:PI11<0><default><default><default>
gpio_pin_11 = port:PI12<0><default><default><default>
gpio_pin_12 = port:PI13<0><default><default><default>
gpio_pin_13 = port:PB05<0><default><default><default>
gpio_pin_14 = port:PB10<0><default><default><default>
gpio_pin_15 = port:PI14<0><default><default><default>
gpio_pin_16 = port:PI06<0><default><default><default>
gpio_pin_17 = port:PI07<0><default><default><default>

What do I have to do to reach the same result in device tree environment?


Thank you in advance for your help.


JohnS

If you _never_ want certain pins to be outputs you need to be sure they power on OK, then uboot leaves them OK and your kernel never sets them as outputs.

If there would be bad enough results of even a glitch then change the hardware.

John

dpierleo

Thank you JohnS for your answer.

Unfortunately some pin like PI10 and PI11 are used as leds in evaluation board so they are set output and on when kernel starts. And I cannot change my hardware. The solution is only change device tree to have PI10 and PI11 not configured as leds. This is impossible using overlay (how selfbg explained to me in a previous post). I am still looking for a solution.

Thanks

dpierleo

Hi selfbg.

I tried to release pins PI10 and PI11 as you suggested to me:

echo leds >  /sys/bus/platform/drivers/leds-gpio/unbind
But I can add this line only in my rc.local file to automate the release.
It is too late!
My leds (so signal in pins PI10 and PI11) remain on for some seconds (from kernel start until the execution of rc.local) and those pins are connected to output in other device, so this condition is very dangerous for the hardware.

I simply need to change device tree to remove PI10 and PI11 reference (because you told me that it is not possible to do it using overlays) and to have those pins as input gpio.

When I used fex, I could use following lines in fex:

[gpio_para]
gpio_used = 1
gpio_num = 17
...
gpio_pin_9 = port:PI10<0><default><default><default>
gpio_pin_10 = port:PI11<0><default><default><default>
...

(1) How can I obtain the same thing with device tree?

(2) If necessary is it possible to recompile sun7i-a20-olimex-som204-evb-emmc.dts to remove lines about those leds? How can I recompile device tree? Which github path? What config and compile options to obtain the same dtb I found in last image Armbian_5.92.4_Olinuxino-a20_Ubuntu_bionic_next_5.2.21_desktop.img?

Thank you in advance

JohnS

You need hardware which is OK in all cases, including software fault.

It sounds like you absolutely need to fix the hardware.

This is completely normal in many use cases.

John

dpierleo

Hi JohnS,

Thank you for your answer. But I would like to keep the focus on my question.
 
In the evaluation board, the pins PI10 and PI11 are correctly set as output and the system drives two leds with those pins.

In my custom board, the pins PI10 and PI11 must be set as inputs.

I simply need to change the device tree file, in order to obtain this different behaviour: at power-up moving directly from reset to input mode of those pins (reset --> input) and NOT reset --> output --> input.