Jump to content

How do I persist GPIO changes across reboots?


PHLAK
Go to solution Solved by PHLAK,

Recommended Posts

I have Armbian up and running on a Rock Pi S with a PoE HAT. To enable the audio jack on the PoE HAT I had to run the following commands as mentioned on the official Rock Pi S PoE Hat wiki.
 

# echo 15 > /sys/class/gpio/export 
# echo out > /sys/class/gpio/gpio15/direction
# echo 1 > /sys/class/gpio/gpio15/value

 

Once enabled, the audio works as needed. However, every time the device is rebooted I have to SSH in and run these commands again to re-enable audio out which is obviously not ideal.

 

How can I persist these changes between reboots?

 

Link to comment
Share on other sites

Armbian & Khadas are rewarding contributors

  • Solution

I was able to solve this by using systemd-tmpfiles to modify these values on boot. Specifically I created a file `/etc/tmpfiles.d/enable-audio-jack.conf` with the following contents.

 

w /sys/class/gpio/export - - - - 15
w /sys/class/gpio/gpio15/direction - - - - out
w /sys/class/gpio/gpio15/value - - - - 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines