1

Hello i've got a board connected to my raspberry pi 3 and according to the pin set on boot of the raspberry this shield reboot which is problematic. I need to be able to reset the board and control the pin. I cannot add an EEPROM to use the Raspberry shield system, so i tried to add an overlay to the DT to activate the gpio to an high output at boot but it doesn't work. My overlay:

// Definitions for gpio module 
/dts-v1/;
/plugin/;

/ {
    compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";

    fragment@0 {
        target-path = "/";
        __overlay__ {
            test_board: test_board {
                compatible = "brcm,bcm2835";
                pinctrl-names = "default";
                pinctrl-0 = <&test_board_pin>;
                gpio-controller;
                gpios = <&gpio 27 0>;//GPIO active high is 0
                default-state = "keep";
                non-removable;
                #gpio-cells = <2>;
                status = "okay";
            };
        };
    };
    fragment@1 {
        target = <&gpio>;
        __overlay__ {
            test_board_pin: test_board_pin {
                status = "okay";
                brcm,pins = <27>;
                brcm,pull = <1>;//pull-down
                brcm,function = <1>; // out 
                output-hight;
            };
        };
    };
};

I compile it:

dtc -W no-unit_address_vs_reg -@ -I dts -O dtb -o test_board.dtbo gpio-test-overlay.dts

I add it to the overlay:

sudo cp test_board.dtbo /boot/overlays

I activate it:

dtoverlay=test_board

I reboot. I check that it wok:

dtc -I fs /proc/device-tree > look1.txt

gpio@7e200000 {
        compatible = "brcm,bcm2835-gpio";
        gpio-controller;
        #interrupt-cells = <0x2>;
        interrupts = <0x2 0x11 0x2 0x12>;
        phandle = <0xc>;
        reg = <0x7e200000 0xb4>;
        #gpio-cells = <0x2>;
        interrupt-controller;

        i2c1 {
            brcm,pins = <0x2 0x3>;
            phandle = <0x13>;
            brcm,function = <0x4>;
        };

        test_board_pin {
            brcm,pins = <0x1b>;
            status = "okay";
            phandle = <0x4b>;
            brcm,pull = <0x1>;
            brcm,function = <0x1>;
            linux,phandle = <0x4b>;
            output-hight;
        };

        spi0_pins {
            brcm,pins = <0x9 0xa 0xb>;
            phandle = <0xd>;
            brcm,function = <0x4>;
        };

        sdhost_pins {
            brcm,pins = <0x30 0x31 0x32 0x33 0x34 0x35>;
            phandle = <0x17>;
            brcm,function = <0x4>;
        };

        uart1_pins {
            brcm,pins;
            phandle = <0x11>;
            brcm,pull;
            brcm,function;
        };

        i2s {
            brcm,pins = <0x12 0x13 0x14 0x15>;
            phandle = <0xb>;
            brcm,function = <0x4>;
        };
aliases {
    intc = "/soc/interrupt-controller@7e00b200";
    spi2 = "/soc/spi@7e2150c0";
    i2c1 = "/soc/i2c@7e804000";
    i2c_vc = "/soc/i2c@7e205000";
    spi0 = "/soc/spi@7e204000";
    thermal = "/soc/thermal";
    vchiq = "/soc/vchiq";
    sdhost = "/soc/sdhost@7e202000";
    aux = "/soc/aux@0x7e215000";
    gpio = "/soc/gpio@7e200000";
    audio = "/soc/audio";
    dma = "/soc/dma@7e007000";
    soc = "/soc";
    leds = "/leds";
    mmc = "/soc/mmc@7e300000";
    serial1 = "/soc/serial@7e201000";
    i2c_arm = "/soc/i2c@7e804000";
    ethernet = "/soc/usb@7e980000/usb1@1/usbether@1";
    uart0 = "/soc/serial@7e201000";
    fb = "/soc/fb";
    i2c2 = "/soc/i2c@7e805000";
    i2s = "/soc/i2s@7e203000";
    spi1 = "/soc/spi@7e215080";
    usb = "/soc/usb@7e980000";
    i2c0 = "/soc/i2c@7e205000";
    watchdog = "/soc/watchdog@7e100000";
    sound = "/soc/sound";
    mailbox = "/soc/mailbox@7e00b880";
    uart1 = "/soc/serial@7e215040";
    random = "/soc/rng@7e104000";
    i2c = "/soc/i2c@7e804000";
    serial0 = "/soc/serial@7e215040";
};
.......................

test_board {
    gpios = <0xc 0x1b 0x0>;
    compatible = "brcm,bcm2835";
    gpio-controller;
    status = "okay";
    phandle = <0x4c>;
    #gpio-cells = <0x2>;
    pinctrl-0 = <0x4b>;
    default-state = "keep";
    linux,phandle = <0x4c>;
    non-removable;
    pinctrl-names = "default";
};

So the code OVERLAY is well integrated in the DT but the gpio is not exported, and when i export it, i can see that it's not set to output but input.

Can you help me to activate my GPIO?

thanks,

  • If I understand your question (which is rather vague) you are ATTEMPTING to change GPIO 27. This is ALREADY defined in the DTS. You will need to modify the existing. – Milliways Jan 15 '18 at 21:53
  • 1
    That's why i'm doing an overlay, which is loaded over the DT – aureliaC Jan 16 '18 at 7:48
2

I resolved my issues more or less. The answer is that the module(driver) doesn't handle very well the IO and all the functionality of the DT(pull up/down). this is what I did:

/dts-v1/;
/plugin/;

/{
    compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";

    // we use pin ctrl and no GPIO ctrl so has to not have a driver claim the GPIO and then not be able to control it normaly
    // see : https://www.kernel.org/doc/Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
    // https://www.kernel.org/doc/Documentation/devicetree/bindings/pinctrl/brcm%2Cbcm2835
    // VS: https://www.kernel.org/doc/Documentation/devicetree/bindings/gpio/gpio.txt
    // driver drivers/pinctrl/bcm/pinctrl-bcm2835.c used by RPI3 doesn't implement the generic "output-low/high" of pinctrl.
    // this mean we cannot set it until boot is complet but we can set a pull-up/down (pinmux-pins not pins)
    // There is no DPI driver module, but we need a platform device node (that doesn't already use pinctrl) to hang the pinctrl
    // reference on - leds will do

    fragment@1 {
        target = <&gpio>;
        __overlay__ {
            my_pins: my_pins {
                brcm,pins = <22 27 23>;
                brcm,pull = <1 2 1>;//no pull on output
                brcm,function = <0 0 0>;//input
            };
        };
    };
    fragment@0 {
        target = <&leds>;
        __overlay__ {
            pinctrl-names = "default";
            pinctrl-0 = <&my_pins>;
        };
    };
};

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.