AML-S905X-CC Wiring Tool Overlays Description

Hey @angus I have scanned i2c-0 as well. No devices show on that bus

If no device show up, then check your wiring and the I2C bus frequency.

Hey @librecomputer I have verified wiring (it is soldered into a pcba) and can detect the chip with a raspberry pi. How would I check the I2C bus frequency on the libre?

Would you be able to help with a device tree overlay for an MCP23017 at address 0x20 that is compatible with the i2c-ao overlay please. I have attempted to copy an existing overlay and apply the overlay but I am getting an error that the overlay does not exist.

Overall I am not certain if an overlay is needed for the MCP23017 to register at address 0x20. Any assistance would be appreciated. Thank you

After writing the overlay, you need to compile it by running make in the root directory before running sudo ./ldto. Do not run sudo ldto as that will use the system version rather than the newly modified version.

Once you tested it, feel free to contribute it back and it will be pushed in the future.

Thank you @librecomputer I got the new overlay to build and applied it successfully.

Does this look correct?

/*
 * Copyright (c) 2017 BayLibre, SAS.
 * Author: Neil Armstrong <narmstrong@baylibre.com>
 *
 * SPDX-License-Identifier: (GPL-2.0+ OR MIT)
 */

/*
 * Overlay aimed to enable MCP23017 on address 0x20 via I2C_AO on Header 7J1 :
 * Pins 3 (SDA), 5 (SCL)
 */

/dts-v1/;
/plugin/;

/ {
        compatible = "libretech,cc", "amlogic,s905x", "amlogic,meson-gxl";

        fragment@0 {
                target = <&i2c_AO>;

                __overlay__ {
                        mcp23017@20 {
                                compatible = "mcp,23017";
                                reg = <0x20>;
                        };
                };
        };

};

Thank you again

Hello all, I am trying to get an MCP23017 working with a LePotato board.

Would someone be able to help with updating a RaspberryPi overlay here: firmware/mcp23017.dtbo at master · raspberrypi/firmware · GitHub

@librecomputer if you would be able to add this as a supported device it would be much appreciated.

Thank you!

We do not have the device to test and verify functionality. The overlay looks correct. You can decompile the Raspberry Pi dtbo via the command dtc -I dtb -O dts FILE.dtbo.

Hello @librecomputer thank you.

I have done the decompile and see that the overlay for the Raspberry Pi has quite a bit more code than my custom overlay above. A few questions:

  1. What sections of the Raspberry Pi .dtbo overlay information do I need to add to the Libre overlay I have above?
  2. Do you have an example of a Raspberry Pi .dtbo that has switched the compatibles, targets, buses, GPIOs, and interrupt for the AML-S905X-CC?
  3. Is there a “master .dtbo” file for the Libre which includes additional info that is shown in the Raspberry Pi .dtbo? I don’t understand why the Raspberry Pi overlay has so much extra code for compatibles, GPIOs and so forth and how this affects the current overlays.

@librecomputer here is what I came up with, any feedback would be greatly appreciated. Thank you!

Change Log (from Raspi .dtbo):
-Changed the compatibles to match Libre
-Updated ‘address’ at fragment 0, 1 and 2 from 0xffffffffto ‘&i2c_A0’

/dts-v1/;

/ {
        compatible = "libretech,cc", "amlogic,s905x", "amlogic,meson-gxl";

        fragment@0 {
                target = <&i2c_A0>;

                __overlay__ {
                        status = "okay";
                };
        };

        fragment@1 {
                target = <&i2c_A0>;

                __overlay__ {

                        mcp23017_pins@20 {
                                brcm,pins = <0x04>;
                                brcm,function = <0x00>;
                                phandle = <0x02>;
                        };
                };
        };

        fragment@2 {
                target = <&i2c_A0>;

                __overlay__ {
                        #address-cells = <0x01>;
                        #size-cells = <0x00>;

                        mcp@20 {
                                compatible = "microchip,mcp23017";
                                reg = <0x20>;
                                gpio-controller;
                                #gpio-cells = <0x02>;
                                status = "okay";
                                phandle = <0x01>;
                        };
                };
        };

        fragment@3 {
                target = <0x01>;

                __dormant__ {
                        compatible = "microchip,mcp23008";
                };
        };

        fragment@4 {
                target = <0x01>;

                __overlay__ {
                        #interrupt-cells = <0x02>;
                        interrupt-parent = <&i2c_A0>;
                        interrupts = <0x04 0x02>;
                        interrupt-controller;
                        microchip,irq-mirror;
                        phandle = <0x03>;
                };
        };

        __overrides__ {
                gpiopin = [00 00 00 02 62 72 63 6d 2c 70 69 6e 73 3a 30 00 00 00                                   00 03 69 6e 74 65 72 72 75 70 74 73 3a 30 00];
                addr = <0x01 0x7265673a 0x30000000 0x27265 0x673a3000>;
                mcp23008 = [00 00 00 00 3d 33 00];
                noints = [00 00 00 00 21 31 21 34 00];
        };

        __symbols__ {
                mcp23017_pins = "/fragment@1/__overlay__/mcp23017_pins@20";
                mcp23017 = "/fragment@2/__overlay__/mcp@20";
                mcp23017_irq = "/fragment@4/__overlay__";
        };

        __fixups__ {
                i2c1 = "/fragment@0:target:0\0/fragment@2:target:0";
                gpio = "/fragment@1:target:0\0/fragment@4/__overlay__:interrupt-                                  parent:0";
        };

        __local_fixups__ {

                fragment@3 {
                        target = <0x00>;
                };

                fragment@4 {
                        target = <0x00>;
                };

                __overrides__ {
                        gpiopin = <0x00 0x10>;
                        addr = <0x00 0x0a>;
                };
        };
};

Got an error on running the above:

root@raspberrypi:/home/pi/libretech-wiring-tool# make
CC      libre-computer/aml-s905x-cc/dt/i2c-ao-mcp23017-a.dts
DTC     libre-computer/aml-s905x-cc/dt/i2c-ao-mcp23017-a.pre.dts
libre-computer/aml-s905x-cc/dt/i2c-ao-mcp23017-a.dts:18.20-24.11: ERROR (phandle_references): /fragment@0: Reference to non-existent node or label "i2c_A0"

libre-computer/aml-s905x-cc/dt/i2c-ao-mcp23017-a.dts:26.20-37.11: ERROR (phandle_references): /fragment@1: Reference to non-existent node or label "i2c_A0"

libre-computer/aml-s905x-cc/dt/i2c-ao-mcp23017-a.dts:39.20-55.11: ERROR (phandle_references): /fragment@2: Reference to non-existent node or label "i2c_A0"

libre-computer/aml-s905x-cc/dt/i2c-ao-mcp23017-a.dts:68.29-75.19: ERROR (phandle_references): /fragment@4/__overlay__: Reference to non-existent node or label "i2c_A0"

ERROR: Input tree has errors, aborting (use -f to force output)
make: *** [Makefile:24: libre-computer/aml-s905x-cc/dt/i2c-ao-mcp23017-a.dtbo] Error 2
rm libre-computer/aml-s905x-cc/dt/i2c-ao-mcp23017-a.pre.dts

Copying the Raspberry Pi overlay without understanding what you are doing is not going to work. The Raspberry Pi overlays have extensive hacks to work with Raspberry Pi boards and are usually non-standard. Standard overlays are much simpler.

Is there a guide on how you could switch compatibles and such?

Linux drivers each have supported compatible strings. They are just names. When you change compatibles in the device tree, you are just telling Linux to change the driver used.

Hi, am trying to operate an LCD screen with the following pin layout from the manufacturer: https://www.waveshare.com/wiki/2inch_LCD_Module#Raspberry_Pi_hardware_connection

Could I use pre existing overlays like the one meant for the 3.5 inch display: AML-S905X-CC (Le Potato) 480x320 ILI9486 SPI Touchscreen Display

Or will I need to create a custom overlay to setup the pin layout communication correctly just as I found someone else doing customization: Custom Device Tree Overlay for MCP23017 via i2c-ao - #2 by blue

Sorry if there is lack of necessary context, I am new to working with modules and these pin layout overlays.

Anything less than 3 inches is usually powered by an ST controller rather than an ILI controller. There’s overlays for 240x320 in the wiring tool that was uploaded recently.