
Raspberry Pi B models before model 4 don't have an EEPROM nor an OTP to store the permanent factory MAC address of the NIC. So the firmware that runs initially computes the factory MAC address of the board and patches the DTB to give that information to the next stage. The MAC is put in the standard property `local-mac-address` which is inserted in the `ethernet0` node of the firmware provided FDT. If the next stage is Linux, Linux uses this MAC if no other MAC was provided by another mechanism. There is also another way to give the MAC to the Linux kernel: using the boot param `smsc95xx.macaddr`.
When CONFIG_MISC_INIT_R=y, U-Boot requests directly the MAC from the running firmware in the GPU through the Raspberry Pi Mailbox. It then stores it in ${usbethaddr} environment variable. In U-Boot, the MAC is then often given to Linux like this:
setenv bootargs [...] smsc95xx.macaddr="${usbethaddr}" [...]
It works because the smsc95xx driver in Linux will take this MAC if the parameter was specified. If there is no MAC information provided, Linux will generate a random MAC address at each boot.
This patch extends commit 6d0642494993 ("rpi: Copy properties from firmware dtb to the loaded dtb") by making U-Boot copy the `local-mac-address` property from the firmware FDT to the loaded FDT. It makes it then possible not to specify the kernel boot param `smsc95xx.macaddr` at all anymore, and still have Linux pick up the correct factory MAC address, without generating a random one at each boot. This is meaningful in a setup where the user configures U-Boot to give a fresh FDT (not the firmware provided one) to the Linux kernel, but still wants the most important firmware provided modifications to be copied (CONFIG_OF_BOARD_SETUP=y) through ft_board_setup() call.
Cc: Matthias Brugger mbrugger@suse.com Cc: Peter Robinson pbrobinson@gmail.com Cc: Antoine Mazeas antoine@karthanis.net Signed-off-by: Martin Wetterwald martin@wetterwald.eu --- board/raspberrypi/rpi/rpi.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c index 2851ebc985..b36a893047 100644 --- a/board/raspberrypi/rpi/rpi.c +++ b/board/raspberrypi/rpi/rpi.c @@ -566,6 +566,9 @@ void update_fdt_from_fw(void *fdt, void *fw_fdt)
/* address of the PHY device as provided by the firmware */ copy_property(fdt, fw_fdt, "ethernet0/mdio@e14/ethernet-phy@1", "reg"); + + /* MAC address of the NIC as provided by the firmware */ + copy_property(fdt, fw_fdt, "ethernet0", "local-mac-address"); }
int ft_board_setup(void *blob, struct bd_info *bd)