Hi,
I’ve found the random MAC address a bit annoying.
I also tried to set it to a fixed value in u-boot but it says that the variabe was protected, so I decided to write a kernel workaround.
There are better solutions for this?
Hi,
I’ve found the random MAC address a bit annoying.
I also tried to set it to a fixed value in u-boot but it says that the variabe was protected, so I decided to write a kernel workaround.
There are better solutions for this?
env set -f then env save should be enough.
EIC7700 boards like Hifive Premier P550 or Megrez can store some persistent data (board info) such as MAC addresses along side with the boot code in SPI flash. (For P550, there’s also a EEPROM on the carrier board for extra storage). U-boot read such block and sets ethaddr/eth1addr, which later gets injected into the Linux device-tree’s local-mac-address property of the ethernet controller node. I guess most likely your SPI flash doesn’t have the board info block programmed and you probably see something like:
Success to initialize SPI flash at spi@51800000
Bootspi flash write protection enabled
Get board info from flash
ERROR: There is no valid hardware board information!!!
Cpu volatge no need boost at 1.6 Ghz!
Card did not respond to voltage select! : -110
Low power features will not be supported!
Net:
Warning: ethernet@50400000 (eth0) using random MAC address - d2:58:bb:de:d4:6d
You can either program the board info blocks in SPI flash, which might be tricky to do. Or you can just patch the Linux device-tree with:
fdtput -t bx <path to .dtb> ethernet0 local-mac-address aa bb cc dd ee ff
# and do the same for ethernet1
There’s no need to change any code of Linux kernel. Regarding env save, I’d refrain from doing it, because it saves the entire u-boot env into persistent storage, but can later break scenarios when you upgrade u-boot. At that point, you’ll have newer u-boot invoking old u-boot scripts. Vendor u-boot code are typically messy and disregard version compat, so I’d just let u-boot load the default environment each time.
Ok thanks.
I already saved the u-boot env, there is a way to restore it?
I upgraded the bootloader and now it’s impossible to stop it and change mac address.
I’m reapplying the patch
Use
env erase
mm I erased the env and now the boot hangs like:
pll config ok
die_num:0,die_ordinal:0
Firmware version:1.4;disable ECC
PHY0 training process:100%
PHY1 training process:100%
DDR type:LPDDR5;Size:32GB,Data Rate:6400MT/s
DDR self test OK
OpenSBI v1.5
____ _____ ____ _____
/ __ \ / ____| _ \_ _|
| | | |_ __ ___ _ __ | (___ | |_) || |
| | | | '_ \ / _ \ '_ \ \___ \| _ < | |
| |__| | |_) | __/ | | |____) | |_) || |_
\____/| .__/ \___|_| |_|_____/|____/_____|
| |
|_|
Platform Name : Milk-V Megrez
Platform Features : medeleg
Platform HART Count : 4
Platform IPI Device : aclint-mswi
Platform Timer Device : aclint-mtimer @ 1000000Hz
Platform Console Device : uart8250
Platform HSM Device : ---
Platform PMU Device : ---
Platform Reboot Device : eswin_eic770x_reset
Platform Shutdown Device : eswin_eic770x_reset
Platform Suspend Device : ---
Platform CPPC Device : ---
Firmware Base : 0x80000000
Firmware Size : 357 KB
Firmware RW Offset : 0x40000
Firmware RW Size : 101 KB
Firmware Heap Offset : 0x4f000
Firmware Heap Size : 41 KB (total), 2 KB (reserved), 11 KB (used), 27 KB (free)
Firmware Scratch Size : 4096 B (total), 416 B (used), 3680 B (free)
Runtime SBI Version : 2.0
Domain0 Name : root
Domain0 Boot HART : 2
Domain0 HARTs : 0*,1*,2*,3*
Domain0 Region00 : 0x0000000002000000-0x000000000200ffff M: (I,R,W) S/U: ()
Domain0 Region01 : 0x0000000080000000-0x000000008007ffff M: (R,W) S/U: ()
Domain0 Region02 : 0x000000c000000000-0x000000d000000000 M: () S/U: (R,W)
Domain0 Region03 : 0x0000001000000000-0x0000008000000000 M: () S/U: ()
Domain0 Region04 : 0x0000000000000000-0xffffffffffffffff M: () S/U: (R,W,X)
Domain0 Next Address : 0x0000000080200000
Domain0 Next Arg1 : 0x00000000f8000000
Domain0 Next Mode : S-mode
Domain0 SysReset : yes
Domain0 SysSuspend : yes
Boot HART ID : 2
Boot HART Domain : root
Boot HART Priv Version : v1.11
Boot HART Base ISA : rv64imafdchx
Boot HART ISA Extensions : sscofpmf,zihpm,sdtrig
Boot HART PMP Count : 8
Boot HART PMP Granularity : 12 bits
Boot HART PMP Address Bits: 39
Boot HART MHPM Info : 4 (0x00000078)
Boot HART Debug Triggers : 4 triggers
Boot HART MIDELEG : 0x0000000000002666
Boot HART MEDELEG : 0x0000000000f0b509
Hardware Feature[7C1]: 0x4000
Hardware Feature[7C2]: 0x80
Hardware Feature[7C3]: 0x104095c1be241
Hardware Feature[7C4]: 0x1d3ff
I guess that I need to recover the bootloader, right?
Interesting. I double checked the env erase command on my Hifive Premier P550, which as the exact same chip (EIC7700) before posting here. It’ worked fine on P550. Apparently it’s not working as expected on Megrez. Sorry for the inconvenience. Looks like some kind of bug in the Megrez u-boot, which, I suspect, erased the wrong block in the boot SPI flash, and corrupted the bootchain. I talked to Revy (maintainer of RockOS) yesterday, and he confirmed the old bootloader is indeed buggy. He recommended to upgrade to https://fast-mirror.isrc.ac.cn/rockos/images/generic/20250630_20250818/bootloader_secboot_ddr5_milkv-megrez.bin. Or we can stay with the old bootloader and just don’t do env erase . The instruction to recover the bootchain is here: Milk-V Megrez Install OS | Milk-V
*bootchain is a ESWIN (chip vendor) specific container format similar to tar/cpio that holds the secondary boot, DDR init blob, and bootloader (opensbi+u-boot). More information here: EIC770x-Docs/board/bootchain/UART-Boot.md at main · ganboing/EIC770x-Docs · GitHub
If you’d like, join the Matrix server for Megrez related discussion so me or someone else can live troubleshoot for you: https://matrix.to/#/#milkv-meg:matrix.org