This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

GPIO/Pinmux on Beaglbone Black EXSDK 7.00



Hello,

I'm trying to use the GPIO on the beaglebone black (REV A5A)

I can't export any gpio pins using the command echo 44> /sys/class/gpio/export

I'm fairly certain that my problem is due to not setting up the pinmux correctly. 

So, I want to use GPIO1_12, GPIO44, beaglebone black p8-12 as a GPIO output.  I've figure out that I need to write value 0x27 to gpmc_ad12 pinmux register, but I don't know where that register is and how to write to it. 

Any suggestions?

  • Hi,

    To use one pin as gpio you have to make these main steps:
      - to declare this pin as gpio in a dts/dtsi file. You can see the name and address from the TRM and data sheet.
      - to request this gpio with: gpio_request() or some modification of this command. The first parameter is a number of gpio. If you have any trouble with this number you can use GPIO_TO_PIN(bank, pin)
      - to declare direction with gpio_direction_input/gpio_direction_output
      - for output gpio with gpio_set_value() you set output level, for input gpio with gpio_get_value you read input level

    From TRM Table 9-7. CONTROL_MODULE REGISTERS you can see that gpmc_ad12 is 830h. This mean that in a dts/dtsi file you have to set to 0x30 address.

    BR
    Ivan

  • Hi Ivan,

    I open the board-support/linuxxx.xx.xx.xx/arch/arm/boot/dts/am335x-boneblack.dts file

    under this section I added the last line

    &am33xx_pinmux {
    nxp_hdmi_bonelt_pins: nxp_hdmi_bonelt_pins {
    pinctrl-single,pins = <
    0x1b0 0x03 /* xdma_event_intr0, OMAP_MUX_MODE3 | AM33XX_PIN_OUTPUT */
    0xa0 0x08 /* lcd_data0.lcd_data0, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
    0xa4 0x08 /* lcd_data1.lcd_data1, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
    0xa8 0x08 /* lcd_data2.lcd_data2, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
    0xac 0x08 /* lcd_data3.lcd_data3, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
    0xb0 0x08 /* lcd_data4.lcd_data4, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
    0xb4 0x08 /* lcd_data5.lcd_data5, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
    0xb8 0x08 /* lcd_data6.lcd_data6, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
    0xbc 0x08 /* lcd_data7.lcd_data7, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
    0xc0 0x08 /* lcd_data8.lcd_data8, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
    0xc4 0x08 /* lcd_data9.lcd_data9, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
    0xc8 0x08 /* lcd_data10.lcd_data10, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
    0xcc 0x08 /* lcd_data11.lcd_data11, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
    0xd0 0x08 /* lcd_data12.lcd_data12, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
    0xd4 0x08 /* lcd_data13.lcd_data13, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
    0xd8 0x08 /* lcd_data14.lcd_data14, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
    0xdc 0x08 /* lcd_data15.lcd_data15, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
    0xe0 0x00 /* lcd_vsync.lcd_vsync, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT */
    0xe4 0x00 /* lcd_hsync.lcd_hsync, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT */
    0xe8 0x00 /* lcd_pclk.lcd_pclk, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT */
    0xec 0x00 /* lcd_ac_bias_en.lcd_ac_bias_en, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT */
    0x30 0x27 /*set pin gpmc_ad12 to GPIO1_12 (GPIO44) output*/
    >;
    };

    I went back to the ti-sdk root dir and ran make linux, then make linux_install

    I could see that it remade the am335x_boneblack.dtb file.

    Then I ran setup.sh and copied the new am335x_boneblack.dtb file to /tftpboot/

    I still couldn't export the proper GPIO pin.

    This seems like an extremely roundabout way to set the pinmux.  Isn't there a way I can set it during runtime instead of through the kernel?

    -Thanks

  • Hi Ivan,

    It looks like I have set the correct pinmux

    root@am335x-evm:/sys/kernel/debug/pinctrl/44e10800.pinmux# more pins | grep 830

    pin 12 (44e10830.0) 00000027 pinctrl-single

    however, 

    root@am335x-evm:/sys/kernel/debug/pinctrl/44e10800.pinmux# cat pinmux-pins | gre
    p "pin 12"

    pin 12 (44e10830.0): (MUX UNCLAIMED) (GPIO UNCLAIMED)

    I think this means that I need to undo the previous change that I made, and then add a GPIO group to the dts, but I'm not sure how to do that.  I'm looking for examples at the moment

  • I modified my am335x-boneblack.dts file to read

    &am33xx_pinmux {

    //nxp hdmi pins declared here


               gpio_pins: gpio_pins {
                         pinctrl-single,pins = <
                            0x30 0x27
                                   >;
                   };

    };

    then I ran <kdir> make am335x-boneblack.dtb

    then I copied that file to /tftpboot/

    still unable to export the GPIO in userspace with echo 44>/sys/class/gpio/export

    What am I missing?

  • Hi Chris,

    To understand well how working GPIO I propose you to comment three of four gpio initialization in .../dts/am335x-bone-common.dtsi file in section leds and corresponding pin mux in am33xx_pinmux user_leds_default/user_leds_sleep. After that you see the file drivers/leds/leds-gpio.c. You will see that only one led will light and will see that in a gpio_led_set() procedure with gpio_set_value() function will make to light and clear the chosen led. Of course you will see the registration and configuration of this gpio in this file.

    BR
    Ivan

  • Ivan,

    Thanks for all of the help.  It turns out that "echo 44>export" is NOT the same thing as "echo 44 > export".   Apparently, an extra space or two makes everything work just fine.