shell scripts clean up and formatting (#874)

pull/876/head
Paul Philippov 2023-06-11 15:44:27 -04:00 committed by GitHub
parent 52f4b1ec5c
commit 500d11cbc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 803 additions and 731 deletions

View File

@ -1,17 +1,17 @@
config BR2_OPENIPC_SOC_VENDOR config BR2_OPENIPC_SOC_VENDOR
string "openipc soc vendor" string "SoC vendor"
default "hisilicon" default "hisilicon"
config BR2_OPENIPC_SOC_MODEL config BR2_OPENIPC_SOC_MODEL
string "openipc soc model" string "SoC model"
default "hi3516ev300" default "hi3516ev300"
config BR2_OPENIPC_SOC_FAMILY config BR2_OPENIPC_SOC_FAMILY
string "openipc soc family" string "SoC family"
default "hi3516ev200" default "hi3516ev200"
config BR2_OPENIPC_FLAVOR config BR2_OPENIPC_FLAVOR
string "openipc flavor" string "OpenIPC flavor"
default "lite" default "lite"
source "$BR2_EXTERNAL_GENERAL_PATH/package/Config.in" source "$BR2_EXTERNAL_GENERAL_PATH/package/Config.in"

View File

@ -36,19 +36,19 @@ stop() {
return "$status" return "$status"
} }
restart() {
stop
sleep 1
start
}
case "$1" in case "$1" in
start|stop|restart) start|stop)
"$1" ;; "$1"
reload) ;;
# Restart, since there is no true "reload" feature.
restart ;; restart|reload)
stop
sleep 1
start
;;
*) *)
echo "Usage: $0 {start|stop|restart|reload}" echo "Usage: $0 {start|stop|restart|reload}"
exit 1 exit 1
;;
esac esac

View File

@ -10,7 +10,8 @@ case "$1" in
[ -r /etc/modules ] || exit 0 [ -r /etc/modules ] || exit 0
while read module args; do while read module args; do
case "$module" in case "$module" in
""|"#"*) continue ;; ""|"#"*) continue
;;
esac esac
# attempt to load modules # attempt to load modules

View File

@ -1,8 +1,8 @@
#!/bin/sh #!/bin/sh
case "$1" in case "$1" in
start) start)
echo -e '\nLoading resetd...' echo -e '\nLoading resetd...'
/usr/sbin/resetd & /usr/sbin/resetd &
;; ;;
esac esac

View File

@ -32,10 +32,16 @@ stop()
case "$1" in case "$1" in
start|stop) start|stop)
"$1" ;; "$1"
;;
restart|reload) restart|reload)
stop; start ;; stop
start
;;
*) *)
echo "Usage: $0 {start|stop|restart|reload}" >&2 echo "Usage: $0 {start|stop|restart|reload}" >&2
exit 1 exit 1
;;
esac esac

View File

@ -9,13 +9,17 @@ case "$1" in
echo /sbin/mdev >/proc/sys/kernel/hotplug echo /sbin/mdev >/proc/sys/kernel/hotplug
/sbin/mdev -s /sbin/mdev -s
;; ;;
stop) stop)
;; ;;
restart|reload) restart|reload)
;; ;;
*) *)
echo "Usage: $0 {start|stop|restart}" echo "Usage: $0 {start|stop|restart|reload}"
exit 1 exit 1
;;
esac esac
exit $? exit $?

View File

@ -36,18 +36,19 @@ stop() {
return "$status" return "$status"
} }
restart() {
stop
sleep 1
start
}
case "$1" in case "$1" in
start|stop|restart) start|stop)
"$1" ;; "$1"
;;
reload) reload)
restart ;; stop
sleep 1
start
;;
*) *)
echo "Usage: $0 {start|stop|restart|reload}" echo "Usage: $0 {start|stop|restart|reload}"
exit 1 exit 1
;;
esac esac

View File

@ -30,24 +30,27 @@ start() {
start-stop-daemon -S -q -p /var/run/dropbear.pid --exec /usr/sbin/dropbear -- $DROPBEAR_ARGS start-stop-daemon -S -q -p /var/run/dropbear.pid --exec /usr/sbin/dropbear -- $DROPBEAR_ARGS
[ $? = 0 ] && echo "OK" || echo "FAIL" [ $? = 0 ] && echo "OK" || echo "FAIL"
} }
stop() { stop() {
printf "Stopping dropbear sshd: " printf "Stopping dropbear sshd: "
start-stop-daemon -K -q -p /var/run/dropbear.pid start-stop-daemon -K -q -p /var/run/dropbear.pid
[ $? = 0 ] && echo "OK" || echo "FAIL" [ $? = 0 ] && echo "OK" || echo "FAIL"
} }
restart() {
stop
start
}
case "$1" in case "$1" in
start|stop|restart) start|stop)
"$1" ;; "$1"
reload) ;;
restart ;;
restart|reload)
stop
start
;;
*) *)
echo "Usage: $0 {start|stop|restart}" echo "Usage: $0 {start|stop|restart|reload}"
exit 1 exit 1
;;
esac esac
exit $? exit $?

View File

@ -38,18 +38,19 @@ stop() {
return "$status" return "$status"
} }
restart() {
stop
sleep 1
start
}
case "$1" in case "$1" in
start|stop|restart) start|stop)
"$1" ;; "$1"
reload) ;;
restart ;;
restart|reload)
stop
sleep 1
start
;;
*) *)
echo "Usage: $0 {start|stop|restart|reload}" echo "Usage: $0 {start|stop|restart|reload}"
exit 1 exit 1
;;
esac esac

View File

@ -22,12 +22,18 @@ stop() {
case "$1" in case "$1" in
start|stop) start|stop)
"$1" ;; "$1"
;;
restart|reload) restart|reload)
stop; start ;; stop
start
;;
*) *)
echo "Usage: $0 {start|stop|restart}" echo "Usage: $0 {start|stop|restart|reload}"
exit 1 exit 1
;;
esac esac
exit $? exit $?

View File

@ -38,18 +38,19 @@ stop() {
return "$status" return "$status"
} }
restart() {
stop
sleep 1
start
}
case "$1" in case "$1" in
start|stop|restart) start|stop)
"$1" ;; "$1"
reload) ;;
restart ;;
restart|reload)
stop
sleep 1
start
;;
*) *)
echo "Usage: $0 {start|stop|restart|reload}" echo "Usage: $0 {start|stop|restart|reload}"
exit 1 exit 1
;;
esac esac

View File

@ -1,7 +1,6 @@
#!/bin/sh #!/bin/sh
# load vendor specific drivers # load vendor specific drivers
#
vendor=$(ipcinfo -v) vendor=$(ipcinfo -v)
status=$(check_mac) status=$(check_mac)

View File

@ -1,37 +1,30 @@
#!/bin/sh #!/bin/sh
# Setting the TimeZone for all processes # Setting the TimeZone for all processes
#
export TZ=$(cat /etc/TZ) export TZ=$(cat /etc/TZ)
# Set the firmware creation time as the base system time # Set the firmware creation time as the base system time
#
/bin/date -s @$(stat -t /etc/os-release | cut -d" " -f12) /bin/date -s @$(stat -t /etc/os-release | cut -d" " -f12)
# Start all init scripts in /etc/init.d # Start all init scripts in /etc/init.d
# executing them in numerical order. # executing them in numerical order.
# for i in /etc/init.d/S??* ; do
for i in /etc/init.d/S??* ;do # Ignore dangling symlinks (if any).
[ ! -f "$i" ] && continue
# Ignore dangling symlinks (if any). case "$i" in
[ ! -f "$i" ] && continue *.sh)
# Source shell script for speed.
(
trap - INT QUIT TSTP
set start
$i
)
;;
case "$i" in *)
*.sh) # No sh extension, so fork subprocess.
# Source shell script for speed. $i start
( ;;
trap - INT QUIT TSTP esac
set start
. $i
)
;;
*)
# No sh extension, so fork subprocess.
$i start
;;
esac
done done

View File

@ -7,13 +7,20 @@
case "$IF_BRIDGE_PORTS" in case "$IF_BRIDGE_PORTS" in
"") "")
exit 0 ;; exit 0
;;
none) none)
INTERFACES="" ;; INTERFACES=""
;;
all) all)
INTERFACES=$(grep eth /proc/net/dev|sed 's/\(\ *\)\(eth[^:]*\)\(.*\)/\2/') ;; INTERFACES=$(grep eth /proc/net/dev|sed 's/\(\ *\)\(eth[^:]*\)\(.*\)/\2/')
;;
*) *)
INTERFACES="$IF_BRIDGE_PORTS" ;; INTERFACES="$IF_BRIDGE_PORTS"
;;
esac esac
brctl delbr $IFACE brctl delbr $IFACE

View File

@ -7,13 +7,20 @@
case "$IF_BRIDGE_PORTS" in case "$IF_BRIDGE_PORTS" in
"") "")
exit 0 ;; exit 0
;;
none) none)
INTERFACES="" ;; INTERFACES=""
;;
all) all)
INTERFACES=$(grep eth /proc/net/dev|sed 's/\(\ *\)\(eth[^:]*\)\(.*\)/\2/') ;; INTERFACES=$(grep eth /proc/net/dev|sed 's/\(\ *\)\(eth[^:]*\)\(.*\)/\2/')
;;
*) *)
INTERFACES="$IF_BRIDGE_PORTS" ;; INTERFACES="$IF_BRIDGE_PORTS"
;;
esac esac
brctl addbr $IFACE && brctl addbr $IFACE &&

View File

@ -3,34 +3,41 @@
# Most of this stuff is to enable vlans # Most of this stuff is to enable vlans
case "$IFACE" in case "$IFACE" in
vlan0*) vlan0*)
vconfig set_name_type VLAN_PLUS_VID vconfig set_name_type VLAN_PLUS_VID
VLANID=$(echo $IFACE|sed "s/vlan0*//") VLANID=$(echo $IFACE|sed "s/vlan0*//")
;; ;;
vlan*) vlan*)
vconfig set_name_type VLAN_PLUS_VID_NO_PAD vconfig set_name_type VLAN_PLUS_VID_NO_PAD
VLANID=$(echo $IFACE|sed "s/vlan*//") VLANID=$(echo $IFACE|sed "s/vlan*//")
;; ;;
*.0*) *.0*)
vconfig set_name_type DEV_PLUS_VID vconfig set_name_type DEV_PLUS_VID
VLANID=$(echo $IFACE|sed "s/.*\.0*\([0-9]\+\)$/\1/g") VLANID=$(echo $IFACE|sed "s/.*\.0*\([0-9]\+\)$/\1/g")
IF_VLAN_RAW_DEVICE=$(echo $IFACE|sed "s/^\(.*\)\.[^.]*/\1/") IF_VLAN_RAW_DEVICE=$(echo $IFACE|sed "s/^\(.*\)\.[^.]*/\1/")
;; ;;
*.*) *.*)
vconfig set_name_type DEV_PLUS_VID_NO_PAD vconfig set_name_type DEV_PLUS_VID_NO_PAD
VLANID=$(echo $IFACE|sed "s/.*\.0*\([0-9]\+\)$/\1/g") VLANID=$(echo $IFACE|sed "s/.*\.0*\([0-9]\+\)$/\1/g")
IF_VLAN_RAW_DEVICE=$(echo $IFACE|sed "s/^\(.*\)\.[^.]*/\1/") IF_VLAN_RAW_DEVICE=$(echo $IFACE|sed "s/^\(.*\)\.[^.]*/\1/")
;; ;;
*) *)
exit 0 exit 0
;;
esac esac
if [ -n "$IF_VLAN_RAW_DEVICE" ]; then if [ -n "$IF_VLAN_RAW_DEVICE" ]; then
[ ! -x /sbin/vconfig ] && exit 0 [ ! -x /sbin/vconfig ] && exit 0
if ! ip link show dev "$IF_VLAN_RAW_DEVICE" > /dev/null; then if ! ip link show dev "$IF_VLAN_RAW_DEVICE" > /dev/null; then
echo "$IF_VLAN_RAW_DEVICE does not exist, unable to create $IFACE" echo "$IF_VLAN_RAW_DEVICE does not exist, unable to create $IFACE"
exit 1 exit 1
fi fi
ip link set up dev $IF_VLAN_RAW_DEVICE ip link set up dev $IF_VLAN_RAW_DEVICE
vconfig add $IF_VLAN_RAW_DEVICE $VLANID vconfig add $IF_VLAN_RAW_DEVICE $VLANID
fi fi

View File

@ -23,17 +23,29 @@ export EDITOR='/bin/vi'
[ -x /usr/bin/arp ] || arp() { cat /proc/net/arp; } [ -x /usr/bin/arp ] || arp() { cat /proc/net/arp; }
differ() { diff -rN "/rom$1" "$1"; } differ() {
diff -rN "/rom$1" "$1"
}
majestic_changes() { diff -L "Majestic changes" -U 3 /rom/etc/majestic.yaml /etc/majestic.yaml; } majestic_changes() {
diff -L "Majestic changes" -U 3 /rom/etc/majestic.yaml /etc/majestic.yaml
}
show_modules() { echo; cat /proc/modules | cut -f 1 -d " " | while read module; do echo "Module: $module"; \ show_modules() {
echo; cat /proc/modules | cut -f 1 -d " " | while read module; do echo "Module: $module"; \
if [ -d "/sys/module/$module/parameters" ]; then ls /sys/module/$module/parameters/ | while read parameter; \ if [ -d "/sys/module/$module/parameters" ]; then ls /sys/module/$module/parameters/ | while read parameter; \
do echo -n "Parameter: $parameter --> "; cat /sys/module/$module/parameters/$parameter; done; fi; echo; done; } do echo -n "Parameter: $parameter --> "; cat /sys/module/$module/parameters/$parameter; done; fi; echo; done
}
show_fullname() { echo "openipc-$(ipcinfo --chip-name)-$(ipcinfo --short-sensor)"; } show_fullname() {
echo "openipc-$(ipcinfo --chip-name)-$(ipcinfo --short-sensor)"
}
set_fullname() { show_fullname >/etc/hostname; } set_fullname() {
show_fullname >/etc/hostname
}
# Source configuration files from /etc/profile.d # Source configuration files from /etc/profile.d
for i in /etc/profile.d/*.sh; do [ -r "$i" ] && . $i; done; unset i for i in /etc/profile.d/*.sh; do
[ -r "$i" ] && . $i
done; unset i

View File

@ -13,9 +13,11 @@ case "${CMD}" in
cli) cli)
yaml-cli -i /etc/majestic.yaml "$@" yaml-cli -i /etc/majestic.yaml "$@"
;; ;;
sensor_cli) sensor_cli)
yaml-cli -i /etc/sensor/$(fw_printenv -n sensor).yaml $@ yaml-cli -i /etc/sensor/$(fw_printenv -n sensor).yaml $@
;; ;;
ipctool) ipctool)
IPCTOOL=/tmp/ipctool IPCTOOL=/tmp/ipctool
if [ ! -x $IPCTOOL ]; then if [ ! -x $IPCTOOL ]; then
@ -25,11 +27,13 @@ case "${CMD}" in
fi fi
$IPCTOOL $@ $IPCTOOL $@
;; ;;
check_mac) check_mac)
if [ "$(fw_printenv -n ethaddr)" = "00:00:23:34:45:66" ]; then if [ "$(fw_printenv -n ethaddr)" = "00:00:23:34:45:66" ]; then
XMMAC="$(ipcinfo --xm-mac)" && [ -n "${XMMAC}" ] && [ ! "Nothing found." = "${XMMAC}" ] && fw_setenv ethaddr ${XMMAC} && reboot -f || echo "Warning. Wired network interface has default MAC address, please change it." XMMAC="$(ipcinfo --xm-mac)" && [ -n "${XMMAC}" ] && [ ! "Nothing found." = "${XMMAC}" ] && fw_setenv ethaddr ${XMMAC} && reboot -f || echo "Warning. Wired network interface has default MAC address, please change it."
fi fi
;; ;;
*) *)
;; ;;
esac esac

View File

@ -5,7 +5,7 @@
set -e set -e
if [ "$1" = "-s" ]; then if [ "$1" = "-s" ]; then
sysupgrade -n -x sysupgrade -n -x
else else
sysupgrade -n sysupgrade -n
fi fi

View File

@ -1,105 +1,105 @@
#!/bin/sh #!/bin/sh
help() { help() {
echo -e "\n=== GPIO usage ===\n" echo -e "\n=== GPIO usage ===\n"
echo -e ">\t gpio <set|clear|toggle|unexport|read> <pin>\n" echo -e ">\t gpio <set|clear|toggle|unexport|read> <pin>\n"
echo -e "set\t\t = Output HI\nclear\t\t = Output LOW\ntoggle\t\t = Swap HI <> LOW\nunexport\t = Release GPIO pin back to the kernel space\nread\t\t = Read GPIO pin output state\n" echo -e "set\t\t = Output HI\nclear\t\t = Output LOW\ntoggle\t\t = Swap HI <> LOW\nunexport\t = Release GPIO pin back to the kernel space\nread\t\t = Read GPIO pin output state\n"
echo -e "---\n" echo -e "---\n"
echo -e ">\t gpio search <from pin> <to pin>\n" echo -e ">\t gpio search <from pin> <to pin>\n"
echo -e "Toggle a range of GPIO pins from HI to LOW" echo -e "Toggle a range of GPIO pins from HI to LOW"
echo -e "gpio search logs to syslog\n" echo -e "gpio search logs to syslog\n"
echo -e "==================\n" echo -e "==================\n"
} }
exp() { exp() {
if [ ! -d /sys/class/gpio/gpio$1 ]; then if [ ! -d /sys/class/gpio/gpio$1 ]; then
[ ! -f /sys/class/gpio/export ] && echo "Error: No export file!" && exit [ ! -f /sys/class/gpio/export ] && echo "Error: No export file!" && exit
echo $1 > /sys/class/gpio/export echo $1 > /sys/class/gpio/export
[ ! -f /sys/class/gpio/gpio$1/direction ] && echo "Error: No direction file!" && exit [ ! -f /sys/class/gpio/gpio$1/direction ] && echo "Error: No direction file!" && exit
echo out > /sys/class/gpio/gpio$1/direction echo out > /sys/class/gpio/gpio$1/direction
fi fi
} }
write(){ write(){
echo $1 > /sys/class/gpio/gpio$2/value echo $1 > /sys/class/gpio/gpio$2/value
} }
read() { read() {
[ ! -f /sys/class/gpio/gpio$1/value ] && echo "Error: GPIO-$1 is not set" && exit [ ! -f /sys/class/gpio/gpio$1/value ] && echo "Error: GPIO-$1 is not set" && exit
echo $(cat /sys/class/gpio/gpio$1/value) echo $(cat /sys/class/gpio/gpio$1/value)
} }
unexport() { unexport() {
if [ -d /sys/class/gpio/gpio$1 ]; then if [ -d /sys/class/gpio/gpio$1 ]; then
echo $1 > /sys/class/gpio/unexport echo $1 > /sys/class/gpio/unexport
else else
echo "GPIO-${1} is not exported." echo "GPIO-${1} is not exported."
fi fi
} }
search() { search() {
echo -e "Start blink (output) on GPIO range $1 to $2\n" echo -e "Start blink (output) on GPIO range $1 to $2\n"
for pin in $(seq $1 $2); do for pin in $(seq $1 $2); do
echo "=================================" echo "================================="
exp ${pin} && echo " Exported GPIO-${pin} from kernel space" && echo " Set GPIO-${pin} to OUTPUT mode" exp ${pin} && echo " Exported GPIO-${pin} from kernel space" && echo " Set GPIO-${pin} to OUTPUT mode"
write 0 ${pin} && echo " Set GPIO-${pin} to LO level" ; sleep 1 write 0 ${pin} && echo " Set GPIO-${pin} to LO level" ; sleep 1
write 1 ${pin} && echo " Set GPIO-${pin} to HI level" ; sleep 1 write 1 ${pin} && echo " Set GPIO-${pin} to HI level" ; sleep 1
echo in > /sys/class/gpio/gpio${pin}/direction && echo " Set GPIO-${pin} to INPUT mode" echo in > /sys/class/gpio/gpio${pin}/direction && echo " Set GPIO-${pin} to INPUT mode"
unexport ${pin} && echo " Unexported GPIO-${pin}" unexport ${pin} && echo " Unexported GPIO-${pin}"
logger HELLO - ${pin} logger HELLO - ${pin}
done done
} }
if [ -n $1 ] && [ -n $2 ] && [ $2 -eq $2 ]; then if [ -n $1 ] && [ -n $2 ] && [ $2 -eq $2 ]; then
case $1 in case $1 in
set) set)
exp $2 exp $2
echo "Setting GPIO-$2 to HI" echo "Setting GPIO-$2 to HI"
write 1 $2 write 1 $2
;; ;;
clear) clear)
exp $2 exp $2
echo "Setting GPIO-$2 to LOW" echo "Setting GPIO-$2 to LOW"
write 0 $2 write 0 $2
;; ;;
toggle) toggle)
exp $2 exp $2
if [ $(read $2) -eq 0 ]; then if [ $(read $2) -eq 0 ]; then
echo "Setting GPIO-$2 to HI" echo "Setting GPIO-$2 to HI"
write 1 $2 write 1 $2
else else
echo "Setting GPIO-$2 to LOW" echo "Setting GPIO-$2 to LOW"
write 0 $2 write 0 $2
fi fi
;; ;;
unexport) unexport)
unexport $2 unexport $2
;; ;;
read) read)
echo $(read $2) echo $(read $2)
;; ;;
search) search)
if [ ! -z $3 ] && [ $3 -eq $3 ]; then if [ ! -z $3 ] && [ $3 -eq $3 ]; then
search $2 $3 search $2 $3
else else
echo -e "\n Caution: Toggling single pin. Use <gpio search <from pin> <to pin> to search a range.\n" echo -e "\n Caution: Toggling single pin. Use <gpio search <from pin> <to pin> to search a range.\n"
search $2 $2 search $2 $2
fi fi
;; ;;
*) *)
help help
;; ;;
esac esac
else else
help help
fi fi

View File

@ -5,90 +5,89 @@ GPIO_GREEN=
GPIO_BLUE= GPIO_BLUE=
help() { help() {
echo -e "\n================= LIGHT usage =================\n" echo -e "\n================= LIGHT usage =================\n"
echo -e "Set the colour of the status light\n" echo -e "Set the colour of the status light\n"
echo -e "light <off|red|green|blue|yellow|magenta|cyan|white>\n" echo -e "light <off|red|green|blue|yellow|magenta|cyan|white>\n"
} }
setRed() { setRed() {
if [ -n "$GPIO_RED" ]; then if [ -n "$GPIO_RED" ]; then
[ $1 -eq 1 ] && gpio set "$GPIO_RED" || gpio clear "$GPIO_RED" [ $1 -eq 1 ] && gpio set "$GPIO_RED" || gpio clear "$GPIO_RED"
else else
echo "[INFO] Status Lights: Red GPIO undefined in /usr/sbin/light" > /dev/kmsg echo "[INFO] Status Lights: Red GPIO undefined in /usr/sbin/light" > /dev/kmsg
fi fi
} }
setGreen() { setGreen() {
if [ -n "$GPIO_GREEN" ]; then if [ -n "$GPIO_GREEN" ]; then
[ $1 -eq 1 ] && gpio set "$GPIO_GREEN" || gpio clear "$GPIO_GREEN" [ $1 -eq 1 ] && gpio set "$GPIO_GREEN" || gpio clear "$GPIO_GREEN"
else else
echo "[INFO] Status Lights: Green GPIO undefined in /usr/sbin/light" > /dev/kmsg echo "[INFO] Status Lights: Green GPIO undefined in /usr/sbin/light" > /dev/kmsg
fi fi
} }
setBlue() { setBlue() {
if [ -n "$GPIO_BLUE" ]; then if [ -n "$GPIO_BLUE" ]; then
[ $1 -eq 1 ] && gpio set "$GPIO_BLUE" || gpio clear "$GPIO_BLUE" [ $1 -eq 1 ] && gpio set "$GPIO_BLUE" || gpio clear "$GPIO_BLUE"
else else
echo "[INFO] Status Lights: Blue GPIO undefined in /usr/sbin/light" > /dev/kmsg echo "[INFO] Status Lights: Blue GPIO undefined in /usr/sbin/light" > /dev/kmsg
fi fi
} }
if [ -n $1 ]; then if [ -n $1 ]; then
case $1 in case $1 in
off)
setRed 0
setGreen 0
setBlue 0
;;
off) red)
setRed 0 setRed 1
setGreen 0 setGreen 0
setBlue 0 setBlue 0
;; ;;
red) green)
setRed 1 setRed 0
setGreen 0 setGreen 1
setBlue 0 setBlue 0
;; ;;
green) blue)
setRed 0 setRed 0
setGreen 1 setGreen 0
setBlue 0 setBlue 1
;; ;;
blue) yellow)
setRed 0 setRed 1
setGreen 0 setGreen 1
setBlue 1 setBlue 0
;; ;;
yellow) magenta|purple)
setRed 1 setRed 1
setGreen 1 setGreen 0
setBlue 0 setBlue 1
;; ;;
magenta|purple) cyan)
setRed 1 setRed 0
setGreen 0 setGreen 1
setBlue 1 setBlue 1
;; ;;
cyan) white)
setRed 0 setRed 1
setGreen 1 setGreen 1
setBlue 1 setBlue 1
;; ;;
white) *)
setRed 1 help
setGreen 1 ;;
setBlue 1 esac
;;
*)
help
;;
esac
else else
help help
fi fi

View File

@ -5,106 +5,115 @@ manufacturer=$(fw_printenv -n manufacturer) || (>&2 echo "Manufacturer not defin
# devid=$(fw_printenv -n devid) || (>&2 echo "Device ID not defined in U-Boot ENV"; exit 1) # devid=$(fw_printenv -n devid) || (>&2 echo "Device ID not defined in U-Boot ENV"; exit 1)
case ${manufacturer} in case ${manufacturer} in
Anjoy) Anjoy)
case ${soc} in case ${soc} in
ssc335|ssc337|ssc337de) ssc335|ssc337|ssc337de)
gpio="ircut1=78 ircut2=79 light=61" gpio="ircut1=78 ircut2=79 light=61"
;; ;;
esac esac
;; ;;
Camhi|Hichip|Xin)
case ${soc} in Camhi|Hichip|Xin)
hi3516ev200|gk7205v200) case ${soc} in
gpio="usb_ena=-9" hi3516ev200|gk7205v200)
;; gpio="usb_ena=-9"
hi3516ev300|gk7205v300) ;;
gpio="ircut1=10 ircut2=11 usb_ena=-7" hi3516ev300|gk7205v300)
;; gpio="ircut1=10 ircut2=11 usb_ena=-7"
hi3518ev200) ;;
gpio="ircut1=1 ircut2=2 light=48" hi3518ev200)
;; gpio="ircut1=1 ircut2=2 light=48"
t31) ;;
gpio="ircut1=N ircut2=n light=n" t31)
;; gpio="ircut1=N ircut2=n light=n"
esac ;;
;; esac
Herospeed|Longsee|Cantonk) ;;
case ${soc} in
hi3516ev200|gk7205v200) Herospeed|Longsee|Cantonk)
gpio="ircut1=12 ircut2=13 irctl=4 alm_in=15 alm_out=14" case ${soc} in
;; hi3516ev200|gk7205v200)
hi3518ev200) gpio="ircut1=12 ircut2=13 irctl=4 alm_in=15 alm_out=14"
gpio="ircut1=64 ircut2=65" ;;
;; hi3518ev200)
hi3516av300) gpio="ircut1=64 ircut2=65"
gpio="ircut1=5 ircut2=6" ;;
;; hi3516av300)
esac gpio="ircut1=5 ircut2=6"
;; ;;
Jabsco) esac
case ${soc} in ;;
hi3516ev200|gk7205v200)
gpio="ircut1=52 ircut2=53 irstatus=9" Jabsco)
;; case ${soc} in
esac hi3516ev200|gk7205v200)
;; gpio="ircut1=52 ircut2=53 irstatus=9"
Jvt) ;;
case ${soc} in esac
hi3516cv200) ;;
gpio="ircut1=64 ircut2=65 light=62"
;; Jvt)
hi3518ev200) case ${soc} in
gpio="ircut1=64 ircut2=65 light=47" hi3516cv200)
;; gpio="ircut1=64 ircut2=65 light=62"
esac ;;
;; hi3518ev200)
Juan|Sannce) gpio="ircut1=64 ircut2=65 light=47"
case ${soc} in ;;
hi3518ev200) esac
gpio="ircut1=65 ircut2=64 irstatus=-62" ;;
;;
esac Juan|Sannce)
;; case ${soc} in
Tiandy) hi3518ev200)
case ${soc} in gpio="ircut1=65 ircut2=64 irstatus=-62"
hi3518ev200) ;;
gpio="ircut1=78 ircut2=79 irctl=37" esac
;; ;;
esac
;; Tiandy)
Uniview) case ${soc} in
case ${soc} in hi3518ev200)
hi3516ev300|gk7205v300) gpio="ircut1=78 ircut2=79 irctl=37"
gpio="ircut1=63 ircut2=67 reset=" ;;
;; esac
esac ;;
;;
Xiongmai) Uniview)
case ${soc} in case ${soc} in
hi3516ev200|gk7205v200) hi3516ev300|gk7205v300)
gpio="ircut1=8 ircut=29 irstatus=15 irctl=16 alm_in=4,53 alm_out=55 eth_act=14 eth_sta=12 reset=0" gpio="ircut1=63 ircut2=67 reset="
;; ;;
hi3516ev300|gk7205v300) esac
gpio="ircut1=10 ircut2=11 irstatus=66 irctl=52 alm_in=4,67 alm_out=65 eth_act=30 eth_sta=31 reset=0" ;;
;;
hi3516dv100) Xiongmai)
gpio="ircut1=14 ircut2=15" case ${soc} in
;; hi3516ev200|gk7205v200)
hi3516cv300) gpio="ircut1=8 ircut=29 irstatus=15 irctl=16 alm_in=4,53 alm_out=55 eth_act=14 eth_sta=12 reset=0"
gpio="ircut1=53 ircut2=54 irstatus=64 irctl=66 alm_in=55 alm_out=1 reset=2 usb_ena=63" ;;
;; hi3516ev300|gk7205v300)
hi3518ev200) gpio="ircut1=10 ircut2=11 irstatus=66 irctl=52 alm_in=4,67 alm_out=65 eth_act=30 eth_sta=31 reset=0"
gpio="ircut1=33 ircut2=34 alm_in=61 alm_out=35" ;;
;; hi3516dv100)
esac gpio="ircut1=14 ircut2=15"
;; ;;
Zenotech|Videopark) hi3516cv300)
case ${soc} in gpio="ircut1=53 ircut2=54 irstatus=64 irctl=66 alm_in=55 alm_out=1 reset=2 usb_ena=63"
hi3516ev300|gk7205v300) ;;
gpio="ircut1=40 ircut2=41 irctl=65" hi3518ev200)
;; gpio="ircut1=33 ircut2=34 alm_in=61 alm_out=35"
esac ;;
;; esac
;;
Zenotech|Videopark)
case ${soc} in
hi3516ev300|gk7205v300)
gpio="ircut1=40 ircut2=41 irctl=65"
;;
esac
;;
esac esac
echo ${gpio} echo ${gpio}

View File

@ -10,24 +10,23 @@ count=0
# prepare the pin # prepare the pin
if [ ! -d /sys/class/gpio/gpio${GPIO} ]; then if [ ! -d /sys/class/gpio/gpio${GPIO} ]; then
echo "${GPIO}" > /sys/class/gpio/export echo "${GPIO}" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio"${GPIO}"/direction echo "in" > /sys/class/gpio/gpio"${GPIO}"/direction
fi fi
# continuously monitor current value of reset switch # continuously monitor current value of reset switch
while [ true ] while [ true ]; do
do if [ "$(cat /sys/class/gpio/gpio"${GPIO}"/value)" -eq 1 ]; then
if [ "$(cat /sys/class/gpio/gpio"${GPIO}"/value)" -eq 1 ]; then count=0
count=0 else
else count=$((count+1))
count=$((count+1))
# 20 counts =~ 5 seconds @ 0.25 sleep intervals # 20 counts =~ 5 seconds @ 0.25 sleep intervals
if [ $count -eq 20 ]; then if [ $count -eq 20 ]; then
echo 'RESETTING FIRMWARE' echo 'RESETTING FIRMWARE'
firstboot firstboot
fi fi
fi fi
# This interval uses 1% CPU. Less sleep = more CPU # This interval uses 1% CPU. Less sleep = more CPU
sleep 0.25 sleep 0.25
done done

View File

@ -1,28 +1,28 @@
#!/bin/sh #!/bin/sh
show_help() { show_help() {
echo "Usage: $0 [OPTIONS] echo "Usage: $0 [OPTIONS]
-m Reset Majestic config. -m Reset Majestic config.
-n Reset network config. -n Reset network config.
-h Show this help. -h Show this help.
" "
exit 0 exit 0
} }
reset_majestic() { reset_majestic() {
cp -f /rom/etc/majestic.yaml /etc/majestic.yaml cp -f /rom/etc/majestic.yaml /etc/majestic.yaml
} }
reset_network() { reset_network() {
cp -f /rom/etc/network/interfaces /etc/network/interfaces cp -f /rom/etc/network/interfaces /etc/network/interfaces
} }
while getopts hmn flag; do while getopts hmn flag; do
case ${flag} in case ${flag} in
m) reset_majestic ;; m) reset_majestic ;;
n) reset_network ;; n) reset_network ;;
h) show_help ;; h) show_help ;;
esac esac
done done
exit 0 exit 0

View File

@ -47,9 +47,9 @@ do_update_kernel() {
local ksoc=$(od -j 32 -N 32 -S 1 -A n "$x" | cut -d- -f3) local ksoc=$(od -j 32 -N 32 -S 1 -A n "$x" | cut -d- -f3)
# FIXME: Ingenic kernels do not include proper SoC identifiers. # FIXME: Ingenic kernels do not include proper SoC identifiers.
case "$soc" in case "$soc" in
t31) [ "t" != "$ksoc" ] && die "Wrong SoC!" ;; t31) [ "t" != "$ksoc" ] && die "Wrong SoC!" ;;
t21) [ "" != "$ksoc" ] && die "Wrong SoC!" ;; t21) [ "" != "$ksoc" ] && die "Wrong SoC!" ;;
*) check_soc "$ksoc" *) check_soc "$ksoc"
esac esac
compare_versions "$kernel_version" "$(get_kernel_version "$x")" && return 0 compare_versions "$kernel_version" "$(get_kernel_version "$x")" && return 0
fi fi
@ -263,69 +263,84 @@ for i in "$@"; do
skip_ver=1 skip_ver=1
shift shift
;; ;;
--force_md5) --force_md5)
skip_md5=1 skip_md5=1
shift shift
;; ;;
--force_soc) --force_soc)
skip_soc=1 skip_soc=1
shift shift
;; ;;
--force_ver) --force_ver)
skip_ver=1 skip_ver=1
shift shift
;; ;;
-d) -d)
branch_dev=1 branch_dev=1
shift shift
;; ;;
-h | --help) -h | --help)
print_sysinfo print_sysinfo
print_usage print_usage
exit 0 exit 0
;; ;;
-k) -k)
update_kernel=1 update_kernel=1
remote_update=1 remote_update=1
shift shift
;; ;;
--kernel=*) --kernel=*)
update_kernel=1 update_kernel=1
kernel_file="${i#*=}" kernel_file="${i#*=}"
[ "$kernel_file" != ${kernel_file#/mnt/mmc} ] && skip_unmount=1 [ "$kernel_file" != ${kernel_file#/mnt/mmc} ] && skip_unmount=1
shift shift
;; ;;
-n | --wipe_overlay) -n | --wipe_overlay)
clear_overlay=1 clear_overlay=1
shift shift
;; ;;
-r) -r)
update_rootfs=1 update_rootfs=1
remote_update=1 remote_update=1
shift shift
;; ;;
--rootfs=*) --rootfs=*)
update_rootfs=1 update_rootfs=1
rootfs_file="${i#*=}" rootfs_file="${i#*=}"
[ "$rootfs_file" != ${rootfs_file#/mnt/mmc} ] && skip_unmount=1 [ "$rootfs_file" != ${rootfs_file#/mnt/mmc} ] && skip_unmount=1
shift shift
;; ;;
--url=*) --url=*)
url="${i#*=}" url="${i#*=}"
shift shift
;; ;;
-x | --no_reboot)
skip_reboot=1
shift
;;
-w) -w)
update_webui=1 update_webui=1
shift shift
;; ;;
-x | --no_reboot)
skip_reboot=1
shift
;;
-z | --no_update) -z | --no_update)
skip_selfupdate=1 skip_selfupdate=1
shift shift
;; ;;
*) *)
print_sysinfo print_sysinfo
echo_c 37 "\nUnknown option: $1" echo_c 37 "\nUnknown option: $1"

View File

@ -17,9 +17,7 @@ RESOLV_CONF="/tmp/resolv.conf"
# Handle stateful DHCPv6 like DHCPv4 # Handle stateful DHCPv6 like DHCPv4
[ -n "$ipv6" ] && ip="$ipv6/128" [ -n "$ipv6" ] && ip="$ipv6/128"
if [ -z "${IF_WAIT_DELAY}" ]; then [ -z "${IF_WAIT_DELAY}" ] && IF_WAIT_DELAY=10
IF_WAIT_DELAY=10
fi
wait_for_ipv6_default_route() { wait_for_ipv6_default_route() {
printf "Waiting for IPv6 default route to appear" printf "Waiting for IPv6 default route to appear"

View File

@ -17,401 +17,401 @@ os_mem_size=${os_mem_size:=32}
# SENSOR=${SENSOR:=ar0130} # SENSOR=${SENSOR:=ar0130}
report_error() { report_error() {
echo "******* Error: There's something wrong, please check! *****" echo "******* Error: There's something wrong, please check! *****"
exit 1 exit 1
} }
insert_osal() { insert_osal() {
insmod mmz.ko mmz=anonymous,0,$mmz_start,$mmz_size anony=1 || report_error insmod mmz.ko mmz=anonymous,0,$mmz_start,$mmz_size anony=1 || report_error
} }
insert_detect() { insert_detect() {
cd /lib/modules/3.0.8/hisilicon cd /lib/modules/3.0.8/hisilicon
sys_config sys_config
insert_osal insert_osal
insmod hi3518_base.ko insmod hi3518_base.ko
insmod hi3518_sys.ko insmod hi3518_sys.ko
insmod hi3518_isp.ko insmod hi3518_isp.ko
insmod hi_i2c.ko insmod hi_i2c.ko
SENSOR=imx122 insert_sns SENSOR=imx122 insert_sns
} }
remove_detect() { remove_detect() {
rmmod -w ssp_sony &>/dev/null rmmod -w ssp_sony &>/dev/null
rmmod -w ssp_pana &>/dev/null rmmod -w ssp_pana &>/dev/null
rmmod -w ssp_ad9020 &>/dev/null rmmod -w ssp_ad9020 &>/dev/null
rmmod -w hi_i2c rmmod -w hi_i2c
rmmod -w hi3518_isp rmmod -w hi3518_isp
rmmod -w hi3518_sys rmmod -w hi3518_sys
rmmod -w hi3518_base rmmod -w hi3518_base
rmmod -w mmz rmmod -w mmz
} }
insert_audio() { insert_audio() {
insmod acodec.ko insmod acodec.ko
insmod hidmac.ko insmod hidmac.ko
insmod hi3518_sio.ko insmod hi3518_sio.ko
insmod hi3518_ai.ko insmod hi3518_ai.ko
insmod hi3518_ao.ko insmod hi3518_ao.ko
insmod hi3518_aenc.ko insmod hi3518_aenc.ko
insmod hi3518_adec.ko insmod hi3518_adec.ko
echo "insert audio" echo "insert audio"
} }
remove_audio() { remove_audio() {
rmmod -w hi3518_adec rmmod -w hi3518_adec
rmmod -w hi3518_aenc rmmod -w hi3518_aenc
rmmod -w hi3518_ao rmmod -w hi3518_ao
rmmod -w hi3518_ai rmmod -w hi3518_ai
rmmod -w hi3518_sio rmmod -w hi3518_sio
rmmod -w acodec rmmod -w acodec
rmmod -w hidmac rmmod -w hidmac
echo "remove audio" echo "remove audio"
} }
insert_sns() { insert_sns() {
case $SENSOR in case $SENSOR in
ar0130 | 9m034 | po3100k | bf3116 | bg0703) ar0130 | 9m034 | po3100k | bf3116 | bg0703)
devmem 0x20030030 32 0x5 #Sensor clock 27 MHz devmem 0x20030030 32 0x5 #Sensor clock 27 MHz
insmod ssp_ad9020.ko insmod ssp_ad9020.ko
;; ;;
icx692) icx692)
devmem 0x200f000c 32 32 0x1 #pinmux SPI0 devmem 0x200f000c 32 32 0x1 #pinmux SPI0
devmem 0x200f0010 32 32 0x1 #pinmux SPI0 devmem 0x200f0010 32 32 0x1 #pinmux SPI0
devmem 0x200f0014 32 0x1 #pinmux SPI0 devmem 0x200f0014 32 0x1 #pinmux SPI0
insmod ssp_ad9020.ko insmod ssp_ad9020.ko
;; ;;
mn34031 | mn34041) mn34031 | mn34041)
devmem 0x200f000c 32 0x1 #pinmux SPI0 devmem 0x200f000c 32 0x1 #pinmux SPI0
devmem 0x200f0010 32 0x1 #pinmux SPI0 devmem 0x200f0010 32 0x1 #pinmux SPI0
devmem 0x200f0014 32 0x1 #pinmux SPI0 devmem 0x200f0014 32 0x1 #pinmux SPI0
devmem 0x20030030 32 0x5 #Sensor clock 27MHz devmem 0x20030030 32 0x5 #Sensor clock 27MHz
insmod ssp_pana.ko insmod ssp_pana.ko
;; ;;
imx104 | imx123 | imx138_spi | imx222 | imx225 | imx322 | imx323) imx104 | imx123 | imx138_spi | imx222 | imx225 | imx322 | imx323)
devmem 0x200f000c 32 0x1 #pinmux SPI0 devmem 0x200f000c 32 0x1 #pinmux SPI0
devmem 0x200f0010 32 0x1 #pinmux SPI0 devmem 0x200f0010 32 0x1 #pinmux SPI0
devmem 0x200f0014 32 0x1 #pinmux SPI0 devmem 0x200f0014 32 0x1 #pinmux SPI0
devmem 0x20030030 32 0x6 #Sensor clock 37.125 MHz devmem 0x20030030 32 0x6 #Sensor clock 37.125 MHz
insmod ssp_sony.ko insmod ssp_sony.ko
;; ;;
imx122) imx122)
devmem 0x200f000c 32 0x1 #pinmux SPI0 devmem 0x200f000c 32 0x1 #pinmux SPI0
devmem 0x200f0010 32 0x1 #pinmux SPI0 devmem 0x200f0010 32 0x1 #pinmux SPI0
devmem 0x200f0014 32 0x1 #pinmux SPI0 devmem 0x200f0014 32 0x1 #pinmux SPI0
devmem 0x20030030 32 0x6 #Sensor clock 37.125 MHz devmem 0x20030030 32 0x6 #Sensor clock 37.125 MHz
devmem 0x200f0124 8 0x0 devmem 0x200f0124 8 0x0
devmem 0x20140400 8 0x2 devmem 0x20140400 8 0x2
devmem 0x201403fc 8 0x2 devmem 0x201403fc 8 0x2
insmod ssp_sony.ko insmod ssp_sony.ko
;; ;;
imx138_i2c) imx138_i2c)
devmem 0x20030030 32 0x6 #Sensor clock 37.125 MHz devmem 0x20030030 32 0x6 #Sensor clock 37.125 MHz
;; ;;
ov9712 | ov9732 | soih22 | ov2710 | jxh22 | jxh42) ov9712 | ov9732 | soih22 | ov2710 | jxh22 | jxh42)
devmem 0x20030030 32 0x1 #Sensor clock 24 MHz devmem 0x20030030 32 0x1 #Sensor clock 24 MHz
insmod ssp_ad9020.ko insmod ssp_ad9020.ko
;; ;;
ar0140 | ar0141) ar0140 | ar0141)
devmem 0x20030030 32 0x1 devmem 0x20030030 32 0x1
;; #Sensor clock 24 MHz ;; #Sensor clock 24 MHz
mt9p006) mt9p006)
devmem 0x20030030 32 0x1 #Sensor clock 24 MHz devmem 0x20030030 32 0x1 #Sensor clock 24 MHz
devmem 0x2003002c 32 0x6a #VI input associated clock phase reversed devmem 0x2003002c 32 0x6a #VI input associated clock phase reversed
devmem 0x200f0138 32 0 # pinmux [GPIO0_6] SVB_PWM TEMPER_DQ devmem 0x200f0138 32 0 # pinmux [GPIO0_6] SVB_PWM TEMPER_DQ
devmem 0x20140400 32 0x60 # set GPIO 0_6 direction OUTPUT devmem 0x20140400 32 0x60 # set GPIO 0_6 direction OUTPUT
devmem 0x201403FC 32 0xff # set GPIO 0_6 0 devmem 0x201403FC 32 0xff # set GPIO 0_6 0
insmod ssp_ad9020.ko insmod ssp_ad9020.ko
;; ;;
hm1375 | ar0330) hm1375 | ar0330)
devmem 0x20030030 32 0x1 devmem 0x20030030 32 0x1
;; #Sensor clock 24 MHz ;; #Sensor clock 24 MHz
imx236) imx236)
devmem 0x20030030 32 0x6 #Sensor clock 37.125 MHz devmem 0x20030030 32 0x6 #Sensor clock 37.125 MHz
;; ;;
sc1035 | sc1135 | sc2135) sc1035 | sc1135 | sc2135)
devmem 0x20030030 32 0x5 #Sensor clock 27 MHz devmem 0x20030030 32 0x5 #Sensor clock 27 MHz
insmod ssp_ad9020.ko insmod ssp_ad9020.ko
;; ;;
*) *)
echo "xxxx Invalid sensor type $SENSOR xxxx" echo "xxxx Invalid sensor type $SENSOR xxxx"
report_error report_error
;; ;;
esac esac
} }
remove_sns() { remove_sns() {
rmmod -w hi_i2c &>/dev/null rmmod -w hi_i2c &>/dev/null
rmmod -w ssp &>/dev/null rmmod -w ssp &>/dev/null
rmmod -w ssp_sony &>/dev/null rmmod -w ssp_sony &>/dev/null
rmmod -w ssp_pana &>/dev/null rmmod -w ssp_pana &>/dev/null
rmmod -w ssp_ad9020 &>/dev/null rmmod -w ssp_ad9020 &>/dev/null
} }
sys_config() { sys_config() {
# lowpower.sh # lowpower.sh
devmem 0x20050080 32 0x000121a8 devmem 0x20050080 32 0x000121a8
#USB PHY #USB PHY
devmem 0x20050084 32 0x005d2188 devmem 0x20050084 32 0x005d2188
#NANDC #NANDC
devmem 0x200300D0 32 0x5 devmem 0x200300D0 32 0x5
devmem 0x200f00c8 32 0x1 devmem 0x200f00c8 32 0x1
devmem 0x200f00cc 32 0x1 devmem 0x200f00cc 32 0x1
devmem 0x200f00d0 32 0x1 devmem 0x200f00d0 32 0x1
devmem 0x200f00d4 32 0x1 devmem 0x200f00d4 32 0x1
devmem 0x200f00d8 32 0x1 devmem 0x200f00d8 32 0x1
devmem 0x200f00dc 32 0x1 devmem 0x200f00dc 32 0x1
devmem 0x200f00e0 32 0x1 devmem 0x200f00e0 32 0x1
devmem 0x200f00e4 32 0x1 devmem 0x200f00e4 32 0x1
devmem 0x200f00e8 32 0x1 devmem 0x200f00e8 32 0x1
devmem 0x200f00ec 32 0x1 devmem 0x200f00ec 32 0x1
devmem 0x200f00f4 32 0x1 devmem 0x200f00f4 32 0x1
devmem 0x200f00f8 32 0x1 devmem 0x200f00f8 32 0x1
#SAR ADC #SAR ADC
devmem 0x20030080 32 0x1 devmem 0x20030080 32 0x1
devmem 0x200b0008 32 0x1 devmem 0x200b0008 32 0x1
#PWM #PWM
devmem 0x20030038 32 0x2 devmem 0x20030038 32 0x2
#IR #IR
devmem 0x20070000 32 0x0 devmem 0x20070000 32 0x0
devmem 0x200f00c4 32 0x1 devmem 0x200f00c4 32 0x1
#UART2 #UART2
devmem 0x200A0030 32 0x0 devmem 0x200A0030 32 0x0
#UART2 #UART2
devmem 0x200f0108 32 0x0 devmem 0x200f0108 32 0x0
devmem 0x200f010c 32 0x0 devmem 0x200f010c 32 0x0
#SPI0 SPI1 #SPI0 SPI1
devmem 0x200C0004 32 0x7F00 devmem 0x200C0004 32 0x7F00
devmem 0x200E0004 32 0x7F00 devmem 0x200E0004 32 0x7F00
#spi0 #spi0
devmem 0x200f000c 32 0x0 devmem 0x200f000c 32 0x0
devmem 0x200f0010 32 0x0 devmem 0x200f0010 32 0x0
devmem 0x200f0014 32 0x0 devmem 0x200f0014 32 0x0
#spi1 #spi1
devmem 0x200f0110 32 0x0 devmem 0x200f0110 32 0x0
devmem 0x200f0114 32 0x0 devmem 0x200f0114 32 0x0
devmem 0x200f0118 32 0x0 devmem 0x200f0118 32 0x0
devmem 0x200f011c 32 0x0 devmem 0x200f011c 32 0x0
#AUDIO CODEC LINE IN #AUDIO CODEC LINE IN
#devmem 0x20050068 32 0xa8022c2c #devmem 0x20050068 32 0xa8022c2c
#devmem 0x2005006c 32 0xf5035a4a #devmem 0x2005006c 32 0xf5035a4a
# PINMUX # PINMUX
devmem 0x200f0008 32 0x00000001 # 0:GPIO1_2 /1:SENSOR_CLK devmem 0x200f0008 32 0x00000001 # 0:GPIO1_2 /1:SENSOR_CLK
#I2C default setting is I2C #I2C default setting is I2C
i2c_type_select() { i2c_type_select() {
devmem 0x200f0018 32 0x00000001 # 0:GPIO2_0 / 1:I2C_SDA devmem 0x200f0018 32 0x00000001 # 0:GPIO2_0 / 1:I2C_SDA
devmem 0x200f001c 32 0x00000001 # 0:GPIO2_1 / 1:I2C_SCL devmem 0x200f001c 32 0x00000001 # 0:GPIO2_1 / 1:I2C_SCL
} }
#I2C default setting is I2C #I2C default setting is I2C
gpio_i2c_type_select() { gpio_i2c_type_select() {
devmem 0x200f0018 32 0x00000000 # 0:GPIO2_0 / 1:I2C_SDA devmem 0x200f0018 32 0x00000000 # 0:GPIO2_0 / 1:I2C_SDA
devmem 0x200f001c 32 0x00000000 # 0:GPIO2_1 / 1:I2C_SCL devmem 0x200f001c 32 0x00000000 # 0:GPIO2_1 / 1:I2C_SCL
} }
#MII #MII
net_mii_mode() { net_mii_mode() {
devmem 0x200f0030 32 0x1 devmem 0x200f0030 32 0x1
devmem 0x200f0034 32 0x1 devmem 0x200f0034 32 0x1
devmem 0x200f0038 32 0x1 devmem 0x200f0038 32 0x1
devmem 0x200f003C 32 0x1 devmem 0x200f003C 32 0x1
devmem 0x200f0040 32 0x1 devmem 0x200f0040 32 0x1
devmem 0x200f0044 32 0x1 devmem 0x200f0044 32 0x1
devmem 0x200f0048 32 0x1 devmem 0x200f0048 32 0x1
devmem 0x200f004C 32 0x1 devmem 0x200f004C 32 0x1
devmem 0x200f0050 32 0x1 devmem 0x200f0050 32 0x1
devmem 0x200f0054 32 0x1 devmem 0x200f0054 32 0x1
devmem 0x200f0058 32 0x1 devmem 0x200f0058 32 0x1
devmem 0x200f005C 32 0x1 devmem 0x200f005C 32 0x1
devmem 0x200f0060 32 0x1 devmem 0x200f0060 32 0x1
devmem 0x200f0064 32 0x1 devmem 0x200f0064 32 0x1
devmem 0x200f0068 32 0x1 devmem 0x200f0068 32 0x1
devmem 0x200f006C 32 0x1 devmem 0x200f006C 32 0x1
#devmem 0x200f0070 32 0x1 #devmem 0x200f0070 32 0x1
devmem 0x200f0074 32 0x1 devmem 0x200f0074 32 0x1
devmem 0x200f0078 32 0x1 devmem 0x200f0078 32 0x1
} }
#RMII #RMII
net_rmii_mode() { net_rmii_mode() {
devmem 0x200f0030 32 0x1 devmem 0x200f0030 32 0x1
devmem 0x200f0034 32 0x1 devmem 0x200f0034 32 0x1
devmem 0x200f0038 32 0x1 devmem 0x200f0038 32 0x1
#devmem 0x200f003C 32 0x1 #devmem 0x200f003C 32 0x1
#devmem 0x200f0040 32 0x1 #devmem 0x200f0040 32 0x1
devmem 0x200f0044 32 0x1 devmem 0x200f0044 32 0x1
devmem 0x200f0048 32 0x1 devmem 0x200f0048 32 0x1
devmem 0x200f004C 32 0x1 devmem 0x200f004C 32 0x1
devmem 0x200f0050 32 0x1 devmem 0x200f0050 32 0x1
devmem 0x200f0054 32 0x1 devmem 0x200f0054 32 0x1
devmem 0x200f0058 32 0x1 devmem 0x200f0058 32 0x1
devmem 0x200f005C 32 0x3 devmem 0x200f005C 32 0x3
devmem 0x200f0060 32 0x1 devmem 0x200f0060 32 0x1
devmem 0x200f0064 32 0x1 devmem 0x200f0064 32 0x1
devmem 0x200f0068 32 0x1 #MII_TXER 0x1,GPIO2_6 0x0 devmem 0x200f0068 32 0x1 #MII_TXER 0x1,GPIO2_6 0x0
devmem 0x200f006C 32 0x1 #MII_RXER 0x1,GPIO2_7 0x0 devmem 0x200f006C 32 0x1 #MII_RXER 0x1,GPIO2_7 0x0
#devmem 0x200f0070 32 0x1 #devmem 0x200f0070 32 0x1
devmem 0x200f0074 32 0x1 devmem 0x200f0074 32 0x1
devmem 0x200f0078 32 0x1 devmem 0x200f0078 32 0x1
} }
clk_cfg() { clk_cfg() {
devmem 0x2003002c 32 0x2a # VICAP, ISP unreset & clock enable devmem 0x2003002c 32 0x2a # VICAP, ISP unreset & clock enable
devmem 0x20030048 32 0x2 # VPSS unreset, code also config devmem 0x20030048 32 0x2 # VPSS unreset, code also config
devmem 0x20030034 32 0x510 # VDP unreset & HD clock enable # XM: 0x00000043 devmem 0x20030034 32 0x510 # VDP unreset & HD clock enable # XM: 0x00000043
devmem 0x20030040 32 0x2 # VEDU unreset devmem 0x20030040 32 0x2 # VEDU unreset
devmem 0x20030060 32 0x2 # JPEG unreset devmem 0x20030060 32 0x2 # JPEG unreset
devmem 0x20030058 32 0x2 # TDE unreset devmem 0x20030058 32 0x2 # TDE unreset
devmem 0x20030068 32 0x2 # MDU unreset devmem 0x20030068 32 0x2 # MDU unreset
#devmem 0x2003006c 32 0x2; # IVE unreset #devmem 0x2003006c 32 0x2 # IVE unreset
#devmem 0x2003008c 32 0x2; # SIO unreset and clock enable,m/f/bclk config in code. #devmem 0x2003008c 32 0x2 # SIO unreset and clock enable,m/f/bclk config in code.
#devmem 0x20050068 32 0x58000000 # Audio Codec channel config for power down. #devmem 0x20050068 32 0x58000000 # Audio Codec channel config for power down.
} }
sysctl() { sysctl() {
devmem 0x20110150 32 0x03ff6 #DMA1 DMA2 devmem 0x20110150 32 0x03ff6 #DMA1 DMA2
devmem 0x20110154 32 0x03ff6 #ETH devmem 0x20110154 32 0x03ff6 #ETH
devmem 0x20110158 32 0x03ff6 #USB devmem 0x20110158 32 0x03ff6 #USB
devmem 0x2011015C 32 0x03ff6 #CIPHER 0x15C devmem 0x2011015C 32 0x03ff6 #CIPHER 0x15C
devmem 0x20110160 32 0x03ff6 #SDIO 0X160 devmem 0x20110160 32 0x03ff6 #SDIO 0X160
devmem 0x20110164 32 0x03ff6 #NAND SFC 0X164 devmem 0x20110164 32 0x03ff6 #NAND SFC 0X164
devmem 0x20110168 32 0x10201 #ARMD 0X168 devmem 0x20110168 32 0x10201 #ARMD 0X168
devmem 0x2011016C 32 0x10201 #ARMI 0X16C devmem 0x2011016C 32 0x10201 #ARMI 0X16C
devmem 0x20110170 32 0x03ff6 #IVE 0X170 devmem 0x20110170 32 0x03ff6 #IVE 0X170
devmem 0x20110174 32 0x03ff6 #MD, DDR_TEST 0x174 devmem 0x20110174 32 0x03ff6 #MD, DDR_TEST 0x174
devmem 0x20110178 32 0x03ff6 #JPGE #0x178 devmem 0x20110178 32 0x03ff6 #JPGE #0x178
devmem 0x2011017C 32 0x03ff3 #TDE0 0X17C devmem 0x2011017C 32 0x03ff3 #TDE0 0X17C
devmem 0x20110180 32 0x03ff4 #VPSS 0X180 devmem 0x20110180 32 0x03ff4 #VPSS 0X180
devmem 0x20110184 32 0x10c82 #VENC 0X184 devmem 0x20110184 32 0x10c82 #VENC 0X184
devmem 0x20110188 32 0x10101 #VICAP FPGA devmem 0x20110188 32 0x10101 #VICAP FPGA
#devmem 0x20110188 32 0x10640 #VICAP ESL #devmem 0x20110188 32 0x10640 #VICAP ESL
devmem 0x2011018c 32 0x10100 #VDP devmem 0x2011018c 32 0x10100 #VDP
devmem 0x20110100 32 0x67 #mddrc order enable mddrc idmap mode select devmem 0x20110100 32 0x67 #mddrc order enable mddrc idmap mode select
#devmem 0x20050054 32 0x123564 #[2:0] VENC [6:4] VPSS [10:8] TDE [14:12] JPGE [18:16] MD #devmem 0x20050054 32 0x123564 #[2:0] VENC [6:4] VPSS [10:8] TDE [14:12] JPGE [18:16] MD
devmem 0x20050038 32 0x3 #DDR0 VICAP VDP devmem 0x20050038 32 0x3 #DDR0 VICAP VDP
} }
i2c_type_select i2c_type_select
#net_rmii_mode #net_rmii_mode
#net_mii_mode #net_mii_mode
clk_cfg clk_cfg
} }
insert_ko() { insert_ko() {
cd /lib/modules/3.0.8/hisilicon cd /lib/modules/3.0.8/hisilicon
sys_config sys_config
insert_osal insert_osal
insmod hi3518_base.ko insmod hi3518_base.ko
insmod hi3518_sys.ko insmod hi3518_sys.ko
insmod hiuser.ko insmod hiuser.ko
insmod hi3518_tde.ko insmod hi3518_tde.ko
insmod hi3518_dsu.ko insmod hi3518_dsu.ko
insmod hi3518_viu.ko insmod hi3518_viu.ko
insmod hi3518_isp.ko insmod hi3518_isp.ko
insmod hi3518_vpss.ko insmod hi3518_vpss.ko
# insmod hi3518_vou.ko # insmod hi3518_vou.ko
# insmod hi3518_vou.ko detectCycle=0 #close dac detect # insmod hi3518_vou.ko detectCycle=0 #close dac detect
# insmod hifb.ko video="hifb:vram0_size:1620" # insmod hifb.ko video="hifb:vram0_size:1620"
insmod hi3518_venc.ko insmod hi3518_venc.ko
insmod hi3518_group.ko insmod hi3518_group.ko
insmod hi3518_chnl.ko insmod hi3518_chnl.ko
insmod hi3518_h264e.ko insmod hi3518_h264e.ko
insmod hi3518_jpege.ko insmod hi3518_jpege.ko
insmod hi3518_rc.ko insmod hi3518_rc.ko
insmod hi3518_region.ko insmod hi3518_region.ko
# insmod hi3518_vda.ko # insmod hi3518_vda.ko
insmod hi3518_ive.ko insmod hi3518_ive.ko
insmod hi_i2c.ko insmod hi_i2c.ko
#insmod gpioi2c.ko #insmod gpioi2c.ko
#insmod gpioi2c_ex.ko #insmod gpioi2c_ex.ko
insmod pwm.ko insmod pwm.ko
#insmod sil9024.ko norm=5 #720P@60fps #insmod sil9024.ko norm=5 #720P@60fps
insert_sns >/dev/null insert_sns >/dev/null
insert_audio insert_audio
echo "==== Your input Sensor type is $SENSOR ====" echo "==== Your input Sensor type is $SENSOR ===="
insmod wdt.ko #nodeamon=1 insmod wdt.ko #nodeamon=1
# system configuration # system configuration
sysctl sysctl
} }
remove_ko() { remove_ko() {
rmmod -w wdt rmmod -w wdt
remove_audio remove_audio
remove_sns remove_sns
# rmmod -w sil9024 &> /dev/null # rmmod -w sil9024 &> /dev/null
rmmod -w hi_i2c.ko &>/dev/null rmmod -w hi_i2c.ko &>/dev/null
rmmod -w pwm rmmod -w pwm
#rmmod -w gpioi2c #rmmod -w gpioi2c
rmmod -w hi3518_ive rmmod -w hi3518_ive
# rmmod -w hi3518_vda # rmmod -w hi3518_vda
rmmod -w hi3518_region rmmod -w hi3518_region
rmmod -w hi3518_rc rmmod -w hi3518_rc
rmmod -w hi3518_jpege rmmod -w hi3518_jpege
rmmod -w hi3518_h264e rmmod -w hi3518_h264e
rmmod -w hi3518_chnl rmmod -w hi3518_chnl
rmmod -w hi3518_group rmmod -w hi3518_group
rmmod -w hi3518_venc rmmod -w hi3518_venc
# rmmod -w hifb # rmmod -w hifb
# rmmod -w hi3518_vou # rmmod -w hi3518_vou
rmmod -w hi3518_vpss rmmod -w hi3518_vpss
rmmod -w hi3518_isp rmmod -w hi3518_isp
rmmod -w hi3518_viu rmmod -w hi3518_viu
rmmod -w hi3518_dsu rmmod -w hi3518_dsu
rmmod -w hi3518_tde rmmod -w hi3518_tde
rmmod -w hiuser rmmod -w hiuser
rmmod -w hi3518_sys rmmod -w hi3518_sys
rmmod -w hi3518_base rmmod -w hi3518_base
rmmod -w mmz rmmod -w mmz
} }
load_usage() { load_usage() {
echo "Usage: ./load3518 [-option] [sensor_name]" echo "Usage: ./load3518 [-option] [sensor_name]"
echo "options:" echo "options:"
echo " -i sensor_name insert modules" echo " -i sensor_name insert modules"
echo " -r remove modules" echo " -r remove modules"
echo " -a sensor_name remove modules first, then insert modules" echo " -a sensor_name remove modules first, then insert modules"
echo " -h help information" echo " -h help information"
echo -e "Available sensors: ar0130, imx104, icx692, ov9715, 9m034, imx122, mt9p006" echo -e "Available sensors: ar0130, imx104, icx692, ov9715, 9m034, imx122, mt9p006"
echo -e "for example: ./load3518 -a ar0130 \n" echo -e "for example: ./load3518 -a ar0130 \n"
} }
calc_mmz_info() { calc_mmz_info() {
mmz_start=$(echo "$mem_start $os_mem_size" | mmz_start=$(echo "$mem_start $os_mem_size" |
awk 'BEGIN { temp = 0; } awk 'BEGIN { temp = 0; }
{ {
temp = $1/1024/1024 + $2; temp = $1/1024/1024 + $2;
} }
END { printf("0x%x00000\n", temp); }') END { printf("0x%x00000\n", temp); }')
mmz_size=$(echo "$mem_total $os_mem_size" | mmz_size=$(echo "$mem_total $os_mem_size" |
awk 'BEGIN { temp = 0; } awk 'BEGIN { temp = 0; }
{ {
temp = $1 - $2; temp = $1 - $2;
} }
END { printf("%dM\n", temp); }') END { printf("%dM\n", temp); }')
echo "mmz_start: $mmz_start, mmz_size: $mmz_size" echo "mmz_start: $mmz_start, mmz_size: $mmz_size"
} }
if [ $os_mem_size -ge $mem_total ]; then if [ $os_mem_size -ge $mem_total ]; then
echo "[err] os_mem[$os_mem_size], over total_mem[$mem_total]" echo "[err] os_mem[$os_mem_size], over total_mem[$mem_total]"
exit exit
fi fi
calc_mmz_info calc_mmz_info
@ -420,42 +420,42 @@ calc_mmz_info
# SENSOR=${SENSOR:=imx307} # SENSOR=${SENSOR:=imx307}
# #
if [ -n "$SENSOR" ]; then if [ -n "$SENSOR" ]; then
logger -s -p daemon.info -t hisilicon "Manualy set SENSOR as ${SENSOR}" logger -s -p daemon.info -t hisilicon "Manualy set SENSOR as ${SENSOR}"
else else
if fw_printenv -n sensor >/dev/null; then if fw_printenv -n sensor >/dev/null; then
SENSOR_ENV=$(fw_printenv -n sensor) SENSOR_ENV=$(fw_printenv -n sensor)
export SENSOR=${SENSOR_ENV} export SENSOR=${SENSOR_ENV}
logger -s -p daemon.info -t hisilicon "Get data from environment and set SENSOR as ${SENSOR}" logger -s -p daemon.info -t hisilicon "Get data from environment and set SENSOR as ${SENSOR}"
else else
insert_detect insert_detect
SENSOR_DETECT=$(ipcinfo --short-sensor) SENSOR_DETECT=$(ipcinfo --short-sensor)
export SENSOR=${SENSOR_DETECT:=unknown} export SENSOR=${SENSOR_DETECT:=unknown}
remove_detect remove_detect
logger -s -p daemon.info -t hisilicon "Get data from ipcinfo and set SENSOR as ${SENSOR}" logger -s -p daemon.info -t hisilicon "Get data from ipcinfo and set SENSOR as ${SENSOR}"
fw_setenv sensor $SENSOR && logger -s -p daemon.info -t hisilicon "Write detected ${SENSOR} to U-Boot ENV" fw_setenv sensor $SENSOR && logger -s -p daemon.info -t hisilicon "Write detected ${SENSOR} to U-Boot ENV"
fi fi
fi fi
# load module # load module
if [ "$SENSOR" = "unknown" ]; then if [ "$SENSOR" = "unknown" ]; then
exit 1 exit 1
else else
if [ "$1" = "-i" ]; then if [ "$1" = "-i" ]; then
cd /lib/modules/3.0.8/hisilicon cd /lib/modules/3.0.8/hisilicon
insert_ko insert_ko
fi fi
fi fi
if [ "$1" = "-r" ]; then if [ "$1" = "-r" ]; then
remove_ko remove_ko
fi fi
if [ "$1" = "-h" ]; then if [ "$1" = "-h" ]; then
load_usage load_usage
exit exit
fi fi
if [ $# -eq 0 ] || [ "$1" = "-a" ]; then if [ $# -eq 0 ] || [ "$1" = "-a" ]; then
remove_ko remove_ko
insert_ko insert_ko
fi fi

View File

@ -11,7 +11,7 @@ fi
echo 1 >/proc/sys/vm/overcommit_memory echo 1 >/proc/sys/vm/overcommit_memory
log_vendor() { log_vendor() {
logger -s -p daemon.info -t ${vendor} "$1" logger -s -p daemon.info -t ${vendor} "$1"
} }
check_return() { check_return() {