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
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:
61
target/linux/mvebu/cortexa9/base-files/etc/board.d/01_leds
Normal file
61
target/linux/mvebu/cortexa9/base-files/etc/board.d/01_leds
Normal file
@@ -0,0 +1,61 @@
|
||||
#
|
||||
# Copyright (C) 2014-2016 OpenWrt.org
|
||||
# Copyright (C) 2016 LEDE-Project.org
|
||||
#
|
||||
|
||||
. /lib/functions/uci-defaults.sh
|
||||
|
||||
board_config_update
|
||||
|
||||
board=$(board_name)
|
||||
boardname="${board##*,}"
|
||||
|
||||
case "$board" in
|
||||
ctera,c200-v2)
|
||||
ucidef_set_led_usbport "usb2" "USB2" "green:usb-2" "usb1-port1" "usb2-port1"
|
||||
ucidef_set_led_usbport "usb3" "USB3" "green:usb-1" "usb1-port2" "usb2-port2"
|
||||
;;
|
||||
kobol,helios4)
|
||||
ucidef_set_led_usbport "USB" "USB" "helios4:green:usb" "usb1-port1" "usb2-port1" "usb3-port1" "usb4-port1" "usb5-port1"
|
||||
;;
|
||||
linksys,wrt1200ac)
|
||||
ucidef_set_led_netdev "wan" "WAN" "pca963x:caiman:white:wan" "wan"
|
||||
ucidef_set_led_usbport "usb1" "USB 1" "pca963x:caiman:white:usb2" "usb1-port1"
|
||||
ucidef_set_led_usbport "usb2" "USB 2" "pca963x:caiman:white:usb3_1" "usb2-port1" "usb3-port1"
|
||||
ucidef_set_led_usbport "usb2_ss" "USB 2 SS" "pca963x:caiman:white:usb3_2" "usb3-port1"
|
||||
;;
|
||||
linksys,wrt1900ac-v1)
|
||||
ucidef_set_led_netdev "wan" "WAN" "mamba:white:wan" "wan"
|
||||
ucidef_set_led_usbport "usb1" "USB 1" "mamba:white:usb2" "usb1-port1"
|
||||
ucidef_set_led_usbport "usb2" "USB 2" "mamba:white:usb3_1" "usb2-port1" "usb3-port1"
|
||||
ucidef_set_led_usbport "usb2_ss" "USB 2 SS" "mamba:white:usb3_2" "usb3-port2"
|
||||
;;
|
||||
linksys,wrt1900ac-v2)
|
||||
ucidef_set_led_netdev "wan" "WAN" "pca963x:cobra:white:wan" "wan"
|
||||
ucidef_set_led_usbport "usb1" "USB 1" "pca963x:cobra:white:usb2" "usb1-port1"
|
||||
ucidef_set_led_usbport "usb2" "USB 2" "pca963x:cobra:white:usb3_1" "usb2-port1" "usb3-port1"
|
||||
ucidef_set_led_usbport "usb2_ss" "USB 2 SS" "pca963x:cobra:white:usb3_2" "usb3-port1"
|
||||
;;
|
||||
linksys,wrt1900acs)
|
||||
ucidef_set_led_netdev "wan" "WAN" "pca963x:shelby:white:wan" "wan"
|
||||
ucidef_set_led_usbport "usb1" "USB 1" "pca963x:shelby:white:usb2" "usb1-port1"
|
||||
ucidef_set_led_usbport "usb2" "USB 2" "pca963x:shelby:white:usb3_1" "usb2-port1" "usb3-port1"
|
||||
ucidef_set_led_usbport "usb2_ss" "USB 2 SS" "pca963x:shelby:white:usb3_2" "usb3-port1"
|
||||
;;
|
||||
linksys,wrt3200acm)
|
||||
ucidef_set_led_netdev "wan" "WAN" "pca963x:rango:white:wan" "wan"
|
||||
ucidef_set_led_usbport "usb1" "USB 1" "pca963x:rango:white:usb2" "usb1-port1"
|
||||
ucidef_set_led_usbport "usb2" "USB 2" "pca963x:rango:white:usb3_1" "usb2-port1" "usb3-port1"
|
||||
ucidef_set_led_usbport "usb2_ss" "USB 2 SS" "pca963x:rango:white:usb3_2" "usb3-port1"
|
||||
;;
|
||||
linksys,wrt32x)
|
||||
ucidef_set_led_netdev "wan" "WAN" "pca963x:venom:blue:wan" "wan"
|
||||
ucidef_set_led_usbport "usb1" "USB 1" "pca963x:venom:blue:usb2" "usb1-port1"
|
||||
ucidef_set_led_usbport "usb2" "USB 2" "pca963x:venom:blue:usb3_1" "usb2-port1" "usb3-port1"
|
||||
ucidef_set_led_usbport "usb2_ss" "USB 2 SS" "pca963x:venom:blue:usb3_2" "usb3-port1"
|
||||
;;
|
||||
esac
|
||||
|
||||
board_config_flush
|
||||
|
||||
exit 0
|
||||
110
target/linux/mvebu/cortexa9/base-files/etc/board.d/02_network
Normal file
110
target/linux/mvebu/cortexa9/base-files/etc/board.d/02_network
Normal file
@@ -0,0 +1,110 @@
|
||||
#
|
||||
# Copyright (C) 2014-2016 OpenWrt.org
|
||||
# Copyright (C) 2016 LEDE-Project.org
|
||||
#
|
||||
|
||||
. /lib/functions.sh
|
||||
. /lib/functions/uci-defaults.sh
|
||||
. /lib/functions/system.sh
|
||||
|
||||
mvebu_setup_interfaces()
|
||||
{
|
||||
local board="$1"
|
||||
|
||||
case "$board" in
|
||||
ctera,c200-v2|\
|
||||
synology,ds213j)
|
||||
ucidef_set_interface_lan "eth0" "dhcp"
|
||||
;;
|
||||
cznic,turris-omnia)
|
||||
ucidef_set_interfaces_lan_wan "lan0 lan1 lan2 lan3 lan4" "eth2"
|
||||
;;
|
||||
fortinet,fg-30e|\
|
||||
linksys,wrt1200ac|\
|
||||
linksys,wrt1900ac-v1|\
|
||||
linksys,wrt1900ac-v2|\
|
||||
linksys,wrt1900acs|\
|
||||
linksys,wrt3200acm|\
|
||||
linksys,wrt32x)
|
||||
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
|
||||
;;
|
||||
fortinet,fg-50e|\
|
||||
fortinet,fg-51e|\
|
||||
fortinet,fg-52e|\
|
||||
fortinet,fwf-50e-2r|\
|
||||
fortinet,fwf-51e)
|
||||
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4 lan5" "eth1 eth2"
|
||||
;;
|
||||
iij,sa-w2)
|
||||
ucidef_set_interfaces_lan_wan "ge1_0 ge1_1 ge1_2 ge1_3" "ge0"
|
||||
;;
|
||||
iptime,nas1dual)
|
||||
ucidef_set_interface_lan "eth0 eth1" "dhcp"
|
||||
;;
|
||||
marvell,a385-db-ap)
|
||||
ucidef_set_interfaces_lan_wan "eth0 eth1" "eth2"
|
||||
;;
|
||||
marvell,axp-gp)
|
||||
ucidef_set_interface_lan "eth0 eth1 eth2 eth3"
|
||||
;;
|
||||
solidrun,clearfog-base-a1)
|
||||
# eth0 is standalone ethernet
|
||||
# eth1 is standalone ethernet
|
||||
# eth2 is SFP
|
||||
ucidef_set_interfaces_lan_wan "eth1" "eth0 eth2"
|
||||
;;
|
||||
solidrun,clearfog-pro-a1)
|
||||
# eth0 is standalone ethernet
|
||||
# eth1 is switch
|
||||
# eth2 is SFP
|
||||
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4 lan5 lan6" "eth0 eth2"
|
||||
;;
|
||||
*)
|
||||
ucidef_set_interface_lan "eth0"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
mvebu_setup_macs()
|
||||
{
|
||||
local board="$1"
|
||||
local lan_mac=""
|
||||
local wan_mac=""
|
||||
local label_mac=""
|
||||
|
||||
case "$board" in
|
||||
buffalo,ls220de|\
|
||||
buffalo,ls421de)
|
||||
lan_mac=$(mtd_get_mac_ascii u-boot-env eth1addr)
|
||||
;;
|
||||
ctera,c200-v2)
|
||||
label_mac=$(mtd_get_mac_ascii dev_params mac)
|
||||
lan_mac=$label_mac
|
||||
;;
|
||||
linksys,wrt1200ac|\
|
||||
linksys,wrt1900ac-v2|\
|
||||
linksys,wrt1900acs|\
|
||||
linksys,wrt3200acm|\
|
||||
linksys,wrt32x)
|
||||
label_mac=$(mtd_get_mac_ascii devinfo hw_mac_addr)
|
||||
wan_mac=$(macaddr_setbit_la $label_mac)
|
||||
;;
|
||||
linksys,wrt1900ac-v1)
|
||||
label_mac=$(mtd_get_mac_ascii devinfo hw_mac_addr)
|
||||
lan_mac=$label_mac
|
||||
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)
|
||||
mvebu_setup_interfaces $board
|
||||
mvebu_setup_macs $board
|
||||
board_config_flush
|
||||
|
||||
exit 0
|
||||
@@ -0,0 +1,25 @@
|
||||
#
|
||||
# Copyright (C) 2020 OpenWrt.org
|
||||
#
|
||||
|
||||
. /lib/functions.sh
|
||||
. /lib/functions/uci-defaults.sh
|
||||
|
||||
board_config_update
|
||||
|
||||
case "$(board_name)" in
|
||||
linksys,wrt1200ac|\
|
||||
linksys,wrt1900ac-v1|\
|
||||
linksys,wrt1900ac-v2|\
|
||||
linksys,wrt1900acs|\
|
||||
linksys,wrt3200acm|\
|
||||
linksys,wrt32x|\
|
||||
solidrun,clearfog-base-a1|\
|
||||
solidrun,clearfog-pro-a1)
|
||||
ucidef_set_compat_version "1.1"
|
||||
;;
|
||||
esac
|
||||
|
||||
board_config_flush
|
||||
|
||||
exit 0
|
||||
@@ -0,0 +1,41 @@
|
||||
#!/bin/sh
|
||||
|
||||
# The pcie-controller device was renamed to pcie in Linux kernel 4.14
|
||||
# commit 28fbb9c539e2 ("ARM: dts: marvell: fix PCI bus dtc warnings").
|
||||
# This script migrates the path in the UCI configuration from the old
|
||||
# name to the new name and also back, when am upgrade or downgrade is
|
||||
# done. It checks if the name exists before changing the configuration.
|
||||
# This has to be done before the 10-wifi-detect script from mac80211 is
|
||||
# executed because this would add the devices again under the new path
|
||||
# name.
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
PATH_CHANGED=0
|
||||
|
||||
rename_wifi_path() {
|
||||
local path_old=$(uci get wireless.${1}.path)
|
||||
local path_new=$(echo ${path_old} | sed "${2}")
|
||||
|
||||
if [ -e "/sys/devices/platform/${path_new}" ] && [ ${path_old} != ${path_new} ]
|
||||
then
|
||||
uci set wireless.${1}.path=${path_new}
|
||||
PATH_CHANGED=1
|
||||
fi
|
||||
}
|
||||
|
||||
rename_wifi_path_list() {
|
||||
# migration from kernel 4.9 to 4.14
|
||||
rename_wifi_path $1 "s/soc:pcie-controller/soc:pcie/"
|
||||
# migration from kernel 4.14 to 4.9
|
||||
rename_wifi_path $1 "s/soc:pcie/soc:pcie-controller/"
|
||||
}
|
||||
|
||||
[ "${ACTION}" = "add" ] && {
|
||||
[ ! -e /etc/config/wireless ] && return
|
||||
|
||||
config_load wireless
|
||||
config_foreach rename_wifi_path_list wifi-device
|
||||
|
||||
[ "$PATH_CHANGED" = "1" ] && uci commit wireless
|
||||
}
|
||||
16
target/linux/mvebu/cortexa9/base-files/etc/init.d/bootcount
Executable file
16
target/linux/mvebu/cortexa9/base-files/etc/init.d/bootcount
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=99
|
||||
|
||||
boot() {
|
||||
case $(board_name) in
|
||||
linksys,wrt1200ac|\
|
||||
linksys,wrt1900ac-v1|\
|
||||
linksys,wrt1900ac-v2|\
|
||||
linksys,wrt1900acs|\
|
||||
linksys,wrt3200acm|\
|
||||
linksys,wrt32x)
|
||||
mtd resetbc s_env || true
|
||||
;;
|
||||
esac
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
#
|
||||
# Copyright (C) 2015 OpenWrt.org
|
||||
#
|
||||
|
||||
[ ! -e /etc/config/wireless ] && exit 0
|
||||
|
||||
. /lib/functions.sh
|
||||
. /lib/functions/system.sh
|
||||
|
||||
board=$(board_name)
|
||||
|
||||
case "$board" in
|
||||
linksys,wrt1200ac|\
|
||||
linksys,wrt1900ac-v1|\
|
||||
linksys,wrt1900ac-v2|\
|
||||
linksys,wrt1900acs|\
|
||||
linksys,wrt3200acm|\
|
||||
linksys,wrt32x)
|
||||
SKU=$(strings /dev/mtd3|sed -ne 's/^cert_region=//p')
|
||||
WIFIMAC2G=$(macaddr_add $(mtd_get_mac_ascii devinfo hw_mac_addr) 1)
|
||||
WIFIMAC5G=$(macaddr_add $WIFIMAC2G 1)
|
||||
case "$SKU" in
|
||||
AP)
|
||||
REGD=CN
|
||||
;;
|
||||
AU)
|
||||
REGD=AU
|
||||
;;
|
||||
CA)
|
||||
REGD=CA
|
||||
;;
|
||||
EU)
|
||||
REGD=FR
|
||||
;;
|
||||
US)
|
||||
REGD=US
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$board" in
|
||||
linksys,wrt1900ac-v1)
|
||||
WIFIMAC0=$WIFIMAC2G
|
||||
WIFIMAC1=$WIFIMAC5G
|
||||
;;
|
||||
*)
|
||||
WIFIMAC0=$WIFIMAC5G
|
||||
WIFIMAC1=$WIFIMAC2G
|
||||
;;
|
||||
esac
|
||||
|
||||
uci get wireless.radio0.country || uci set wireless.radio0.country=$REGD
|
||||
uci get wireless.@wifi-iface[0].macaddr || uci set wireless.@wifi-iface[0].macaddr=$WIFIMAC0
|
||||
uci get wireless.radio1.country || uci set wireless.radio1.country=$REGD
|
||||
uci get wireless.@wifi-iface[1].macaddr || uci set wireless.@wifi-iface[1].macaddr=$WIFIMAC1
|
||||
;;
|
||||
esac
|
||||
|
||||
uci commit wireless
|
||||
|
||||
exit 0
|
||||
@@ -0,0 +1,22 @@
|
||||
#
|
||||
# Copyright (C) 2017 LEDE-Project.org
|
||||
#
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
board=$(board_name)
|
||||
|
||||
case "$board" in
|
||||
linksys,wrt1900ac-v1)
|
||||
# Set fan script execution in crontab
|
||||
grep -s -q fan_ctrl.sh /etc/crontabs/root && exit 0
|
||||
|
||||
echo "# mamba fan script runs every 5 minutes" >> /etc/crontabs/root
|
||||
echo "*/5 * * * * /sbin/fan_ctrl.sh" >> /etc/crontabs/root
|
||||
|
||||
# Execute one time after initial flash (instead of waiting 5 min for cron)
|
||||
/sbin/fan_ctrl.sh
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
@@ -0,0 +1,11 @@
|
||||
. /lib/functions.sh
|
||||
|
||||
case "$(board_name)" in
|
||||
linksys,wrt1900ac-v1|\
|
||||
linksys,wrt32x)
|
||||
uci set system.@system[0].compat_version="2.0"
|
||||
uci commit system
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
@@ -0,0 +1,42 @@
|
||||
#
|
||||
# Copyright (C) 2014-2016 OpenWrt.org
|
||||
# Copyright (C) 2016 LEDE-Project.org
|
||||
#
|
||||
|
||||
preinit_mount_syscfg() {
|
||||
. /lib/functions.sh
|
||||
. /lib/upgrade/common.sh
|
||||
|
||||
case $(board_name) in
|
||||
linksys,wrt1200ac|\
|
||||
linksys,wrt1900ac-v1|\
|
||||
linksys,wrt1900ac-v2|\
|
||||
linksys,wrt1900acs|\
|
||||
linksys,wrt3200acm|\
|
||||
linksys,wrt32x)
|
||||
needs_recovery=0
|
||||
syscfg_part=$(grep syscfg /proc/mtd |cut -c4)
|
||||
ubiattach -m $syscfg_part || needs_recovery=1
|
||||
if [ $needs_recovery -eq 1 ]
|
||||
then
|
||||
echo "ubifs syscfg partition is damaged, reformatting"
|
||||
ubidetach -m $syscfg_part
|
||||
ubiformat -y -O 2048 -q /dev/mtd$syscfg_part
|
||||
ubiattach -m $syscfg_part
|
||||
ubimkvol /dev/ubi1 -n 0 -N syscfg -t dynamic --maxavsize
|
||||
fi
|
||||
mkdir /tmp/syscfg
|
||||
mount -t ubifs ubi1:syscfg /tmp/syscfg
|
||||
[ -f "/tmp/syscfg/$BACKUP_FILE" ] && {
|
||||
echo "- config restore -"
|
||||
cd /
|
||||
mv "/tmp/syscfg/$BACKUP_FILE" /tmp
|
||||
tar xzf "/tmp/$BACKUP_FILE"
|
||||
rm -f "/tmp/$BACKUP_FILE"
|
||||
sync
|
||||
}
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
boot_hook_add preinit_main preinit_mount_syscfg
|
||||
186
target/linux/mvebu/cortexa9/base-files/lib/upgrade/fortinet.sh
Normal file
186
target/linux/mvebu/cortexa9/base-files/lib/upgrade/fortinet.sh
Normal file
@@ -0,0 +1,186 @@
|
||||
. /lib/functions.sh
|
||||
|
||||
fortinet_bswap32() {
|
||||
local val="$(printf %08x $(($1)))"
|
||||
|
||||
# swap and print in hex
|
||||
echo "0x${val:6:2}${val:4:2}${val:2:2}${val:0:2}"
|
||||
}
|
||||
|
||||
fortinet_by2bl() {
|
||||
local blks="$(($1 / 0x200))"
|
||||
[ $(($1 % 0x200)) -gt 0 ] && blks=$((blks + 1))
|
||||
|
||||
printf "0x%08x" $blks
|
||||
}
|
||||
|
||||
fortinet_bl2by() {
|
||||
printf "0x%08x" $(($1 * 0x200))
|
||||
}
|
||||
|
||||
fortinet_build_partmap() {
|
||||
local new="$1" old="$2"
|
||||
local len="${old%%@*}" ofs="${old##*@}"
|
||||
|
||||
case "$new" in
|
||||
@*) ofs="$(fortinet_by2bl ${new##@})" ;; # "@<offset>"
|
||||
|
||||
*@*) len="$(fortinet_by2bl ${new%%@*})" # "<length>@<offset>"
|
||||
ofs="$(fortinet_by2bl ${new##*@})" ;;
|
||||
|
||||
"") ;; # "" (empty)
|
||||
|
||||
*) len="$(fortinet_by2bl ${new%%@*})" ;; # "<length>"
|
||||
esac
|
||||
|
||||
# print N blocks of length/offset in dec
|
||||
echo "${len}@${ofs}"
|
||||
}
|
||||
|
||||
# Update firmware information in "firmware-info" partition
|
||||
#
|
||||
# parameters:
|
||||
# $1: image index (0/1)
|
||||
# $2: new image name (up to 32 characters)
|
||||
# $3: length and/or offset for kernel (bytes)
|
||||
# $4: length and/or offset for rootfs (bytes)
|
||||
#
|
||||
# Note: $3 and $4 support multiple formats:
|
||||
#
|
||||
# - <length>@<offset>: set <length> and <rootfs>
|
||||
# - <length> : set <length> and keep the current offset
|
||||
# - @<offset> : set <offset> and keep the current length
|
||||
# - "" (empty) : keep the current length and offset
|
||||
fortinet_update_fwinfo() {
|
||||
local fwinfo_mtd="$(find_mtd_part firmware-info)"
|
||||
local index="$1"
|
||||
local name="$2"
|
||||
local offset
|
||||
local old_kr
|
||||
local old new tmp part pos
|
||||
local output
|
||||
|
||||
if [ -z "$fwinfo_mtd" ]; then
|
||||
echo "ERROR: MTD device \"firmware-info\" not found"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Image Name
|
||||
case "$index" in
|
||||
0) offset=0x10 ;;
|
||||
1) offset=0x30 ;;
|
||||
*) echo "ERROR: invalid image index specified!"; return 1 ;;
|
||||
esac
|
||||
|
||||
printf "Image Index: %d\n" $index
|
||||
|
||||
old="$(dd bs=16 count=2 skip=$((offset / 16)) if=$fwinfo_mtd 2>/dev/null)"
|
||||
printf "Image Name : \"%s\"\n" "$old"
|
||||
if [ -n "$name" ]; then
|
||||
echo -n "$name" | \
|
||||
dd bs=32 count=1 oflag=seek_bytes seek=$((offset)) \
|
||||
conv=sync,notrunc of=$fwinfo_mtd 2>/dev/null
|
||||
printf " --> \"%s\"\n\n" "$name"
|
||||
else
|
||||
printf "\n"
|
||||
fi
|
||||
|
||||
# length/offset values of kernel/rootfs
|
||||
case "$index" in
|
||||
0) offset=0x180 ;;
|
||||
1) offset=0x190 ;;
|
||||
esac
|
||||
|
||||
# <kernel offset:4><kernel length:4><rootfs offset:4><rootfs length:4>
|
||||
old_kr="$(hexdump -n 16 -v -s $((offset)) -e '1/4 "%08x"' $fwinfo_mtd)"
|
||||
|
||||
pos=0
|
||||
for part in kernel rootfs; do
|
||||
old="0x${old_kr:$((8 + pos)):8}@0x${old_kr:$((0 + pos)):8}"
|
||||
new="$(fortinet_build_partmap "$3" "$old")"
|
||||
shift
|
||||
|
||||
printf " %s:\n" $part
|
||||
printf " old: 0x%08x@0x%08x\n" \
|
||||
$(fortinet_bl2by ${old%%@*}) $(fortinet_bl2by ${old##*@})
|
||||
printf " new: 0x%08x@0x%08x\n\n" \
|
||||
$(fortinet_bl2by ${new%%@*}) $(fortinet_bl2by ${new##*@})
|
||||
|
||||
tmp="$(fortinet_bswap32 ${new%%@*})@$(fortinet_bswap32 ${new##*@})"
|
||||
new="$(echo $tmp | sed 's/0x\([0-9a-f]\{8\}\)@0x\([0-9a-f]\{8\}\)/\2\1/')"
|
||||
output="${output}${new}"
|
||||
|
||||
pos=$((pos + 16))
|
||||
done
|
||||
|
||||
data_2bin "$output" | \
|
||||
dd bs=16 count=1 seek=$((offset / 16)) conv=notrunc \
|
||||
of=$fwinfo_mtd 2>/dev/null
|
||||
}
|
||||
|
||||
fortinet_do_upgrade() {
|
||||
local board_dir="$(tar tf "$1" | grep -m 1 '^sysupgrade-.*/$')"
|
||||
local kern_mtd="$(find_mtd_part kernel)"
|
||||
local root_mtd="$(find_mtd_part rootfs)"
|
||||
local kern_len kern_ofs root_len root_ofs
|
||||
local imgname
|
||||
|
||||
board_dir="${board_dir%/}"
|
||||
|
||||
if [ -z "$kern_mtd" ] || [ -z "$root_mtd" ]; then
|
||||
echo "ERROR: MTD device \"kernel\" or \"rootfs\" not found"
|
||||
umount -a
|
||||
reboot -f
|
||||
fi
|
||||
kern_ofs=$(cat /sys/class/mtd/${kern_mtd//\/dev\/mtdblock/mtd}/offset)
|
||||
root_ofs=$(cat /sys/class/mtd/${root_mtd//\/dev\/mtdblock/mtd}/offset)
|
||||
|
||||
if [ -z "$kern_ofs" ] || [ -z "$root_ofs" ]; then
|
||||
echo "ERROR: failed to get offset of kernel or rootfs"
|
||||
umount -a
|
||||
reboot -f
|
||||
fi
|
||||
|
||||
kern_len=$( (tar xOf "$1" "$board_dir/kernel" | wc -c) 2> /dev/null)
|
||||
root_len=$( (tar xOf "$1" "$board_dir/root" | wc -c) 2> /dev/null)
|
||||
|
||||
if [ -z "$kern_len" ] || [ -z "$root_len" ]; then
|
||||
echo "ERROR: failed to get length of new kernel or rootfs"
|
||||
umount -a
|
||||
reboot -f
|
||||
fi
|
||||
|
||||
# try to load and parse /tmp/sysupgrade.meta for image name
|
||||
if [ -r "/tmp/sysupgrade.meta" ]; then
|
||||
local key value
|
||||
|
||||
sed -e 's/, \{1,2\}\"/\n"/g' \
|
||||
-e 's/{ \{1,2\}/\n/g' \
|
||||
-e 's/ \{1,2\}}/\n/g' < /tmp/sysupgrade.meta \
|
||||
> /tmp/sysupgrade.meta.tmp
|
||||
while read key value; do
|
||||
key="${key//\"/}"
|
||||
value="${value//\"/}"
|
||||
|
||||
[ -z "$value" ] && continue
|
||||
case "$key" in
|
||||
dist:|\
|
||||
version:|\
|
||||
revision:) imgname="${imgname}$value " ;;
|
||||
esac
|
||||
done < /tmp/sysupgrade.meta.tmp
|
||||
else
|
||||
imgname="OpenWrt"
|
||||
fi
|
||||
|
||||
fortinet_update_fwinfo 0 "${imgname%% }" \
|
||||
"${kern_len}@${kern_ofs}" "${root_len}@${root_ofs}" || {
|
||||
umount -a
|
||||
reboot -f
|
||||
}
|
||||
|
||||
tar xOf "$1" "$board_dir/kernel" | \
|
||||
mtd write - "kernel"
|
||||
tar xOf "$1" "$board_dir/root" | \
|
||||
mtd ${UPGRADE_BACKUP:+-j "${UPGRADE_BACKUP}"} write - "rootfs"
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
#
|
||||
# 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
|
||||
bootcmd "run altnandboot"
|
||||
EOF
|
||||
printf "kernel2"
|
||||
return
|
||||
;;
|
||||
2)
|
||||
fw_setenv -s - <<-EOF
|
||||
boot_part 1
|
||||
bootcmd "run nandboot"
|
||||
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
|
||||
v "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
|
||||
|
||||
if nand_upgrade_tar "$1" ; then
|
||||
nand_do_upgrade_success
|
||||
else
|
||||
nand_do_upgrade_failed
|
||||
fi
|
||||
|
||||
}
|
||||
[ "$magic_long" = "27051956" -o "$magic_long" = "0000a0e1" ] && {
|
||||
get_image "$1" | mtd write - $part_label
|
||||
}
|
||||
}
|
||||
|
||||
platform_copy_config_linksys() {
|
||||
cp -f "$UPGRADE_BACKUP" "/tmp/syscfg/$BACKUP_FILE"
|
||||
sync
|
||||
}
|
||||
110
target/linux/mvebu/cortexa9/base-files/lib/upgrade/platform.sh
Executable file
110
target/linux/mvebu/cortexa9/base-files/lib/upgrade/platform.sh
Executable file
@@ -0,0 +1,110 @@
|
||||
#
|
||||
# Copyright (C) 2014-2016 OpenWrt.org
|
||||
# Copyright (C) 2016 LEDE-Project.org
|
||||
#
|
||||
|
||||
RAMFS_COPY_BIN='fw_printenv fw_setenv seq strings'
|
||||
RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock'
|
||||
|
||||
REQUIRE_IMAGE_METADATA=1
|
||||
|
||||
platform_check_image() {
|
||||
case "$(board_name)" in
|
||||
cznic,turris-omnia|\
|
||||
kobol,helios4|\
|
||||
solidrun,clearfog-base-a1|\
|
||||
solidrun,clearfog-pro-a1)
|
||||
legacy_sdcard_check_image "$1"
|
||||
;;
|
||||
*)
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
platform_do_upgrade() {
|
||||
case "$(board_name)" in
|
||||
buffalo,ls220de)
|
||||
# Kernel UBI volume name must be "boot"
|
||||
CI_KERNPART=boot
|
||||
CI_KERN_UBIPART=ubi_kernel
|
||||
CI_ROOT_UBIPART=ubi
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
buffalo,ls421de)
|
||||
nand_do_upgrade "$1"
|
||||
;;
|
||||
ctera,c200-v2)
|
||||
part=$(find_mtd_part "active_bank")
|
||||
|
||||
if [ -n "$part" ]; then
|
||||
CI_KERNPART="$(strings $part | grep bank)"
|
||||
nand_do_upgrade "$1"
|
||||
else
|
||||
echo "active_bank partition missed!"
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
cznic,turris-omnia|\
|
||||
kobol,helios4|\
|
||||
solidrun,clearfog-base-a1|\
|
||||
solidrun,clearfog-pro-a1)
|
||||
legacy_sdcard_do_upgrade "$1"
|
||||
;;
|
||||
fortinet,fg-30e|\
|
||||
fortinet,fg-50e|\
|
||||
fortinet,fg-51e|\
|
||||
fortinet,fg-52e|\
|
||||
fortinet,fwf-50e-2r|\
|
||||
fortinet,fwf-51e)
|
||||
fortinet_do_upgrade "$1"
|
||||
;;
|
||||
iij,sa-w2)
|
||||
local envmtd=$(find_mtd_part "bootloader-env")
|
||||
local bootdev=$(grep "BOOTDEV=" "$envmtd")
|
||||
case "${bootdev#*=}" in
|
||||
flash) PART_NAME="firmware" ;;
|
||||
rescue) PART_NAME="rescue" ;;
|
||||
*)
|
||||
echo "invalid BOOTDEV is set (\"${bootdev#*=}\")"
|
||||
umount -a
|
||||
reboot -f
|
||||
;;
|
||||
esac
|
||||
default_do_upgrade "$1"
|
||||
;;
|
||||
iptime,nas1dual)
|
||||
PART_NAME=firmware
|
||||
default_do_upgrade "$1"
|
||||
;;
|
||||
linksys,wrt1200ac|\
|
||||
linksys,wrt1900ac-v1|\
|
||||
linksys,wrt1900ac-v2|\
|
||||
linksys,wrt1900acs|\
|
||||
linksys,wrt3200acm|\
|
||||
linksys,wrt32x)
|
||||
platform_do_upgrade_linksys "$1"
|
||||
;;
|
||||
*)
|
||||
default_do_upgrade "$1"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
platform_copy_config() {
|
||||
case "$(board_name)" in
|
||||
cznic,turris-omnia|\
|
||||
kobol,helios4|\
|
||||
solidrun,clearfog-base-a1|\
|
||||
solidrun,clearfog-pro-a1)
|
||||
legacy_sdcard_copy_config
|
||||
;;
|
||||
linksys,wrt1200ac|\
|
||||
linksys,wrt1900ac-v1|\
|
||||
linksys,wrt1900ac-v2|\
|
||||
linksys,wrt1900acs|\
|
||||
linksys,wrt3200acm|\
|
||||
linksys,wrt32x)
|
||||
platform_copy_config_linksys
|
||||
;;
|
||||
esac
|
||||
}
|
||||
28
target/linux/mvebu/cortexa9/base-files/sbin/fan_ctrl.sh
Executable file
28
target/linux/mvebu/cortexa9/base-files/sbin/fan_ctrl.sh
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
CPU_TEMP=$(cut -c1-2 /sys/class/hwmon/hwmon2/temp1_input)
|
||||
DDR_TEMP=$(cut -c1-2 /sys/class/hwmon/hwmon1/temp1_input)
|
||||
WIFI_TEMP=$(cut -c1-2 /sys/class/hwmon/hwmon1/temp2_input)
|
||||
|
||||
CPU_LOW=85
|
||||
CPU_HIGH=95
|
||||
DDR_LOW=65
|
||||
DDR_HIGH=75
|
||||
WIFI_LOW=100
|
||||
WIFI_HIGH=115
|
||||
|
||||
if [ -d /sys/devices/pwm_fan ];then
|
||||
FAN_CTRL=/sys/devices/pwm_fan/hwmon/hwmon0/pwm1
|
||||
elif [ -d /sys/devices/platform/pwm_fan ];then
|
||||
FAN_CTRL=/sys/devices/platform/pwm_fan/hwmon/hwmon0/pwm1
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$CPU_TEMP" -ge "$CPU_HIGH" -o "$DDR_TEMP" -ge "$DDR_HIGH" -o "$WIFI_TEMP" -ge "$WIFI_HIGH" ];then
|
||||
echo "255" > $FAN_CTRL
|
||||
elif [ "$CPU_TEMP" -ge "$CPU_LOW" -o "$DDR_TEMP" -ge "$DDR_LOW" -o "$WIFI_TEMP" -ge "$WIFI_LOW" ];then
|
||||
echo "100" > $FAN_CTRL
|
||||
else
|
||||
echo "0" > $FAN_CTRL
|
||||
fi
|
||||
Reference in New Issue
Block a user