Give the board a stable MAC and a USB port that works - #12
Merged
Conversation
The Type-C port came up as an unpowered host and the Ethernet MAC was random on every boot. Both were devicetree, and both needed a kernel patch behind them. The port has no ID pin, so dr_mode = "otg" left dwc3 reading a grounded CONIDSTS and bringing up xHCI: no VBUS for a downstream device, no UDC for the gadget. It is a peripheral, so say so. dwmac-rk keeps the MAC in Rockchip vendor storage, which this board has never had, and its fallback is eth_random_addr(). Point it at the SoC's OTP unique id instead and hash a locally administered address out of that. The USB gadget's own MACs get the same treatment, from /proc/cpuinfo's Serial, so two boards on one host no longer collide. Co-authored-by: Codesmith <codesmith-bot@users.noreply.github.com>
The ACM function gave the board a /dev/ttyGS0 and the host a /dev/ttyACM0 with nothing on either end of it, so opening it showed a blank screen. Pull serial-getty@ttyGS0 in from the gadget unit, ordered after it because the getty is BindsTo=dev-ttyGS0.device and the node only exists once the function has been created -- which also means the teardown takes the getty with it. The gadget's serial number came from boot_id, so it was new on every boot and so was the host's /dev/serial/by-id path. Take it from the same SoC id the MACs now use. Co-authored-by: Codesmith <codesmith-bot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two of the three things the README lists as wrong on a booted board.
The Type-C port did nothing in either direction
dr_mode = "otg"looks like the flexible choice and is not. The connector has no ID pin and there is no CC controller behind it, so with no extcon to consult dwc3 falls back to the OTG block'sCONIDSTS, which follows the PHY'siddiginput, which nothing on this board drives. It reads as grounded, dwc3 concludes it is the A-device, and xHCI comes up on a port with no VBUS to offer and no UDC forluckfox-usb-gadget.serviceto bind to:The
illegal modeline is the same event seen from the other side:usb_add_hcd()offers the PHYPHY_MODE_USB_HOST_SS, whichrockchip_usb2phy_set_mode()does not handle. It disappears with the host that produced it.The port is also the board's power inlet, so peripheral is what the hardware is, and is what Luckfox's own devicetree says:
The Ethernet MAC was new on every boot
rk_get_eth_addr()reads the MAC out of Rockchip vendor storage, a reserved area at the end of the boot medium that the factory programs. Nothing ever programmed this one, and an SD card written bymk-image.shhas no such area at all, so every boot went:A new MAC means a new DHCP lease, so the board never keeps an address.
The SoC does have something unique and permanent: the 16-byte OTP id that
rockchip-cpuinfoalready hashes into/proc/cpuinfo's Serial. Patch0003teaches the driver to use it when the ethernet node names the cell, after vendor storage has had its turn:The id is neither a MAC nor an OUI, so it is hashed rather than copied. Boards with working vendor storage are unaffected, and boards that do not name the cell keep the old random address.
The gadget's own two MACs were a hard-coded constant, identical on every Pico Max; they now come from the same serial, so two boards plugged into one laptop are distinguishable.
The ACM half of the gadget had nothing behind it
Falling out of testing the above: the ACM function gives the board a
/dev/ttyGS0and the host a/dev/ttyACM0, but the image only ever enabledserial-getty@ttyS2, so a host that opened the port sat looking at a blank screen. The gadget unit now pulls the getty in, ordered after itself because the getty isBindsTo=dev-ttyGS0.deviceand that node only exists onceuphas created the function:The same
BindsTomeansdowntakes the getty with it, so no explicit stop is needed.While there: the gadget's USB serial number came from
boot_id, so it was new on every boot and so was the host's/dev/serial/by-id/...path. It now comes from the same SoC id the MACs do, which makesusb-Luckfox_Pico_Max_<serial>-if02a name worth writing down.Patch
0004is unrelated to either but is the third USB line in the log: the probe asks for the muxed per-phy interrupt withplatform_get_irq(), which logserror -ENXIO: IRQ index 0 not foundon SoCs like the RV1106 that describe their interrupts per port instead. Every use of it is already guarded byrphy->irq > 0, so ask withplatform_get_irq_optional().Checked locally: all four patches apply to the pinned tree, both touched drivers cross-compile clean, and the DTB builds through kbuild.
make checkpasses.Need help on this PR? Tag
@codesmithwith what you need. Autofix is enabled.