m2i / MAVRIC-General

ISU Mars Rover Project
http://m2i.github.io/MAVRIC-General/home
1 stars 3 forks source link

Raspberry Pi HAT EEPROM info #7

Closed ghost closed 6 years ago

ghost commented 7 years ago

Add links/other data as useful

ghost commented 6 years ago

At the moment, it looks like I can't set the state of an output pin. I can only set the pull state of an input pin. This seems like a serious limitation of the system. Regardless, the ability to self-identify to the board is nice. We can make a boot script that checks the which HAT is present and runs the correct roslaunch configuration on startup. This will let us get away with simpler updates (just pull the repository and compile) if we have 1 repository, and has no effect if we have separate repos.

ghost commented 6 years ago

@matgyver Did you say you'd used these before at all? If so, did you explore having preset (high) outputs?

ghost commented 6 years ago

Device Tree overlay node, I found this for flash on an i2c bus, I'll look at pins next.

flash@50 {
    compatible = "atmel,24c256";
    reg = <0x50>;
};

That would go inside the i2c node, but it needs to be made as an overlay. I think it would look like this:

// Enable the i2s interface
/dts-v1/;
/plugin/;

/ {
    compatible = "atmel,24c256";

    fragment@0 {
        target = <&i2c1>;
        __overlay__ {
            flash@50 {
                compatible = "atmel,24c256";
                reg = <0x50>;
            };
        };
    };
};

Compile with dtc -@ -I dts -O dtb -o 1st.dtbo 1st-overlay.dts If that fails, try sudo apt-get install device-tree-compiler

Sauce:

ghost commented 6 years ago

https://www.kernel.org/doc/Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt

ghost commented 6 years ago

This post seems to indicate that not even the DT can configure the GPIO output states, I have a small amount of hope from the pinctrl link above, which has parameters to define output-high states. I think the issue is that though the DT can define these states, it can't invoke them automatically or something.

By states, I mean high/low, the eeprom can set the input/output mode, and the input pullup/pulldown state.

matgyver commented 6 years ago

I'm assuming you are wanting to set the default for the I/O pins. Did you read this? https://github.com/raspberrypi/hats/tree/master/eepromutils

ghost commented 6 years ago

Yeah, but if I do setgpio 4 OUTPUT HIGH it does not output high. setgpio 4 INPUT HIGH causes it to pull the line up, but cannot drive say, an LED, and is just a bad idea for logic signals.

ghost commented 6 years ago

I might be able to use https://www.raspberrypi.org/documentation/configuration/pin-configuration.md with https://github.com/raspberrypi/firmware/blob/master/extra/dt-blob.dts to make an overlay with active-on-startup pins.

Node to change:

pin@p# {
    function = "output";
   startup_state = ["active" | "inactive"];
};

overlay (maybe, I can't test right now.)

/dts-v1/;
/plugin/;

/ {
    fragment@0 {
        target = <&pin_config>;
        __overlay__ {
            pin@p# {
                function = "output";
                startup_state = ["active" | "inactive"];
            };
        };
    };
};

This would need to be included as a DT Blob in the eeprom.

matgyver commented 6 years ago

So what is the concern here? Do you want to make sure the pin is high or low on boot up? If that was the case I would just use the weak pull up on the pi that can be configured through the EEPROM and setgpio or use a pull up resistor on the design of the hardware. That would make sure your line is where it should be until pulled down by the pin.