GPIO output on startup



  • I feel like I must be missing something obvious here... I'm using two pins (18,19) as output to drive relays. During boot I need them to be either high or low, but right now they seem to switch about mid-boot starting low and ending high. Is there a way to permanently set their state on startup?



  • After reset of the MT7688AN chip, all GPIOs start in input mode (high impedance). If your relay drivers have high impedance (CMOS, FET) inputs, then you'd need a pullup or pulldown resistor to keep the GPIO line at a defined level during the startup until a program of yours gets control.

    Only then you can make the GPIO an ouput, and then control the level from normal user land software.

    With your own kernel drivers and/or device tree (building the entire firmware from LEDE sources), or even by replacing the bootloader with a custom version (real hardcore), you could gain control over gpios a little earlier, but there will be still be some period if time after powerup where the pins are in input mode.

    Please also note that GPIO18/19 can be configured to be part of the second ethernet port (so called AGPIO mode). This is off at MT7688 reset, but it seems that depending on network components in use, the MT7688 can enter AGPIO mode during LEDE boot. It seems that this does not happen with regular Onion firmware, but I mention it because I did struggle a long time with strange signals on GPIO18/19 before I found out about AGPIO mode.



  • Thanks, luz! I think I understand the situation much better after reading your response and finding the annotated pinout online.


Log in to reply
 

Looks like your connection to Onion Community was lost, please wait while we try to reconnect.