Initial commit
This commit is contained in:
55
target/linux/mvebu/base-files/etc/board.d/01_leds
Executable file
55
target/linux/mvebu/base-files/etc/board.d/01_leds
Executable file
@@ -0,0 +1,55 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 2014-2016 OpenWrt.org
|
||||
# Copyright (C) 2016 LEDE-Project.org
|
||||
#
|
||||
|
||||
. /lib/functions/uci-defaults.sh
|
||||
|
||||
board_config_update
|
||||
|
||||
board=$(board_name)
|
||||
|
||||
case "$board" in
|
||||
linksys,caiman)
|
||||
ucidef_set_led_netdev "wan" "WAN" "pca963x:caiman:white:wan" "eth1"
|
||||
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,cobra)
|
||||
ucidef_set_led_netdev "wan" "WAN" "pca963x:cobra:white:wan" "eth1"
|
||||
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,mamba)
|
||||
ucidef_set_led_netdev "wan" "WAN" "mamba:white:wan" "eth1"
|
||||
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,rango)
|
||||
ucidef_set_led_netdev "wan" "WAN" "pca963x:rango:white:wan" "eth1"
|
||||
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,shelby)
|
||||
ucidef_set_led_netdev "wan" "WAN" "pca963x:shelby:white:wan" "eth1"
|
||||
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,venom)
|
||||
ucidef_set_led_netdev "wan" "WAN" "pca963x:venom:blue:wan" "eth1"
|
||||
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
|
||||
71
target/linux/mvebu/base-files/etc/board.d/02_network
Executable file
71
target/linux/mvebu/base-files/etc/board.d/02_network
Executable file
@@ -0,0 +1,71 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 2014-2016 OpenWrt.org
|
||||
# Copyright (C) 2016 LEDE-Project.org
|
||||
#
|
||||
|
||||
. /lib/functions/uci-defaults.sh
|
||||
|
||||
board_config_update
|
||||
|
||||
board=$(board_name)
|
||||
|
||||
case "$board" in
|
||||
cznic,turris-omnia)
|
||||
ucidef_set_interface_lan "lan0 lan1 lan2 lan3 lan4"
|
||||
ucidef_set_interface_wan "eth2"
|
||||
;;
|
||||
globalscale,espressobin|\
|
||||
globalscale,espressobin-emmc|\
|
||||
globalscale,espressobin-v7|\
|
||||
globalscale,espressobin-v7-emmc)
|
||||
ucidef_set_interfaces_lan_wan "lan0 lan1" "wan"
|
||||
;;
|
||||
linksys,caiman|\
|
||||
linksys,cobra|\
|
||||
linksys,mamba|\
|
||||
linksys,rango|\
|
||||
linksys,shelby|\
|
||||
linksys,venom)
|
||||
ucidef_set_interfaces_lan_wan "eth0.1" "eth1.2"
|
||||
ucidef_add_switch "switch0" \
|
||||
"0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5@eth0" "4:wan" "6@eth1"
|
||||
;;
|
||||
marvell,a385-db-ap)
|
||||
ucidef_set_interfaces_lan_wan "eth0 eth1" "eth2"
|
||||
;;
|
||||
marvell,armada8040-mcbin)
|
||||
ucidef_set_interfaces_lan_wan "eth0 eth1 eth3" "eth2"
|
||||
;;
|
||||
marvell,armada8040-db)
|
||||
ucidef_set_interfaces_lan_wan "eth0 eth2 eth3" "eth1"
|
||||
;;
|
||||
marvell,armada7040-db)
|
||||
ucidef_set_interfaces_lan_wan "eth0 eth2" "eth1"
|
||||
;;
|
||||
marvell,armada-3720-db)
|
||||
ucidef_set_interfaces_lan_wan "eth1" "eth0"
|
||||
;;
|
||||
marvell,axp-gp)
|
||||
ucidef_set_interface_lan "eth0 eth1 eth2 eth3"
|
||||
;;
|
||||
solidrun,clearfog*a1)
|
||||
# eth2 is standalone ethernet
|
||||
# eth0 is switch (-pro) or standalone ethernet (-base)
|
||||
# eth1 is SFP
|
||||
ucidef_set_interfaces_lan_wan "eth0" "eth2 eth1"
|
||||
|
||||
# if switch exists (clearfog-pro)
|
||||
# switch port 5 is connected to eth0
|
||||
swconfig list 2>&1 | grep -q switch0 && \
|
||||
ucidef_add_switch "switch0" \
|
||||
"0:lan:5" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5u@eth0" "6:lan:6"
|
||||
;;
|
||||
*)
|
||||
ucidef_set_interface_lan "eth0"
|
||||
;;
|
||||
esac
|
||||
|
||||
board_config_flush
|
||||
|
||||
exit 0
|
||||
48
target/linux/mvebu/base-files/etc/diag.sh
Normal file
48
target/linux/mvebu/base-files/etc/diag.sh
Normal file
@@ -0,0 +1,48 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2014-2016 OpenWrt.org
|
||||
# Copyright (C) 2016 LEDE-Project.org
|
||||
|
||||
. /lib/functions.sh
|
||||
. /lib/functions/leds.sh
|
||||
|
||||
get_status_led() {
|
||||
case $(board_name) in
|
||||
linksys,caiman)
|
||||
status_led="caiman:white:power"
|
||||
;;
|
||||
linksys,cobra)
|
||||
status_led="cobra:white:power"
|
||||
;;
|
||||
linksys,mamba)
|
||||
status_led="mamba:white:power"
|
||||
;;
|
||||
linksys,rango)
|
||||
status_led="rango:white:power"
|
||||
;;
|
||||
linksys,shelby)
|
||||
status_led="shelby:white:power"
|
||||
;;
|
||||
linksys,venom)
|
||||
status_led="venom:blue:power"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
set_state() {
|
||||
get_status_led
|
||||
|
||||
case "$1" in
|
||||
preinit)
|
||||
status_led_blink_preinit
|
||||
;;
|
||||
failsafe)
|
||||
status_led_blink_failsafe
|
||||
;;
|
||||
preinit_regular)
|
||||
status_led_blink_preinit_regular
|
||||
;;
|
||||
done)
|
||||
status_led_on
|
||||
;;
|
||||
esac
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
18
target/linux/mvebu/base-files/etc/init.d/bootcount
Executable file
18
target/linux/mvebu/base-files/etc/init.d/bootcount
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=99
|
||||
|
||||
start() {
|
||||
. /lib/functions.sh
|
||||
|
||||
case $(board_name) in
|
||||
linksys,caiman |\
|
||||
linksys,cobra |\
|
||||
linksys,mamba |\
|
||||
linksys,rango |\
|
||||
linksys,shelby |\
|
||||
linksys,venom)
|
||||
mtd resetbc s_env || true
|
||||
;;
|
||||
esac
|
||||
}
|
||||
56
target/linux/mvebu/base-files/etc/uci-defaults/03_wireless
Normal file
56
target/linux/mvebu/base-files/etc/uci-defaults/03_wireless
Normal file
@@ -0,0 +1,56 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# 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,caiman|linksys,cobra|linksys,mamba|linksys,shelby|linksys,venom)
|
||||
SKU=$(strings /dev/mtd3|sed -ne 's/^cert_region=//p')
|
||||
WIFIMAC2G=$(macaddr_add $(cat /sys/class/net/eth0/address) +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,mamba)
|
||||
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
|
||||
23
target/linux/mvebu/base-files/etc/uci-defaults/04_mambafan
Normal file
23
target/linux/mvebu/base-files/etc/uci-defaults/04_mambafan
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 2017 LEDE-Project.org
|
||||
#
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
board=$(board_name)
|
||||
|
||||
case "$board" in
|
||||
linksys,mamba)
|
||||
# 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,44 @@
|
||||
# This must be sourced after 30_uboot-envtools
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
board=$(board_name)
|
||||
|
||||
case "$board" in
|
||||
cznic,turris-omnia)
|
||||
# Do nothing if this is not the old U-Boot
|
||||
grep -q 'U-Boot 2015.10-rc2' /dev/mtd0 || exit 0
|
||||
# Do nothing if we already have distro_bootcmd
|
||||
fw_printenv distro_bootcmd >/dev/null 2>/dev/null && exit 0
|
||||
# Set the complete environment, since U-Boot does not merge the default environment from its own image!
|
||||
fw_setenv -s - <<-"EOF"
|
||||
baudrate 115200
|
||||
bootdelay 3
|
||||
ethact neta2
|
||||
fdt_high 0x10000000
|
||||
initrd_high 0x10000000
|
||||
bootargs earlyprintk console=ttyS0,115200 rootfstype=btrfs rootdelay=2 root=b301 rootflags=subvol=@,commit=5 rw
|
||||
bootcmd i2c dev 1; i2c read 0x2a 0x9 1 0x00FFFFF0; setexpr.b rescue *0x00FFFFF0; if test $rescue -ge 1; then echo BOOT RESCUE; run rescueboot; else echo BOOT eMMC FS; run mmcboot; setenv bootargs; run distro_bootcmd; fi
|
||||
rescueboot i2c mw 0x2a.1 0x3 0x1c 1; i2c mw 0x2a.1 0x4 0x1c 1; mw.l 0x01000000 0x00ff000c; i2c write 0x01000000 0x2a.1 0x5 4 -s; setenv bootargs "$bootargs omniarescue=$rescue"; sf probe; sf read 0x1000000 0x100000 0x700000; bootz 0x1000000
|
||||
mmcboot btrload mmc 0 ${kernel_addr_r} boot/zImage @ && btrload mmc 0 ${fdt_addr_r} boot/dtb @ && setenv bootargs ${bootargs} cfg80211.freg=${regdomain} && bootz ${kernel_addr_r} - ${fdt_addr_r}
|
||||
kernel_addr_r 0x1000000
|
||||
scriptaddr 0x1800000
|
||||
fdt_addr_r 0x2000000
|
||||
boot_targets mmc0 scsi0
|
||||
boot_prefixes / /boot/
|
||||
boot_scripts boot.scr
|
||||
distro_bootcmd scsi_need_init=true; for target in ${boot_targets}; do run bootcmd_${target}; done
|
||||
bootcmd_mmc0 devnum=0; run mmc_boot
|
||||
mmc_boot if mmc dev ${devnum}; then devtype=mmc; run scan_dev_for_boot_part; fi
|
||||
bootcmd_scsi0 devnum=0; run scsi_boot
|
||||
scsi_boot run scsi_init; if scsi dev ${devnum}; then devtype=scsi; run scan_dev_for_boot_part; fi
|
||||
scsi_init if ${scsi_need_init}; then scsi_need_init=false; scsi scan; fi
|
||||
scan_dev_for_boot_part for distro_bootpart in 1; do if fstype ${devtype} ${devnum}:${distro_bootpart} bootfstype; then run scan_dev_for_boot; fi; done
|
||||
scan_dev_for_boot echo Scanning ${devtype} ${devnum}:${distro_bootpart}...; for prefix in ${boot_prefixes}; do run scan_dev_for_scripts; done
|
||||
scan_dev_for_scripts for script in ${boot_scripts}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${script}; then echo Found U-Boot script ${prefix}${script}; run boot_a_script; echo SCRIPT FAILED: continuing...; fi; done
|
||||
boot_a_script load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${prefix}${script}; source ${scriptaddr}
|
||||
EOF
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
46
target/linux/mvebu/base-files/lib/preinit/06_set_iface_mac
Normal file
46
target/linux/mvebu/base-files/lib/preinit/06_set_iface_mac
Normal file
@@ -0,0 +1,46 @@
|
||||
#
|
||||
# Copyright (C) 2014-2015 OpenWrt.org
|
||||
# Copyright (C) 2016 LEDE-Project.org
|
||||
#
|
||||
|
||||
preinit_set_mac_address() {
|
||||
local mac
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
case $(board_name) in
|
||||
linksys,caiman|linksys,cobra|linksys,rango|linksys,shelby|linksys,venom)
|
||||
# rename interfaces back to the way they were with 4.4
|
||||
case "$(readlink /sys/class/net/eth0)" in
|
||||
*f1070000*)
|
||||
ip link set eth0 name tmp0
|
||||
ip link set eth1 name eth0
|
||||
ip link set tmp0 name eth1
|
||||
;;
|
||||
esac
|
||||
|
||||
mac=$(mtd_get_mac_ascii devinfo hw_mac_addr)
|
||||
mac_wan=$(macaddr_setbit_la "$mac")
|
||||
ip link set dev eth1 address $mac 2>/dev/null
|
||||
ip link set dev eth0 address $mac_wan 2>/dev/null
|
||||
;;
|
||||
linksys,mamba)
|
||||
mac=$(mtd_get_mac_ascii devinfo hw_mac_addr)
|
||||
ip link set dev eth0 address $mac 2>/dev/null
|
||||
ip link set dev eth1 address $mac 2>/dev/null
|
||||
;;
|
||||
marvell,a385-db-ap|solidrun,clearfog*a1)
|
||||
# rename interfaces back to the way they were with 4.4
|
||||
case "$(readlink /sys/class/net/eth0)" in
|
||||
*f1070000*)
|
||||
ip link set eth0 name tmp0
|
||||
ip link set eth1 name eth0
|
||||
ip link set eth2 name eth1
|
||||
ip link set tmp0 name eth2
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
boot_hook_add preinit_main preinit_set_mac_address
|
||||
26
target/linux/mvebu/base-files/lib/preinit/79_move_config
Normal file
26
target/linux/mvebu/base-files/lib/preinit/79_move_config
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2015 OpenWrt.org
|
||||
|
||||
. /lib/functions.sh
|
||||
. /lib/upgrade/common.sh
|
||||
|
||||
move_config() {
|
||||
local partdev
|
||||
|
||||
if export_bootdevice && export_partdevice partdev 1; then
|
||||
case $(board_name) in
|
||||
cznic,turris-omnia)
|
||||
insmod nls_cp437
|
||||
insmod nls_iso8859-1
|
||||
insmod fat
|
||||
insmod vfat
|
||||
;;
|
||||
esac
|
||||
mkdir -p /boot
|
||||
mount -o rw,noatime "/dev/$partdev" /boot
|
||||
[ -f "/boot/$BACKUP_FILE" ] && mv -f "/boot/$BACKUP_FILE" /
|
||||
umount /boot
|
||||
fi
|
||||
}
|
||||
|
||||
boot_hook_add preinit_mount_root move_config
|
||||
37
target/linux/mvebu/base-files/lib/preinit/81_linksys_syscfg
Normal file
37
target/linux/mvebu/base-files/lib/preinit/81_linksys_syscfg
Normal file
@@ -0,0 +1,37 @@
|
||||
#
|
||||
# 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,caiman|linksys,cobra|linksys,mamba|linksys,rango|linksys,shelby|linksys,venom)
|
||||
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
|
||||
98
target/linux/mvebu/base-files/lib/upgrade/linksys.sh
Normal file
98
target/linux/mvebu/base-files/lib/upgrade/linksys.sh
Normal file
@@ -0,0 +1,98 @@
|
||||
#
|
||||
# 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/devices/virtual/ubi/ubi0/mtd_num)
|
||||
case $(egrep ^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
|
||||
}
|
||||
|
||||
linksys_get_root_magic() {
|
||||
(get_image "$@" | dd skip=786432 bs=4 count=1 | hexdump -v -n 4 -e '1/1 "%02x"') 2>/dev/null
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
nand_upgrade_tar "$1"
|
||||
}
|
||||
[ "$magic_long" = "27051956" -o "$magic_long" = "0000a0e1" ] && {
|
||||
# check firmwares' rootfs types
|
||||
local target_mtd=$(find_mtd_part $part_label)
|
||||
local oldroot="$(linksys_get_root_magic $target_mtd)"
|
||||
local newroot="$(linksys_get_root_magic "$1")"
|
||||
|
||||
if [ "$newroot" = "55424923" -a "$oldroot" = "55424923" ]
|
||||
# we're upgrading from a firmware with UBI to one with UBI
|
||||
then
|
||||
# erase everything to be safe
|
||||
mtd erase $part_label
|
||||
get_image "$1" | mtd -n write - $part_label
|
||||
else
|
||||
get_image "$1" | mtd write - $part_label
|
||||
fi
|
||||
}
|
||||
}
|
||||
|
||||
platform_copy_config_linksys() {
|
||||
cp -f "$UPGRADE_BACKUP" "/tmp/syscfg/$BACKUP_FILE"
|
||||
sync
|
||||
}
|
||||
46
target/linux/mvebu/base-files/lib/upgrade/platform.sh
Executable file
46
target/linux/mvebu/base-files/lib/upgrade/platform.sh
Executable file
@@ -0,0 +1,46 @@
|
||||
#
|
||||
# Copyright (C) 2014-2016 OpenWrt.org
|
||||
# Copyright (C) 2016 LEDE-Project.org
|
||||
#
|
||||
|
||||
RAMFS_COPY_BIN='fw_printenv fw_setenv'
|
||||
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|globalscale,espressobin|globalscale,espressobin-emmc|globalscale,espressobin-v7|globalscale,espressobin-v7-emmc|\
|
||||
marvell,armada8040-mcbin|solidrun,clearfog-base-a1|solidrun,clearfog-pro-a1)
|
||||
platform_check_image_sdcard "$1"
|
||||
;;
|
||||
*)
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
platform_do_upgrade() {
|
||||
case "$(board_name)" in
|
||||
linksys,caiman|linksys,cobra|linksys,mamba|linksys,rango|linksys,shelby|linksys,venom)
|
||||
platform_do_upgrade_linksys "$1"
|
||||
;;
|
||||
cznic,turris-omnia|globalscale,espressobin|globalscale,espressobin-emmc|globalscale,espressobin-v7|globalscale,espressobin-v7-emmc|\
|
||||
marvell,armada8040-mcbin|solidrun,clearfog-base-a1|solidrun,clearfog-pro-a1)
|
||||
platform_do_upgrade_sdcard "$1"
|
||||
;;
|
||||
*)
|
||||
default_do_upgrade "$1"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
platform_copy_config() {
|
||||
case "$(board_name)" in
|
||||
linksys,caiman|linksys,cobra|linksys,mamba|linksys,rango|linksys,shelby|linksys,venom)
|
||||
platform_copy_config_linksys
|
||||
;;
|
||||
cznic,turris-omnia|globalscale,espressobin|globalscale,espressobin-emmc|globalscale,espressobin-v7|globalscale,espressobin-v7-emmc|\
|
||||
marvell,armada8040-mcbin|solidrun,clearfog-base-a1|solidrun,clearfog-pro-a1)
|
||||
platform_copy_config_sdcard
|
||||
;;
|
||||
esac
|
||||
}
|
||||
104
target/linux/mvebu/base-files/lib/upgrade/sdcard.sh
Normal file
104
target/linux/mvebu/base-files/lib/upgrade/sdcard.sh
Normal file
@@ -0,0 +1,104 @@
|
||||
get_magic_at() {
|
||||
local file="$1"
|
||||
local pos="$2"
|
||||
get_image "$file" | dd bs=1 count=2 skip="$pos" 2>/dev/null | hexdump -v -n 2 -e '1/1 "%02x"'
|
||||
}
|
||||
|
||||
platform_check_image_sdcard() {
|
||||
local file="$1"
|
||||
local magic diskdev partdev diff
|
||||
|
||||
magic=$(get_magic_at "$file" 510)
|
||||
[ "$magic" != "55aa" ] && {
|
||||
echo "Failed to verify MBR boot signature."
|
||||
return 1
|
||||
}
|
||||
|
||||
export_bootdevice && export_partdevice diskdev 0 || {
|
||||
echo "Unable to determine upgrade device"
|
||||
return 1
|
||||
}
|
||||
|
||||
get_partitions "/dev/$diskdev" bootdisk
|
||||
|
||||
#extract the boot sector from the image
|
||||
get_image "$@" | dd of=/tmp/image.bs count=1 bs=512b 2>/dev/null
|
||||
|
||||
get_partitions /tmp/image.bs image
|
||||
|
||||
#compare tables
|
||||
diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)"
|
||||
|
||||
rm -f /tmp/image.bs /tmp/partmap.bootdisk /tmp/partmap.image
|
||||
|
||||
if [ -n "$diff" ]; then
|
||||
echo "Partition layout has changed. Full image will be written."
|
||||
ask_bool 0 "Abort" && exit 1
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
platform_do_upgrade_sdcard() {
|
||||
local board=$(board_name)
|
||||
local diskdev partdev diff
|
||||
|
||||
export_bootdevice && export_partdevice diskdev 0 || {
|
||||
echo "Unable to determine upgrade device"
|
||||
return 1
|
||||
}
|
||||
|
||||
sync
|
||||
|
||||
if [ "$UPGRADE_OPT_SAVE_PARTITIONS" = "1" ]; then
|
||||
get_partitions "/dev/$diskdev" bootdisk
|
||||
|
||||
#extract the boot sector from the image
|
||||
get_image "$@" | dd of=/tmp/image.bs count=1 bs=512b
|
||||
|
||||
get_partitions /tmp/image.bs image
|
||||
|
||||
#compare tables
|
||||
diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)"
|
||||
else
|
||||
diff=1
|
||||
fi
|
||||
|
||||
if [ -n "$diff" ]; then
|
||||
get_image "$@" | dd of="/dev/$diskdev" bs=4096 conv=fsync
|
||||
|
||||
# Separate removal and addtion is necessary; otherwise, partition 1
|
||||
# will be missing if it overlaps with the old partition 2
|
||||
partx -d - "/dev/$diskdev"
|
||||
partx -a - "/dev/$diskdev"
|
||||
else
|
||||
#write uboot image
|
||||
get_image "$@" | dd of="$diskdev" bs=512 skip=1 seek=1 count=2048 conv=fsync
|
||||
#iterate over each partition from the image and write it to the boot disk
|
||||
while read part start size; do
|
||||
if export_partdevice partdev $part; then
|
||||
echo "Writing image to /dev/$partdev..."
|
||||
get_image "$@" | dd of="/dev/$partdev" ibs="512" obs=1M skip="$start" count="$size" conv=fsync
|
||||
else
|
||||
echo "Unable to find partition $part device, skipped."
|
||||
fi
|
||||
done < /tmp/partmap.image
|
||||
|
||||
#copy partition uuid
|
||||
echo "Writing new UUID to /dev/$diskdev..."
|
||||
get_image "$@" | dd of="/dev/$diskdev" bs=1 skip=440 count=4 seek=440 conv=fsync
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
}
|
||||
|
||||
platform_copy_config_sdcard() {
|
||||
local partdev
|
||||
|
||||
if export_partdevice partdev 1; then
|
||||
mkdir -p /boot
|
||||
[ -f /boot/kernel.img ] || mount -o rw,noatime /dev/$partdev /boot
|
||||
cp -af "$UPGRADE_BACKUP" "/boot/$BACKUP_FILE"
|
||||
sync
|
||||
umount /boot
|
||||
fi
|
||||
}
|
||||
28
target/linux/mvebu/base-files/sbin/fan_ctrl.sh
Executable file
28
target/linux/mvebu/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