Skip to contentSkip to conversation

Support for reading GPIO's in boot scripts?

U-Boot Rogan Dawes 4 participants 5 messages Mar 28, 2011

lore
Share & tools
lore
#0 lore raw

Hi folks,

I'm wondering if there is any support in u-boot for reading the state of a GPIO input (i.e. button) to control the sequence of boot events?

i.e. my board has a reset button, can I read its state to determine whether to try to TFTP-boot a new kernel, or to boot the existing one in flash?

I did try to grep the sources for any hints, but did not find anything. I may have been looking in the wrong place, of course!

Thanks,

Rogan

#1 lore raw
Quoted 9 lines · Rogan Dawes

I'm wondering if there is any support in u-boot for reading the state of a GPIO input (i.e. button) to control the sequence of boot events?

i.e. my board has a reset button, can I read its state to determine whether to try to TFTP-boot a new kernel, or to boot the existing one in flash?

I did try to grep the sources for any hints, but did not find anything. I may have been looking in the wrong place, of course!

i plan on generalizing arch/blackfin/cpu/cmd_gpio.c for all arches in this next cycle (it is mostly done). but that would require your arch to support the generic gpio layer.
-mike

#2 lore raw
Quoted 8 lines · Mike Frysinger
Quoted 7 lines · Rogan Dawes

I'm wondering if there is any support in u-boot for reading the state of a GPIO input (i.e. button) to control the sequence of boot events?

i.e. my board has a reset button, can I read its state to determine whether to try to TFTP-boot a new kernel, or to boot the existing one in flash?

Quoted 7 lines
Quoted 2 lines

I did try to grep the sources for any hints, but did not find anything. I may have been looking in the wrong place, of course!

i plan on generalizing arch/blackfin/cpu/cmd_gpio.c for all arches in this next cycle (it is mostly done). but that would require your arch to support the generic gpio layer.
-mike

Cool, thanks for the answer, Mike!

I'll wait to see what you do, and whatever needs to be done for my arch/board.

Rogan

#3 lore raw
In reply to Rogan Dawes

Let me add my $.02. I have a request to be able to boot a USB drive. So, reading a GPIO pin and making a decision in a script is a desirable thing. Certainly a 'MD 0x12345678' can read a pin but then making a decision in an environment string chain would help. Can we do this?

Quoted 19 lines · Rogan Dawes

Hi folks,

I'm wondering if there is any support in u-boot for reading the state of a GPIO input (i.e. button) to control the sequence of boot events?

i.e. my board has a reset button, can I read its state to determine whether to try to TFTP-boot a new kernel, or to boot the existing one in flash?

I did try to grep the sources for any hints, but did not find anything. I may have been looking in the wrong place, of course!

Thanks,

Rogan
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#4 lore raw

Dear Charles Krinke,

Quoted 5 lines · In message <[email protected]> you…

Let me add my $.02. I have a request to be able to boot a USB drive. So, reading a GPIO pin and making a decision in a script is a desirable thing. Certainly a 'MD 0x12345678' can read a pin but then making a decision in an environment string chain would help. Can we do this?

Sure we can do this. It's as trivial as for example

	setexpr tmpvar *12345678.l "&" 00010000
	if itest ${tmpvar} != 0; then do something ; fi

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
History is only a confused heap of facts.
                                       -- Philip Earl of Chesterfield