Skip to content

Commit

Permalink
mediatek: bpi-r4: store random MAC addresses for the BPi-R4
Browse files Browse the repository at this point in the history
Despite coming with multiple I2C EEPROMs supposedly dedicated for that
purpose, the BPi-R4 does not seem to have factory assigned MAC addresses.
Hence, just like for all other BPi boards, store a randomly generated
MAC address on first boot and derive WAN and Wi-Fi MAC addresses from
that as well. Not perfect, but better than random on every boot.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
  • Loading branch information
dangowrt committed Apr 28, 2024
1 parent abbcbb9 commit 5709254
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ unielec,u7623-02)
fw_setenv ethaddr "$(cat /sys/class/net/eth0/address)"
;;
bananapi,bpi-r3|\
bananapi,bpi-r3-mini)
bananapi,bpi-r3-mini|\
bananapi,bpi-4)
[ -z "$(fw_printenv -n ethaddr 2>/dev/null)" ] &&
fw_setenv ethaddr "$(cat /sys/class/net/eth0/address)"
[ -z "$(fw_printenv -n eth1addr 2>/dev/null)" ] &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
"mediatek,mt7988a";

aliases {
ethernet0 = &gmac0;
ethernet1 = &gmac1;
serial0 = &uart0;
led-boot = &led_green;
led-failsafe = &led_green;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ mediatek_setup_macs()

case $board in
bananapi,bpi-r3|\
bananapi,bpi-r3-mini)
bananapi,bpi-r3-mini|\
bananapi,bpi-r4)
wan_mac=$(macaddr_add $(cat /sys/class/net/eth0/address) 1)
;;
cmcc,rax3000m)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ case "$board" in
[ "$PHYNBR" = "0" ] && macaddr_add $addr 2 > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "1" ] && macaddr_add $addr 3 > /sys${DEVPATH}/macaddress
;;
bananapi,bpi-r4)
addr=$(cat /sys/class/net/eth0/address)
[ "$PHYNBR" = "0" ] && macaddr_add $addr 2 > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "1" ] && macaddr_add $addr 3 > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "2" ] && macaddr_add $addr 4 > /sys${DEVPATH}/macaddress
;;
cetron,ct3003)
addr=$(mtd_get_mac_binary "art" 0)
[ "$PHYNBR" = "0" ] && macaddr_add $addr 1 > /sys${DEVPATH}/macaddress
Expand Down

0 comments on commit 5709254

Please sign in to comment.