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
  • Loading branch information
coolsnowwolf committed Jun 30, 2024
1 parent b35c02a commit 9f2db43
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 19 deletions.
53 changes: 36 additions & 17 deletions package/boot/uboot-envtools/files/mediatek_filogic
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,45 @@ touch /etc/config/ubootenv

board=$(board_name)

ubootenv_add_mmc_default() {
local envdev="$(find_mmc_part "ubootenv" "${1:-mmcblk0}")"
ubootenv_add_uci_config "$envdev" "0x0" "0x40000" "0x40000" "1"
ubootenv_add_uci_config "$envdev" "0x40000" "0x40000" "0x40000" "1"
}

ubootenv_add_nor_default() {
local envdev="/dev/mtd$(find_mtd_index "u-boot-env")"
ubootenv_add_uci_config "$envdev" "0x0" "0x20000" "0x20000" "1"
ubootenv_add_uci_config "$envdev" "0x20000" "0x20000" "0x20000" "1"
}

ubootenv_add_ubi_default() {
. /lib/upgrade/nand.sh
local envubi=$(nand_find_ubi ubi)
local envdev=/dev/$(nand_find_volume $envubi ubootenv)
local envdev2=/dev/$(nand_find_volume $envubi ubootenv2)
ubootenv_add_uci_config "$envdev" "0x0" "0x1f000" "0x1f000" "1"
ubootenv_add_uci_config "$envdev2" "0x0" "0x1f000" "0x1f000" "1"
}

case "$board" in
bananapi,bpi-r3)
case "$(cmdline_get_var root)" in
/dev/mmc*)
local envdev=$(find_mmc_part "ubootenv" $rootdev)
ubootenv_add_uci_config "$envdev" "0x0" "0x40000" "0x40000" "1"
ubootenv_add_uci_config "$envdev" "0x40000" "0x40000" "0x40000" "1"
bananapi,bpi-r3|\
bananapi,bpi-r3-mini|\
bananapi,bpi-r4|\
bananapi,bpi-r4-poe|\
jdcloud,re-cp-03)
. /lib/upgrade/common.sh

bootdev="$(fitblk_get_bootdev)"
case "$bootdev" in
ubi*)
ubootenv_add_ubi_default
;;
/dev/mtd*)
local envdev=/dev/mtd$(find_mtd_index "u-boot-env")
ubootenv_add_uci_config "$envdev" "0x0" "0x20000" "0x20000" "1"
ubootenv_add_uci_config "$envdev" "0x20000" "0x20000" "0x20000" "1"
mmc*)
ubootenv_add_mmc_default "${bootdev%%p[0-9]*}"
;;
/dev/ubi*)
. /lib/upgrade/nand.sh
local envubi=$(nand_find_ubi ubi)
local envdev=/dev/$(nand_find_volume $envubi ubootenv)
local envdev2=/dev/$(nand_find_volume $envubi ubootenv2)
ubootenv_add_uci_config "$envdev" "0x0" "0x1f000" "0x1f000" "1"
ubootenv_add_uci_config "$envdev2" "0x0" "0x1f000" "0x1f000" "1"
mtd*)
ubootenv_add_nor_default
;;
esac
;;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ unielec,u7623-02)
[ -z "$(fw_printenv -n ethaddr 2>/dev/null)" ] &&
fw_setenv ethaddr "$(cat /sys/class/net/eth0/address)"
;;
bananapi,bpi-r3)
bananapi,bpi-r3|\
bananapi,bpi-r3-mini|\
bananapi,bpi-r4|\
bananapi,bpi-r4-poe)
[ -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 @@ -81,7 +81,9 @@ mediatek_setup_macs()
wan_mac="${addr}"
lan_mac="${addr}"
;;
bananapi,bpi-r3)
bananapi,bpi-r3|\
bananapi,bpi-r3-mini|\
bananapi,bpi-r4)
wan_mac=$(macaddr_add $(cat /sys/class/net/eth0/address) 1)
;;
cmcc,rax3000m-emmc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,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 9f2db43

Please sign in to comment.