Regarding adding support for this router (most of the work has already been done here), how to solve the problem of different board files depending on the country/region?
Here is the /etc/system/wait
script used by the vendor:
#!/bin/sh
#------------------------------------------------------------------
# © 2013 Belkin International, Inc. and/or its affiliates. All rights reserved.
#------------------------------------------------------------------
#------------------------------------------------------------------
# This file contains the code run by init process during the wait target
# It starts the sysevent daemon, and then runs through all of the sysevent
# registration scripts
#------------------------------------------------------------------
source /etc/init.d/syscfg_api.sh
#init_hotplug2() {
# [ -c /dev/console ] || mknod /dev/console c 5 1
# /sbin/hotplug2 --set-worker /lib/hotplug2/worker_fork.so --set-rules-file /etc/hotplug2-init.rules --no-persistent --set-coldplug-cmd /sbin/udevtrigger
# /sbin/hotplug2 --set-worker /lib/hotplug2/worker_fork.so --set-rules-file /etc/hotplug2-init.rules --persistent &
#}
find_mtd_part() {
local PART="$(grep "\"$1\"" /proc/mtd | awk -F: '{print $1}')"
local PREFIX=/dev/mtdblock
PART="${PART##mtd}"
[ -d /dev/mtdblock ] && PREFIX=/dev/mtdblock/
echo "${PART:+$PREFIX$PART}"
}
#03847295
enable_rps()
{
irq_nss_rps=`grep nss_queue1 /proc/interrupts | cut -d ':' -f 1 | tr -d ' '`
for entry in $irq_nss_rps
do
echo 2 > /proc/irq/$entry/smp_affinity
done
irq_nss_rps=`grep nss_queue2 /proc/interrupts | cut -d ':' -f 1 | tr -d ' '`
for entry in $irq_nss_rps
do
echo 4 > /proc/irq/$entry/smp_affinity
done
irq_nss_rps=`grep nss_queue3 /proc/interrupts | cut -d ':' -f 1 | tr -d ' '`
for entry in $irq_nss_rps
do
echo 8 > /proc/irq/$entry/smp_affinity
done
# Enable NSS RPS
sysctl -w dev.nss.rps.enable=1 >/dev/null 2>/dev/null
}
# create our passwd/shadow/group files
mkdir -p /tmp/etc/.root
chmod 711 /tmp/etc/.root
if [ -f "/tmp/etc/.root/passwd" ] ; then chmod 644 /tmp/etc/.root/passwd; else touch /tmp/etc/.root/passwd; chmod 644 /tmp/etc/.root/passwd; fi
if [ -f "/tmp/etc/.root/shadow" ] ; then chmod 600 /tmp/etc/.root/shadow; else touch /tmp/etc/.root/shadow; chmod 600 /tmp/etc/.root/shadow; fi
if [ -f "/tmp/etc/.root/group" ] ; then chmod 600 /tmp/etc/.root/group; else touch /tmp/etc/.root/group; chmod 600 /tmp/etc/.root/group; fi
# create the default profile. This is linked to by /etc/profile
echo "export setenv PATH=/bin:/sbin:/usr/sbin:/usr/bin:/opt/sbin:/opt/bin" > /tmp/profile
echo "export setenv LD_LIBRARY_PATH=/lib:/usr/lib:/opt/lib" >> /tmp/profile
#echo "export setenv LD_LIBRARY_PATH=/lib:/usr/lib:/opt/lib:/usr/local/lib/lua/5.1/" >> /tmp/profile
# create other files that are linked to by etc
mkdir -p /tmp/udev/rules.d
echo -n > /tmp/hosts
echo -n > /tmp/hostname
echo -n > /tmp/resolv.conf
echo -n > /tmp/igmpproxy.conf
echo -n > /tmp/ez-ipupdate.conf
echo -n > /tmp/ez-ipupdate.out
echo -n > /tmp/TZ
echo -n > /tmp/.htpasswd
echo -n > /tmp/dnsmasq.conf
echo -n > /tmp/dhcp_options
echo -n > /tmp/dhcp_static_hosts
echo -n > /tmp/dnsmasq.leases
echo -n > /tmp/zebra.conf
echo -n > /tmp/ripd.conf
echo -n > /tmp/dhcp6c.conf
# SYSTEM TUNING
# reserve 8Mb RAM for kernel
echo 8192 > /proc/sys/vm/min_free_kbytes
# For LION-7: Increase concurrent connection limit
if [ -e /proc/sys/net/netfilter/nf_conntrack_max ] ; then
echo 65535 > /proc/sys/net/netfilter/nf_conntrack_max
fi
mount -t debugfs none /sys/kernel/debug
###########################################################################
# 2. Create syscfg and set the default configuration ( this should be
# cleaned up )
###########################################################################
# We'd nomally use /var/lib as the mount point for persistent
# application data. But /var/lib is already being used for
# non-persistent application data (e.g. /var/lib/tc). So, we fall
# back to using /mnt/lib.
APPLICATION_DIR=/var/config
SYSCFG_DIR=${APPLICATION_DIR}/syscfg
SYSCFG_FILE=${SYSCFG_DIR}/syscfg.dat
SYSCFG_RESET="0"
PERSISTENT_PARTITION=$(awk -F: '/syscfg/ { print $1 }' /proc/mtd)
if [ -z $PERSISTENT_PARTITION ]; then
echo [utopia][init] Cannot find syscfg partition, assuming /dev/$PERSISTENT_PARTITION
fi
MTD_DEVICE=/dev/${PERSISTENT_PARTITION}
MTD_BLOCK_DEVICE=/dev/$(echo ${PERSISTENT_PARTITION} | sed s/mtd/mtdblock/)
MTD_NUM="`echo -n $PERSISTENT_PARTITION | sed 's/mtd//g'`"
mounted=0
mkdir -p ${APPLICATION_DIR} || echo [utopia][init] No mount point for persistent storage.
echo "Attempting mount of ubifs syscfg partition"
UBIDEV=1 #if not using UBI block, set to 0, else 1
# suggested change by Roger at MediaTek to ensure that /dev/ubi_ctrl is available
# prior to calling ubiattach
# mdev -s
if [ ! -e "/dev/ubi_ctrl" ] ; then
mknod /dev/ubi_ctrl c 10 62
fi
# echo "ubiattach /dev/ubi_ctrl -m ${MTD_NUM} -d ${UBIDEV}" >> /dev/console
ubiattach /dev/ubi_ctrl -m ${MTD_NUM} -d ${UBIDEV}
#if mount -t jffs2 $MTD_BLOCK_DEVICE ${APPLICATION_DIR}; then
if mount -o sync -t ubifs ubi${UBIDEV}_0 ${APPLICATION_DIR}; then
mounted=1
else
echo [utopia][init] Persistent storage mount failed, attempting format
# echo [utopia][init] Backing up syscfg partition to /tmp/mtd${MTD_NUM}_corrupt
# dd if=/dev/${MTD_NUM} of=/tmp/mtd${MTD_NUM}_corrupt
# echo [utopia][init] Backing up syscfg partition to /tmp/mtd${MTD_NUM}_corrupt DONE!
tmp=$(mktemp -t -d)
mkdir -p ${tmp}/syscfg
echo "erasing flash partition $MTD_DEVICE"
# flash_erase ${MTD_DEVICE} 0 0
# change suggested by Adam to get ubifs commands working from uboot
ubidetach /dev/ubi_ctrl -m ${MTD_NUM}
flash_erase -N ${MTD_DEVICE} 0 0
ubiformat -y ${MTD_DEVICE}
echo "ubiattach /dev/ubi_ctrl -m ${MTD_NUM}"
ubiattach /dev/ubi_ctrl -m ${MTD_NUM}
echo "trying to create ubi volume"
if ! ubimkvol /dev/ubi${UBIDEV} -N syscfg -m; then
echo [utopia][init] Format persistent storage failed. Perhaps ubimkvol not installed. Giving up.
else
if ! mount -o sync -t ubifs ubi${UBIDEV}_0 ${APPLICATION_DIR}; then
echo [utopia][init] Format succeeded, mount still failed. Giving up.
else
mounted=1
fi
fi
rm -rf ${tmp}
SYSCFG_RESET="1"
fi
if [ ${mounted} -ne 0 ]; then
[ -d ${SYSCFG_DIR} ] || mkdir -p ${SYSCFG_DIR}
syscfg_create -f ${SYSCFG_FILE}
echo [utopia][init] Using persistent syscfg data from ${SYSCFG_DIR}
else
echo [utopia][init] Using raw partition ${MTD_DEVICE} for syscfg data
syscfg_check -d $MTD_DEVICE
if [ $? = 0 ]; then
echo "[utopia][init] Starting syscfg subsystem using flash partition $MTD_DEVICE"
/sbin/syscfg_create -d $MTD_DEVICE
else
echo "[utopia][init] Formating flash partition $MTD_DEVICE for syscfg use"
syscfg_format -d $MTD_DEVICE
if [ $? = 0 ]; then
echo "[utopia][init] Starting syscfg subsystem using flash partition $MTD_DEVICE with default settings"
/sbin/syscfg_create -d $MTD_DEVICE
else
echo "[utopia][init] FAILURE: formatting flash partition $MTD_DEVICE for syscfg use"
echo "[utopia][init] Starting syscfg with default settings using file store (/tmp/syscfg.db)"
echo "" > /tmp/syscfg.db
/sbin/syscfg_create -f /tmp/syscfg.db
fi
fi
fi
product_name=$(cat /etc/product)
[ -f /etc/fw_env.config.$product_name ] && cp -f /etc/fw_env.config.$product_name /tmp/fw_env.config
#start hotplug2 before QCA driver loading. Could possibly handle by udev
#init_hotplug2
echo "[utopia][init] Starting system logging"
/etc/init.d/service_syslog.sh syslog-start
echo "[utopia][init] Starting sysevent subsystem"
if [ -f /usr/sbin/start_syseventd.sh ];then
/usr/sbin/start_syseventd.sh
else
/sbin/syseventd
fi
# set flag to show that syscfg was reset
if [ "$SYSCFG_RESET" == "1" ] ; then
sysevent set notify_that_syscfg_was_reset 1
fi
# LED start pulsing blue
echo "[utopia][init] Starting blue ..."
/etc/led/nodes_led_pulse.sh blue 3
# load kernel modules to handle FTP PORT command
MODULE_PATH=/lib/modules/`uname -r`/
# Load ssdk.ko for QCA platform
if [ -f $MODULE_PATH/qca-ssdk.ko ] ; then
/sbin/modprobe qca-ssdk
fi
#load QCA NSS and GMAC drivers
echo "[utopia][init] Enabling DesignWare USB3 DRD Core drivers"
/sbin/modprobe usb-common
/sbin/modprobe usbcore
#/sbin/modprobe usb_nls_base
#/sbin/modprobe usb_udc_core
#/sbin/modprobe libcomposite
/sbin/modprobe phy_qcom_dwc3
/sbin/modprobe phy_msm_qusb
/sbin/modprobe phy_msm_ssusb_qmp
/sbin/modprobe usb_f_diag
/sbin/modprobe dwc3_of_simple
/sbin/modprobe dwc3
/sbin/modprobe ehci-hcd
/sbin/modprobe ehci_platform
/sbin/modprobe xhci-hcd
/sbin/modprobe xhci-pci
/sbin/modprobe xhci_plat_hcd
#/sbin/modprobe usb-storage
#/sbin/modprobe uas
echo "[utopia][init] Loading QCA Ethernet, NSS and GMAC drivers"
/sbin/modprobe cfg80211
/sbin/modprobe qca-nss-dp
/sbin/modprobe qca-nss-drv
/sbin/modprobe nat46
/sbin/modprobe qca-nss-bridge-mgr
/sbin/modprobe qca-nss-gre
/sbin/modprobe qca-nss-l2tpv2
/sbin/modprobe qca-nss-lag-mgr
/sbin/modprobe qca-nss-map-t
/sbin/modprobe qca-nss-pppoe
/sbin/modprobe qca-nss-pptp
/sbin/modprobe qca-nss-vlan
/sbin/modprobe qca-nss-crypto
/sbin/modprobe qca-nss-macsec
/sbin/modprobe qca-nss-qdisc
/sbin/modprobe qca-nss-cfi-cryptoapi
#/sbin/modprobe qca-nss-gmac
/sbin/modprobe qca-nss-tun6rd
/sbin/modprobe qca-nss-tunipip6
/sbin/modprobe qca-nss-ipsecmgr
/sbin/modprobe qca-nss-cfi-ocf
/sbin/modprobe qca-nss-ipsec
/sbin/modprobe qca-nss-crypto_tool
/sbin/modprobe nf_conntrack_ftp
/sbin/modprobe nf_nat_ftp
/sbin/modprobe qca-mcs
/sbin/modprobe qrfs
#03847295
enable_rps
sysctl -w net.netfilter.nf_conntrack_acct=1
# load the watchdog module and start the watchdog program
# insmod $MODULE_PATH/mod_wdtutil.ko
# /bin/mknod /dev/watchdog c $(awk ' /wdtutil/{ print $1 }' /proc/devices) 1
# /usr/sbin/wdtutil -c 16 -i 5
# echo "watchdog running"
# we want plugged in usb devices to propagate events to sysevent
echo "[utopia][init] Late loading usb drivers"
#/sbin/modprobe nls_base
/sbin/modprobe sd_mod
#/sbin/modprobe usb_storage
/sbin/modprobe vfat
#/sbin/modprobe ntfs
mknod /dev/gpio c 252 0
mknod /dev/rdm0 c 253 0
echo "[utopia][init] Setting any unset system values to default"
apply_system_defaults
PIN="`syscfg get smart_connect::client_pin`"
if [ -z "$PIN" ] ; then
WPS_PIN=`syscfg get device::wps_pin`
PIN=`echo ${WPS_PIN:4}`
echo "[utopia][init] Set smart_connect::client_pin $PIN" > /dev/console
syscfg set smart_connect::client_pin "$PIN"
fi
# RAINIER-5849 is fixed by moving vconfig to immediately after the Ethernet
# driver in the wait script. This is a Broadcom only issue.
if [ -f /usr/sbin/vlan_setup.sh ]; then
/usr/sbin/vlan_setup.sh
# To maintain compatibility with service_interface we manually set vlan2-status started
sysevent set vlan2-status started
fi
# for nodes, at boot up always set the backhaul status to down
sysevent set backhaul::status down
INIT_DIR=/etc/registration.d
# run all executables in the sysevent registration directory
# echo "[utopia][init] Running registration using $INIT_DIR"
execute_dir $INIT_DIR
# Load bdutil daemon
lsmod | grep mod_bdutil 2>&1 > /dev/null
#if [ $? -eq 0 ]; then
# echo "[utopia][init] Starting bdutil daemon" > /dev/console
# /usr/sbin/bdutil &
#fi
# This is an entry point where developers can quickly add test scripts
# that will be run after boot up
if [ -d "/var/config/run_scripts" ] ; then
echo "running scripts in /var/config/run_script directory !!!" >> /dev/console
execute_dir "/var/config/run_scripts" &
fi
# The code below attempts to sync up the current admin password ( which may have
# been changed, with the admin http_auth password for the sysinfo.cgi file.
# Matt Fatheree appologizes in advance for this spaghetti code.
# BEWARE: here there be dragons
if [ ! -f "/var/config/.sysinfo_pswd" ] ; then
if [ -f "/var/config/syspwl.lst" ] ; then
# if there is an admin password already set try to use that
ADMPASS="`cat /var/config/syspwl.lst | grep 1000 | cut -d':' -f2`"
echo "admin:$ADMPASS" > /var/config/.sysinfo_pswd
else
echo "admin:admin" > /var/config/.sysinfo_pswd
fi
else
# this is a case for when someone has changed the admin passwd
# before they had code that supported protecting sysinfo.cgi
# in that case the sysinfo_pswd exists, but has the default admin:admin
# password combination. In that case, we basically do what we did above, but
# recreate the sysinfo_pswd file
if [ -f "/var/config/syspwl.lst" ] ; then
# quick hack to sync up sysinfo passwords
echo "attempting to sync sysinfo.cgi auth credentials" >> /dev/console
ORGPASS="`cat /var/config/.sysinfo_pswd | grep admin | cut -d':' -f2`"
ADMPASS="`cat /var/config/syspwl.lst | grep 1000 | cut -d':' -f2`"
if [ "$ORGPASS" != "$ADMPASS" ] ; then
echo "sync sysinfo.cgi auth credentials from syspwl.lst" >> /dev/console
echo "admin:$ADMPASS" > /var/config/.sysinfo_pswd
fi
else
echo "admin:admin" > /var/config/.sysinfo_pswd
fi
fi
#echo "[utopia][init] Loading LEDS and Buttons drivers" - not in dakota
#/sbin/modprobe gpio_keys
/sbin/modprobe button-hotplug
#killall -q hotplug2
#wait
#QCA driver will load cal data from /tmp. Cannot be any other directory
calpart=`grep "0:ART" /proc/mtd | awk -F: '{print $1}'`
if [ "$calpart" != "" ]; then
echo "[utopia][init] Load WiFi cal data from MTD("$calpart") to FS."
HK_BD_FILENAME=/lib/firmware/IPQ8074_FW/bdwlan.bin
mkdir -p /tmp/IPQ8074
dd if=/dev/$calpart of=/tmp/wifi1.caldata bs=1 count=12064 skip=208896
FILESIZE=$(stat -Lc%s "$HK_BD_FILENAME")
dd if=/dev/$calpart of=/tmp/IPQ8074/caldata.bin bs=1 count=$FILESIZE skip=4096
fi
#restart run-time hotplug2 for buttons handler
[ -x /sbin/hotplug2 ] && /sbin/hotplug2 --override --persistent \
--set-rules-file /etc/hotplug2.rules \
--set-coldplug-cmd /sbin/udevtrigger \
--max-children 1 >/dev/null 2>&1 &
#Create wifi f/w directory and copy all files there to this place
#so that wifi devices can load its firmware and board data file when
#special files are needed for specific region.
REGION=`skuapi -g cert_region | cut -d'=' -f2 | tr -d ' '`
echo "[utopia][init] Setup link to WiFi firmware and board data ($REGION)"
if [ "$REGION" = "ME" -o "$REGION" = "CN" -o "$REGION" = "AH" -o "$REGION" = "KR" ] ; then
syscfg_set wifi::multiregion_enable 1
syscfg_set wifi::multiregion_supportedcountries "USA,CAN,EEE,CHN,HKG,IND,PHL,SGP,THA,XAH,TWN,JPN,KOR,AUS,NZL,XME,SAU"
SELECTEDCOUNTRY=`syscfg get wifi::multiregion_selectedcountry`
if [ "$SELECTEDCOUNTRY" = "" ] && [ "$REGION" = "ME" ] ; then
syscfg_set wifi::multiregion_region ME
syscfg_set wifi::multiregion_selectedcountry XME
fi
if [ "$SELECTEDCOUNTRY" = "" ] && [ "$REGION" = "CN" ] ; then
syscfg_set wifi::multiregion_region CN
syscfg_set wifi::multiregion_selectedcountry CHN
fi
if [ "$SELECTEDCOUNTRY" = "" ] && [ "$REGION" = "AH" ] ; then
syscfg_set wifi::multiregion_region AH
syscfg_set wifi::multiregion_selectedcountry XAH
fi
if [ "$SELECTEDCOUNTRY" = "" ] && [ "$REGION" = "KR" ] ; then
syscfg_set wifi::multiregion_region KR
syscfg_set wifi::multiregion_selectedcountry KOR
fi
else
syscfg_set wifi::multiregion_enable 0
fi
COUNTRY=""
if [ "1" = "`syscfg get wifi::multiregion_support`" -a "1" = "`syscfg get wifi::multiregion_enable`" ] ; then
echo "[utopia][init] Multi-region is supported and enabled"
MULTIREGION=`syscfg get wifi::multiregion_region`
COUNTRY=`syscfg get wifi::multiregion_selectedcountry`
echo "[utopia][init] Region: $MULTIREGION, Country: $COUNTRY"
#echo "$MULTIREGION" > /tmp/zb_power_region
else
echo "[utopia][init] Multi-region is not supported or not enabled"
echo "[utopia][init] Cert region: $REGION"
#echo "$REGION" > /tmp/zb_power_region
fi
if [ ! -d /tmp/IPQ8074/WIFI_FW ]; then
mkdir -p /tmp/IPQ8074/WIFI_FW
cp -r /lib/firmware/IPQ8074_FW/*.* /tmp/IPQ8074/WIFI_FW
cd /tmp/IPQ8074 && ln -sf WIFI_FW/*.* .
rm /tmp/IPQ8074/bdwlan.bin
rm /tmp/IPQ8074/bdwlan.b293
ln -sf /tmp/IPQ8074/bdwlan.bin /tmp/IPQ8074/bdwlan.b293
fi
if [ ! -d /tmp/QCA9984 ]; then
mkdir /tmp/QCA9984
cp -r /lib/firmware/QCA9984/hw_1 /tmp/QCA9984/hw.1
rm /tmp/QCA9984/hw.1/boardData_QCA9984_CUS239_high_band_5G_v1_006.bin
ln -sf /tmp/QCA9984/hw.1/boarddata_1.bin /tmp/QCA9984/hw.1/boardData_QCA9984_CUS239_high_band_5G_v1_006.bin
fi
#Override with default FCC data
cp /lib/firmware/QCA9984/FCC/* /tmp/QCA9984/hw.1
cp /lib/firmware/IPQ8074_FW/FCC/* /tmp/IPQ8074
#Override with regional board data if not FCC.
if [ "$COUNTRY" ] ; then
case "$COUNTRY" in
"CHN") #China
echo "[utopia][init] Using CHN region for WiFi firmware and board data"
syscfg_set wifi::multiregion_region CN
cp /lib/firmware/IPQ8074_FW/CN/* /tmp/IPQ8074
cp /lib/firmware/QCA9984/CN/* /tmp/QCA9984/hw.1
;;
"HKG") #HKG
echo "[utopia][init] Using HKG region for WiFi firmware and board data"
syscfg_set wifi::multiregion_region HK
cp /lib/firmware/IPQ8074_FW/HK/* /tmp/IPQ8074
cp /lib/firmware/QCA9984/HK/* /tmp/QCA9984/hw.1
;;
"IND") #India
echo "[utopia][init] Using IND region for WiFi firmware and board data"
syscfg_set wifi::multiregion_region IN
cp /lib/firmware/IPQ8074_FW/IN/* /tmp/IPQ8074
cp /lib/firmware/QCA9984/IN/* /tmp/QCA9984/hw.1
;;
"PHL") #Philippines
echo "[utopia][init] Using PHL region for WiFi firmware and board data"
syscfg_set wifi::multiregion_region PH
cp /lib/firmware/IPQ8074_FW/PH/* /tmp/IPQ8074
cp /lib/firmware/QCA9984/PH/* /tmp/QCA9984/hw.1
;;
"SGP") #Singapore
echo "[utopia][init] Using SGP region for WiFi firmware and board data"
syscfg_set wifi::multiregion_region SG
cp /lib/firmware/IPQ8074_FW/SG/* /tmp/IPQ8074
cp /lib/firmware/QCA9984/SG/* /tmp/QCA9984/hw.1
;;
"THA") #Thailand
echo "[utopia][init] Using THA region for WiFi firmware and board data"
syscfg_set wifi::multiregion_region TH
cp /lib/firmware/IPQ8074_FW/TH/* /tmp/IPQ8074
cp /lib/firmware/QCA9984/TH/* /tmp/QCA9984/hw.1
;;
"XAH")
echo "[utopia][init] Using XAH region for WiFi firmware and board data"
syscfg_set wifi::multiregion_region AH
cp /lib/firmware/IPQ8074_FW/AH/* /tmp/IPQ8074
cp /lib/firmware/QCA9984/AH/* /tmp/QCA9984/hw.1
;;
"TWN")
echo "[utopia][init] Using TWN region for WiFi firmware and board data"
syscfg_set wifi::multiregion_region US
cp /lib/firmware/IPQ8074_FW/TW/* /tmp/IPQ8074
cp /lib/firmware/QCA9984/TW/* /tmp/QCA9984/hw.1
;;
"AUS")
echo "[utopia][init] Using AUS region for WiFi firmware and board data"
syscfg_set wifi::multiregion_region AU
cp /lib/firmware/IPQ8074_FW/AU/* /tmp/IPQ8074
cp /lib/firmware/QCA9984/AU/* /tmp/QCA9984/hw.1
;;
"CAN")
echo "[utopia][init] Using CAN region for WiFi firmware and board data"
syscfg_set wifi::multiregion_region CA
if [ "$REGION" = "CN" ] ; then
cp /lib/firmware/IPQ8074_FW/IC_MPT/* /tmp/IPQ8074
cp /lib/firmware/QCA9984/IC_MPT/* /tmp/QCA9984/hw.1
else
cp /lib/firmware/IPQ8074_FW/IC/* /tmp/IPQ8074
cp /lib/firmware/QCA9984/IC/* /tmp/QCA9984/hw.1
fi
;;
"EEE")
echo "[utopia][init] Using EEE region for WiFi firmware and board data"
syscfg_set wifi::multiregion_region EU
if [ "$REGION" = "CN" ] ; then
cp /lib/firmware/IPQ8074_FW/EU_MPT/* /tmp/IPQ8074
cp /lib/firmware/QCA9984/EU_MPT/* /tmp/QCA9984/hw.1
else
cp /lib/firmware/IPQ8074_FW/EU/* /tmp/IPQ8074
cp /lib/firmware/QCA9984/EU/* /tmp/QCA9984/hw.1
fi
;;
"XME")
echo "[utopia][init] Using XME region for WiFi firmware and board data"
syscfg_set wifi::multiregion_region ME
cp /lib/firmware/IPQ8074_FW/ME/* /tmp/IPQ8074
cp /lib/firmware/QCA9984/ME/* /tmp/QCA9984/hw.1
;;
"NZL")
echo "[utopia][init] Using NZL region for WiFi firmware and board data"
syscfg_set wifi::multiregion_region AU
cp /lib/firmware/IPQ8074_FW/AU/* /tmp/IPQ8074
cp /lib/firmware/QCA9984/AU/* /tmp/QCA9984/hw.1
;;
"SAU")
echo "[utopia][init] Using SAU region for WiFi firmware and board data"
syscfg_set wifi::multiregion_region ME
cp /lib/firmware/IPQ8074_FW/ME/* /tmp/IPQ8074
cp /lib/firmware/QCA9984/ME/* /tmp/QCA9984/hw.1
;;
"USA")
echo "[utopia][init] Using USA region for WiFi firmware and board data"
syscfg_set wifi::multiregion_region US
if [ "$REGION" = "CN" ] ; then
cp /lib/firmware/IPQ8074_FW/FCC_MPT/* /tmp/IPQ8074
cp /lib/firmware/QCA9984/FCC_MPT/* /tmp/QCA9984/hw.1
else
cp /lib/firmware/IPQ8074_FW/FCC/* /tmp/IPQ8074
cp /lib/firmware/QCA9984/FCC/* /tmp/QCA9984/hw.1
fi
;;
"JPN")
echo "[utopia][init] Using JPN region for WiFi firmware and board data"
syscfg_set wifi::multiregion_region JP
cp /lib/firmware/IPQ8074_FW/JP/* /tmp/IPQ8074
cp /lib/firmware/QCA9984/JP/* /tmp/QCA9984/hw.1
;;
"KOR")
echo "[utopia][init] Using KOR region for WiFi firmware and board data"
syscfg_set wifi::multiregion_region KR
cp /lib/firmware/IPQ8074_FW/KR/* /tmp/IPQ8074
cp /lib/firmware/QCA9984/KR/* /tmp/QCA9984/hw.1
;;
*)
echo "[utopia][init] Critical error, no support Country Code"
;;
esac
else
case "$REGION" in
"CA")
echo "[utopia][init] Using CA region for WiFi firmware and board data"
cp /lib/firmware/IPQ8074_FW/IC/* /tmp/IPQ8074
cp /lib/firmware/QCA9984/IC/* /tmp/QCA9984/hw.1
;;
"AU")
echo "[utopia][init] Using AU region for WiFi firmware and board data"
cp /lib/firmware/IPQ8074_FW/AU/* /tmp/IPQ8074
cp /lib/firmware/QCA9984/AU/* /tmp/QCA9984/hw.1
;;
"AH")
echo "[utopia][init] Using AH region for WiFi firmware and board data"
cp /lib/firmware/IPQ8074_FW/AH/* /tmp/IPQ8074
cp /lib/firmware/QCA9984/AH/* /tmp/QCA9984/hw.1
;;
"AP")
echo "[utopia][init] Using AP region for WiFi firmware and board data"
cp /lib/firmware/IPQ8074_FW/AP/* /tmp/IPQ8074
cp /lib/firmware/QCA9984/AP/* /tmp/QCA9984/hw.1
;;
"EU")
echo "[utopia][init] Using EU region for WiFi firmware and board data"
cp /lib/firmware/IPQ8074_FW/EU/* /tmp/IPQ8074
cp /lib/firmware/QCA9984/EU/* /tmp/QCA9984/hw.1
;;
"PH")
echo "[utopia][init] Using PH region for WiFi firmware and board data"
cp /lib/firmware/IPQ8074_FW/PH/* /tmp/IPQ8074
cp /lib/firmware/QCA9984/PH/* /tmp/QCA9984/hw.1
;;
"ME")
echo "[utopia][init] Using ME region for WiFi firmware and board data"
cp /lib/firmware/IPQ8074_FW/ME/* /tmp/IPQ8074
cp /lib/firmware/QCA9984/ME/* /tmp/QCA9984/hw.1
;;
"CN")
echo "[utopia][init] Using CN region for WiFi firmware and board data"
cp /lib/firmware/IPQ8074_FW/CN/* /tmp/IPQ8074
cp /lib/firmware/QCA9984/CN/* /tmp/QCA9984/hw.1
;;
"JP")
echo "[utopia][init] Using JP region for WiFi firmware and board data"
cp /lib/firmware/IPQ8074_FW/JP/* /tmp/IPQ8074
cp /lib/firmware/QCA9984/JP/* /tmp/QCA9984/hw.1
;;
"KR")
echo "[utopia][init] Using KR region for WiFi firmware and board data"
cp /lib/firmware/IPQ8074_FW/KR/* /tmp/IPQ8074
cp /lib/firmware/QCA9984/KR/* /tmp/QCA9984/hw.1
;;
"HK")
echo "[utopia][init] Using HK region for WiFi firmware and board data"
cp /lib/firmware/IPQ8074_FW/HK/* /tmp/IPQ8074
cp /lib/firmware/QCA9984/HK/* /tmp/QCA9984/hw.1
;;
"ID")
echo "[utopia][init] Using ID region for WiFi firmware and board data"
cp /lib/firmware/IPQ8074_FW/ID/* /tmp/IPQ8074
cp /lib/firmware/QCA9984/ID/* /tmp/QCA9984/hw.1
;;
"IN")
echo "[utopia][init] Using IN region for WiFi firmware and board data"
cp /lib/firmware/IPQ8074_FW/IN/* /tmp/IPQ8074
cp /lib/firmware/QCA9984/IN/* /tmp/QCA9984/hw.1
;;
"TH")
echo "[utopia][init] Using TH region for WiFi firmware and board data"
cp /lib/firmware/IPQ8074_FW/TH/* /tmp/IPQ8074
cp /lib/firmware/QCA9984/TH/* /tmp/QCA9984/hw.1
;;
"SG")
echo "[utopia][init] Using SG region for WiFi firmware and board data"
cp /lib/firmware/IPQ8074_FW/SG/* /tmp/IPQ8074
cp /lib/firmware/QCA9984/SG/* /tmp/QCA9984/hw.1
;;
"VN")
echo "[utopia][init] Using Vietnam region for WiFi firmware and board data"
cp /lib/firmware/IPQ8074_FW/VN/* /tmp/IPQ8074
cp /lib/firmware/QCA9984/VN/* /tmp/QCA9984/hw.1
;;
"MY")
echo "[utopia][init] Using MY region for WiFi firmware and board data"
cp /lib/firmware/IPQ8074_FW/AH/* /tmp/IPQ8074
cp /lib/firmware/QCA9984/AH/* /tmp/QCA9984/hw.1
;;
"TW")
echo "[utopia][init] Using TW region for WiFi firmware and board data"
cp /lib/firmware/IPQ8074_FW/TW/* /tmp/IPQ8074
cp /lib/firmware/QCA9984/TW/* /tmp/QCA9984/hw.1
;;
*)
echo "[utopia][init] No REGION definded, use FCC"
;;
esac
fi
syscfg_commit
#start NSS RPS
if [ -e /etc/init.d/qca-nss-drv ]; then
/etc/init.d/qca-nss-drv start autoscaling-disable
fi
if [ -f /etc/sysctl.d/qca-nss-drv.conf ]; then
sysctl -p /etc/sysctl.d/qca-nss-drv.conf
fi
# ECM start, sysctl also call in service_system script
/sbin/modprobe bonding
echo "[utopia][init] Loading QCA Enhanced Connection manager"
if [ -e /etc/init.d/qca-nss-ecm ]; then
/etc/init.d/qca-nss-ecm start
fi
if [ -f /etc/sysctl.d/qca-nss-ecm.conf ]; then
sysctl -p /etc/sysctl.d/qca-nss-ecm.conf
fi
#echo "inserting fpbypass"
if [ "`syscfg get fastpath_support`" == "1" ] ; then
if [ "`syscfg get nss_support`" == "1" ] && [ -e $MODULE_PATH/ecm.ko ] ; then
echo "inserting fpbypass.ko for QCA"
insmod $MODULE_PATH/fpbypass.ko
else
echo "error when inserting fpbypass"
fi
fi
# set up kernel panic logging if needed.
if [ -e /etc/init.d/setup_kpaniclog.sh ]; then
/etc/init.d/setup_kpaniclog.sh
fi
# The code below attempts to sync up the current admin password ( which may have
# been changed, with the admin http_auth password for the sysinfo.cgi file.
# Matt Fatheree appologizes in advance for this spaghetti code.
# BEWARE: here there be dragons
if [ ! -f "/var/config/.sysinfo_pswd" ] ; then
if [ -f "/var/config/syspwl.lst" ] ; then
# if there is an admin password already set try to use that
ADMPASS="`cat /var/config/syspwl.lst | grep 1000 | cut -d':' -f2`"
echo "admin:$ADMPASS" > /var/config/.sysinfo_pswd
else
echo "admin:admin" > /var/config/.sysinfo_pswd
fi
else
# this is a case for when someone has changed the admin passwd
# before they had code that supported protecting sysinfo.cgi
# in that case the sysinfo_pswd exists, but has the default admin:admin
# password combination. In that case, we basically do what we did above, but
# recreate the sysinfo_pswd file
if [ -f "/var/config/syspwl.lst" ] ; then
# quick hack to sync up sysinfo passwords
echo "attempting to sync sysinfo.cgi auth credentials" >> /dev/console
ORGPASS="`cat /var/config/.sysinfo_pswd | grep admin | cut -d':' -f2`"
ADMPASS="`cat /var/config/syspwl.lst | grep 1000 | cut -d':' -f2`"
if [ "$ORGPASS" != "$ADMPASS" ] ; then
echo "sync sysinfo.cgi auth credentials from syspwl.lst" >> /dev/console
echo "admin:$ADMPASS" > /var/config/.sysinfo_pswd
fi
else
echo "admin:admin" > /var/config/.sysinfo_pswd
fi
fi
# NODES-2358
ethtool -K eth0 tso off
ethtool -K eth1 tso off
if [ -e "/usr/bin/lldpd" ] ; then
#addgroup _lldpd
echo "adding group for lldpd user"
echo "_lldpd:x:1005:admin" >> /tmp/etc/.root/group
fi
# make sure /dev/null permission is 666
chmod 666 /dev/null
# fix syscfg bridge_1 variables so that users do not need to factory reset
# fixed needed because of splitting bridge into two; bridge_2 will automatically be added
# added to end because sysevent daemon wasn't up
syscfg_reset "switch::bridge_max"
# bridge_1
syscfg_reset "switch::bridge_1::ifname"
syscfg_reset "switch::bridge_1::physical_ifname"
syscfg_reset "switch::bridge_1::port_numbers"
syscfg_reset "switch::bridge_1::port_names"
# unset switch::bridge_1::wan_monitor_port; monitor using bridge_2 instead
#syscfg_unset "switch::bridge_1::wan_monitor_port"
# commit if any changes
syscfg_commit
#move to here for Bronx, because Quartz need more time to become ready
# Get BTLE radio ready
echo "[utopia][init] Initializing BTLE interface" >> /dev/console
BTRESETGPIO="21"
echo $BTRESETGPIO >/sys/class/gpio/export
echo out >/sys/class/gpio/gpio${BTRESETGPIO}/direction
#moved to iotd
#echo 0 >/sys/class/gpio/gpio${BTRESETGPIO}/value
#sleep 0.05
#echo 1 >/sys/class/gpio/gpio${BTRESETGPIO}/value
#sleep 0.05
# Program BT Mac address
BT_MAC_ADDR=`syscfg get bt_mac_addr`
BT_MAC_ADDR=`echo "$BT_MAC_ADDR" | tr -s ':' ' '`
MAC0=`echo "$BT_MAC_ADDR" | awk '{print $1}'`
MAC1=`echo "$BT_MAC_ADDR" | awk '{print $2}'`
MAC2=`echo "$BT_MAC_ADDR" | awk '{print $3}'`
MAC3=`echo "$BT_MAC_ADDR" | awk '{print $4}'`
MAC4=`echo "$BT_MAC_ADDR" | awk '{print $5}'`
MAC5=`echo "$BT_MAC_ADDR" | awk '{print $6}'`
CERT_REGION=`skuapi -g cert_region | cut -d'=' -f2 | tr -d ' '`
# Dallas uses the same psr file for all cert regions.
#PSR="/etc/csr8x11-a12-bt4.2.psr"
echo "[utopia][init] Bluetooth Mac Address: $BT_MAC_ADDR" >> /dev/console
echo "[utopia][init] Cert Region: $CERT_REGION" >> /dev/console
#echo "[utopia][init] BT PSR: $PSR" >> /dev/console
if [ -c /dev/spidev32765.0 ] ; then
echo "[utopia][init] BTLE interface ready to use" >> /dev/console
# Start btsetup service
sysevent set btsetup-start
sysevent set quartzfwup 0
else
echo "[utopia][init] BTLE interface failed" >> /dev/console
fi
# Change guest access auth port to 11161 (Ref. OLYMPUS-154)
# Some clients unable to get redirect to guest captive portal for authentication
if [ "$(syscfg get guest_auth_port)" != "11161" ]; then
echo "[utopia][init] Setting guest access auth port to 11161" >> /dev/console
syscfg set guest_auth_port 11161
syscfg commit
fi