sipeed / LonganPi-3H-SDK

LonganPi 3H SDK
GNU General Public License v3.0
28 stars 14 forks source link

GPIO example doesn't work! #34

Closed grge-v closed 5 months ago

grge-v commented 5 months ago

I like this board, but unfortunately the example of using GPIO does not work in build 20240228. Perhaps it worked in previous builds. I can’t control the LED from the echo and the C code doesn’t work either. Please fix this in the build or example.

num=194
echo ${num} > /sys/class/gpio/export  
-bash: echo: write error: Device or resource busy
wu-yue-yu commented 5 months ago

This example uses the led light which is already defined by dts: arch/arm64/boot/dts/allwinner/sun50i-h618-longanpi-3h.dts

        leds {
                compatible = "gpio-leds";

                led-0 {
                        color = <LED_COLOR_ID_ORANGE>;
                        function = LED_FUNCTION_INDICATOR;
                        function-enumerator = <0>;
                        gpios = <&pio 6 2 GPIO_ACTIVE_LOW>; /* PG2 */
                };

                led-1 {
                        color = <LED_COLOR_ID_ORANGE>;
                        function = LED_FUNCTION_INDICATOR;
                        function-enumerator = <1>;
                        gpios = <&pio 6 4 GPIO_ACTIVE_LOW>; /* PG4 */
                };
        };

which means it already occupied, if you want to control the leds in userspace, you can disable them in dts. The GPIO example is to show how to control a GPIO generically.