raspberrypi / rpi-eeprom

Installation scripts and binaries for the Raspberry Pi 4 and Raspberry Pi 5 bootloader EEPROMs
https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#raspberry-pi-boot-eeprom
Other
1.27k stars 203 forks source link

Support for skip network boot with tftp prefix #376

Open RomanValov opened 3 years ago

RomanValov commented 3 years ago

Board: Raspberry Pi Compute Module 4 Rev 1.0

I'm developing an automated network flashing daemon for RPi boards based on PXE/TFTP server. My boards are configured with BOOT_ORDER=0xf12 and TFTP_PREFIX=2, so network boot is preferred and tftp prefix based on MAC-address is preferred.

Flashing workflow is following:

Everything is working fine. However I'm relying on kind of undocumented behavior of boot from prefixed directory. My goal is to prevent to boot from network for flashed devices.

If prefixed directory didn't contain any start4.elf/start.elf files the bootloader fallbacks to network boot from non-prefixed directory and that would break the workflow.

If prefixed directory contained proper start4.elf/start.elf files the bootloader continues network boot from prefixed directory and that would break the workflow.

I'm afraid relying on zero-sized start4.elf/start.elf as a method to skip network boot could be broken one day. So I would ask either to provide a guarantee for the behavior (i.e. document it), or maybe provide some kind of more clean and straight-forward way to skip network boot, i.e. putting kind of skip-marker-file in a prefix dir to prevent fallback to non-prefixed dir and skip network boot method.

Sorry if there is already a method to do this that I have missed.

cat /sys/firmware/devicetree/base/chosen/bootloader/version 
c258ef8fe1d2334a750078b17dab5e2c1a1787fc
# cat /sys/bus/nvmem/devices/rmem0/nvmem
[all]
BOOT_UART=1
WAKE_ON_GPIO=1
POWER_OFF_ON_HALT=0
BOOT_ORDER=0xf12
ENABLE_SELF_UPDATE=1
TFTP_PREFIX=2

Network boot (please complete the following information):

$ cat ./dnsmasq.conf 
port=0
dhcp-range=192.168.1.3,proxy
log-dhcp
pxe-service=0,"Raspberry Pi Boot"
enable-tftp
tftp-root=/srv/pxe/boot
dhcp-script=/srv/pxe/dhcp-script

Here is a log of boot from prefixed directory:

PM_RSTS: 0x00000020
RPi: BOOTLOADER release VERSION:c258ef8f DATE: Jul  6 2021 TIME: 11:44:56 BOOTMODE: 0x00000006 part: 0 BUILD_TIMESTAMP=1625568293 0x97533126 0x00c03140 0x000c5fe0
PM_RSTS: 0x00000020
part 00000000 reset_info 00000000
uSD voltage 3.3V
Initialising SDRAM 'Samsung' 16Gb x2 total-size: 32 Gbit 3200
Boot mode: NETWORK (02) order f1
GENET: RESET_PHY
NET_BOOT: e4:5f:01:1f:da:6d wait for link TFTP: 0.0.0.0
LINK STATUS: speed: 1000 full duplex
Link ready
GENET START: 64 16 32
GENET: UMAC_START 0xe45f011f 0xda6d0000
RX: 0 IP: 0 IPV4: 0 MAC: 0 UDP: 0 UDP RECV: 0 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
DHCP src: 00:15:5d:01:02:06 192.168.1.3
OPTIONS:-
    op: 53 len:   1 DHCP recv OFFER (2) expect OFFER
    op: 54 len:   4 192.168.1.3
    op: 60 len:   9 
    op: 97 len:  17 
    op: 43 len:  71 
        PXE op:  6 len:   1 
        PXE op:  9 len:  24 
00000000  7e 7e 52 61 73 70 62 65  72 72 79 20 50 69 20 42 |~~Raspberry Pi B|
00000010  6f 6f 74 7e 7e 0a 27 ff                          |oot~~.'.        |

        PXE op: 10 len:  39 

DHCP src: 48:8f:5a:c0:e3:06 192.168.1.1
YI_ADDR 192.168.1.17
SI_ADDR 192.168.1.1
OPTIONS:-
    op: 53 len:   1 DHCP recv OFFER (2) expect OFFER
    op: 54 len:   4 192.168.1.1
    op: 51 len:   4 
    op:  1 len:   4 255.255.255.0
    op:  3 len:   4 192.168.1.1
NET 192.168.1.17 255.255.255.0 gw 0.0.0.0 tftp 192.168.1.3
DHCP src: 48:8f:5a:c0:e3:06 192.168.1.1
YI_ADDR 192.168.1.17
SI_ADDR 192.168.1.1
OPTIONS:-
    op: 53 len:   1 DHCP recv ACK (5) expect ACK
    op: 54 len:   4 192.168.1.1
    op: 51 len:   4 
ARP 192.168.1.3 00:15:5d:01:02:06
NET 192.168.1.17 255.255.255.0 gw 0.0.0.0 tftp 192.168.1.3
RX: 8 IP: 0 IPV4: 6 MAC: 3 UDP: 3 UDP RECV: 3 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
TFTP_GET: 00:15:5d:01:02:06 192.168.1.3 e4-5f-01-1f-da-6d/start4.elf

RX: 8 IP: 0 IPV4: 6 MAC: 3 UDP: 3 UDP RECV: 3 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
RX: 9 IP: 0 IPV4: 8 MAC: 4 UDP: 4 UDP RECV: 4 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
TFTP_GET: 00:15:5d:01:02:06 192.168.1.3 e4-5f-01-1f-da-6d/config.txt

RX: 9 IP: 0 IPV4: 8 MAC: 4 UDP: 4 UDP RECV: 4 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
TFTP 1: file /srv/pxe/boot/e4-5f-01-1f-da-6d/config.txt not found 
RX: 10 IP: 0 IPV4: 10 MAC: 5 UDP: 5 UDP RECV: 5 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
Read e4-5f-01-1f-da-6d/config.txt failed
TFTP_GET: 00:15:5d:01:02:06 192.168.1.3 e4-5f-01-1f-da-6d/pieeprom.sig

RX: 10 IP: 0 IPV4: 10 MAC: 5 UDP: 5 UDP RECV: 5 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
TFTP 1: file /srv/pxe/boot/e4-5f-01-1f-da-6d/pieeprom.sig not found 
RX: 11 IP: 0 IPV4: 12 MAC: 6 UDP: 6 UDP RECV: 6 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
Read e4-5f-01-1f-da-6d/pieeprom.upd failed
TFTP_GET: 00:15:5d:01:02:06 192.168.1.3 e4-5f-01-1f-da-6d/recover4.elf

RX: 11 IP: 0 IPV4: 12 MAC: 6 UDP: 6 UDP RECV: 6 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
TFTP 1: file /srv/pxe/boot/e4-5f-01-1f-da-6d/recover4.elf not found 
RX: 12 IP: 0 IPV4: 14 MAC: 7 UDP: 7 UDP RECV: 7 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
Read e4-5f-01-1f-da-6d/recover4.elf failed
TFTP_GET: 00:15:5d:01:02:06 192.168.1.3 e4-5f-01-1f-da-6d/recovery.elf

RX: 12 IP: 0 IPV4: 14 MAC: 7 UDP: 7 UDP RECV: 7 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
TFTP 1: file /srv/pxe/boot/e4-5f-01-1f-da-6d/recovery.elf not found 
RX: 13 IP: 0 IPV4: 16 MAC: 8 UDP: 8 UDP RECV: 8 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
Read e4-5f-01-1f-da-6d/recovery.elf failed
TFTP_GET: 00:15:5d:01:02:06 192.168.1.3 e4-5f-01-1f-da-6d/start4.elf

RX: 13 IP: 0 IPV4: 16 MAC: 8 UDP: 8 UDP RECV: 8 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
TFTP: complete 0
RX: 15 IP: 0 IPV4: 20 MAC: 10 UDP: 10 UDP RECV: 10 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
Read e4-5f-01-1f-da-6d/start4.elf bytes        0 hnd 0x00000000
TFTP_GET: 00:15:5d:01:02:06 192.168.1.3 e4-5f-01-1f-da-6d/fixup4.dat

RX: 15 IP: 0 IPV4: 20 MAC: 10 UDP: 10 UDP RECV: 10 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
TFTP: complete 0
RX: 17 IP: 0 IPV4: 24 MAC: 12 UDP: 12 UDP RECV: 12 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
Read e4-5f-01-1f-da-6d/fixup4.dat bytes        0 hnd 0x00000000
Invalid ELF header: 'start4.elf'
TFTP_GET: 00:15:5d:01:02:06 192.168.1.3 e4-5f-01-1f-da-6d/start.elf

RX: 17 IP: 0 IPV4: 24 MAC: 12 UDP: 12 UDP RECV: 12 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
TFTP: complete 0
RX: 19 IP: 0 IPV4: 28 MAC: 14 UDP: 14 UDP RECV: 14 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
Read e4-5f-01-1f-da-6d/start.elf bytes        0 hnd 0x00000000
TFTP_GET: 00:15:5d:01:02:06 192.168.1.3 e4-5f-01-1f-da-6d/fixup.dat

RX: 19 IP: 0 IPV4: 28 MAC: 14 UDP: 14 UDP RECV: 14 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
TFTP: complete 0
RX: 21 IP: 0 IPV4: 32 MAC: 16 UDP: 16 UDP RECV: 16 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
Read e4-5f-01-1f-da-6d/fixup.dat bytes        0 hnd 0x00000000
Invalid ELF header: 'start.elf'
Firmware not found
ERROR: 00000004
Boot mode: SD (01) order f
ARP TX resp: sender: e4:5f:01:1f:da:6d 192.168.1.17 target: 192.168.1.3
SD HOST: 250000000 CTL0: 0x00000000 BUS: 100000 Hz actual: 100000 HZ div: 2500 (1250) status: 0x1fff0000 delay: 1080
SD HOST: 250000000 CTL0: 0x00000f00 BUS: 100000 Hz actual: 100000 HZ div: 2500 (1250) status: 0x1fff0000 delay: 1080
EMMC
SD retry 1 oc 0
SD HOST: 250000000 CTL0: 0x00000000 BUS: 100000 Hz actual: 100000 HZ div: 2500 (1250) status: 0x1fff0000 delay: 1080
OCR c0ff8080 [0]
CID: 00150100384754463452068694fe6328
SD HOST: 250000000 CTL0: 0x00000f00 BUS: 25000000 Hz actual: 25000000 HZ div: 10 (5) status: 0x1fff0000 delay: 4
SD HOST: 250000000 CTL0: 0x00000f04 BUS: 50000000 Hz actual: 41666666 HZ div: 6 (3) status: 0x1fff0000 delay: 2
MBR: 0x00000800, 1026048 type: 0x06
MBR: 0x000fb000, 2097152 type: 0x83
MBR: 0x002fb000, 5261312 type: 0x83
MBR: 0x00000000,       0 type: 0x00
Trying partition: 0
lba: 2048 oem: 'mkfs.fat' volume: '  V       ^ '
rsc 16 fat-sectors 256 c-count 64093 c-size 16 r-dir 1 r-sec 32 r-entries 512
FAT16 clusters 64093
PM_RSTS: 0x00000020
Trying partition: 0
lba: 2048 oem: 'mkfs.fat' volume: '  V       ^ '
rsc 16 fat-sectors 256 c-count 64093 c-size 16 r-dir 1 r-sec 32 r-entries 512
FAT16 clusters 64093
Read config.txt bytes     1919 hnd 0x00000000
Read start4x.elf bytes  2992200 hnd 0x00000000
Read fixup4x.dat bytes     8408 hnd 0x00000000
Firmware: 1ecd7d49359f3b48737f1a9e33c2f1513f90743d Jul 14 2021 14:21:46
0x00c03140 0x00000000 0x00000fff
MEM GPU: 32 ARM: 992 TOTAL: 1024
Starting start4x.elf @ 0xfec00200 partition 0
Stopping network
RX: 25 IP: 0 IPV4: 32 MAC: 16 UDP: 16 UDP RECV: 16 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
RX: 25 IP: 0 IPV4: 32 MAC: 16 UDP: 16 UDP RECV: 16 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
RX_DISCARD: 0
  GR64: 0x0000000d   GR64: 0x0000000b  GR127: 0x00000000  GR255: 0x00000003 
 GR511: 0x00000000 GR1023: 0x00000000 GR1518: 0x00000000  GRMGV: 0x00000000 
GR2047: 0x00000000 GR4095: 0x00000000 GR9216: 0x0000001b  GRPKT: 0x00000b52 
 GRBYT: 0x00000009  GRMCA: 0x00000001  GRBCA: 0x00000000  GRFCS: 0x00000000 
 GRXCF: 0x00000000  GRXPF: 0x00000000  GRXUO: 0x00000000  GRALN: 0x00000000 
 GRFLR: 0x00000000  GRCDE: 0x00000000  GRFCR: 0x00000000  GROVR: 0x00000000 
 GRJBR: 0x00000000 GRMTUE: 0x0000001b  GRPOK: 0x00000011   GRUC: 0x00000000 
 GRPPP: 0x00000000  GRCRC: 0x00000000 

  TR64: 0x0000000a  TR127: 0x0000000a  TR255: 0x00000000  TR511: 0x00000003 
TR1023: 0x00000000 TR1518: 0x00000000  TRMGV: 0x00000000 TR2047: 0x00000000 
TR4095: 0x00000000 TR9216: 0x00000000  GTPKT: 0x00000017  GTMCA: 0x00000000 
 GTBCA: 0x00000004  GTXPF: 0x00000000  GTXCF: 0x00000000  GTFCS: 0x00000000 
 GTOVR: 0x00000000  GTDRF: 0x00000000  GTEDF: 0x00000000  GTSCL: 0x00000000 
 GTMCL: 0x00000000  GTLCL: 0x00000000  GTXCL: 0x00000000  GTFRG: 0x00000000 
 GTNCL: 0x00000000  GTJBR: 0x00000000  GTBYT: 0x00000ab1  GTPOK: 0x00000017 
  GTUC: 0x00000013 
GENET STOP: 0
GENET: RESET_PHY
+
...

Here is a log of boot from non-prefixed directory:

PM_RSTS: 0x00000020
RPi: BOOTLOADER release VERSION:c258ef8f DATE: Jul  6 2021 TIME: 11:44:56 BOOTMODE: 0x00000006 part: 0 BUILD_TIMESTAMP=1625568293 0x97533126 0x00c03140 0x000c5fe0
PM_RSTS: 0x00000020
part 00000000 reset_info 00000000
uSD voltage 3.3V
Initialising SDRAM 'Samsung' 16Gb x2 total-size: 32 Gbit 3200
Boot mode: NETWORK (02) order f1
GENET: RESET_PHY
NET_BOOT: e4:5f:01:1f:da:6d wait for link TFTP: 0.0.0.0
LINK STATUS: speed: 1000 full duplex
Link ready
GENET START: 64 16 32
GENET: UMAC_START 0xe45f011f 0xda6d0000
RX: 0 IP: 0 IPV4: 0 MAC: 0 UDP: 0 UDP RECV: 0 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
DHCP src: 00:15:5d:01:02:06 192.168.1.3
OPTIONS:-
    op: 53 len:   1 DHCP recv OFFER (2) expect OFFER
    op: 54 len:   4 192.168.1.3
    op: 60 len:   9 
    op: 97 len:  17 
    op: 43 len:  71 
        PXE op:  6 len:   1 
        PXE op:  9 len:  24 
00000000  7e 7e 52 61 73 70 62 65  72 72 79 20 50 69 20 42 |~~Raspberry Pi B|
00000010  6f 6f 74 7e 7e 0a 27 ff                          |oot~~.'.        |

        PXE op: 10 len:  39 

DHCP src: 48:8f:5a:c0:e3:06 192.168.1.1
YI_ADDR 192.168.1.17
SI_ADDR 192.168.1.1
OPTIONS:-
    op: 53 len:   1 DHCP recv OFFER (2) expect OFFER
    op: 54 len:   4 192.168.1.1
    op: 51 len:   4 
    op:  1 len:   4 255.255.255.0
    op:  3 len:   4 192.168.1.1
NET 192.168.1.17 255.255.255.0 gw 0.0.0.0 tftp 192.168.1.3
DHCP src: 48:8f:5a:c0:e3:06 192.168.1.1
YI_ADDR 192.168.1.17
SI_ADDR 192.168.1.1
OPTIONS:-
    op: 53 len:   1 DHCP recv ACK (5) expect ACK
    op: 54 len:   4 192.168.1.1
    op: 51 len:   4 
ARP 192.168.1.3 00:15:5d:01:02:06
NET 192.168.1.17 255.255.255.0 gw 0.0.0.0 tftp 192.168.1.3
RX: 8 IP: 0 IPV4: 6 MAC: 3 UDP: 3 UDP RECV: 3 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
TFTP_GET: 00:15:5d:01:02:06 192.168.1.3 e4-5f-01-1f-da-6d/start4.elf

RX: 8 IP: 0 IPV4: 6 MAC: 3 UDP: 3 UDP RECV: 3 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
TFTP 1: file /srv/pxe/boot/e4-5f-01-1f-da-6d/start4.elf not found 
RX: 9 IP: 0 IPV4: 8 MAC: 4 UDP: 4 UDP RECV: 4 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
e4-5f-01-1f-da-6d/start4.elf not found
TFTP_GET: 00:15:5d:01:02:06 192.168.1.3 e4-5f-01-1f-da-6d/start.elf

RX: 9 IP: 0 IPV4: 8 MAC: 4 UDP: 4 UDP RECV: 4 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
TFTP 1: file /srv/pxe/boot/e4-5f-01-1f-da-6d/start.elf not found 
RX: 10 IP: 0 IPV4: 10 MAC: 5 UDP: 5 UDP RECV: 5 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
e4-5f-01-1f-da-6d/start.elf not found
TFTP_GET: 00:15:5d:01:02:06 192.168.1.3 config.txt

RX: 10 IP: 0 IPV4: 10 MAC: 5 UDP: 5 UDP RECV: 5 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
TFTP: complete 1996
RX: 13 IP: 0 IPV4: 16 MAC: 8 UDP: 8 UDP RECV: 8 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
Read config.txt bytes     1996 hnd 0x00000000
TFTP_GET: 00:15:5d:01:02:06 192.168.1.3 pieeprom.sig

RX: 13 IP: 0 IPV4: 16 MAC: 8 UDP: 8 UDP RECV: 8 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
TFTP: complete 80
RX: 15 IP: 0 IPV4: 20 MAC: 10 UDP: 10 UDP RECV: 10 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
SIG pieeprom.sig 0c85ff7d483d89984e8da94405e354fc63f026e13e284e41d58abb5ea1480255 1634490928
TFTP_GET: 00:15:5d:01:02:06 192.168.1.3 pieeprom.upd

RX: 15 IP: 0 IPV4: 20 MAC: 10 UDP: 10 UDP RECV: 10 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
TFTP: complete 524288
RX: 529 IP: 0 IPV4: 1048 MAC: 524 UDP: 524 UDP RECV: 524 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
SELF-UPDATE timestamp current 1634490928 new 1634490928 skip
TFTP_GET: 00:15:5d:01:02:06 192.168.1.3 recover4.elf

RX: 529 IP: 0 IPV4: 1048 MAC: 524 UDP: 524 UDP RECV: 524 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
TFTP 1: file /srv/pxe/boot/recover4.elf not found 
RX: 530 IP: 0 IPV4: 1050 MAC: 525 UDP: 525 UDP RECV: 525 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
Read recover4.elf failed
TFTP_GET: 00:15:5d:01:02:06 192.168.1.3 recovery.elf

RX: 530 IP: 0 IPV4: 1050 MAC: 525 UDP: 525 UDP RECV: 525 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
TFTP 1: file /srv/pxe/boot/recovery.elf not found 
RX: 531 IP: 0 IPV4: 1052 MAC: 526 UDP: 526 UDP RECV: 526 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
Read recovery.elf failed
TFTP_GET: 00:15:5d:01:02:06 192.168.1.3 start4x.elf

RX: 531 IP: 0 IPV4: 1052 MAC: 526 UDP: 526 UDP RECV: 526 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
TFTP: complete 2992200
RX: 3456 IP: 0 IPV4: 6900 MAC: 3450 UDP: 3450 UDP RECV: 3450 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
Read start4x.elf bytes  2992200 hnd 0x00000000
TFTP_GET: 00:15:5d:01:02:06 192.168.1.3 fixup4x.dat

RX: 3456 IP: 0 IPV4: 6900 MAC: 3450 UDP: 3450 UDP RECV: 3450 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
TFTP: complete 8408
RX: 3466 IP: 0 IPV4: 6920 MAC: 3460 UDP: 3460 UDP RECV: 3460 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
Read fixup4x.dat bytes     8408 hnd 0x00000000
Firmware: 1ecd7d49359f3b48737f1a9e33c2f1513f90743d Jul 14 2021 14:21:46
0x00c03140 0x00000000 0x00000fff
MEM GPU: 32 ARM: 992 TOTAL: 1024
Starting start4x.elf @ 0xfec00200 partition -1
Stopping network
RX: 3466 IP: 0 IPV4: 6920 MAC: 3460 UDP: 3460 UDP RECV: 3460 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
RX: 3466 IP: 0 IPV4: 6920 MAC: 3460 UDP: 3460 UDP RECV: 3460 IP_CSUM_ERR: 0 UDP_CSUM_ERR: 0
RX_DISCARD: 0
  GR64: 0x00000008   GR64: 0x0000000a  GR127: 0x00000001  GR255: 0x00000004 
 GR511: 0x00000001 GR1023: 0x00000d73 GR1518: 0x00000000  GRMGV: 0x00000000 
GR2047: 0x00000000 GR4095: 0x00000000 GR9216: 0x00000d8b  GRPKT: 0x00387bb7 
 GRBYT: 0x00000006  GRMCA: 0x00000001  GRBCA: 0x00000000  GRFCS: 0x00000000 
 GRXCF: 0x00000000  GRXPF: 0x00000000  GRXUO: 0x00000000  GRALN: 0x00000000 
 GRFLR: 0x00000000  GRCDE: 0x00000000  GRFCR: 0x00000000  GROVR: 0x00000000 
 GRJBR: 0x00000000 GRMTUE: 0x00000d8b  GRPOK: 0x00000d84   GRUC: 0x00000000 
 GRPPP: 0x00000000  GRCRC: 0x00000000 

  TR64: 0x00000d7e  TR127: 0x00000009  TR255: 0x00000000  TR511: 0x00000003 
TR1023: 0x00000000 TR1518: 0x00000000  TRMGV: 0x00000000 TR2047: 0x00000000 
TR4095: 0x00000000 TR9216: 0x00000000  GTPKT: 0x00000d8a  GTMCA: 0x00000000 
 GTBCA: 0x00000004  GTXPF: 0x00000000  GTXCF: 0x00000000  GTFCS: 0x00000000 
 GTOVR: 0x00000000  GTDRF: 0x00000000  GTEDF: 0x00000000  GTSCL: 0x00000000 
 GTMCL: 0x00000000  GTLCL: 0x00000000  GTXCL: 0x00000000  GTFRG: 0x00000000 
 GTNCL: 0x00000000  GTJBR: 0x00000000  GTBYT: 0x000366f6  GTPOK: 0x00000d8a 
  GTUC: 0x00000d86 
GENET STOP: 0
+
...
lurch commented 3 years ago

My goal is to prevent to boot from network for flashed devices.

If you changed the boot-order to BOOT_ORDER=0xf21 would it attempt to boot from eMMC, but then fail (because the eMMC is empty) and drop through to network-booting? And if the network-boot then flashed an image onto the eMMC and rebooted, I guess it'd then boot from eMMC for all subsequent boots?

timg236 commented 3 years ago

Zero byte start.elf / start4.elf files are fine and I see no reason to change remove support for that.

It might be reasonable to add something to the EEPROM_CONFIG to disable the fallback to the non-prefixed directory. The default would be the same as Pi3 which has the fallback.

RomanValov commented 3 years ago

My goal is to prevent to boot from network for flashed devices.

If you changed the boot-order to BOOT_ORDER=0xf21 would it attempt to boot from eMMC, but then fail (because the eMMC is empty) and drop through to network-booting? And if the network-boot then flashed an image onto the eMMC and rebooted, I guess it'd then boot from eMMC for all subsequent boots?

Your proposal may work in some scenarios. However in my case in some scenarios I have to periodically switch between network and eMMC boots. I.e. testing firmwares from the CI/CD pipeline: boot from network - flash - boot from eMMC - test - revert to network boot. Making eMMC boot a priority will require dealing with eMMC which is not always as convenient. I.e. in case of broken image I have to connect the board with USB cable and run usbboot. I consider it to be less convenient than wipe directory on the server (maybe automated) and power cycle the board.

RomanValov commented 3 years ago

Zero byte start.elf / start4.elf files are fine and I see no reason to change remove support for that.

It might be reasonable to add something to the EEPROM_CONFIG to disable the fallback to the non-prefixed directory. The default would be the same as Pi3 which has the fallback.

Thank you for the clarification.

As of option, just a note that in my scenario fallback to non-prefixed directory should be disabled only if prefixed directory exists but enabled otherwise.

lurch commented 3 years ago

Ahhh, so what you actually want is "selectively prevent boot from network for flashed devices, with the network still having the ability to override that choice" ? :wink:

timg236 commented 3 years ago

TFTP doesn't support directory existence checks. The firmware would failover to the non-prefix dir or if specified only request firmware from the prefix dir. For customising the BOOT_ORDER at runtime you might be better of using conditional GPIO filters.

RomanValov commented 3 years ago

Ahhh, so what you actually want is "selectively prevent boot from network for flashed devices, with the network still having the ability to override that choice" ? wink

Yeah, exactly

RomanValov commented 3 years ago

TFTP doesn't support directory existence checks. The firmware would failover to the non-prefix dir or if specified only request firmware from the prefix dir. For customising the BOOT_ORDER at runtime you might be better of using conditional GPIO filters.

Unfortunately using GPIO filters completely break my idea of fully automated setup and would require human interaction to alter GPIO configuration (I admit you meant using something like jumpers).

timg236 commented 3 years ago

Tweaking the TFTP rules to fit a custom flashing process seems like the wrong approach. Since the server will see the MAC address in the DHCP request I think you can do this all server side.