TreeDee
Posts: 10
Joined: Thu Jan 23, 2014 1:06 am

Bootloader control GPIO output

Sun Jan 10, 2016 3:29 pm

Hi All:

I am working on a custom hardware add-on to rpi2. The hardware requires the GPIO output from the pi to be programmed to a particular output value at boot time as early as possible. Is it possible to set the GPIO output value in the bootloader cmdline.txt ? (And then once the OS has booted a driver can take over to control the output value.)

If so, what is the syntax to do so.

If not, this would be a very useful upgrade to the bootloader.

Thanks :)

User avatar
jackokring
Posts: 815
Joined: Tue Jul 31, 2012 8:27 am
Location: London, UK
Contact: ICQ

Re: Bootloader control GPIO output

Sun Jan 10, 2016 4:52 pm

From what I understand, the best you can do is make a dtb overlay to 'fix' the pin before loading the driver. but this still takes some time to enable, and if wait for network is selected, all bets are off, or maybe not, ...
Pi[NFA]=B256R0USB CL4SD8GB Raspbian Stock.
Pi[Work]=A+256 CL4SD8GB Raspbian Stock.
My favourite constant 1.65056745028

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5536
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Bootloader control GPIO output

Sun Jan 10, 2016 8:06 pm

You need to either be referring to section 6.2 of the BCM2835 datasheet at https://www.raspberrypi.org/documentati ... herals.pdf for the default GPIO pull states, or be looking at https://www.raspberrypi.org/documentati ... uration.md for how to use dt-blob.bin to get the GPU firmware to apply custom pin states as soon as it starts.
device tree overlays are there to load and configure the appropriate driver for your hardware, and that in turn would take control of any GPIOs. I don't see there being any benefit in trying to get one of those to muck with pin states as there would be no time saving over having your driver do it (assuming you are writing a kernel driver, not hacking something in userspace).
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

TreeDee
Posts: 10
Joined: Thu Jan 23, 2014 1:06 am

Re: Bootloader control GPIO output

Mon Jan 11, 2016 3:26 pm

Thanks very much this is exactly what I was looking for. :D

BTW, I'm surprised there isn't a "generic" DT-blob overlay that someone made to program the other GPIOs to default values (I see the "max_usb_current=1 and safe_mode_gpio=4" ones that is used to configure the hardware on the board, and others for specific projects (hifi,etc), ... but nobody has made a generic DT blob overlay for custom hardware projects so (eg. GPIO3=out,1) can set some hardware values etc). Anyway no worries, I can roll my own. :D

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5536
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Bootloader control GPIO output

Mon Jan 11, 2016 3:48 pm

AIUI If you ask the kernel to do it via device tree, then it generally reserves the GPIO for that driver to the exclusion of others. Not what you want if you're just setting up state.

max_usb_current=1 and safe_mode_gpio=4 are setting up pins that are nominally under the GPU control (there is no Linux kernel driver for those functions), so those are easy to use aliases to certain pin operations. The aliasing also allows changes of pin allocation between platforms without breaking configs.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

TreeDee
Posts: 10
Joined: Thu Jan 23, 2014 1:06 am

Re: Bootloader control GPIO output

Tue Jan 12, 2016 2:09 am

Hmmm, I made a custom dt-blob.dtb but I can't tell if it is doing it. It appears to be ignoring it.

Anyone familiar with doing making a custom DT Blob ? :)

Return to “Interfacing (DSI, CSI, I2C, etc.)”

Who is online

Users browsing this forum: No registered users and 4 guests