raspberrypi / firmware

This repository contains pre-compiled binaries of the current Raspberry Pi kernel and modules, userspace libraries, and bootloader/GPU firmware.
5.15k stars 1.68k forks source link

Pi3 retry network (PXE) booting #825

Closed FezzFest closed 5 years ago

FezzFest commented 7 years ago

Can the Raspberry Pi 3 be programmed to retry network booting if it fails to boot the first time? We have some Raspberry Pi 3's at remote sites and if a power outage occurs, the Pi requests an IP-address through DHCP before networking equipment is fully up and running. This means the DHCP-request goes unanswered and the raspberry pi sets itself to USB device mode, then waits.

Is it possible to reprogram the Pi to retry network booting after a failed attempt and not switch to device mode? Or does this require reprogramming the boot ROM (which, as I understand, is not possible as it is readonly and part of the SoC)?

mangodan2003 commented 7 years ago

We are booting a bunch of slave rpis from a master rpi and have a similar problem described above. We currently have to boot the master first and then the slaves once the Master has booted. A way to allow the slaves to wait a time before booting - or to retry would be nice. We are using the bootloader.bin on the SD card to avoid setting the OTP flag at present so in theory this could be updated to accommodate our needs, only we cannot do this due to the closed nature of some parts of the RPi and thus need to ask someone who reads these issues and can do it to look at this for us.

timmmmmey commented 7 years ago

This would be really useful. Especially in enviroments with a STP-switch.

popcornmix commented 7 years ago

Without an sdcard present this is impossible as the bootrom can't be changed.

Ping @ghollingworth

schoerg commented 7 years ago

@timmmmmey Usually there is something like "portfast" (Cisco names it that way), which could be used as a workaround.

mikemccabe commented 6 years ago

This is also biting us. We're shipping integrated units with pis behind a switch that takes some time to come up - currently when the unit is power cycled, the pis attempt to boot before the switch (which provides access to PXE resources) is ready, and we have to wait for a hardware watchdog to reset the pi.

@popcornmix we use SD cards with an updated bootcode.bin, as the bootrom bootcode.bin doesn't function reliably. Thus we could resolve this with updated SD cards.

ghollingworth commented 6 years ago

bootcode.bin option for sticking permanently with ethernet sounds like an easy thing to add... What release of bootcode.bin are you using at the moment?

mikemccabe commented 6 years ago

Thanks for your reply!

We're using the bootcode.bin from the 2017-09-07-raspbian-stretch-lite release.

$ shasum bootcode.bin d3852e9a9bcf9b3fbacfb84725fcad2d138baa12 bootcode.bin

ghollingworth commented 6 years ago

Can you try following the instructions and using the bootcode.bin attached to the Wiki to get UART debug out?

https://github.com/raspberrypi/firmware/wiki/USB-MSD-and-network-boot-debugging

mikemccabe commented 6 years ago

Hi, I've set this up.

Did you also change the logic in that bootcode.bin? Things seem to work now! Will you be incorporating these changes into the mainline bootcode.bin?

Booting fails in my test setup with the older bootcode.bin.

My test setup: Pi is connected to PXE server via an intermediate switch powered on after boot starts, thus DHCP may fail for a time even though the link is up.

Here's the dump: (note I added a timeout file, likely irrelevant here)

Raspberry Pi Bootcode

Found SD card, config.txt = 0, start.elf = 0, recovery.elf = 0, timeout = 1 Trying USB Hub device found at addr 4, enumerating HUB Initialise hub Found 5 ports, multi_tt = 1 Setting interface 0 Enabling PORT POWER on port 1 Enabling PORT POWER on port 2 Enabling PORT POWER on port 3 Enabling PORT POWER on port 4 Enabling PORT POWER on port 5 Waiting for devices to respond to reset Found device on port 1 Found highspeed device Device found: type = Ethernet adapter, addr = 5 Trying booting from Ethernet device addr 5 Initialise ethernet with MAC b8:27:eb:ae:8f:85 Wait for Link up Failed to initialise link Trying booting from Ethernet device addr 5 Initialise ethernet with MAC b8:27:eb:ae:8f:85 Wait for Link up Failed to initialise link Trying booting from Ethernet device addr 5 Initialise ethernet with MAC b8:27:eb:ae:8f:85 Wait for Link up Link up Sending DHCP request Waiting for dhcp_reply Sending DHCP request Waiting for dhcp_reply Sending DHCP request Waiting for dhcp_reply Sending DHCP request Waiting for dhcp_reply Sending DHCP request Waiting for dhcp_reply Trying booting from Ethernet device addr 5 Initialise ethernet with MAC b8:27:eb:ae:8f:85 Wait for Link up Link up Waiting for dhcp_reply Sending DHCP request Waiting for dhcp_reply Sending DHCP request Waiting for dhcp_reply Sending DHCP request Waiting for dhcp_reply Sending DHCP request Waiting for dhcp_reply Trying booting from Ethernet device addr 5 Initialise ethernet with MAC b8:27:eb:ae:8f:85 Wait for Link up Link up Sending DHCP request Waiting for dhcp_reply Sending DHCP request Waiting for dhcp_reply Done ARP for 100.0.64.10 got 00:e0:4c:01:27:dd Read File: config.txt, 2389 (bytes)

Raspberry Pi Bootcode Read File: config.txt, 2389 Read File: start_x.elf, 3902404 (bytes) Read File: fixup_x.dat, 9691 (bytes)

mikemccabe commented 6 years ago

I've moved comments describing a related issue to #907 .

The debug bootcode.bin you supplied seems to have resolved this issue, can we expect those changes to land in the mainline code?

ghollingworth commented 6 years ago

They will end up there, it's taking some time putting together an update for various reasons...

JamesH65 commented 5 years ago

@ghollingworth Missed this one when cataloging PXE/netboot issues.