2

I want to control the expansion ports (GPIO) of an embedded device (BeagleBoard-xM). However, I found that they are set to be "high" on startup.

Is there any programming way to set them "low" on startup? I'm thinking writing a shell script running on startup, that will access GPIOs and set them "low". I tried also to find, if there is a script that sets GPIOs "high", in order to disable it, but without success.

Any help would be highly appreciated.

BeagleBoard-xM Rev C, Angstrom Linux, kernel: 3.0.7

dempap
  • 352
  • 1
  • 9
  • 21

3 Answers3

2

Usually, GPIOs default to high impedance (Z) on start up. How do you know that the value is high? It might have a weak pull-up on it.

If you want them to go from Z to 0, then usually you write the value first, then the direction (out).

Also make sure that the pull-up is disabled.

Mark Lakata
  • 19,989
  • 5
  • 106
  • 123
2

When you want to have them low on startup (as early as possible), then it's not about Linux, but about your Bootloader. The GPIO settings there are easily done in 2-3 lines (I'm not sure which Bootloader you're using but:)

I wrote a script for BusyBox distro which puts a pin "low" (here 10 is the actual pin - you have to look it up, which number you need). Put this script into the /etc/init.d/ directory, so it will be executed before login.

#! /bin/sh
#Pin 10
Echo 10     > /sys/class/gpio/export
Echo out    > /sys/class/gpio/gpio10/direction
Echo 1  > /sys/class/gpio/gpio10/value

And I had a script for the Bootloader AT91Bootstrap that puts a pin high

Const struct pio_desc gpio_values[] = 
{{„PC1“, AT91C_PIN_PC(1), 1, PIO_DEFAULT, PIO_OUTPUT}};

pio_setup(gpio_values);

I hope this could help you

user3085931
  • 1,757
  • 4
  • 29
  • 55
0

Can you not use this code in the gpio_init.sh file?

sudo sh -c "echo '10' > /sys/class/gpio/export"
sudo sh -c "echo 'out' > /sys/class/gpio/gpio10/direction"
sudo sh -c "echo '1' > /sys/class/gpio/gpio10/value"