Repository navigation
Conversation
PR Summary by QodoSkip eth0 DHCP when the interface cannot be opened
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
A board without a PHY still gets an eth0 from a MAC driver such as the V83x sunxi-gmac, but opening it fails. busybox udhcpc then gets a read error from every poll, logs "read error: Network is down, reopening socket" and starts over. It only backgrounds on a poll timeout, so -b never takes effect, S40network never returns and getty never starts. Try to open eth0 first and skip ifup when that fails. Close it again before ifup, which sets hwaddress.
Code Review by Qodo
1. Boot fix has no on-hardware proof
|
96aa9e7 to
46b67d2
Compare
Problem
On a board with no Ethernet PHY the boot never reaches a login prompt. The console fills with this, about once a second:
Seen on a YI V831 camera (no Ethernet port). The MAC driver registers
eth0, butsunxi-gmacfailsndo_openwhen no PHY answers, so the interface can't come up.S40networkrunsifup eth0in the foreground. busyboxudhcpconly acts on-b(or-n,-t) whenpoll()times out. On this interface every poll ends in a read error, so the timeout path is never reached.S40networkdoesn't return,rcSdoesn't finish, andgettynever starts.Fix
In
start(), try to openeth0and only runifup eth0if that succeeds. sysfs can't answer this beforehand:sunxi-gmaconly looks for the PHY inndo_open, so before the first openeth0looks the same with or without one.The interface goes back down before
ifupso that it can still applyhwaddress, which some drivers refuse on a running interface. The cost on boards with working Ethernet is one extra open and close at boot, which may restart link negotiation. An unplugged cable doesn't affect the probe.Testing
sh -npasses.