andrum99
Posts: 1415
Joined: Fri Jul 20, 2012 2:41 pm

[SOLVED] (No) Potential to brick a CM4

Mon Apr 19, 2021 7:15 pm

I believe I may have spotted a potential hole which would allow a developer to inadvertently brick their CM4. The documentation at https://www.raspberrypi.org/documentati ... lashing.md says that CM4 never runs recovery.bin from SD/eMMC, which is the method for recovering the Pi 4 from an invalid EEPROM image. Absent some other way of running recovery.bin, this means that if, for example, there is a power cut while the CM4 bootloader EEPROM is being updated, then the CM4 could end up being bricked. I'm assuming this is not actually the case though, so what is the method for running recovery.bin on the CM4?

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

Re: Potential to brick a CM4

Mon Apr 19, 2021 7:22 pm


cleverca22
Posts: 3598
Joined: Sat Aug 18, 2012 2:33 pm

Re: Potential to brick a CM4

Mon Apr 19, 2021 7:35 pm

ive asked the same question before, and got the answer that recovery.bin is disabled on a CM4

https://github.com/librerpi/rpi-open-fi ... xt#L88-L93
according to my notes, bits 11-13 of OTP17 control which pins the sd/eMMC have to be on, for recovery.bin loading to work
a value of 0 in those 3 bits, will disable recovery.bin loading

Code: Select all

pi@pi400:~ $ vcgencmd otp_dump | grep 17:
17:000008b0
clever@c2d ~ $ node
> (0x000008b0 >> 11) & 7
1
on my pi400, it is enabled, as expected
i havent gotten an eMMC CM4 yet, to verify if this is how it got disabled

andrum99
Posts: 1415
Joined: Fri Jul 20, 2012 2:41 pm

Re: Potential to brick a CM4

Mon Apr 19, 2021 9:19 pm

That page does not specify a method to run recovery.bin on CM4. It does say that recovery.bin not running on the CM4 can be overridden, but it does not specify a way of doing this. Can you possibly explain how to run recovery.bin on CM4? My reason for asking is that it would seem to be a useful thing to add to the documentation, which I intend to do.

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

Re: Potential to brick a CM4

Mon Apr 19, 2021 9:24 pm

You use rpiboot/usbboot:
Flashing the bootloader EEPROM - Compute Module 4
To flash the bootloader EEPROM follow the same hardware setup as for flashing the EMMC but also ensure EEPROM_nWP is NOT pulled low. Once complete EEPROM_nWP may be pulled low again.

# Writes recovery/pieeprom.bin to the bootloader EEPROM.
./rpiboot -d recovery

cleverca22
Posts: 3598
Joined: Sat Aug 18, 2012 2:33 pm

Re: Potential to brick a CM4

Tue Apr 20, 2021 4:24 am

to explain it a bit further

loading of recovery.bin from the eMMC is disabled
when you close the nRPI_BOOT jumper, then loading of bootcode.bin from SPI flash will also fail
the rom's only remaining option is rpiboot/usbboot

you can then push a copy of recovery.bin over usb, using the rpiboot protocol (but its been renamed to bootcode4.bin, to keep you on your toes)
it will detect that your using it in rpiboot mode, and request the poeeprom.bin + pieeprom.sig over the rpiboot protocol, and re-flash things

timg236
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 831
Joined: Thu Jun 21, 2018 4:30 pm

Re: Potential to brick a CM4

Tue Apr 20, 2021 9:44 am

Pulling nRPIBOOT low instructs the ROM to skip all other boot modes and enter a loop waiting for the usbboot/rpiboot.

You can't brick this by erasing the EEPROM contents, in fact manufacturing test relies upon this working because the EEPROM starts out as a blank image.

Documented here https://www.raspberrypi.org/documentati ... ow_2711.md

andrum99
Posts: 1415
Joined: Fri Jul 20, 2012 2:41 pm

Re: Potential to brick a CM4

Tue Apr 20, 2021 4:15 pm

timg236 wrote:
Tue Apr 20, 2021 9:44 am
Pulling nRPIBOOT low instructs the ROM to skip all other boot modes and enter a loop waiting for the usbboot/rpiboot.
Thank you for explaining this - that's the bit I was missing.
timg236 wrote:
Tue Apr 20, 2021 9:44 am
Documented here https://www.raspberrypi.org/documentati ... ow_2711.md
Not quite - it doesn't mention anything about the ROM skipping all other boot modes and waiting for usbboot/rpiboot - it makes no mention of what happens if nRPIBOOT is enabled and asserted. I'm assuming if nRPIBOOT is enabled and asserted then the ROM does not attempt to run the bootloader EEPROM?

cleverca22
Posts: 3598
Joined: Sat Aug 18, 2012 2:33 pm

Re: [SOLVED] (No) Potential to brick a CM4

Tue Apr 20, 2021 5:38 pm

i cant find the schematic to back up my claim, but i remember seeing that nRPIBOOT is just wired to one of the spi data lines
so pulling it low isnt asking the rom to skip SPI, its forcing SPI access to fail

but the rom does have support to let any gpio pin temporarily skip SPI loading, so doing it better is an option
i just cant be sure which way the CM4 is doing it, and the schematics are missing from the old documentation repo on github

timg236
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 831
Joined: Thu Jun 21, 2018 4:30 pm

Re: [SOLVED] (No) Potential to brick a CM4

Wed Apr 21, 2021 4:53 pm

cleverca22 wrote:
Tue Apr 20, 2021 5:38 pm
i cant find the schematic to back up my claim, but i remember seeing that nRPIBOOT is just wired to one of the spi data lines
so pulling it low isnt asking the rom to skip SPI, its forcing SPI access to fail
It doesn't force SPI accesses to fail. If it did, it would be impossible to use recovery.bin with nRPIBOOT pulled low to update the bootloader EEPROM.

Return to “Compute Module”