pietjepuk1001
Posts: 11
Joined: Wed Oct 11, 2017 1:00 pm

FIXED - program_gpio_bootmode broken on pi3b

Wed Oct 11, 2017 1:10 pm

Hi everybody, I can't seem to get program_gpio_bootmode to work,

I've put program_gpio_bootmode=1 in the config.txt, rebooted, pulled the power to do a hard reboot but still it boots with nothing connected to gpio, which it should not according to the documentation.
I've also tried to pull all pins (22-26) low and high but there is no change.

I really need this feature as the pi wil be potted in epoxy to "ruggadize" it but I would like to bring a usb connection out, so this way I can boot a recovery os with the sd card inserted.

Does anybody know which otp bit is involved ??

pi@raspberrypi:~ $ vcgencmd otp_dump
08:00000000
09:00000000
10:00000000
11:00000000
12:00000000
13:00000000
14:00000000
15:00000000
16:00280000
17:3030000a
18:3030000a
19:ffffffff
20:ffffffff
21:ffffffff
22:ffffffff
23:ffffffff
24:ffffffff
25:ffffffff
26:ffffffff
27:00002727
28:3f0a45b4
29:c0f5ba4b
30:00a02082
31:00000000
32:00000000
33:00000000
34:00000000
35:00000000
36:00000000
37:00000000
38:00000000
39:00000000
40:00000000
41:00000000
42:00000000
43:00000000
44:00000000
45:00000000
46:00000000
47:00000000
48:00000000
49:00000000
50:00000000
51:00000000
52:00000000
53:00000000
54:00000000
55:00000000
56:00000000
57:00000000
58:00000000
59:00000000
60:00000000
61:00000000
62:00000000
63:00000000
64:00000000
65:00000000
66:00009daa

Thanx !!
Last edited by pietjepuk1001 on Sun Nov 05, 2017 10:32 am, edited 2 times in total.

pietjepuk1001
Posts: 11
Joined: Wed Oct 11, 2017 1:00 pm

Re: Can't get program_gpio_bootmode to work

Thu Oct 12, 2017 7:53 pm

Ok, guess I'll post my progress here for people who want this feature but hit the same wall as I do...

I got a new pi3b in the mail today, an ideal opportunity to map out these otp changes on program_gpio_bootmode=1

pi@raspberrypi:~ $ uname -a
Linux raspberrypi 4.9.41-v7+ #1023 SMP Tue Aug 8 16:00:15 BST 2017 armv7l GNU/Linux

using otpdump I see only line 17 and 18 change if I set program_gpio_bootmode=1

Fresh, unmodified pi:
17:1020000a
18:1020000a

after setting program_gpio_bootmode=1 in /boot/config.txt, a soft reboot and a hard reboot:
17:1030000a
18:1030000a

The documentation states here: https://www.raspberrypi.org/documentati ... ootflow.md that I should expect the pi to no longer boot.
But it does boot, also when I pull gpio 22 low or high, which, as I understand the documentation should disable / enable the sdcard.

Is this feature disabled maybe ??

Please advice....

pietjepuk1001
Posts: 11
Joined: Wed Oct 11, 2017 1:00 pm

Re: Can't get program_gpio_bootmode to work

Fri Oct 13, 2017 7:07 pm

Ok, still swimming here....

I've tried to find the source code responsible for deciding to boot from sd-card or usb (or ...), no luck.
This all seems to be propriety-binarys, no clues to changed firmwares..
I've confirmed that the "program_gpio_bootmode" flipped a switch on a new pi.
I've confirmed the correct bits are flipped by digging through this: https://github.com/christinaa/rpi-open-firmware

Strange: I have not found any stories of success ....

Did anybody ever have a successful implementation of "boot device decided by hardware switch" ???

This obviously errors out before there is even a notion of a config.txt or whatever..

Kind of lost, please advice..

User avatar
davidcoton
Posts: 2428
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK

Re: Can't get program_gpio_bootmode to work

Fri Oct 13, 2017 8:45 pm

This might be obvious, but have you set it to boot from USB before trying to make the boot switchable? See here.
I'm not certain, the first post OTP dump looks correct, but the second (after reboot) does not lookm right.
"If it ain't broke, fix it until it is."
“Raspberry Pi is a trademark of the Raspberry Pi Foundation”
The Pink Unicorn is a symbol of commitment to sensible discussion of future versions of the Raspberry Pi ™

pietjepuk1001
Posts: 11
Joined: Wed Oct 11, 2017 1:00 pm

Re: Can't get program_gpio_bootmode to work

Sat Oct 14, 2017 7:12 am

Hi davidcoton, thanx for answering !

Sure, before it boots from usb I need to set "program_usb_boot_mode", you are right.

But that is the next step... in the first place it should not boot after setting "program_gpio_bootmode" (as I understand the documentation..)

Of course I tried this, setting usb_boot_mode changes the 17:1030000a into 17:3030000a, afterwards the pi boots fine off usb but only without a sd-card in it..
If there is a sd-card in it it always boots off it, that's the problem.

I need to boot off usb with a bootable sd-card inserted.. so I need a real "boot-select".

Found someone here who solved the same problem rather creatively by pulling one of the sd-card lines high so it can't be read.. not ideal...

Regards

User avatar
davidcoton
Posts: 2428
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK

Re: Can't get program_gpio_bootmode to work

Sat Oct 14, 2017 9:34 am

Okay, so if I've understood correctly you've done both "usb_boot_mode" and "program_gpio_bootmode".
I've not tried, but AIUI you need both before you can use GPIOs to select the boot source.
Then pull GPIO26 high(3V3) to select USB (only). And GPIO22 high for SDCard. SDCard will take priority if both are high.
Pulling low (0V) makes no difference, that is the default state.
I do not know what happens if no GPIOs are pulled high -- possibly it then defaults back to SDCard. Would that fit with what you are seeing?
Similarly if GPIO26 is high but here is no bootable USB device.
"If it ain't broke, fix it until it is."
“Raspberry Pi is a trademark of the Raspberry Pi Foundation”
The Pink Unicorn is a symbol of commitment to sensible discussion of future versions of the Raspberry Pi ™

pietjepuk1001
Posts: 11
Joined: Wed Oct 11, 2017 1:00 pm

Re: Can't get program_gpio_bootmode to work

Sat Oct 14, 2017 11:25 am

Hi davidcoton,

No, that does not reflect what I am seeing..

According to the documentation, after burning the "gpio_bootmode-bit" the pi should not boot at all.
What I see is that there is absolutely no difference in booting after burning that bit.
It boots from sd-card as always (and it boots perfectly fine off usb when there is no sd-card).

I've also found a custom bootcode.bin that spits data over the uart and with that I've checked that it does not read bootcode.bin from usb and then switches to sd-card ... It really starts booting from the sd-card only. No matter if I pull 26 high and 22 low.

As this booting decision is made in the gpu before there is anything loaded from sd or usb, there can only be 2 things wrong in my opinion:
1. The wrong bit in the otp was burned.. difficult to find out without documentation.. but my results seem consistent with what I find in the forums.
2. This never worked before (at least for a pi3b and pi0w) and is plainly documented wrongly. ( I also posted this as a remark on the documentation github page )

Do you know of any other avenues of debugging this ?
What writes the otp bits ? is that bootcode.bin ?

Regards.

User avatar
davidcoton
Posts: 2428
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK

Re: Can't get program_gpio_bootmode to work

Sat Oct 14, 2017 12:30 pm

It won't work on a Pi0W, only on a Pi3 or the latest Pi2. The boot ROM on Pi0, Pi1, and earlier Pi2 models does not have the USB boot code.
So, to reiterate, on the Pi3B, with both OTP bits set (two commands used in config.txt at power on), the OTP dump should give:
17:3030000a
With no SDCard, confirm that USB boots.
If you pull GPIO26 high, no connection (or low) to GPIO22, it should boot from USB, regardless of the prescense or absence of SDCard.
If that is not so, I think there is a bug with documentation or implementation.
"If it ain't broke, fix it until it is."
“Raspberry Pi is a trademark of the Raspberry Pi Foundation”
The Pink Unicorn is a symbol of commitment to sensible discussion of future versions of the Raspberry Pi ™

pietjepuk1001
Posts: 11
Joined: Wed Oct 11, 2017 1:00 pm

Re: Can't get program_gpio_bootmode to work

Sat Oct 14, 2017 1:35 pm

Hi davidcoton,
So, to reiterate, on the Pi3B, with both OTP bits set (two commands used in config.txt at power on), the OTP dump should give:
17:3030000a
--> it does.
With no SDCard, confirm that USB boots.
--> it does.
If you pull GPIO26 high, no connection (or low) to GPIO22, it should boot from USB, regardless of the presence or absence of SDCard.
--> It does not, tested on 2 different rpi3b's.

For now I've decided to go for the "pull cmd high" solution as described here : viewtopic.php?f=63&t=155167&p=1061759#p1061759 as this works flawless for me now and I need to get going on this project.. (And this is only the disaster recovery solution, normal boot would always be form sd-card..)
In the end a "neat" solution is definitely preferred though.

Thanx for your time..

User avatar
DougieLawson
Posts: 30416
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: program_gpio_bootmode broken on pi3b

Sun Oct 15, 2017 8:27 am

I'm not sure why you're doing this stuff - what's the point? Which pins are you pulling high (3V3) or low (GND)? Are you sure you've found the right ones on the header? Leave your connections in place after your RPi boots and run gpio readall or raspi-gpio get to see the state of the pins.

Pin#15 GPIO22=SD1
https://pinout.xyz/pinout/pin15_gpio22

Pin#37 GPIO26=USB
https://pinout.xyz/pinout/pin15_gpio26
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.

pietjepuk1001
Posts: 11
Joined: Wed Oct 11, 2017 1:00 pm

Re: program_gpio_bootmode broken on pi3b

Sun Oct 15, 2017 9:33 am

Hi DougieLawson,
I'm not sure why you're doing this stuff - what's the point?
Please read the first post on the topic / Because the whole wil be potted in epoxy and I want a disaster-recovery option as this is a first batch of 60 pi's and I'm afraid of my over-the-air-updating-skills ;-)
Which pins are you pulling high (3V3) or low (GND)?
Please read the 1st, second, seventh, ninth post on the topic / It does not matter, there is no change. According to the documentation it should not boot at all if you leave the pins alone but there is no change, it still boots as normal off sd-card.https://www.raspberrypi.org/documentati ... ootflow.md
Are you sure you've found the right ones on the header?
Yes.
Leave your connections in place after your RPi boots and run gpio readall or raspi-gpio get to see the state of the pins.
Did that (maybe 5 times, on 2 pi's), the correct pins are pulled to the correct state.

Did you ever encounter a successful "boot decided by gpio" on this forum / anywhere ??

Do you know to whom I could escalate this issue ? the firmware section on github maybe ?

Thanx !

User avatar
davidcoton
Posts: 2428
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK

Re: program_gpio_bootmode broken on pi3b

Sun Oct 15, 2017 11:35 am

pietjepuk1001 wrote: Do you know to whom I could escalate this issue ? the firmware section on github maybe ?
I guess so, it looks like you have reached that stage.

I too am not aware of any posts about success with these options, but then, people tend to post problem rather than success, and I think yours is the first problem report I have seen. :?
"If it ain't broke, fix it until it is."
“Raspberry Pi is a trademark of the Raspberry Pi Foundation”
The Pink Unicorn is a symbol of commitment to sensible discussion of future versions of the Raspberry Pi ™

User avatar
DougieLawson
Posts: 30416
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: program_gpio_bootmode broken on pi3b

Sun Oct 15, 2017 5:37 pm

pietjepuk1001 wrote:
Sun Oct 15, 2017 9:33 am
Did you ever encounter a successful "boot decided by gpio" on this forum / anywhere ??
You're the first.

Create an issue at: https://github.com/raspberrypi/firmware/issues and the very kind folks at the RPF/RP(T)Ltd. in Cambridge should see it.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.

pietjepuk1001
Posts: 11
Joined: Wed Oct 11, 2017 1:00 pm

Re: program_gpio_bootmode broken on pi3b

Sun Oct 15, 2017 5:41 pm

Hey DougieLawson,

Already did that, thanx !

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1408
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: program_gpio_bootmode broken on pi3b

Sun Oct 15, 2017 8:17 pm

pietjepuk1001, I think you've found a bug. The code which handles program_gpio_bootmode ends up setting the wrong bits in the OTP. Bit 19 (0x00080000) at offset 17 (and 18 for redundancy) enables the GPIO bootmode selection, while bit 20 (0x00100000) selects the high bank (39-43). By setting bit 20 instead of bit 19 the firmware has not enabled GPIO bootmode but has prevented you from successfully using it in the future on your Pi 3B.

PM me with your postal address and we'll send you a replacement. In the meantime we'll push out a fixed firmware and you should remove "program_gpio_bootmode" from the card image in the affected Pi unless you want to brick it if you ever update.

pietjepuk1001
Posts: 11
Joined: Wed Oct 11, 2017 1:00 pm

Re: program_gpio_bootmode broken on pi3b

Sun Oct 15, 2017 8:41 pm

Hi PhilE,

Do I understand correctly that the pi won't be able to boot anymore becouse the high gpio pins are selected by the bug and they are not broken out on the p3b ?
Are you sure it is a good idea to fix this in this way ?
I've got about 10 pi's here that have had that sd-card, and probably a lot of people played with this and dismissed it becouse it didn't work.
You would kill all pi's that stil have that line in config.txt.

Maybe it's a better idea to just ignore "program_gpio_bootmode" and create a new variable eg. "program_boot_select" or something.
Or make your update check for the line in config.txt and remove it before executing it..

Just trying to think along...

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1408
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: program_gpio_bootmode broken on pi3b

Sun Oct 15, 2017 9:07 pm

I haven't been through the pin states for 39-43, but an unbootable Pi is a plausible outcome.

I would prefer to add a test for the invalid bootmode bits (19 clear and 20 set) which disables further attempts to program the GPIO bootmode bits.

User avatar
DougieLawson
Posts: 30416
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: program_gpio_bootmode broken on pi3b

Mon Oct 16, 2017 9:35 am

PhilE wrote:
Sun Oct 15, 2017 8:17 pm
pietjepuk1001, I think you've found a bug. The code which handles program_gpio_bootmode ends up setting the wrong bits in the OTP. Bit 19 (0x00080000) at offset 17 (and 18 for redundancy) enables the GPIO bootmode selection, while bit 20 (0x00100000) selects the high bank (39-43). By setting bit 20 instead of bit 19 the firmware has not enabled GPIO bootmode but has prevented you from successfully using it in the future on your Pi 3B.

PM me with your postal address and we'll send you a replacement. In the meantime we'll push out a fixed firmware and you should remove "program_gpio_bootmode" from the card image in the affected Pi unless you want to brick it if you ever update.
Wow. Well done Phil, what a fantastic response. That program_gpio_bootmode needs some massive health warnings in the documentation if there's a chance it can really "brick" your RPi.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.

pietjepuk1001
Posts: 11
Joined: Wed Oct 11, 2017 1:00 pm

Re: program_gpio_bootmode broken on pi3b

Sun Nov 05, 2017 10:31 am

I can confirm this has been fixed in the update to kernel 4.9.60.
After setting program_gpio_bootmode=1 and setting program_usb_boot_mode=1 my otp bit reads:
17:3028000a

Thanx for the update guys !! You rock !

ptkatch
Posts: 6
Joined: Wed Nov 08, 2017 8:16 pm

Re: FIXED - program_gpio_bootmode broken on pi3b

Fri Nov 10, 2017 12:54 am

Yes, please add warning to https://www.raspberrypi.org/documentati ... ootflow.md ASAP,
I fall into the same trap today :-(

So to get corrected firmware all I need is to update kernel to 4.9.60, correct?

Thanks for the prompt issue fix.

pietjepuk1001
Posts: 11
Joined: Wed Oct 11, 2017 1:00 pm

Re: FIXED - program_gpio_bootmode broken on pi3b

Fri Nov 10, 2017 4:55 am

ptkatch wrote:
Fri Nov 10, 2017 12:54 am
Yes, please add warning to https://www.raspberrypi.org/documentati ... ootflow.md ASAP,
I fall into the same trap today :-(

So to get corrected firmware all I need is to update kernel to 4.9.60, correct?

Thanks for the prompt issue fix.
Hi ptkatch .. I'm sorry.. but these are called One Time Programmable for a reason.. They are "fuses".

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1408
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: FIXED - program_gpio_bootmode broken on pi3b

Fri Nov 10, 2017 10:00 am

There's a documentation change in the pipeline.

ptkatch
Posts: 6
Joined: Wed Nov 08, 2017 8:16 pm

Re: FIXED - program_gpio_bootmode broken on pi3b

Fri Nov 10, 2017 7:00 pm

> Hi ptkatch .. I'm sorry.. but these are called One Time Programmable for a reason.. They are "fuses".

Hi! Three points. First, bootflow.md doesn't tell "program_gpio_bootmode=n" in config.txt will change OTP. You can guess, but it doesn't say it
explicitly. Second, you start project implementation from reading official docs, and in this particular case by the time you get the problem it's
already too late to search forums for solution - board is already "broken".

That's why it's important to add warning and kernel 4.9.60+ requirement sooner, than later so other guys won't "damage" their boards.

Third, I'd like to thank Pi engineers for thinking ahead and making this feature available. It is huge help to the project I'm working on.

ptkatch
Posts: 6
Joined: Wed Nov 08, 2017 8:16 pm

Re: FIXED - program_gpio_bootmode broken on pi3b

Sat Nov 11, 2017 12:10 am

Hello Phil,

What is the minimum time from powering Pi up relevant GPIO [22-26] has to stay HIGH for boot ROM to reliably read it and select correct boot device?

Thanks.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1408
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: FIXED - program_gpio_bootmode broken on pi3b

Sat Nov 11, 2017 2:27 pm

I can't give you timings because I don't have them, but I can say that reading the GPIOs is the second initialisation step after reading the OTP. I suggest you time the interval between applying power and the very first SD card activity and treat that as a pessimistic version of the time taken - so probably a safe minimum.

Return to “Advanced users”

Who is online

Users browsing this forum: No registered users and 16 guests