Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rpi-eeprom firmware #939

Merged
merged 4 commits into from Nov 25, 2020
Merged

Add rpi-eeprom firmware #939

merged 4 commits into from Nov 25, 2020

Conversation

tmm1
Copy link
Contributor

@tmm1 tmm1 commented Oct 27, 2020

This will allow us to take advantage of the RPI4 self-update feature to push new stable eeprom bootloader firmwares as part of HassOS updates

cc #899 (comment) @Jpsy

Copy link
Member

@pvizeli pvizeli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work

@agners
Copy link
Member

agners commented Oct 27, 2020

Seems to work here, with enable_uart=1 I can see that the EEPROM is being updated:

Read config.txt bytes     1826 hnd 0x00000780 hash '1850978bb5bda2bb'
Read pieeprom.upd bytes   524288 hnd 0x00000136 hash '5159f01d9c15fe32'
Reading EEPROM: 524288
Writing EEPROM
+++++++++++++++++++++++++.......++++++++++++++++++++++++++++++++++++++++++++++++++..............................................
Verify BOOT EEPROM
Reading EEPROM: 524288

@pvizeli
Copy link
Member

pvizeli commented Oct 27, 2020

On the next OTA update, the file is present again, do that flash it again?

@agners
Copy link
Member

agners commented Oct 27, 2020

The files are still there after the update, so I assume it detects if its newer? I don't have diagnostic output on UART anymore since the update also sets the config back...

@pvizeli
Copy link
Member

pvizeli commented Oct 27, 2020

Look like, so we have still open the rpi4_devconfig before we can merge it

@agners
Copy link
Member

agners commented Oct 27, 2020

I tried to make it update again, but it just wouldn't... I am now on 2020-09-03, and it seems that this version does not automatically update from SD card. Quote from https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2711_bootloader_config.md:

Self-update is not enabled in SD boot; the ROM can already load recovery.bin from the SD card.

@tmm1
Copy link
Contributor Author

tmm1 commented Oct 27, 2020

The files are still there after the update, so I assume it detects if its newer?

Yes it checks and only applies the .upd file is the current firmware does not match. It will show this info over HDMI as well telling you if update was skipped.

I don't have diagnostic output on UART anymore since the update also sets the config back...

This part is annoying for development. If you have a custom eeprom with NETCONSOLE or UART it gets overwritten. Maybe we can have a special dev file inside the boot partition and if it exists the eeprom file is removed or renamed during rauc update?

Self-update is not enabled in SD boot; the ROM can already load recovery.bin from the SD card.

Correct, there was some big problem with self-update from SD card: raspberrypi/rpi-eeprom#209

So this technique is mostly useful for USB boot scenarios. In this PR I customized USB_PWR_OFF_TIME for the eeprom to fix issues with some types of drives: raspberrypi/rpi-eeprom#241


define RPI_EEPROM_BUILD_CMDS
$(@D)/rpi-eeprom-config $(@D)/$(RPI_EEPROM_FIRMWARE_PATH) --out $(@D)/default.conf
(cat $(@D)/default.conf | grep -v ^$$; echo USB_MSD_PWR_OFF_TIME=1500) > $(@D)/boot.conf
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I changed USB_MSD_PWR_OFF_TIME from 1000 to 1500 as workaround for some drives not booting after soft-reboot.

Soon there will be a new beta firmware with a better fix, so we can use this same technique to update to that as part of HassOS update.

@agners
Copy link
Member

agners commented Oct 27, 2020

The files are still there after the update, so I assume it detects if its newer?

Yes it checks and only applies the .upd file is the current firmware does not match. It will show this info over HDMI as well telling you if update was skipped.

Not in the SD card case, it seems.

my_photo-20

I don't have diagnostic output on UART anymore since the update also sets the config back...

This part is annoying for development. If you have a custom eeprom with NETCONSOLE or UART it gets overwritten. Maybe we can have a special dev file inside the boot partition and if it exists the eeprom file is removed or renamed during rauc update?

I tried to just rebuild the upd file manually and flash it. I think its good enough, I hope we don't have to do this very often 😄

Self-update is not enabled in SD boot; the ROM can already load recovery.bin from the SD card.

Correct, there was some big problem with self-update from SD card: raspberrypi/rpi-eeprom#209

So this technique is mostly useful for USB boot scenarios. In this PR I customized USB_PWR_OFF_TIME for the eeprom to fix issues with some types of drives: raspberrypi/rpi-eeprom#241

Hm, yeah that is a bit annoying. I think most people still run SD-card boot. Can we update via recovery.bin?
I tried that, but I am not sure where to get recovery.bin from... Is that just the same file with different name? That I tried, it did not pick it up.

@pvizeli
Copy link
Member

pvizeli commented Oct 27, 2020

This part is annoying for development. If you have a custom eeprom with NETCONSOLE or UART it gets overwritten. Maybe we can have a special dev file inside the boot partition and if it exists the eeprom file is removed or renamed during rauc update?

We should not allow user to customize it. It's already hard to maintain, if every device has x variation to run, it's killing us or bite later in our a**. We decide what we want that people run and we can support.

@tmm1
Copy link
Contributor Author

tmm1 commented Oct 27, 2020

I think most people still run SD-card boot. Can we update via recovery.bin?

Yes I think so. The recovery.bin is a special firmware, but once it loads it will look for pieeprom.upd and flash it, then rename itself to recovery.000

You can find it here: https://github.com/raspberrypi/rpi-eeprom/blob/master/firmware/stable/recovery.bin

According to https://www.raspberrypi.org/documentation/hardware/raspberrypi/booteeprom.md, the recovery.bin can only be loaded from SD and is ignored on USB boot.

So I think we simply need to place the recovery.bin into boot and then it will pick up and flash the pieeprom.upd on the next boot.

If the bootloader update image is called pieeprom.upd then recovery.bin renames itself to recovery.000 and resets the CPU. Since recovery.bin is no longer present the ROM loads the newly updated bootloader from SPI EEPROM and the OS is booted as normal.

@agners
Copy link
Member

agners commented Oct 27, 2020

You can find it here: https://github.com/raspberrypi/rpi-eeprom/blob/master/firmware/stable/recovery.bin

This does not work for me either. Leads to a red screen 😕

@McGiverGim

This comment has been minimized.

this improves boot from USB and speeds up boot times.
also includes sd card v1 boot reliability.
see raspberrypi/rpi-eeprom#246

i removed the previous USB_MSD_PWR_OFF_TIME override since it is no longer required.
added HDMI_DELAY=0 so hdmi display is always visible for debugging.
@agners
Copy link
Member

agners commented Nov 24, 2020

I am generally ok merging this, however currently it uses a beta firmware. I rather prefer not shipping a beta firmware. Let's wait until the firmware gets promoted to stable.

Have there been issues with 2020-09-03?

@tmm1
Copy link
Contributor Author

tmm1 commented Nov 24, 2020

With the 2020-09 stable firmware, many drives get stuck inside the bootloader after a soft reboot.

raspberrypi/rpi-eeprom#241

@agners
Copy link
Member

agners commented Nov 25, 2020

Interesting thread. Thinking a bit more about this I think we should add the current beta update as you propose: Only people with USB boot will get the update applied. And for those this new beta firmware seems to really bring improvements. And since your tests were successful too, let's give it a go.

@agners agners merged commit 1fa53bc into home-assistant:dev Nov 25, 2020
@agners agners added the board/raspberrypi Raspberry Pi Boards label Nov 25, 2020
@Jpsy
Copy link

Jpsy commented Nov 26, 2020

Would this mean that starting with 5.6 there will be no more need to update the RPI boot firmware through Raspberry Pi Imager before installing HA on an RPi 4 with SSD attached through USB?

Or will it still be necessary to update with the Imager at least once to get HA running for the first time. And from there on HA would install further boot EEPROM updates?

I would update the guide to reflect your answer.

jens-maus added a commit to jens-maus/RaspberryMatic that referenced this pull request Nov 30, 2020
pieeprom.upd/sig files which we can put into the bootfs partition of the
rpi4 image so that a rpi4 (if booted from USB) will be able to update
its EEPROM immediately. This refs home-assistant/operating-system#939
@agners
Copy link
Member

agners commented Dec 15, 2020

Would this mean that starting with 5.6 there will be no more need to update the RPI boot firmware through Raspberry Pi Imager before installing HA on an RPi 4 with SSD attached through USB?

There is a chicken egg issue here: The update can only happen if the current firmware supports that feature/is capable to actually talk to that USB SSD drive attached. This is not the case with older firmwares. So depending on what is on the Pi now, a manual upgrade is required first still...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants