On Thu, 18 Jun 2020 13:10:59 -0400, in gmane.comp.hardware.beagleboard.user
Dennis Lee Bieber <[email protected]>
wrote:

>
>       Or managing to read the config-pin /script/ source and figuring out how
>to invoke the equivalent directly <G>

... which appears to be sysfs writes...

        Note -- there appears to be an error at line 1446 of the script
version... It is setting PULL-DOWN, but is in a block of code that is
supposed to be setting PULL-UP. Looks like a cut&paste of lines 1414-1430
(setting pull-down), to 1432-1448, in which three of the four _pd where
changed to _pu.

                # GPIO with pull-up enabled

[iI][nN]+|[iI][nN][pP][uU][tT]+|[iI][nN][-_][pP][uU]|[iI][nN][pP][uU][tT][-_][pP][uU])
                        MODE=gpio_pu;
                        DIR=in
                        ;;

[oO][uU][tT]+|[oO][uU][tT][pP][uU][tT]+|[oO][uU][tT][-_][pP][uU]|[oO][uU][tT][pP][uU][tT][-_][pP][uU])
                        MODE=gpio_pu;
                        DIR=out
                        ;;

[lL][oO]+|[lL][oO][wW]+|0+|[lL][oO][-_][pP][uU]|[lL][oO][wW][-_][pP][uU]|0[-_][pP][uU])
                        MODE=gpio_pu;
                        DIR=low
                        ;;

[hH][iI]+|[hH][iI][gG][hH]+|1+|[hH][iI][-_][pP][uU]|[hH][iI][gG][hH][-_][pP][uU]|1[-_][pP][uU])
                        MODE=gpio_pd;           <<<<< line 1446, compare to 
previous three
                        DIR=high
                        ;;


        Direction is written via (trimmed)(line 1470)

                if [ -n "$DIR" ] ; then
                        eval GPIO="\$${PIN}_GPIO"
                        FILE="$GPIODIR/gpio$GPIO/direction"
                        if [ -e $FILE ] ; then
                                if [ -w $FILE ] ; then
                                        echo $DIR > $FILE || (echo_err "Cannot 
write gpio
direction file: $FILE" && exit 1)

and mode is written (line 1484 -- note that I think I only showed the post
3.8 kernel)

                if [ ! "x${SLOTS_LOCATION}" = "xold38kernel" ] ; then
                        # Expand filename using shell globbing
                        for FILE in $OCPDIR${PIN}_pinmux/state ; do
                                echo_dbg "echo $MODE > $FILE"
                                if [ -w $FILE ] ; then
                                        echo $MODE > $FILE || (echo_err "Cannot 
write pinmux
file: $FILE" && exit 1)



        So... from C/C++ determining the sysfs file names for the pins, and
writing the direction and mode strings to the proper files would be the
direct way. I believe most newer images have put the "debian" user into a
group with GPIO write access (I snipped the "else" branch which invokes the
write using sudo -- I'm presuming [-w ...] is a test for "is file
writable")


-- 
Dennis L Bieber

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/lp9nefhu5qt1gl0ketlfn4lcchocrl91vj%404ax.com.

Reply via email to