diff --git a/package/base-files/files/lib/preinit/02_sysinfo b/package/base-files/files/lib/preinit/02_sysinfo index f0ed0ff9f..65b50968e 100644 --- a/package/base-files/files/lib/preinit/02_sysinfo +++ b/package/base-files/files/lib/preinit/02_sysinfo @@ -1,11 +1,10 @@ do_sysinfo_generic() { - mkdir -p /tmp/sysinfo [ -d /proc/device-tree ] || return + mkdir -p /tmp/sysinfo [ -e /tmp/sysinfo/board_name ] || \ echo "$(strings /proc/device-tree/compatible | head -1)" > /tmp/sysinfo/board_name [ ! -e /tmp/sysinfo/model -a -e /proc/device-tree/model ] && \ echo "$(cat /proc/device-tree/model)" > /tmp/sysinfo/model - [ -z "$(fw_printenv model_name)" ] || fw_printenv model_name > /tmp/sysinfo/model } boot_hook_add preinit_main do_sysinfo_generic diff --git a/package/boot/uboot-envtools/files/ramips b/package/boot/uboot-envtools/files/ramips index 51e84fa05..48dd3b573 100644 --- a/package/boot/uboot-envtools/files/ramips +++ b/package/boot/uboot-envtools/files/ramips @@ -16,8 +16,7 @@ alfa-network,ac1200rm|\ alfa-network,awusfree1|\ alfa-network,quad-e4g|\ alfa-network,r36m-e4g|\ -alfa-network,tube-e4g|\ -huasifei,mt7621dtu) +alfa-network,tube-e4g) ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x1000" "0x1000" ;; allnet,all0256n-4m|\ @@ -35,6 +34,7 @@ beeline,smartbox-turbo-plus) ;; buffalo,wsr-1166dhp|\ buffalo,wsr-600dhp|\ +huasifei,mt7621dtu|\ mediatek,linkit-smart-7688|\ samknows,whitebox-v8|\ xiaomi,mi-router-4c|\ diff --git a/target/linux/ramips/base-files/sbin/getmac b/target/linux/ramips/base-files/sbin/getmac new file mode 100755 index 000000000..894a0c444 --- /dev/null +++ b/target/linux/ramips/base-files/sbin/getmac @@ -0,0 +1,15 @@ +#!/bin/sh + +. /lib/functions.sh +. /lib/functions/system.sh + +if [ -e "/dev/mtd0" ]; then + wifi_mac="$(mtd_get_mac_binary factory 0x4)" +elif [ -e "/dev/mmcblk0" ]; then + wifi_mac="$(mmc_get_mac_binary factory 0x4)" +else + echo "Error: unsupported flash." + exit 1 +fi + +echo "$wifi_mac" | awk '{print toupper($0)}' diff --git a/target/linux/ramips/base-files/sbin/setmac b/target/linux/ramips/base-files/sbin/setmac new file mode 100755 index 000000000..9dd20a08d --- /dev/null +++ b/target/linux/ramips/base-files/sbin/setmac @@ -0,0 +1,22 @@ +#!/bin/sh + +. /lib/functions/caldata.sh + +if [ -e "/dev/mtd0" ]; then + part="$(find_mtd_part factory)" +elif [ -e "/dev/mmcblk0" ]; then + part="$(find_mmc_part factory)" +fi +[ -n "$part" ] || { echo "Partition 'Factory' not found!"; exit 1; } + +mac="$1" +validate_data macaddr "$mac" >"/dev/null" 2>&1 || { echo "Please specify a correct MAC address!"; exit 1; } + +dd if="$part" of="/tmp/Factory.backup" 2>"/dev/null" +caldata_patch_mac "$mac" "0x4" "" "/tmp/Factory.backup" 2>"/dev/null" +if [ -e "/dev/mtd0" ]; then + mtd -qq write "/tmp/Factory.backup" "factory" +else + dd if="/tmp/Factory.backup" of="$part" bs=512 conv=fsync 2>"/dev/null" +fi +rm -rf "/tmp/Factory.backup" diff --git a/target/linux/ramips/dts/mt7621_huasifei_mt7621dtu.dts b/target/linux/ramips/dts/mt7621_huasifei_mt7621dtu.dts index b80f43c0d..aeb8cd159 100644 --- a/target/linux/ramips/dts/mt7621_huasifei_mt7621dtu.dts +++ b/target/linux/ramips/dts/mt7621_huasifei_mt7621dtu.dts @@ -102,13 +102,11 @@ partition@30000 { label = "u-boot-env"; reg = <0x30000 0x10000>; - read-only; }; factory: partition@40000 { label = "factory"; reg = <0x40000 0x10000>; - read-only; compatible = "nvmem-cells"; #address-cells = <1>; diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index 91ab20284..b734b77c9 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -859,7 +859,7 @@ define Device/huasifei_mt7621dtu DEVICE_MODEL := MT7621 DTU DEVICE_PACKAGES := kmod-ata-ahci kmod-mt7603 kmod-mt76x2 kmod-sdhci-mt7620 \ kmod-usb3 kmod-usb-net-cdc-mbim kmod-usb-net-qmi-wwan \ - kmod-usb-serial-option luci-proto-qmi sendat + kmod-usb-serial-option luci-proto-qmi sendat uboot-envtools endef TARGET_DEVICES += huasifei_mt7621dtu diff --git a/target/linux/ramips/mt7621/base-files/etc/init.d/set-model-name b/target/linux/ramips/mt7621/base-files/etc/init.d/set-model-name new file mode 100755 index 000000000..1b8143fab --- /dev/null +++ b/target/linux/ramips/mt7621/base-files/etc/init.d/set-model-name @@ -0,0 +1,11 @@ +#!/bin/sh /etc/rc.common + +START=99 + +start() { + [ -n "$(fw_printenv -n model_name 2>/dev/null)" ] && fw_printenv -n model_name > /tmp/sysinfo/model +} + + + +