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,59 @@
#!/bin/sh
# base on work of: Karol Przybylski <itor@o2.pl>
. /lib/functions.sh
get_gpio() {
local config_section="config"
config_load 'fanctld'
config_get FAN_GPIO "$config_section" Gpio
[ -z "$FAN_GPIO" ] || {
return 1
}
[ -f "/sys/class/gpio/$FAN_GPIO/value" ] || {
return 1
}
}
get_gpio
GPIO="$FAN_GPIO"
usage() {
echo "usage: $0 [start|stop|status]"
}
fan_start() {
echo 1 > /sys/class/gpio/$GPIO/value
}
fan_stop() {
echo 0 > /sys/class/gpio/$GPIO/value
}
fan_status() {
status=`cat /sys/class/gpio/$GPIO/value`
if [ $status = 0 ]; then
echo "disable"
else
echo "enable"
fi
}
case $1 in
start)
fan_start
;;
stop)
fan_stop
;;
status)
fan_status
;;
*)
usage
;;
esac
exit 0

View File

@@ -0,0 +1,77 @@
. /lib/functions/uci-defaults.sh
board_config_update
board=$(board_name)
case "$board" in
arcadyan,aw1000)
ucidef_set_led_netdev "5g" "5G" "green:5g" "wwan0"
ucidef_set_led_netdev "wan" "WAN" "green:internet" "wan"
ucidef_set_led_netdev "wan-port-link" "WAN-PORT-LINK" "90000.mdio-1:1c:green:wan" "wan" "tx rx link_10 link_100 link_1000 link_2500"
;;
asus,rt-ax89x)
ucidef_set_led_netdev "aqr" "AQR" "white:aqr10g" "10g-copper"
ucidef_set_led_netdev "sfp" "SFP" "white:sfp" "10g-sfp"
ucidef_set_led_netdev "wan" "WAN" "white:wan" "wan"
;;
dynalink,dl-wrx36)
ucidef_set_led_netdev "wan-port-link-green" "WAN-PORT-LINK-GREEN" "90000.mdio-1:1c:green:wan" "wan" "link_2500"
ucidef_set_led_netdev "wan-port-link-yellow" "WAN-PORT-LINK-YELLOW" "90000.mdio-1:1c:yellow:wan" "wan" "tx rx link_10 link_100 link_1000"
;;
edgecore,eap102)
ucidef_set_led_netdev "wan" "WAN" "green:wanpoe" "wan"
;;
netgear,rax120v2)
ucidef_set_led_netdev "aqr" "AQR" "white:aqr" "lan5"
;;
netgear,wax218)
ucidef_set_led_netdev "lan" "LAN" "blue:lan" "lan"
ucidef_set_led_wlan "wlan5g" "WIFI 5GHz" "blue:wlan5g" "phy0radio"
ucidef_set_led_wlan "wlan2g" "WIFI 2.4GHz" "blue:wlan2g" "phy1radio"
;;
netgear,wax620)
ucidef_set_led_netdev "lan" "LAN" "lan:green" "lan"
;;
netgear,wax630)
ucidef_set_led_netdev "lan1" "LAN1" "lan1:green" "lan1"
ucidef_set_led_netdev "lan2" "LAN2" "lan2:green" "lan2"
;;
redmi,ax6)
ucidef_set_led_netdev "wan" "WAN" "blue:network" "wan"
;;
xiaomi,ax3600)
ucidef_set_led_netdev "wan-port-link" "WAN-PORT-LINK" "90000.mdio-1:01:green:wan" "wan" "tx rx link_10 link_100 link_1000"
ucidef_set_led_netdev "lan1-port-link" "LAN1-PORT-LINK" "90000.mdio-1:02:green:lan" "lan1" "tx rx link_10 link_100 link_1000"
ucidef_set_led_netdev "lan2-port-link" "LAN2-PORT-LINK" "90000.mdio-1:03:green:lan" "lan2" "tx rx link_10 link_100 link_1000"
ucidef_set_led_netdev "lan3-port-link" "LAN3-PORT-LINK" "90000.mdio-1:04:green:lan" "lan3" "tx rx link_10 link_100 link_1000"
ucidef_set_led_netdev "wan" "WAN" "blue:network" "wan"
;;
xiaomi,ax9000)
ucidef_set_led_netdev "wan-port-link" "WAN-PORT-LINK" "90000.mdio-1:18:green:wan" "wan" "tx rx link_10 link_100 link_1000 link_2500"
ucidef_set_led_netdev "lan1-port-link" "LAN1-PORT-LINK" "90000.mdio-1:03:green:lan" "lan1" "tx rx link_10 link_100 link_1000"
ucidef_set_led_netdev "lan2-port-link" "LAN2-PORT-LINK" "90000.mdio-1:02:green:lan" "lan2" "tx rx link_10 link_100 link_1000"
ucidef_set_led_netdev "lan3-port-link" "LAN3-PORT-LINK" "90000.mdio-1:01:green:lan" "lan3" "tx rx link_10 link_100 link_1000"
ucidef_set_led_netdev "lan4-port-link" "LAN4-PORT-LINK" "90000.mdio-1:00:green:lan" "lan4" "tx rx link_10 link_100 link_1000"
;;
qnap,301w)
ucidef_set_led_netdev "lan1" "LAN1" "green:lan-1" "lan1"
ucidef_set_led_netdev "lan2" "LAN2" "green:lan-2" "lan2"
ucidef_set_led_netdev "lan3" "LAN3" "green:lan-3" "lan3"
ucidef_set_led_netdev "lan4" "LAN4" "green:lan-4" "lan4"
ucidef_set_led_netdev "10G_1" "10G_1" "green:10g-1" "10g-1"
ucidef_set_led_netdev "10G_2" "10G_2" "green:10g-2" "10g-2"
;;
yuncore,ax880)
ucidef_set_led_netdev "wan-port-link" "WAN-PORT-LINK" "90000.mdio-1:18:green:wan" "wan" "tx rx link_10 link_100 link_1000 link_2500"
ucidef_set_led_netdev "lan-port-link" "LAN-PORT-LINK" "90000.mdio-1:1c:green:lan" "lan" "tx rx link_10 link_100 link_1000 link_2500"
;;
zbtlink,zbt-z800ax)
ucidef_set_led_netdev "internet" "Internet" "green:wan-online" "wan"
;;
esac
board_config_flush
exit 0

View File

@@ -0,0 +1,105 @@
#
# Copyright (c) 2015 The Linux Foundation. All rights reserved.
# Copyright (c) 2011-2015 OpenWrt.org
#
. /lib/functions/uci-defaults.sh
. /lib/functions/system.sh
ipq807x_setup_interfaces()
{
local board="$1"
case "$board" in
asus,rt-ax89x)
ucidef_set_interfaces_lan_wan "10g-sfp 10g-copper lan1 lan2 lan3 lan4 lan5 lan6 lan7 lan8" "wan"
;;
arcadyan,aw1000|\
buffalo,wxr-5950ax12|\
dynalink,dl-wrx36|\
linksys,mx5300|\
linksys,mx8500|\
xiaomi,ax9000|\
zbtlink,zbt-z800ax)
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
;;
cmcc,rm2-6)
ucidef_set_interfaces_lan_wan "lan plc" "wan"
;;
compex,wpq873|\
linksys,mx4200v1|\
linksys,mx4200v2|\
prpl,haze|\
redmi,ax6|\
spectrum,sax1v1k|\
xiaomi,ax3600)
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" "wan"
;;
edgecore,eap102|\
yuncore,ax880|\
zte,mf269)
ucidef_set_interfaces_lan_wan "lan" "wan"
;;
edimax,cax1800)
ucidef_set_interfaces_lan_wan "lan"
;;
netgear,rax120v2)
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4 lan5" "wan"
;;
netgear,sxr80|\
netgear,sxs80)
ucidef_set_interfaces_lan_wan "lan2 lan3 lan4 lan5" "wan"
;;
netgear,wax218|\
netgear,wax620)
ucidef_set_interface_lan "lan" "dhcp"
;;
netgear,wax630)
ucidef_set_interface_lan "lan1 lan2" "dhcp"
;;
qnap,301w)
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4 10g-2" "10g-1"
;;
zyxel,nbg7815)
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4 10g" "wan"
;;
*)
echo "Unsupported hardware. Network interfaces not initialized"
;;
esac
}
ipq807x_setup_macs()
{
local board="$1"
local lan_mac=""
local wan_mac=""
local label_mac=""
case "$board" in
linksys,mx4200v2)
label_mac=$(mtd_get_mac_ascii devinfo hw_mac_addr)
for i in $(seq 3 5); do
[ "$(mtd_get_mac_ascii u_env eth${i}addr)" != "$label_mac" ] && lan_mac=$label_mac
done
[ "$(mtd_get_mac_ascii u_env eth2addr)" != "$label_mac" ] && wan_mac=$label_mac
;;
linksys,mx8500)
label_mac=$(mtd_get_mac_ascii devinfo hw_mac_addr)
lan_mac=$(macaddr_add $label_mac 1)
wan_mac=$label_mac
;;
esac
[ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
[ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
[ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac
}
board_config_update
board=$(board_name)
ipq807x_setup_interfaces $board
ipq807x_setup_macs $board
board_config_flush
exit 0

View File

@@ -0,0 +1,8 @@
config fanctld 'config'
option Enabled '0'
option Gpio 'fan'
option Debug '0'
option Delay '5'
option Hits '3'
option Temp '75000'
option Hyst '5000'

View File

@@ -0,0 +1,118 @@
#!/bin/sh
[ -e /lib/firmware/$FIRMWARE ] && exit 0
. /lib/functions/caldata.sh
board=$(board_name)
case "$FIRMWARE" in
"ath11k/IPQ8074/hw2.0/cal-ahb-c000000.wifi.bin")
case "$board" in
asus,rt-ax89x)
CI_UBIPART="UBI_DEV"
caldata_extract_ubi "Factory" 0x1000 0x20000
;;
arcadyan,aw1000|\
buffalo,wxr-5950ax12|\
cmcc,rm2-6|\
compex,wpq873|\
dynalink,dl-wrx36|\
edgecore,eap102|\
edimax,cax1800|\
linksys,mx5300|\
netgear,wax218|\
qnap,301w|\
redmi,ax6|\
xiaomi,ax3600|\
xiaomi,ax9000|\
yuncore,ax880|\
zte,mf269)
caldata_extract "0:art" 0x1000 0x20000
;;
linksys,mx4200v1|\
linksys,mx8500)
caldata_extract "0:art" 0x1000 0x20000
ath11k_remove_regdomain
;;
linksys,mx4200v2)
caldata_extract "0:art" 0x1000 0x20000
label_mac=$(mtd_get_mac_ascii devinfo hw_mac_addr)
ath11k_patch_mac $(macaddr_add $label_mac 2) 0
ath11k_patch_mac $(macaddr_add $label_mac 1) 1
ath11k_patch_mac $(macaddr_add $label_mac 3) 2
ath11k_remove_regdomain
ath11k_set_macflag
;;
netgear,rax120v2)
caldata_extract "0:art" 0x1000 0x20000
ath11k_patch_mac $(mtd_get_mac_binary boarddata1 0xc) 0
ath11k_patch_mac $(mtd_get_mac_binary boarddata1 0x0) 1
ath11k_patch_mac $(mtd_get_mac_binary boarddata1 0x6) 2
ath11k_set_macflag
;;
netgear,sxr80|\
netgear,sxs80)
caldata_extract "0:art" 0x1000 0x20000
label_mac=$(get_mac_label)
ath11k_patch_mac $(mtd_get_mac_binary boarddata1 0x0c) 0
#boarddata1 doesn't have a MAC for the 2G interface
ath11k_patch_mac $(macaddr_setbit_la $label_mac) 1
ath11k_patch_mac $(mtd_get_mac_binary boarddata1 0x12) 2
ath11k_set_macflag
;;
netgear,wax620)
caldata_extract "0:art" 0x1000 0x20000
label_mac=$(get_mac_label)
ath11k_patch_mac $(macaddr_add $label_mac -31) 1
ath11k_patch_mac $(macaddr_add $label_mac 1) 0
ath11k_set_macflag
;;
netgear,wax630)
caldata_extract "0:art" 0x1000 0x20000
label_mac=$(get_mac_label)
ath11k_patch_mac $(macaddr_add $label_mac -31) 1
ath11k_patch_mac $(macaddr_add $label_mac 1) 0
ath11k_patch_mac $(macaddr_add $label_mac 33) 2
ath11k_set_macflag
;;
prpl,haze|\
spectrum,sax1v1k)
caldata_extract_mmc "0:ART" 0x1000 0x20000
;;
zbtlink,zbt-z800ax)
caldata_extract "0:art" 0x1000 0x20000
label_mac=$(get_mac_label)
ath11k_patch_mac $(macaddr_add $label_mac -1) 0
ath11k_patch_mac $(macaddr_add $label_mac -2) 1
ath11k_set_macflag
;;
zyxel,nbg7815)
caldata_extract "0:art" 0x1000 0x20000
label_mac=$(get_mac_label)
ath11k_patch_mac $(macaddr_add $label_mac 3) 0
ath11k_patch_mac $(macaddr_add $label_mac 2) 1
ath11k_patch_mac $(macaddr_add $label_mac 4) 2
ath11k_set_macflag
;;
esac
;;
"ath11k/QCN9074/hw1.0/cal-pci-0000:01:00.0.bin"|\
"ath11k/QCN9074/hw1.0/cal-pci-0001:01:00.0.bin")
case "$board" in
linksys,mx8500)
caldata_extract "0:art" 0x26800 0x20000
ath11k_remove_regdomain
;;
prpl,haze)
caldata_extract_mmc "0:ART" 0x26800 0x20000
;;
xiaomi,ax9000)
caldata_extract "0:art" 0x26800 0x20000
;;
esac
;;
*)
exit 1
;;
esac

View File

@@ -0,0 +1,68 @@
#!/bin/sh
# This must run before 10-wifi-detect
[ "${ACTION}" = "add" ] || return
. /lib/functions.sh
check_kernel()
{
local kernel_current=$(uname -r)
if [ ${kernel_current//./} -lt "6600" ]; then
return 1
fi
}
do_migrate_radio()
{
local cfg="$1" from="$2" to="$3"
config_get path "$cfg" path
[ "$path" = "$from" ] || return
uci set "wireless.${cfg}.path=${to}"
WIRELESS_CHANGED=true
logger -t wifi-migrate "Updated path of wireless.${cfg} from '${from}' to '${to}'"
}
check_path()
{
local config
config="$1"
config_get path "$config" path
to=${path/soc\//soc@0\/}
# Checks if kernel version is less than 6.6.0, if it is and the path is using the new format,
# then path should be migrated to the old format. This would allow users on platforms with two partitions,
# to test 6.1 and 6.6.
check_kernel || to=${path/soc@0\//soc\/}
[ "$path" = "$to" ] || do_migrate_radio "$config" "$path" "$to"
}
migrate_radio()
{
config_load wireless
# Check if there is already a section with the target path: In this case, the system
# was already upgraded to a version without this migration script before; better bail out,
# as we can't be sure we don't break more than we fix.
config_foreach check_path wifi-device
}
WIRELESS_CHANGED=false
case "$(board_name)" in
*)
migrate_radio
;;
esac
$WIRELESS_CHANGED && uci commit wireless
exit 0

View File

@@ -0,0 +1,26 @@
[ "$ACTION" == "add" ] || exit 0
PHYNBR=${DEVPATH##*/phy}
[ -n $PHYNBR ] || exit 0
. /lib/functions.sh
. /lib/functions/system.sh
board=$(board_name)
case "$board" in
arcadyan,aw1000)
[ "$PHYNBR" = "0" ] && macaddr_add $(get_mac_label) 1 > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "1" ] && macaddr_add $(get_mac_label) 2 > /sys${DEVPATH}/macaddress
;;
buffalo,wxr-5950ax12)
[ "$PHYNBR" = "0" ] && macaddr_add $(get_mac_label) 8 > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "1" ] && macaddr_add $(get_mac_label) 16 > /sys${DEVPATH}/macaddress
;;
cmcc,rm2-6|\
zte,mf269)
[ "$PHYNBR" = "0" ] && macaddr_add $(get_mac_label) 2 > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "1" ] && macaddr_add $(get_mac_label) 3 > /sys${DEVPATH}/macaddress
;;
esac

View File

@@ -0,0 +1,25 @@
#!/bin/sh /etc/rc.common
START=99
boot() {
case $(board_name) in
edgecore,eap102|\
yuncore,ax880)
fw_setenv upgrade_available 0
# Unset changed flag after sysupgrade complete
fw_setenv changed
;;
linksys,mx4200v1|\
linksys,mx4200v2|\
linksys,mx5300|\
linksys,mx8500)
mtd resetbc s_env || true
;;
esac
#stability increase reserved mem to avoid oom when services are used that consume large amounts of mem e.g. samba with attached usb disk etc.
sysctl -w vm.min_free_kbytes=65536
#use vimrc with enabled copy and paste: set mouse-=a
cp /usr/share/vim/vimrc /root/.vimrc
}

View File

@@ -0,0 +1,26 @@
#!/bin/sh /etc/rc.common
START=95
USE_PROCD=1
PROG=/sbin/fanctld
start_service() {
local config_section="config"
config_load 'fanctld'
config_get_bool enabled "$config_section" Enabled
[ "$enabled" -gt 0 ] || {
return 1
}
procd_open_instance
procd_set_param command "$PROG"
procd_set_param respawn
procd_close_instance
}
stop_service() {
/bin/fanctl stop
echo "Fanctld Service stopped. Fan is disabled!"
}

View File

@@ -0,0 +1,122 @@
#!/bin/sh /etc/rc.common
######################################################################
# vim: set ft=bash
# shellcheck disable=2155,3019,3043,3057,3060
######################################################################
START=93
PROG=smp_affinity
log_msg() {
local irq_name="$1" affinity="$2" irq="$3"
msg="$(printf "Pinning IRQ($irq) %-24s to CPU ${affinity}\n" "$irq_name")"
logger -t "$PROG" "$msg"
}
######################################################################
### Takes a comma, space separated, or range list of CPU numbers and
## returns a bitmask of CPUs.
## cpus_to_bitmask "0,1,2,3" -> f
## cpus_to_bitmask "0 1 2 3" -> f
## cpus_to_bitmask "0-3" -> f
## cpus_to_bitmask "3" -> 8
#######################################################################
cpus_to_bitmask() {
local bitmask=0
# shellcheck disable=2048
for range in ${*//,/ }; do
start="${range%-*}"
end="${range#*-}"
if [ -z "$end" ]; then
bitmask="$((bitmask | 1 << start))"
else
bitmask="$((bitmask | (2 ** (end - start + 1) - 1) << start))"
fi
done
printf '%x' $bitmask
}
######################################################################
### Takes a bitmask of CPUs and returns a space separated list of
## CPU numbers.
## bitmask_to_cpus f -> 0 1 2 3
######################################################################
bitmask_to_cpus() {
[ "${1:0:2}" != "0x" ] && set -- "0x$1"
local bitmask="$(printf '%d' "$1")"
local cpus=""
for i in $(seq 0 63); do
if [ $((bitmask & 1)) -ne 0 ]; then
cpus="$cpus $i"
fi
bitmask=$((bitmask >> 1))
done
echo "${cpus# }"
}
######################################################################
### Sets the affinity of the IRQs with the given name to the given CPU.
## 1st argument: IRQ name ("reo2host-destination-ring1") (req)
## 2nd argument: CPU number (req)
######################################################################
set_affinity() {
local irq_name="$1" affinity="$2" bitmask irq
awk -v irq_name="$1" '$0 ~ irq_name { print substr($1, 1, length($1)-1); exit }' /proc/interrupts \
| while read -r irq; do
$enable_log && {
log_msg "$irq_name" "$affinity" "$irq"
}
bitmask=$(cpus_to_bitmask "$affinity") && echo "$bitmask" > "/proc/irq/$irq/smp_affinity"
done
}
enable_affinity_ipq807x() {
# assign 4 rx interrupts to each core
set_affinity 'reo2host-destination-ring1' 0
set_affinity 'reo2host-destination-ring2' 1
set_affinity 'reo2host-destination-ring3' 2
set_affinity 'reo2host-destination-ring4' 3
# assign 3 tcl completions to last 3 CPUs
set_affinity 'wbm2host-tx-completions-ring1' 1
set_affinity 'wbm2host-tx-completions-ring2' 2
set_affinity 'wbm2host-tx-completions-ring3' 3
# assign 3 ppdu mac interrupts to last 3 cores
set_affinity 'ppdu-end-interrupts-mac1' 1
set_affinity 'ppdu-end-interrupts-mac2' 2
set_affinity 'ppdu-end-interrupts-mac3' 3
# assign 4 lan/wan to core 4
set_affinity 'edma_txcmpl' 3
set_affinity 'edma_rxfill' 3
set_affinity 'edma_rxdesc' 3
set_affinity 'edma_misc' 3
}
boot() {
local enable
config_load smp_affinity
config_get_bool enable "general" enable 1
config_get_bool enable_log "general" enable_log 1
[ "$enable" -eq 1 ] && enable=true || enable=false
[ "$enable_log" -eq 1 ] && enable_log=true || enable_log=false
$enable && enable_affinity_ipq807x
}

View File

@@ -0,0 +1,23 @@
#!/bin/sh
. /lib/functions.sh
board=$(board_name)
case "$board" in
zyxel,nbg7815)
local config_section="config"
uci set fanctld.$config_section.Enabled='1'
uci set fanctld.$config_section.Gpio='fan'
uci set fanctld.$config_section.Temp='75000'
uci set fanctld.$config_section.Hyst='5000'
uci set fanctld.$config_section.Debug='0'
uci set fanctld.$config_section.Delay='5'
uci set fanctld.$config_section.Hits='3'
uci commit fanctld
/etc/init.d/fanctld enable
/etc/init.d/fanctld start
;;
esac
exit 0

View File

@@ -0,0 +1,11 @@
#!/bin/sh
uci -q get smp_affinity && exit 0
touch /etc/config/smp_affinity
uci -q batch << EOF
set smp_affinity.general=smp_affinity
set smp_affinity.general.enable='1'
set smp_affinity.general.enable_log='1'
commit smp_affinity
EOF

View File

@@ -0,0 +1,55 @@
. /lib/functions.sh
# Prepare UBI devices for OpenWrt installation
# - rootfs (mtd22)
# - remove "ubi_rootfs" volume (rootfs on stock)
# - remove "fw_hash" volume (firmware hash)
# - user_property (mtd24)
# - remove "user_property_ubi" volume (user configuration)
# - remove "extra_property" volume (gzipped syslog)
buffalo_upgrade_prepare() {
local ubi_rootdev ubi_propdev
if ! ubi_rootdev="$(nand_attach_ubi rootfs)" || \
! ubi_propdev="$(nand_attach_ubi user_property)"; then
echo "failed to attach UBI volume \"rootfs\" or \"user_property\", rebooting..."
reboot -f
fi
ubirmvol /dev/$ubi_rootdev -N ubi_rootfs &> /dev/null || true
ubirmvol /dev/$ubi_rootdev -N fw_hash &> /dev/null || true
ubirmvol /dev/$ubi_propdev -N user_property_ubi &> /dev/null || true
ubirmvol /dev/$ubi_propdev -N extra_property &> /dev/null || true
}
# Re-create small dummy ubi_rootfs volume and update
# fw_hash volume to pass the checking by U-Boot
# - rootfs (mtd22)
# - re-create "ubi_rootfs" volume
# - re-create and update "fw_hash" volume
# - rootfs_recover (mtd23)
# - update "fw_hash" volume
buffalo_upgrade_optvol() {
local ubi_rootdev ubi_rcvrdev
local hashvol_root hashvol_rcvr
if ! ubi_rootdev="$(nand_attach_ubi rootfs)" || \
! ubi_rcvrdev="$(nand_attach_ubi rootfs_recover)"; then
echo "failed to attach UBI volume \"rootfs\" or \"rootfs_recover\", rebooting..."
reboot -f
fi
ubimkvol /dev/$ubi_rootdev -N ubi_rootfs -S 1
ubimkvol /dev/$ubi_rootdev -N fw_hash -S 1 -t static
if ! hashvol_root="$(nand_find_volume $ubi_rootdev fw_hash)" || \
! hashvol_rcvr="$(nand_find_volume $ubi_rcvrdev fw_hash)"; then
echo "\"fw_hash\" volume in \"rootfs\" or \"rootfs_recover\" not found, rebooting..."
reboot -f
fi
echo -n "00000000000000000000000000000000" > /tmp/dummyhash.txt
ubiupdatevol /dev/$hashvol_root /tmp/dummyhash.txt
ubiupdatevol /dev/$hashvol_rcvr /tmp/dummyhash.txt
}

View File

@@ -0,0 +1,83 @@
#
# Copyright (C) 2016 lede-project.org
#
# this can be used as a generic mmc upgrade script
# just add a device entry in platform.sh,
# define "kernelname" and "rootfsname" and call mmc_do_upgrade
# after the kernel and rootfs flash a loopdev (as overlay) is
# setup on top of the rootfs partition
# for the proper function a padded rootfs image is needed, basically
# append "pad-to 64k" to the image definition
# this is based on the ipq806x zyxel.sh mmc upgrade
. /lib/functions.sh
mmc_do_upgrade() {
local tar_file="$1"
local rootfs=
local kernel=
[ -z "$kernel" ] && kernel=$(find_mmc_part ${kernelname})
[ -z "$rootfs" ] && rootfs=$(find_mmc_part ${rootfsname})
[ -z "$kernel" ] && echo "Upgrade failed: kernel partition not found! Rebooting..." && reboot -f
[ -z "$rootfs" ] && echo "Upgrade failed: rootfs partition not found! Rebooting..." && reboot -f
mmc_do_flash $tar_file $kernel $rootfs
return 0
}
mmc_do_flash() {
local tar_file=$1
local kernel=$2
local rootfs=$3
# 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
}
# Cleanup
losetup -d $loopdev >/dev/null 2>&1
sync
umount -a
reboot -f
}

View File

@@ -0,0 +1,188 @@
PART_NAME=firmware
REQUIRE_IMAGE_METADATA=1
RAMFS_COPY_BIN='fw_printenv fw_setenv head'
RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock'
xiaomi_initramfs_prepare() {
# Wipe UBI if running initramfs
[ "$(rootfs_type)" = "tmpfs" ] || return 0
local rootfs_mtdnum="$( find_mtd_index rootfs )"
if [ ! "$rootfs_mtdnum" ]; then
echo "unable to find mtd partition rootfs"
return 1
fi
local kern_mtdnum="$( find_mtd_index ubi_kernel )"
if [ ! "$kern_mtdnum" ]; then
echo "unable to find mtd partition ubi_kernel"
return 1
fi
ubidetach -m "$rootfs_mtdnum"
ubiformat /dev/mtd$rootfs_mtdnum -y
ubidetach -m "$kern_mtdnum"
ubiformat /dev/mtd$kern_mtdnum -y
}
asus_initial_setup() {
# Remove existing linux and jffs2 volumes
[ "$(rootfs_type)" = "tmpfs" ] || return 0
ubirmvol /dev/ubi0 -N linux
ubirmvol /dev/ubi0 -N jffs2
}
platform_check_image() {
return 0;
}
platform_pre_upgrade() {
case "$(board_name)" in
asus,rt-ax89x)
asus_initial_setup
;;
redmi,ax6|\
xiaomi,ax3600|\
xiaomi,ax9000)
xiaomi_initramfs_prepare
;;
esac
}
platform_do_upgrade() {
case "$(board_name)" in
arcadyan,aw1000|\
cmcc,rm2-6|\
compex,wpq873|\
dynalink,dl-wrx36|\
edimax,cax1800|\
netgear,rax120v2|\
netgear,sxr80|\
netgear,sxs80|\
netgear,wax218|\
netgear,wax620|\
netgear,wax630)
nand_do_upgrade "$1"
;;
asus,rt-ax89x)
CI_UBIPART="UBI_DEV"
CI_KERNPART="linux"
CI_ROOTPART="jffs2"
nand_do_upgrade "$1"
;;
buffalo,wxr-5950ax12)
CI_KERN_UBIPART="rootfs"
CI_ROOT_UBIPART="user_property"
buffalo_upgrade_prepare
nand_do_flash_file "$1" || nand_do_upgrade_failed
nand_do_restore_config || nand_do_upgrade_failed
buffalo_upgrade_optvol
;;
edgecore,eap102)
active="$(fw_printenv -n active)"
if [ "$active" -eq "1" ]; then
CI_UBIPART="rootfs2"
else
CI_UBIPART="rootfs1"
fi
# force altbootcmd which handles partition change in u-boot
fw_setenv bootcount 3
fw_setenv upgrade_available 1
nand_do_upgrade "$1"
;;
linksys,mx4200v1|\
linksys,mx4200v2|\
linksys,mx5300|\
linksys,mx8500)
boot_part="$(fw_printenv -n boot_part)"
if [ "$boot_part" -eq "1" ]; then
fw_setenv boot_part 2
CI_KERNPART="alt_kernel"
CI_UBIPART="alt_rootfs"
else
fw_setenv boot_part 1
CI_UBIPART="rootfs"
fi
fw_setenv boot_part_ready 3
fw_setenv auto_recovery yes
nand_do_upgrade "$1"
;;
prpl,haze|\
qnap,301w|\
spectrum,sax1v1k)
kernelname="0:HLOS"
rootfsname="rootfs"
mmc_do_upgrade "$1"
;;
redmi,ax6|\
xiaomi,ax3600|\
xiaomi,ax9000)
# Make sure that UART is enabled
fw_setenv boot_wait on
fw_setenv uart_en 1
# Enforce single partition.
fw_setenv flag_boot_rootfs 0
fw_setenv flag_last_success 0
fw_setenv flag_boot_success 1
fw_setenv flag_try_sys1_failed 8
fw_setenv flag_try_sys2_failed 8
# Kernel and rootfs are placed in 2 different UBI
CI_KERN_UBIPART="ubi_kernel"
CI_ROOT_UBIPART="rootfs"
nand_do_upgrade "$1"
;;
yuncore,ax880)
active="$(fw_printenv -n active)"
if [ "$active" -eq "1" ]; then
CI_UBIPART="rootfs_1"
else
CI_UBIPART="rootfs"
fi
# force altbootcmd which handles partition change in u-boot
fw_setenv bootcount 3
fw_setenv upgrade_available 1
nand_do_upgrade "$1"
;;
zbtlink,zbt-z800ax)
local mtdnum="$(find_mtd_index 0:bootconfig)"
local alt_mtdnum="$(find_mtd_index 0:bootconfig1)"
part_num="$(hexdump -e '1/1 "%01x|"' -n 1 -s 168 -C /dev/mtd$mtdnum | cut -f 1 -d "|" | head -n1)"
# vendor firmware may swap the rootfs partition location, u-boot append: ubi.mtd=rootfs
# since we use fixed-partitions, need to force boot from the first rootfs partition
if [ "$part_num" -eq "1" ]; then
mtd erase /dev/mtd$mtdnum
mtd erase /dev/mtd$alt_mtdnum
fi
nand_do_upgrade "$1"
;;
zte,mf269)
CI_KERN_UBIPART="ubi_kernel"
CI_ROOT_UBIPART="rootfs"
nand_do_upgrade "$1"
;;
zyxel,nbg7815)
echo 3 > /sys/devices/platform/soc@0/78b6000.i2c/i2c-0/0-0032/led_pattern
echo 1 > /sys/devices/platform/soc@0/78b6000.i2c/i2c-0/0-0032/run_engine
local config_mtdnum="$(find_mtd_index 0:bootconfig)"
[ -z "$config_mtdnum" ] && reboot
part_num="$(hexdump -e '1/1 "%01x|"' -n 1 -s 168 -C /dev/mtd$config_mtdnum | cut -f 1 -d "|" | head -n1)"
if [ "$part_num" -eq "0" ]; then
kernelname="0:HLOS"
rootfsname="rootfs"
mmc_do_upgrade "$1"
else
kernelname="0:HLOS_1"
rootfsname="rootfs_1"
mmc_do_upgrade "$1"
fi
;;
*)
default_do_upgrade "$1"
;;
esac
}

View File

@@ -0,0 +1,116 @@
#!/bin/sh
. /lib/functions.sh
dlog() {
[ $debug = '1' ] && echo "$@" >> /tmp/fanctld.log
}
load_config() {
local config_section="config"
config_load 'fanctld'
config_get enabled "$config_section" Enabled
config_get fan_gpio "$config_section" Gpio
config_get debug "$config_section" Debug
config_get delay "$config_section" Delay
config_get hit_level "$config_section" Hits
config_get temp_trip "$config_section" Temp
config_get temp_hyst "$config_section" Hyst
}
load_config
temp_clr=$((($temp_trip)-($temp_hyst)))
nss_temp() {
cat /sys/class/thermal/thermal_zone0/temp
}
cpu_temp() {
cat /sys/class/thermal/thermal_zone9/temp
}
wifi0_temp() {
cat /sys/devices/platform/soc@0/c000000.wifi/ieee80211/phy0/hwmon*/temp1_input
}
wifi1_temp() {
cat /sys/devices/platform/soc@0/c000000.wifi/ieee80211/phy1/hwmon*/temp1_input
}
wifi2_temp() {
cat /sys/devices/platform/soc@0/c000000.wifi/ieee80211/phy2/hwmon*/temp1_input
}
aqr_temp() {
cat /sys/devices/platform/soc@0/90000.mdio/mdio_bus/90000.mdio-1/90000.mdio-1:08/hwmon/hwmon*/temp1_input
}
check_temps() {
temp1=$(nss_temp)
temp2=$(cpu_temp)
temp3=$(($(wifi0_temp)-1000))
temp4=$(($(wifi1_temp)))
temp5=$(($(wifi2_temp)-2000))
temp6=$(($(aqr_temp)-2000))
dlog "nss_temp=$temp1 cpu_temp=$temp2 wifi0_temp=$temp3 wifi1_temp=$temp4 wifi2_temp=$temp5 aqr_temp=$temp6"
load_config
if [ $temp1 -ge $temp_trip -o $temp2 -ge $temp_trip -o $temp3 -ge $temp_trip -o $temp4 -ge $temp_trip -o $temp5 -ge $temp_trip -o $temp6 -ge $temp_trip ]; then
echo 2
elif [ $temp1 -le $temp_clr -a $temp2 -le $temp_clr -a $temp3 -le $temp_clr -a $temp4 -le $temp_clr -a $temp5 -le $temp_clr -a $temp6 -le $temp_clr ]; then
echo 1
else
echo 0
fi
}
fan_status() {
fanctl status
}
load_config
dlog "----- fanctld debug log -----"
dlog "enabled=$enabled, delay=$delay, hit_level=$hit_level, temp=$temp_trip, hyst=$temp_hyst, debug=$debug"
>> /tmp/fanctld.log
trip_hits=0
clr_hits=0
while true; do
sleep $delay
result=$(check_temps)
if [ $result = '2' ]; then
trip_hits=$((trip_hits+1))
elif [ $result = '1' ]; then
clr_hits=$((clr_hits+1))
else
trip_hits=0
clr_hits=0
fi
if [ $trip_hits -ge $hit_level ]; then
trip_hits=0
if [ $(fan_status) = 'disable' ]; then
fanctl start
logger -p info -t fanctld "Fan switch on temperature reached ("$temp_trip"), start fan"
fi
elif [ $clr_hits -ge $hit_level ]; then
clr_hits=0
if [ $(fan_status) = 'enable' ]; then
fanctl stop
logger -p info -t fanctld "Fan switch off temperature reached ("$temp_clr"), stop fan"
fi
fi
done

View File

@@ -0,0 +1,12 @@
#!/bin/sh
echo $1 > /sys/devices/platform/soc@0/78b6000.i2c/i2c-0/0-0032/led_pattern
echo 1 > /sys/devices/platform/soc@0/78b6000.i2c/i2c-0/0-0032/run_engine
echo $2 > /sys/devices/platform/soc@0/78b6000.i2c/i2c-0/0-0035/led_pattern
echo 1 > /sys/devices/platform/soc@0/78b6000.i2c/i2c-0/0-0035/run_engine
#for testing
#solid blue echo 11 > /sys/devices/platform/soc@0/78b6000.i2c/i2c-0/0-0032/led_pattern
#light solid blue echo 15 > /sys/devices/platform/soc@0/78b6000.i2c/i2c-0/0-0032/led_pattern
#red blink echo 3 > /sys/devices/platform/soc@0/78b6000.i2c/i2c-0/0-0032/led_pattern

View File

@@ -0,0 +1,40 @@
CONFIG_ARM_PSCI_CPUIDLE_DOMAIN=y
CONFIG_DT_IDLE_GENPD=y
CONFIG_GRO_CELLS=y
CONFIG_IPQ_GCC_8074=y
CONFIG_MDIO_BITBANG=y
CONFIG_MDIO_GPIO=y
# CONFIG_MFD_HI6421_SPMI is not set
CONFIG_MFD_SPMI_PMIC=y
CONFIG_NET_DEVLINK=y
CONFIG_NET_DSA=y
CONFIG_NET_DSA_QCA8K=y
CONFIG_NET_DSA_TAG_QCA=y
# CONFIG_NVMEM_SPMI_SDAM is not set
CONFIG_PHYLINK=y
CONFIG_PINCTRL_IPQ8074=y
CONFIG_PINCTRL_QCOM_SPMI_PMIC=y
# CONFIG_PM8916_WATCHDOG is not set
CONFIG_PM_GENERIC_DOMAINS=y
CONFIG_PM_GENERIC_DOMAINS_OF=y
# CONFIG_POWER_RESET_QCOM_PON is not set
CONFIG_QCA83XX_PHY=y
CONFIG_QCOM_APM=y
# CONFIG_QCOM_COINCELL is not set
CONFIG_QCOM_GDSC=y
CONFIG_QCOM_SPMI_ADC5=y
# CONFIG_QCOM_SPMI_RRADC is not set
CONFIG_QCOM_VADC_COMMON=y
CONFIG_REGMAP_SPMI=y
CONFIG_REGULATOR_CPR3=y
# CONFIG_REGULATOR_CPR3_NPU is not set
CONFIG_REGULATOR_CPR4_APSS=y
# CONFIG_REGULATOR_QCOM_LABIBB is not set
CONFIG_REGULATOR_QCOM_SPMI=y
# CONFIG_REGULATOR_QCOM_USB_VBUS is not set
CONFIG_REGULATOR_USERSPACE_CONSUMER=y
CONFIG_RTC_DRV_PM8XXX=y
CONFIG_SPMI=y
# CONFIG_SPMI_HISI3670 is not set
CONFIG_SPMI_MSM_PMIC_ARB=y
# CONFIG_SPMI_PMIC_CLKDIV is not set

View File

@@ -0,0 +1,7 @@
SUBTARGET:=ipq807x
BOARDNAME:=Qualcomm Atheros IPQ807x
DEFAULT_PACKAGES += kmod-phy-aquantia ath11k-firmware-ipq8074
define Target/Description
Build firmware images for Qualcomm Atheros IPQ807x based boards.
endef