diff options
Diffstat (limited to 'target/linux/ipq806x/base-files')
7 files changed, 108 insertions, 4 deletions
diff --git a/target/linux/ipq806x/base-files/etc/board.d/02_network b/target/linux/ipq806x/base-files/etc/board.d/02_network index 3f9d96881d..eecf81a8cd 100755 --- a/target/linux/ipq806x/base-files/etc/board.d/02_network +++ b/target/linux/ipq806x/base-files/etc/board.d/02_network @@ -12,6 +12,11 @@ board_config_update board=$(board_name) case "$board" in +asrock,g10 |\ +nec,wg2600hp) + ucidef_add_switch "switch0" \ + "2:lan" "3:lan" "4:lan" "5:lan" "6@eth1" "1:wan" "0@eth0" + ;; buffalo,wxr-2533dhp |\ compex,wpq864 |\ netgear,d7800 |\ @@ -41,10 +46,6 @@ linksys,ea8500) ucidef_set_interface_macaddr "lan" "$hw_mac_addr" ucidef_set_interface_macaddr "wan" "$hw_mac_addr" ;; -nec,wg2600hp) - ucidef_add_switch "switch0" \ - "2:lan" "3:lan" "4:lan" "5:lan" "6@eth1" "1:wan" "0@eth0" - ;; netgear,r7800 |\ tplink,c2600) ucidef_add_switch "switch0" \ diff --git a/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index 74ad00c5ce..a22af9b676 100644 --- a/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -9,6 +9,9 @@ board=$(board_name) case "$FIRMWARE" in "ath10k/pre-cal-pci-0000:01:00.0.bin") case $board in + asrock,g10) + caldata_extract "0:ART" 0x1000 0x2f20 + ;; buffalo,wxr-2533dhp) caldata_extract "ART" 0x1000 0x2f20 ath10k_patch_mac $(mtd_get_mac_binary ART 0x1e) @@ -47,6 +50,9 @@ case "$FIRMWARE" in ;; "ath10k/pre-cal-pci-0001:01:00.0.bin") case $board in + asrock,g10) + caldata_extract "0:ART" 0x5000 0x2f20 + ;; buffalo,wxr-2533dhp) caldata_extract "ART" 0x5000 0x2f20 ath10k_patch_mac $(mtd_get_mac_binary ART 0x18) diff --git a/target/linux/ipq806x/base-files/etc/init.d/bootcount b/target/linux/ipq806x/base-files/etc/init.d/bootcount index 77965e647b..7a54c34dba 100755 --- a/target/linux/ipq806x/base-files/etc/init.d/bootcount +++ b/target/linux/ipq806x/base-files/etc/init.d/bootcount @@ -2,8 +2,16 @@ START=99 +. /lib/upgrade/asrock.sh + boot() { case $(board_name) in + asrock,g10) + asrock_bootconfig_mangle "bootcheck" + if [ $? -eq 0 ]; then + reboot + fi + ;; edgecore,ecw5410) fw_setenv bootcount 0 ;; diff --git a/target/linux/ipq806x/base-files/lib/preinit/05_set_iface_mac_ipq806x.sh b/target/linux/ipq806x/base-files/lib/preinit/05_set_iface_mac_ipq806x.sh new file mode 100644 index 0000000000..ca8d0b1555 --- /dev/null +++ b/target/linux/ipq806x/base-files/lib/preinit/05_set_iface_mac_ipq806x.sh @@ -0,0 +1,14 @@ +. /lib/functions.sh + +preinit_set_mac_address() { + case $(board_name) in + asrock,g10) + lan_mac=$(mtd_get_mac_ascii hwconfig HW.LAN.MAC.Address) + wan_mac=$(mtd_get_mac_ascii hwconfig HW.WAN.MAC.Address) + ip link set dev eth0 address "${lan_mac}" + ip link set dev eth1 address "${wan_mac}" + ;; + esac +} + +boot_hook_add preinit_main preinit_set_mac_address diff --git a/target/linux/ipq806x/base-files/lib/upgrade/asrock.sh b/target/linux/ipq806x/base-files/lib/upgrade/asrock.sh new file mode 100644 index 0000000000..71cac3faac --- /dev/null +++ b/target/linux/ipq806x/base-files/lib/upgrade/asrock.sh @@ -0,0 +1,55 @@ +. /lib/functions.sh + + +asrock_bootconfig_mangle() { + local mtdnum="$( find_mtd_index 0:BOOTCONFIG )" + + if [ -z "$mtdnum" ]; then + echo "cannot find bootconfig mtd partition" + return 1 + fi + dd if=/dev/mtd$mtdnum of=/tmp/mtd$mtdnum bs=1k + + local partition_byte="$(dd if=/tmp/mtd$mtdnum bs=1 skip=52 count=1)" + local upgrade_byte="$(dd if=/tmp/mtd$mtdnum bs=1 skip=4 count=1)" + + if [ $1 = "bootcheck" ]; then + if [ ! -s $upgrade_byte ]; then + dd if=/dev/mtd$mtdnum of=/tmp/mtd$mtdnum bs=1k + printf '\x00' | dd of=/tmp/mtd$mtdnum conv=notrunc bs=1 seek=4 + printf '\x00' | dd of=/tmp/mtd$mtdnum conv=notrunc bs=1 seek=56 + else + return 1 + fi + elif [ $1 = "sysupgrade" ]; then + printf '\x01' | dd of=/tmp/mtd$mtdnum conv=notrunc bs=1 seek=4 + printf '\x01' | dd of=/tmp/mtd$mtdnum conv=notrunc bs=1 seek=56 + fi + + if [ -s $partition_byte ]; then + printf '\x01' | dd of=/tmp/mtd$mtdnum conv=notrunc bs=1 seek=52 + else + printf '\x00' | dd of=/tmp/mtd$mtdnum conv=notrunc bs=1 seek=52 + fi + + mtd write /tmp/mtd$mtdnum /dev/mtd$mtdnum + return 0 +} + +asrock_upgrade_prepare() { + local ubidev="$( nand_find_ubi ubi )" + + #Set upgrade flag. If something goes wrong, router will boot with + #factory firmware. + asrock_bootconfig_mangle 'sysupgrade' + + if [ $? -ne 0 ]; then + echo "cannot find bootconfig mtd partition" + exit 1 + fi + + # Just delete these partitions if present and use + # OpenWrt's standard names for those. + ubirmvol /dev/$ubidev -N ubi_rootfs &> /dev/null || true + ubirmvol /dev/$ubidev -N ubi_rootfs_data &> /dev/null || true +} diff --git a/target/linux/ipq806x/base-files/lib/upgrade/platform.sh b/target/linux/ipq806x/base-files/lib/upgrade/platform.sh index f61e8ee878..f5d6c5d55d 100644 --- a/target/linux/ipq806x/base-files/lib/upgrade/platform.sh +++ b/target/linux/ipq806x/base-files/lib/upgrade/platform.sh @@ -10,6 +10,10 @@ platform_check_image() { platform_do_upgrade() { case "$(board_name)" in + asrock,g10) + asrock_upgrade_prepare + nand_do_upgrade "$1" + ;; buffalo,wxr-2533dhp) buffalo_upgrade_prepare_ubi CI_ROOTPART="ubi_rootfs" diff --git a/target/linux/ipq806x/base-files/sbin/asrock_g10_back_to_factory b/target/linux/ipq806x/base-files/sbin/asrock_g10_back_to_factory new file mode 100755 index 0000000000..55aa91eab6 --- /dev/null +++ b/target/linux/ipq806x/base-files/sbin/asrock_g10_back_to_factory @@ -0,0 +1,16 @@ +#!/bin/sh + +. /lib/upgrade/asrock.sh + +case $(board_name) in +asrock,g10) + asrock_bootconfig_mangle "factory" + if [ $? -eq 0 ]; then + reboot + fi + ;; +*) + echo "Unsupported hardware." + ;; +esac + |