forked from openwrt/openwrt
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rockchip: fix preinit ethernet and failsafe mode
Failsafe mode requires setting up a network interface for incoming SSH to work. Select LAN interface (lan0 on BPi-R2 Pro, single LAN port on all other devices) and set MAC addresses for all interfaces in preinit. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
- Loading branch information
Showing
2 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
target/linux/rockchip/armv8/base-files/lib/preinit/04_set_iface_mac
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
. /lib/functions.sh | ||
|
||
preinit_set_mac_address() { | ||
case "$board" in | ||
friendlyarm,nanopi-r2c|\ | ||
friendlyarm,nanopi-r2s) | ||
wan_mac=$(macaddr_generate_from_mmc_cid mmcblk0) | ||
ip link set dev eth0 address $wan_mac | ||
ip link set dev eth1 address $(macaddr_add "$wan_mac" 1) | ||
;; | ||
friendlyarm,nanopi-r2c-plus|\ | ||
friendlyarm,nanopi-r4s|\ | ||
friendlyarm,nanopi-r5s|\ | ||
sinovoip,rk3568-bpi-r2pro) | ||
wan_mac=$(macaddr_generate_from_mmc_cid mmcblk1) | ||
ip link set dev eth0 address $wan_mac | ||
ip link set dev eth1 address $(macaddr_add "$wan_mac" 1) | ||
;; | ||
sinovoip,rk3568-bpi-r2pro) | ||
wan_mac=$(macaddr_generate_from_mmc_cid mmcblk1) | ||
lan_mac=$(macaddr_add "$wan_mac" 1) | ||
ip link set dev eth0 address $wan_mac | ||
ip link set dev eth1 address $lan_mac | ||
ip link set dev lan0 address $lan_mac | ||
ip link set dev lan1 address $lan_mac | ||
ip link set dev lan2 address $lan_mac | ||
ip link set dev lan3 address $lan_mac | ||
;; | ||
friendlyarm,nanopi-r4s-enterprise) | ||
wan_mac=$(get_mac_binary "/sys/bus/i2c/devices/2-0051/eeprom" 0xfa) | ||
ip link set dev eth0 address $wan_mac | ||
ip link set dev eth1 address $(macaddr_setbit_la "$wan_mac") | ||
;; | ||
friendlyarm,nanopi-r5c) | ||
wan_mac=$(macaddr_generate_from_mmc_cid mmcblk*) | ||
ip link set dev eth1 address $wan_mac | ||
ip link set dev eth0 address $(macaddr_add "$wan_mac" 1) | ||
;; | ||
xunlong,orangepi-r1-plus|\ | ||
xunlong,orangepi-r1-plus-lts) | ||
wan_mac=$(macaddr_add "$(cat /sys/class/net/eth1/address)" -1) | ||
ip link set dev eth0 address $wan_mac | ||
;; | ||
esac | ||
} | ||
|
||
boot_hook_add preinit_main preinit_set_mac_address |
24 changes: 24 additions & 0 deletions
24
target/linux/rockchip/armv8/base-files/lib/preinit/05_set_preinit_iface
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
set_preinit_iface() { | ||
case $(board_name) in | ||
friendlyarm,nanopi-r2c|\ | ||
friendlyarm,nanopi-r2c-plus|\ | ||
friendlyarm,nanopi-r2s|\ | ||
friendlyarm,nanopi-r4s|\ | ||
friendlyarm,nanopi-r4s-enterprise|\ | ||
xunlong,orangepi-r1-plus|\ | ||
xunlong,orangepi-r1-plus-lts) | ||
ip link set eth1 up | ||
ifname=eth1 | ||
;; | ||
sinovoip,rk3568-bpi-r2pro) | ||
ip link set eth1 up | ||
ifname=lan0 | ||
;; | ||
*) | ||
ip link set eth0 up | ||
ifname=eth0 | ||
;; | ||
esac | ||
} | ||
|
||
boot_hook_add preinit_main set_preinit_iface |