Initial commit
Some checks failed
Build Kernel / Build all affected Kernels (push) Has been cancelled
Build all core packages / Build all core packages for selected target (push) Has been cancelled
Build and Push prebuilt tools container / Build and Push all prebuilt containers (push) Has been cancelled
Build Toolchains / Build Toolchains for each target (push) Has been cancelled
Build host tools / Build host tools for linux and macos based systems (push) Has been cancelled
Coverity scan build / Coverity x86/64 build (push) Has been cancelled

This commit is contained in:
domenico
2025-06-24 12:51:15 +02:00
commit 27c9d80f51
10493 changed files with 1885777 additions and 0 deletions

View File

@@ -0,0 +1,127 @@
#
# Copyright (C) 2015 OpenWrt.org
#
. /lib/functions/uci-defaults.sh
board_config_update
board=$(board_name)
case "$board" in
askey,rt4230w-rev6)
ucidef_set_led_netdev "wan-port-link" "WAN-PORT-LINK" "qca8k-0.0:00:green:wan" "wan" "link_10 link_100 link_1000"
ucidef_set_led_netdev "wan-port-activity" "WAN-PORT-ACTIVITY" "qca8k-0.0:00:amber:wan" "wan" "tx rx"
ucidef_set_led_netdev "lan1-port-link" "LAN1-PORT-LINK" "qca8k-0.0:01:green:lan" "lan1" "link_10 link_100 link_1000"
ucidef_set_led_netdev "lan1-port-activity" "LAN1-PORT-ACTIVITY" "qca8k-0.0:01:amber:lan" "lan1" "tx rx"
ucidef_set_led_netdev "lan2-port-link" "LAN2-PORT-LINK" "qca8k-0.0:02:green:lan" "lan2" "link_10 link_100 link_1000"
ucidef_set_led_netdev "lan2-port-activity" "LAN2-PORT-ACTIVITY" "qca8k-0.0:02:amber:lan" "lan2" "tx rx"
ucidef_set_led_netdev "lan3-port-link" "LAN3-PORT-LINK" "qca8k-0.0:03:green:lan" "lan3" "link_10 link_100 link_1000"
ucidef_set_led_netdev "lan3-port-activity" "LAN3-PORT-ACTIVITY" "qca8k-0.0:03:amber:lan" "lan3" "tx rx"
ucidef_set_led_netdev "lan4-port-link" "LAN4-PORT-LINK" "qca8k-0.0:04:green:lan" "lan4" "link_10 link_100 link_1000"
ucidef_set_led_netdev "lan4-port-activity" "LAN4-PORT-ACTIVITY" "qca8k-0.0:04:amber:lan" "lan4" "tx rx"
;;
buffalo,wxr-2533dhp)
ucidef_set_led_wlan "wlan" "WLAN" "white:wireless" "phy0tpt"
ucidef_set_led_netdev "wan" "WAN" "white:internet" "wan"
;;
compex,wpq864)
ucidef_set_led_usbport "usb" "USB" "green:usb" "usb1-port1" "usb2-port1"
ucidef_set_led_usbport "pcie-usb" "PCIe USB" "green:usb-pcie" "usb3-port1"
;;
edgecore,ecw5410)
ucidef_set_led_wlan "wlan2g" "WLAN2G" "green:wlan2g" "phy1tpt"
ucidef_set_led_wlan "wlan5g" "WLAN5G" "green:wlan5g" "phy0tpt"
;;
extreme,ap3935)
ucidef_set_led_netdev "wan" "wan" "orange:lan1" "eth1"
ucidef_set_led_netdev "lan" "lan" "orange:lan2" "eth0"
;;
fortinet,fap-421e)
ucidef_set_led_netdev "eth1-100" "ETH1-100" "amber:eth1" "eth0" "link_100"
ucidef_set_led_netdev "eth1-1000" "ETH1-1000" "yellow:eth1" "eth0" "link_1000"
ucidef_set_led_netdev "eth2-100" "ETH2-100" "amber:eth2" "eth1" "link_100"
ucidef_set_led_netdev "eth2-1000" "ETH2-1000" "yellow:eth2" "eth1" "link_1000"
ucidef_set_led_wlan "wlan2g" "2.4G" "yellow:2g" "phy1tpt"
ucidef_set_led_wlan "wlan5g" "5G" "yellow:5g" "phy0tpt"
ucidef_set_led_usbport "usb" "USB" "amber:power" "usb1-port1" "usb2-port1"
;;
linksys,e8350-v1)
ucidef_set_led_wlan "wlan" "WLAN" "green:wifi" "phy0tpt"
;;
meraki,mr52)
ucidef_set_led_netdev "eth0" "eth0" "green:lan1" "eth0"
ucidef_set_led_netdev "eth1" "eth1" "green:lan2" "eth1"
;;
nec,wg2600hp)
ucidef_set_led_wlan "wlan2g" "WLAN2G" "green:wlan2g" "phy1tpt"
ucidef_set_led_wlan "wlan5g" "WLAN5G" "green:wlan5g" "phy0tpt"
ucidef_set_led_netdev "wan" "WAN" "green:active" "wan"
;;
nec,wg2600hp3)
ucidef_set_led_netdev "wan" "WAN" "green:active" "wan"
ucidef_set_led_netdev "wan-port-10" "WAN-PORT-10" "qca8k-0.0:00:green:wan-1" "wan" "tx rx link_10"
ucidef_set_led_netdev "wan-port-100" "WAN-PORT-100" "qca8k-0.0:00:green:wan-2" "wan" "tx rx link_100"
ucidef_set_led_netdev "wan-port-1000" "WAN-PORT-1000" "qca8k-0.0:00:green:wan-3" "wan" "tx rx link_1000"
ucidef_set_led_netdev "lan1-port-10" "LAN1-PORT-10" "qca8k-0.0:01:green:lan-1" "lan1" "tx rx link_10"
ucidef_set_led_netdev "lan1-port-100" "LAN1-PORT-100" "qca8k-0.0:01:green:lan-2" "lan1" "tx rx link_100"
ucidef_set_led_netdev "lan1-port-1000" "LAN1-PORT-1000" "qca8k-0.0:01:green:lan-3" "lan1" "tx rx link_1000"
ucidef_set_led_netdev "lan2-port-10" "LAN2-PORT-10" "qca8k-0.0:02:green:lan-1" "lan2" "tx rx link_10"
ucidef_set_led_netdev "lan2-port-100" "LAN2-PORT-100" "qca8k-0.0:02:green:lan-2" "lan2" "tx rx link_100"
ucidef_set_led_netdev "lan2-port-1000" "LAN2-PORT-1000" "qca8k-0.0:02:green:lan-3" "lan2" "tx rx link_1000"
ucidef_set_led_netdev "lan3-port-10" "LAN3-PORT-10" "qca8k-0.0:03:green:lan-1" "lan3" "tx rx link_10"
ucidef_set_led_netdev "lan3-port-100" "LAN3-PORT-100" "qca8k-0.0:03:green:lan-2" "lan3" "tx rx link_100"
ucidef_set_led_netdev "lan3-port-1000" "LAN3-PORT-1000" "qca8k-0.0:03:green:lan-3" "lan3" "tx rx link_1000"
ucidef_set_led_netdev "lan4-port-10" "LAN4-PORT-10" "qca8k-0.0:04:green:lan-1" "lan4" "tx rx link_10"
ucidef_set_led_netdev "lan4-port-100" "LAN4-PORT-100" "qca8k-0.0:04:green:lan-2" "lan4" "tx rx link_100"
ucidef_set_led_netdev "lan4-port-1000" "LAN4-PORT-1000" "qca8k-0.0:04:green:lan-3" "lan4" "tx rx link_1000"
;;
netgear,d7800 |\
netgear,r7500 |\
netgear,r7500v2 |\
netgear,r7800 |\
netgear,xr450 |\
netgear,xr500)
ucidef_set_led_usbport "usb1" "USB 1" "white:usb1" "usb1-port1" "usb2-port1"
ucidef_set_led_usbport "usb2" "USB 2" "white:usb2" "usb3-port1" "usb4-port1"
ucidef_set_led_netdev "wan" "WAN" "white:wan" "wan"
ucidef_set_led_ide "esata" "eSATA" "white:esata"
;;
nokia,ac400i)
ucidef_set_led_wlan "wlan5g" "5G" "green:wlan5g" "wlan0"
ucidef_set_led_wlan "wlan2g" "2.4G" "green:wlan2g" "wlan1"
ucidef_set_led_netdev "eth1" "ETH1" "green:eth1" "eth0"
ucidef_set_led_netdev "eth2" "ETH2" "green:eth2" "eth1"
ucidef_set_led_default "ctrl" "CTRL" "green:ctrl" "0"
ucidef_set_led_default "pwr" "PWR" "green:power" "1"
;;
tplink,ad7200)
ucidef_set_led_usbport "usb1" "USB 1" "blue:usb1" "usb1-port1" "usb2-port1"
ucidef_set_led_usbport "usb2" "USB 2" "blue:usb3" "usb3-port1" "usb4-port1"
ucidef_set_led_netdev "wan" "wan" "blue:wan" "wan"
ucidef_set_led_netdev "lan" "lan" "blue:lan" "br-lan"
ucidef_set_led_wlan "wlan2g" "wlan2g" "blue:wlan2g" "phy2tpt"
ucidef_set_led_wlan "wlan5g" "wlan5g" "blue:wlan5g" "phy1tpt"
ucidef_set_led_netdev "wlan60g" "wlan60g" "blue:wlan60g" "wlan0"
;;
tplink,c2600)
ucidef_set_led_usbport "usb1" "USB 1" "white:usb_2" "usb1-port1" "usb2-port1"
ucidef_set_led_usbport "usb2" "USB 2" "white:usb_4" "usb3-port1" "usb4-port1"
ucidef_set_led_netdev "wan" "wan" "white:wan" "wan"
ucidef_set_led_netdev "lan" "lan" "white:lan" "br-lan"
;;
tplink,vr2600v)
ucidef_set_led_usbport "usb" "USB" "white:usb" "usb1-port1" "usb2-port1" "usb3-port1" "usb4-port1"
ucidef_set_led_netdev "lan" "lan" "white:lan" "br-lan"
ucidef_set_led_wlan "wlan2g" "WLAN2G" "white:wlan2g" "phy0tpt"
ucidef_set_led_wlan "wlan5g" "WLAN5G" "white:wlan5g" "phy1tpt"
ucidef_set_led_netdev "wan" "WAN" "white:wan" "wan"
;;
zyxel,nbg6817)
ucidef_set_led_netdev "wan" "WAN" "white:internet" "wan"
;;
esac
board_config_flush
exit 0

View File

@@ -0,0 +1,114 @@
#
# Copyright (c) 2015 The Linux Foundation. All rights reserved.
# Copyright (c) 2011-2015 OpenWrt.org
#
. /lib/functions/uci-defaults.sh
. /lib/functions/system.sh
ipq806x_setup_interfaces()
{
local board="$1"
case "$board" in
arris,tr4400-v2)
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "eth2"
;;
askey,rt4230w-rev6 |\
asrock,g10 |\
nec,wg2600hp |\
buffalo,wxr-2533dhp |\
compex,wpq864 |\
netgear,d7800 |\
netgear,r7500 |\
netgear,r7500v2 |\
qcom,ipq8064-ap148 |\
linksys,e8350-v1 |\
linksys,ea7500-v1 |\
linksys,ea8500 |\
nec,wg2600hp3 |\
netgear,r7800 |\
netgear,xr500 |\
netgear,xr450 |\
tplink,c2600 |\
tplink,vr2600v |\
tplink,ad7200 |\
zyxel,nbg6817)
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
ucidef_set_network_device_conduit "lan1" "eth1"
ucidef_set_network_device_conduit "lan2" "eth1"
ucidef_set_network_device_conduit "lan3" "eth1"
ucidef_set_network_device_conduit "lan4" "eth1"
ucidef_set_network_device_conduit "wan" "eth0"
;;
asus,onhub |\
tplink,onhub)
ucidef_set_interfaces_lan_wan "lan1" "wan"
ucidef_set_network_device_conduit "lan1" "eth1"
ucidef_set_network_device_conduit "wan" "eth0"
;;
edgecore,ecw5410)
ucidef_set_interfaces_lan_wan "eth1" "eth0"
;;
qcom,ipq8064-ap161)
ucidef_set_interface_lan "eth1 eth2 lan1 lan2 lan3 lan4" "wan"
;;
qcom,ipq8064-db149)
ucidef_set_interface_lan "eth1 eth2 eth3 lan1 lan2 lan3 lan4" "wan"
;;
fortinet,fap-421e |\
ubnt,unifi-ac-hd)
ucidef_set_interface_lan "eth0 eth1"
;;
meraki,mr42)
ucidef_set_interface_lan "eth0"
;;
extreme,ap3935 |\
meraki,mr52)
ucidef_set_interfaces_lan_wan "eth0" "eth1"
;;
*)
echo "Unsupported hardware. Network interfaces not intialized"
;;
esac
}
ipq806x_setup_macs()
{
local board="$1"
case "$board" in
linksys,ea7500-v1)
hw_mac_addr=$(mtd_get_mac_ascii devinfo hw_mac_addr)
ucidef_set_interface_macaddr "lan" "$hw_mac_addr"
ucidef_set_interface_macaddr "wan" "$hw_mac_addr"
;;
linksys,ea8500)
hw_mac_addr=$(mtd_get_mac_ascii devinfo hw_mac_addr)
ucidef_set_interface_macaddr "lan" "$hw_mac_addr"
ucidef_set_interface_macaddr "wan" "$hw_mac_addr"
;;
linksys,e8350-v1 |\
zyxel,nbg6817)
hw_mac_addr=$(mtd_get_mac_ascii 0:appsblenv ethaddr)
ucidef_set_interface_macaddr "lan" "$(macaddr_add $hw_mac_addr 2)"
ucidef_set_interface_macaddr "wan" "$(macaddr_add $hw_mac_addr 3)"
;;
asrock,g10)
hw_mac_addr=$(mtd_get_mac_ascii hwconfig HW.LAN.MAC.Address)
ucidef_set_interface_macaddr "lan" "$hw_mac_addr"
hw_mac_addr=$(mtd_get_mac_ascii hwconfig HW.WAN.MAC.Address)
ucidef_set_interface_macaddr "wan" "$hw_mac_addr"
;;
esac
}
board_config_update
board=$(board_name)
ipq806x_setup_macs $board
ipq806x_setup_interfaces $board
board_config_flush
exit 0

View File

@@ -0,0 +1,46 @@
#!/bin/sh
#
# Copyright (C) 2020 OpenWrt.org
#
. /lib/functions.sh
. /lib/functions/uci-defaults.sh
board_config_update
case "$(board_name)" in
arris,tr4400-v2 |\
askey,rt4230w-rev6 |\
asrock,g10 |\
buffalo,wxr-2533dhp |\
compex,wpq864 |\
fortinet,fap-421e |\
nec,wg2600hp |\
nec,wg2600hp3 |\
netgear,d7800 |\
netgear,r7500 |\
netgear,r7500v2 |\
netgear,r7800 |\
netgear,xr450 |\
netgear,xr500 |\
nokia,ac400i |\
qcom,ipq8064-ap148 |\
qcom,ipq8064-ap161 |\
qcom,ipq8064-db149 |\
tplink,ad7200 |\
tplink,c2600 |\
tplink,vr2600v |\
zyxel,nbg6817 |\
asus,onhub |\
tplink,onhub)
ucidef_set_compat_version "1.1"
;;
linksys,ea7500-v1 |\
linksys,ea8500)
ucidef_set_compat_version "2.1"
;;
esac
board_config_flush
exit 0

View File

@@ -0,0 +1,127 @@
#!/bin/sh
[ -e /lib/firmware/$FIRMWARE ] && exit 0
. /lib/functions/caldata.sh
board=$(board_name)
dt_base64_extract() {
local target_dir="/sys$DEVPATH"
local source="$target_dir/../../of_node/qcom,ath10k-calibration-data-base64"
[ -e "$source" ] || caldata_die "cannot find base64 calibration data: $source"
[ -d "$target_dir" ] || \
caldata_die "no sysfs dir to write: $target"
echo 1 > "$target_dir/loading"
base64decode.uc "$source" > "$target_dir/data"
if [ $? != 0 ]; then
echo 1 > "$target_dir/loading"
caldata_die \
"failed to write calibration data to $target_dir/data"
else
echo 0 > "$target_dir/loading"
fi
}
case "$FIRMWARE" in
"ath10k/cal-pci-0000:01:00.0.bin")
case "$board" in
asus,onhub |\
tplink,onhub)
dt_base64_extract
;;
meraki,mr52)
CI_UBIPART=art
caldata_extract_ubi "ART" 0x1000 0x844
;;
esac
;;
"ath10k/pre-cal-pci-0000:01:00.0.bin")
case $board in
asrock,g10)
caldata_extract "0:art" 0x1000 0x2f20
;;
linksys,ea7500-v1 |\
linksys,ea8500)
caldata_extract "art" 0x1000 0x2f20
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii devinfo hw_mac_addr) 1)
;;
meraki,mr42)
CI_UBIPART=art
caldata_extract_ubi "ART" 0x1000 0x2f20
;;
nokia,ac400i)
caldata_extract "0:art" 0x1000 0x2f20
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii 0:appsblenv ethaddr) +2)
;;
zyxel,nbg6817)
caldata_extract "0:art" 0x1000 0x2f20
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii 0:appsblenv ethaddr) 1)
;;
esac
;;
"ath10k/cal-pci-0001:01:00.0.bin")
case "$board" in
asus,onhub |\
tplink,onhub)
dt_base64_extract
;;
esac
;;
"ath10k/pre-cal-pci-0001:01:00.0.bin")
case $board in
asrock,g10)
caldata_extract "0:art" 0x5000 0x2f20
;;
edgecore,ecw5410)
caldata_extract "0:art" 0x1000 0x2f20
;;
linksys,ea7500-v1 |\
linksys,ea8500)
caldata_extract "art" 0x5000 0x2f20
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii devinfo hw_mac_addr) 2)
;;
meraki,mr42 |\
meraki,mr52)
CI_UBIPART=art
caldata_extract_ubi "ART" 0x5000 0x2f20
;;
nokia,ac400i)
caldata_extract "0:art" 0x5000 0x2f20
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii 0:appsblenv ethaddr) +3)
;;
zyxel,nbg6817)
caldata_extract "0:art" 0x5000 0x2f20
ath10k_patch_mac $(mtd_get_mac_ascii 0:appsblenv ethaddr)
;;
esac
;;
"ath10k/cal-pci-0002:01:00.0.bin")
case "$board" in
asus,onhub |\
tplink,onhub)
dt_base64_extract
;;
meraki,mr42)
CI_UBIPART=art
caldata_extract_ubi "ART" 0x9000 0x844
;;
esac
;;
"ath10k/pre-cal-pci-0002:01:00.0.bin")
case $board in
edgecore,ecw5410)
caldata_extract "0:art" 0x5000 0x2f20
;;
meraki,mr52)
CI_UBIPART=art
caldata_extract_ubi "ART" 0x9000 0x2f20
;;
esac
;;
*)
exit 1
;;
esac

View File

@@ -0,0 +1,44 @@
#!/bin/ash
[ "$ACTION" == "add" ] || exit 0
PHYNBR=${DEVPATH##*/phy}
[ -n $PHYNBR ] || exit 0
. /lib/functions.sh
. /lib/functions/system.sh
board=$(board_name)
case "$board" in
ubnt,unifi-ac-hd)
macaddr_add $(mtd_get_mac_binary EEPROM 0x6) $(($PHYNBR + 1)) > /sys${DEVPATH}/macaddress
;;
extreme,ap3935)
echo "##### PHYNBR=$PHYNBR DEVPATH=$DEVPATH"
[ "$PHYNBR" = "0" ] && echo $(mtd_get_mac_ascii CFG1 RADIOADDR0) > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "1" ] && echo $(mtd_get_mac_ascii CFG1 RADIOADDR1) > /sys${DEVPATH}/macaddress
;;
esac
OPATH=${DEVPATH##/devices/platform/}
OPATH=${OPATH%%/ieee*}
# 10 radios is enough for anyone!
for i in $(seq 0 9);
do
BUS=$(uci get wireless.@wifi-device[$i].path)
if [ "$BUS " == "$OPATH " ]
then
PHYNAME=${DEVPATH##*ieee80211/}
NPHYNAME=$(uci get wireless.@wifi-device[$i].phyname)
if [ "$NPHYNAME " != " " ]
then
if [ "$PHYNAME " != "$NPHYNAME " ]
then
iw $PHYNAME set name $NPHYNAME
fi
fi
fi
done

View File

@@ -0,0 +1,23 @@
#!/bin/sh /etc/rc.common
START=99
. "$IPKG_INSTROOT/lib/upgrade/asrock.sh"
boot() {
case $(board_name) in
asrock,g10)
asrock_bootconfig_mangle "bootcheck" && reboot
;;
edgecore,ecw5410)
fw_setenv bootcount 0
;;
extreme,ap3935)
fw_setenv WATCHDOG_COUNT 0x00000000
;;
linksys,ea7500-v1 |\
linksys,ea8500)
mtd resetbc s_env || true
;;
esac
}

View File

@@ -0,0 +1,17 @@
#!/bin/sh /etc/rc.common
START=15
boot() {
local governor
governor=$(cat /sys/devices/system/cpu/cpufreq/policy0/scaling_governor)
if [ "$governor" = "ondemand" ]; then
# Effective only with ondemand
echo 600000 > /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq
echo 600000 > /sys/devices/system/cpu/cpufreq/policy1/scaling_min_freq
echo 10 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor
echo 50 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
fi
}

View File

@@ -0,0 +1,4 @@
# Copyright (c) 2013 The Linux Foundation. All rights reserved.
::sysinit:/etc/init.d/rcS S boot
::shutdown:/etc/init.d/rcS K shutdown
ttyMSM0::askfirst:/usr/libexec/login.sh

View File

@@ -0,0 +1,7 @@
. /lib/functions/migrations.sh
remove_devicename_leds
migrations_apply system
exit 0

View File

@@ -0,0 +1,13 @@
. /lib/functions.sh
preinit_reorder_eth() {
case $(board_name) in
ubnt,unifi-ac-hd)
ip link set eth0 name ethtmp
ip link set eth1 name eth0
ip link set ethtmp name eth1
;;
esac
}
boot_hook_add preinit_main preinit_reorder_eth

View File

@@ -0,0 +1,54 @@
. "$IPKG_INSTROOT/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
}

View File

@@ -0,0 +1,44 @@
# Copyright (C) 2018 OpenWrt.org
#
. /lib/functions.sh
# The mtd partition 'ubi' and 'rootfs_1' on NAND flash are os-image
# partitions. These partitions are called as "Bank1/Bank2" in U-Boot
# on WXR-2533DHP, and they are checked conditions when booting.
# Then, U-Boot checks kernel and rootfs volumes in ubi, but U-Boot
# needs "ubi_rootfs" as rootfs volume name. And, U-Boot checks the
# checksum at the end of rootfs (ubi_rootfs).
# When U-Boot writes os-image into the Bank, only kernel, rootfs
# (ubi_rootfs) and rootfs_data (ubi_rootfs_data) volumes are wrote
# into the Bank. (not full ubi image)
#
# == U-Boot Behaviors ==
# - Bank1/Bank2 images are good, images are different
# -> writes os-image to Bank1 from Bank2
# (this behavior is used to firmware upgrade in stock firmware)
# - Bank1 image is broken (or checksum error)
# -> writes os-image to Bank1 from Bank2
# - Bank2 image is broken (or checksum error)
# -> writes os-image to Bank2 from Bank1
# - Bank1/Bank2 images are broken (or checksum error)
# -> start tftp
buffalo_upgrade_prepare_ubi() {
local ubidev="$( nand_find_ubi ubi )"
local mtdnum2="$( find_mtd_index rootfs_1 )"
if [ ! "$mtdnum2" ]; then
echo "cannot find second ubi mtd partition rootfs_1"
return 1
fi
local ubidev2="$( nand_find_ubi rootfs_1 )"
if [ ! "$ubidev2" ] && [ -n "$mtdnum2" ]; then
ubiattach -m "$mtdnum2"
ubidev2="$( nand_find_ubi rootfs_1 )"
fi
ubirmvol /dev/$ubidev -N ubi_rootfs_data &> /dev/null || true
ubirmvol /dev/$ubidev2 -N kernel &> /dev/null || true
}

View File

@@ -0,0 +1,107 @@
#
# Copyright (C) 2014-2015 OpenWrt.org
#
linksys_get_target_firmware() {
local cur_boot_part mtd_ubi0
cur_boot_part=$(/usr/sbin/fw_printenv -n boot_part)
if [ -z "${cur_boot_part}" ] ; then
mtd_ubi0=$(cat /sys/class/ubi/ubi0/mtd_num)
case $(grep -E ^mtd${mtd_ubi0}: /proc/mtd | cut -d '"' -f 2) in
kernel1|rootfs1)
cur_boot_part=1
;;
kernel2|rootfs2)
cur_boot_part=2
;;
esac
>&2 printf "Current boot_part='%s' selected from ubi0/mtd_num='%s'" \
"${cur_boot_part}" "${mtd_ubi0}"
fi
case $cur_boot_part in
1)
fw_setenv -s - <<-EOF
boot_part 2
auto_recovery yes
EOF
printf "kernel2"
return
;;
2)
fw_setenv -s - <<-EOF
boot_part 1
auto_recovery yes
EOF
printf "kernel1"
return
;;
*)
return
;;
esac
}
platform_do_upgrade_linksys() {
local magic_long="$(get_magic_long "$1")"
mkdir -p /var/lock
local part_label="$(linksys_get_target_firmware)"
touch /var/lock/fw_printenv.lock
if [ ! -n "$part_label" ]
then
echo "cannot find target partition"
exit 1
fi
local target_mtd=$(find_mtd_part $part_label)
[ "$magic_long" = "73797375" ] && {
CI_KERNPART="$part_label"
if [ "$part_label" = "kernel1" ]
then
CI_UBIPART="rootfs1"
else
CI_UBIPART="rootfs2"
fi
# remove "squashfs" vol (in case we are flashing over a stock image, which is also UBI)
local mtdnum="$( find_mtd_index "$CI_UBIPART" )"
if [ ! "$mtdnum" ]; then
echo "cannot find ubi mtd partition $CI_UBIPART"
return 1
fi
local ubidev="$( nand_find_ubi "$CI_UBIPART" )"
if [ ! "$ubidev" ]; then
ubiattach -m "$mtdnum"
sync
ubidev="$( nand_find_ubi "$CI_UBIPART" )"
fi
if [ "$ubidev" ]; then
local squash_ubivol="$( nand_find_volume $ubidev squashfs )"
# kill volume
[ "$squash_ubivol" ] && ubirmvol /dev/$ubidev -N squashfs || true
fi
# complete std upgrade
if nand_upgrade_tar "$1" ; then
nand_do_upgrade_success
else
nand_do_upgrade_failed
fi
}
[ "$magic_long" = "27051956" ] && {
get_image "$1" | mtd write - $part_label
}
}

View File

@@ -0,0 +1,99 @@
PART_NAME=firmware
REQUIRE_IMAGE_METADATA=1
RAMFS_COPY_BIN='fw_printenv fw_setenv'
RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock'
platform_check_image() {
return 0;
}
platform_do_upgrade() {
case "$(board_name)" in
arris,tr4400-v2 |\
askey,rt4230w-rev6 |\
compex,wpq864|\
fortinet,fap-421e|\
linksys,e8350-v1|\
netgear,d7800 |\
netgear,r7500 |\
netgear,r7500v2 |\
netgear,r7800 |\
netgear,xr450 |\
netgear,xr500 |\
nokia,ac400i |\
qcom,ipq8064-ap148 |\
qcom,ipq8064-ap161)
nand_do_upgrade "$1"
;;
asrock,g10)
asrock_upgrade_prepare
nand_do_upgrade "$1"
;;
buffalo,wxr-2533dhp)
buffalo_upgrade_prepare_ubi
CI_ROOTPART="ubi_rootfs"
nand_do_upgrade "$1"
;;
edgecore,ecw5410)
part="$(awk -F 'ubi.mtd=' '{printf $2}' /proc/cmdline | sed -e 's/ .*$//')"
if [ "$part" = "rootfs1" ]; then
fw_setenv active 2 || exit 1
CI_UBIPART="rootfs2"
else
fw_setenv active 1 || exit 1
CI_UBIPART="rootfs1"
fi
nand_do_upgrade "$1"
;;
extreme,ap3935)
CI_ROOTPART="nand_flash"
CI_KERNPART="PriImg"
nand_do_upgrade "$1"
;;
linksys,ea7500-v1 |\
linksys,ea8500)
platform_do_upgrade_linksys "$1"
;;
meraki,mr42 |\
meraki,mr52)
CI_KERNPART="bootkernel2"
nand_do_upgrade "$1"
;;
tplink,ad7200 |\
tplink,c2600)
PART_NAME="os-image:rootfs"
MTD_CONFIG_ARGS="-s 0x200000"
default_do_upgrade "$1"
;;
asus,onhub |\
tplink,onhub)
export_bootdevice
export_partdevice CI_ROOTDEV 0
CI_KERNPART="kernel"
CI_ROOTPART="rootfs"
CI_DATAPART="rootfs_data"
emmc_do_upgrade "$1"
;;
tplink,vr2600v)
MTD_CONFIG_ARGS="-s 0x200000"
default_do_upgrade "$1"
;;
zyxel,nbg6817)
zyxel_do_upgrade "$1"
;;
*)
default_do_upgrade "$1"
;;
esac
}
platform_copy_config() {
case "$(board_name)" in
asus,onhub |\
tplink,onhub)
emmc_copy_config
;;
esac
return 0
}

View File

@@ -0,0 +1,124 @@
#
# Copyright (C) 2016 lede-project.org
#
zyxel_get_rootfs() {
local rootfsdev
if read cmdline < /proc/cmdline; then
case "$cmdline" in
*root=*)
rootfsdev="${cmdline##*root=}"
rootfsdev="${rootfsdev%% *}"
;;
esac
echo "${rootfsdev}"
fi
}
zyxel_do_flash() {
local tar_file=$1
local kernel=$2
local rootfs=$3
local dualflagmtd=$4
# keep sure its unbound
losetup --detach-all || {
echo Failed to detach all loop devices. Skip this try.
reboot -f
}
# use the first found directory in the tar archive
local board_dir=$(tar tf $tar_file | grep -m 1 '^sysupgrade-.*/$')
board_dir=${board_dir%/}
echo "flashing kernel to $kernel"
tar xf $tar_file ${board_dir}/kernel -O >$kernel
echo "flashing rootfs to ${rootfs}"
tar xf $tar_file ${board_dir}/root -O >"${rootfs}"
# a padded rootfs is needed for overlay fs creation
local offset=$(tar xf $tar_file ${board_dir}/root -O | wc -c)
[ $offset -lt 65536 ] && {
echo Wrong size for rootfs: $offset
sleep 10
reboot -f
}
# Mount loop for rootfs_data
local loopdev="$(losetup -f)"
losetup -o $offset $loopdev $rootfs || {
echo "Failed to mount looped rootfs_data."
sleep 10
reboot -f
}
echo "Format new rootfs_data at position ${offset}."
mkfs.ext4 -F -L rootfs_data $loopdev
mkdir /tmp/new_root
mount -t ext4 $loopdev /tmp/new_root && {
echo "Saving config to rootfs_data at position ${offset}."
cp -v "$UPGRADE_BACKUP" "/tmp/new_root/$BACKUP_FILE"
umount /tmp/new_root
}
# flashing successful, toggle the dualflag
case "$rootfs" in
"/dev/mmcblk0p5")
printf "\xff" >$dualflagmtd
;;
"/dev/mmcblk0p8")
printf "\x01" >$dualflagmtd
;;
esac
# Cleanup
losetup -d $loopdev >/dev/null 2>&1
sync
umount -a
reboot -f
}
zyxel_do_upgrade() {
local tar_file="$1"
local board=$(board_name)
local rootfs="$(zyxel_get_rootfs)"
local kernel=
[ -b "${rootfs}" ] || return 1
case "$board" in
zyxel,nbg6817)
local dualflagmtd="$(find_mtd_part 0:dual_flag)"
[ -b $dualflagmtd ] || return 1
case "$rootfs" in
"/dev/mmcblk0p5")
# booted from the primary partition set
# write to the alternative set
kernel="/dev/mmcblk0p7"
rootfs="/dev/mmcblk0p8"
;;
"/dev/mmcblk0p8")
# booted from the alternative partition set
# write to the primary set
kernel="/dev/mmcblk0p4"
rootfs="/dev/mmcblk0p5"
;;
*)
return 1
;;
esac
;;
*)
return 1
;;
esac
zyxel_do_flash $tar_file $kernel $rootfs $dualflagmtd
nand_do_upgrade "$1"
return 0
}

View File

@@ -0,0 +1,15 @@
#!/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

View File

@@ -0,0 +1,23 @@
#!/usr/bin/ucode
import { stdin, open, error } from 'fs';
if (length(ARGV) == 0 && stdin.isatty()) {
warn("usage: b64decode [stdin|path]\n");
exit(1);
}
let fp = stdin;
let source = ARGV[0];
if (source) {
fp = open(source);
if (!fp) {
warn('b64decode: unable to open ${source}: ${error()}\n');
exit(1);
}
}
print(b64dec(fp.read("all")));
fp.close();
exit(0);