I built and compiled the gpio.c program @ https://gist.github.com/six519/836484d73327e1c206db00d4f92bee97#file-gpio-c
It builds and runs fine (using GPIO14 that I had an LED attached to), however when I run it a second time I get a “Segmentation fault”.
The segmentation fault is occurring in the “setPinMode” function command “fwrite(mode, 1, sizeof(mode) , sysfs_direction);”
After the first execution if I check the gpio status the gpio pin is not showing with a “ls /sys/class/gpio/ ” command.
After the segmentation fault the gpio direction shows as “in”. So the segmentation error would appear to be that I am trying to write to an input which makes sense.
Why does the gpio direction get set to “input”?
William Hanna is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.