diff options
Diffstat (limited to 'target/linux/mediatek/base-files')
4 files changed, 125 insertions, 7 deletions
diff --git a/target/linux/mediatek/base-files/etc/board.d/02_network b/target/linux/mediatek/base-files/etc/board.d/02_network index 8015cf3cc2..faa2434241 100755 --- a/target/linux/mediatek/base-files/etc/board.d/02_network +++ b/target/linux/mediatek/base-files/etc/board.d/02_network @@ -13,9 +13,21 @@ mediatek_setup_interfaces() ucidef_set_interface_lan "lan0 lan1 lan2 lan3" ucidef_set_interface_wan eth1 ;; - 'bananapi,bpi-r2') - ucidef_set_interface_lan "lan0 lan1 lan2 lan3" - ucidef_set_interface_wan wan + 'bananapi,bpi-r2'|\ + "unielec,u7623"*) + ucidef_set_interfaces_lan_wan "lan0 lan1 lan2 lan3" "wan" + ;; + esac +} + +mediatek_setup_macs() +{ + local board="$1" + + case $board in + "unielec,u7623"*) + mac=$(cat /sys/class/net/wan/address) + ucidef_set_interface_macaddr "wan" $mac ;; esac } @@ -23,6 +35,7 @@ mediatek_setup_interfaces() board_config_update board=$(board_name) mediatek_setup_interfaces $board +mediatek_setup_macs $board board_config_flush exit 0 diff --git a/target/linux/mediatek/base-files/lib/preinit/07_set_iface_mac b/target/linux/mediatek/base-files/lib/preinit/07_set_iface_mac new file mode 100644 index 0000000000..3d04000738 --- /dev/null +++ b/target/linux/mediatek/base-files/lib/preinit/07_set_iface_mac @@ -0,0 +1,47 @@ +#!/bin/sh +# Copyright (C) 2018 OpenWrt.org + +RECOVERY_PART=/dev/mmcblk0p1 + +preinit_set_mac_address() { + local mac + + . /lib/functions.sh + . /lib/functions/system.sh + + case $(board_name) in + "unielec,u7623"*) + if [ -b $RECOVERY_PART ]; then + insmod nls_cp437 + insmod nls_iso8859-1 + insmod fat + insmod vfat + mkdir -p /tmp/recovery + mount -o rw,noatime $RECOVERY_PART /tmp/recovery + + if [ -f "/tmp/recovery/mac_addr" ]; + then + mac=$(cat /tmp/recovery/mac_addr) + else + mac=$(cat /sys/class/net/eth0/address) + echo "$mac" > /tmp/recovery/mac_addr + fi + + sync + umount /tmp/recovery + rm -rf /tmp/recovery + fi + + ip link set dev wan address $mac 2> /dev/null + + mac=$(macaddr_add $mac 1) + + ip link set dev lan0 address $mac 2>/dev/null + ip link set dev lan1 address $mac 2>/dev/null + ip link set dev lan2 address $mac 2>/dev/null + ip link set dev lan3 address $mac 2>/dev/null + ;; + esac +} + +boot_hook_add preinit_main preinit_set_mac_address diff --git a/target/linux/mediatek/base-files/lib/preinit/79_move_config b/target/linux/mediatek/base-files/lib/preinit/79_move_config new file mode 100644 index 0000000000..e8e62883dc --- /dev/null +++ b/target/linux/mediatek/base-files/lib/preinit/79_move_config @@ -0,0 +1,19 @@ +#!/bin/sh +# Copyright (C) 2015 OpenWrt.org + +RECOVERY_PART=/dev/mmcblk0p1 + +move_config() { + if [ -b $RECOVERY_PART ]; then + insmod nls_cp437 + insmod nls_iso8859-1 + insmod fat + insmod vfat + mkdir -p /recovery + mount -o rw,noatime $RECOVERY_PART /recovery + [ -f /recovery/sysupgrade.tgz ] && mv -f /recovery/sysupgrade.tgz / + umount /recovery + fi +} + +boot_hook_add preinit_mount_root move_config diff --git a/target/linux/mediatek/base-files/lib/upgrade/platform.sh b/target/linux/mediatek/base-files/lib/upgrade/platform.sh index 646ce0dc53..487a262dc2 100755 --- a/target/linux/mediatek/base-files/lib/upgrade/platform.sh +++ b/target/linux/mediatek/base-files/lib/upgrade/platform.sh @@ -1,6 +1,28 @@ platform_do_upgrade() { - default_do_upgrade "$ARGV" -} + local board=$(board_name) + case "$board" in + "unielec,u7623"*) + #Keep the persisten random mac address (if it exists) + mkdir -p /tmp/recovery + mount -o rw,noatime /dev/mmcblk0p1 /tmp/recovery + [ -f "/tmp/recovery/mac_addr" ] && \ + mv -f /tmp/recovery/mac_addr /tmp/ + umount /tmp/recovery + + #1310720 is the offset in bytes from the start of eMMC and to + #the location of the kernel (2560 512 byte sectors) + get_image "$1" | dd of=/dev/mmcblk0 bs=1310720 seek=1 conv=fsync + + mount -o rw,noatime /dev/mmcblk0p1 /tmp/recovery + [ -f "/tmp/mac_addr" ] && mv -f /tmp/mac_addr /tmp/recovery + sync + umount /tmp/recovery + ;; + *) + default_do_upgrade "$ARGV" + ;; + esac +} PART_NAME=firmware @@ -11,7 +33,8 @@ platform_check_image() { [ "$#" -gt 1 ] && return 1 case "$board" in - bananapi,bpi-r2) + bananapi,bpi-r2|\ + "unielec,u7623"*) [ "$magic" != "27051956" ] && { echo "Invalid image type." return 1 @@ -26,4 +49,20 @@ platform_check_image() { esac return 0 -} +} + +platform_copy_config_emmc() { + mkdir -p /recovery + mount -o rw,noatime /dev/mmcblk0p1 /recovery + cp -af "$CONF_TAR" /recovery/ + sync + umount /recovery +} + +platform_copy_config() { + case "$(board_name)" in + "unielec,u7623"*) + platform_copy_config_emmc + ;; + esac +} |