I have two boards, so I pulled out the second one (a good chance to test it) and it doesn't blink either. Both boards probably aren't defective (and as you will learn, they are not, apparently the Wiki is inaccurate and the kernel no longer blinks the LED).
Let's look at the wretched linux filesystem driven GPIO scheme.
cd /sys/class/gpio ls -l --w------- 1 root root 4096 Jan 1 1970 export lrwxrwxrwx 1 root root 0 Jan 1 1970 gpiochip0 -> ../../devices/platform/c0000000.soc/c001a000.pinctrl/gpio/gpiochip0 lrwxrwxrwx 1 root root 0 Jan 1 1970 gpiochip128 -> ../../devices/platform/c0000000.soc/c001a000.pinctrl/gpio/gpiochip128 lrwxrwxrwx 1 root root 0 Jan 1 1970 gpiochip160 -> ../../devices/platform/c0000000.soc/c001a000.pinctrl/gpio/gpiochip160 lrwxrwxrwx 1 root root 0 Jan 1 1970 gpiochip32 -> ../../devices/platform/c0000000.soc/c001a000.pinctrl/gpio/gpiochip32 lrwxrwxrwx 1 root root 0 Jan 1 1970 gpiochip64 -> ../../devices/platform/c0000000.soc/c001a000.pinctrl/gpio/gpiochip64 lrwxrwxrwx 1 root root 0 Jan 1 1970 gpiochip96 -> ../../devices/platform/c0000000.soc/c001a000.pinctrl/gpio/gpiochip96 --w------- 1 root root 4096 Jan 1 1970 unexport cd gpiochip32 ls -l -r--r--r-- 1 root root 4096 Aug 16 19:53 base lrwxrwxrwx 1 root root 0 Aug 16 19:53 device -> ../../../c001a000.pinctrl -r--r--r-- 1 root root 4096 Aug 16 19:53 label -r--r--r-- 1 root root 4096 Aug 16 19:53 ngpio drwxr-xr-x 2 root root 0 Aug 16 19:53 power lrwxrwxrwx 1 root root 0 Jan 1 1970 subsystem -> ../../../../../../class/gpio -rw-r--r-- 1 root root 4096 Jan 1 1970 uevent cat label gpiob cat base 32 cat ngpio 32And there you have it, the starting point for the usual haywire linux gpio setup. If you have kernel sources handy, you can read linux/Documentation/gpio.txt. Or, just use this link:
cd /sys/class/gpio echo 44 > exportIndeed, after doing this, a new directory "gpio44" magically appears! In addition, the LED goes out!!
cd gpio44 ls -l ls -al -rw-r--r-- 1 root root 4096 Aug 16 20:12 active_low lrwxrwxrwx 1 root root 0 Aug 16 20:12 device -> ../../../c001a000.pinctrl -rw-r--r-- 1 root root 4096 Aug 16 20:12 direction -rw-r--r-- 1 root root 4096 Aug 16 20:12 edge drwxr-xr-x 2 root root 0 Aug 16 20:12 power lrwxrwxrwx 1 root root 0 Aug 16 20:12 subsystem -> ../../../../../../class/gpio -rw-r--r-- 1 root root 4096 Aug 16 20:11 uevent -rw-r--r-- 1 root root 4096 Aug 16 20:12 valueNow let's fiddle:
cat direction in echo out >direction cat direction outAnd after this, the LED is back on again!
cat value 0 echo 1 >value echo 0 >value echo 1 >value cat value 1Indeed, this lets me turn on and off the green status LED. So, let's package up this knowledge as a nice little ruby script. Here is a link to download it, and if your browser will cooperate, a listing you could copy and paste if that works better. This blinks until you type Control-C, then cleans up and exits.
#!/usr/bin/ruby # Must be run as root # Blink the status LED on a Nanopi Fire3 # This is on GPIO B12, so bit 32+12 = 44 $bit = 44.to_s $base = "/sys/class/gpio" $export = "/sys/class/gpio/export" $unexport = "/sys/class/gpio/unexport" $gpiodir = $base + "/gpio" + $bit $gpioval = $gpiodir + "/value" def setup system "echo \"#{$bit}\" > #{$export}" end def cleanup system "echo \"#{$bit}\" > #{$unexport}" puts "" puts "All done" end def blink loop { sleep 0.5 system "echo 0 >#{$gpioval}" sleep 0.5 system "echo 1 >#{$gpioval}" } end setup begin blink rescue Interrupt cleanup end # THE END
Tom's electronics pages / tom@mmto.org