how to keep GPIO settings after restart and change default settings

Discussion in 'UDOO NEO' started by redblade, Nov 30, 2015.

  1. redblade

    redblade New Member

    Joined:
    Nov 28, 2015
    Messages:
    5
    Likes Received:
    1
    Hi, I'm working on a sample project and I need to keep the gpio settings (e.g. some gpios in out mode) persistent after reboot.
    Also, is there a way to change default gpio settings when I export a new gpio number?
    Where can I find some documentation about this subject?

    Thanks
     
  2. Andrea Rovai

    Andrea Rovai Well-Known Member

    Joined:
    Oct 27, 2014
    Messages:
    1,703
    Likes Received:
    240
    Dear redblade,
    you should create a script at boot that exports GPIOs and set them in output.
    What is the default GPIO setting?
    Cheers
     
  3. redblade

    redblade New Member

    Joined:
    Nov 28, 2015
    Messages:
    5
    Likes Received:
    1
    Hi Andrea,
    thanks for your help, here is what I am trying to do.
    After a reboot, if I enable a gpio (e.g. 173) with "export", I get direction "in".
    I want it "out", so I change the direction and it works right.
    Then if I unexport and export again the direction is out, and that's great.
    But if I reboot, and enable again 173, I get direction "in"; is there a way to choose a direction for each gpio and keep it after reboot?

    I know the solution could be to write a script that set the direction too, but here is the problem I am facing:
    I am using the gpio to manage a few relays,; after a reboot if I enable a gpio, direction is in, so when I change the direction I got the relay switching on, because I cannot change active_low or value before changing the direction, and this is gonna be a problem for my automation project.

    It would be great to have a predefined bunch of gpio already set, after reboot, with "out" direction and active_low/value predefined
    Is it possible to achieve?

    thanks
     
  4. necromancer

    necromancer New Member

    Joined:
    Nov 10, 2015
    Messages:
    26
    Likes Received:
    8
    I am interested in doing this as well. I hadn't thought about it but I am sure i will run into same problem in future.
     
  5. jas-mx

    jas-mx Active Member

    Joined:
    Dec 31, 2013
    Messages:
    407
    Likes Received:
    118
    [QUOTE="redblade, post: 15227, member: 37859"
    It would be great to have a predefined bunch of gpio already set, after reboot, with "out" direction and active_low/value predefined
    Is it possible to achieve?
    thanks[/QUOTE]

    The correct way to do this would be to assign and configure gpios in uboot and not relying on the kernel to do this. uboot could be patched to read to some environment variables to know which pins need to be configured.
     
  6. vpeter

    vpeter Active Member

    Joined:
    Nov 29, 2014
    Messages:
    303
    Likes Received:
    62
    You could also set those pins in device tree. This is one example (for some other similar board).
     

Share This Page