add Xiaomi MJSXJ02HL

This commit is contained in:
cronyx
2023-12-10 01:08:49 +03:00
parent d79140919f
commit 90a410ad48
13 changed files with 639 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
#
Experimental system for building OpenIPC firmware for known devices
#

View File

@@ -0,0 +1,41 @@
#!/bin/sh
AUTOLED_ARGS=""
AUTOLED_PID_FILE=/var/run/autoled.pid
start() {
printf "Starting automatic LED control: "
umask 077
start-stop-daemon -b -m -S -q -p $AUTOLED_PID_FILE \
--exec /usr/sbin/autoled.sh -- $AUTOLED_ARGS
[ $? = 0 ] && echo "OK" || echo "FAIL"
}
stop() {
printf "Stopping automatic LED control: "
start-stop-daemon -K -q -p $AUTOLED_PID_FILE
[ $? = 0 ] && echo "OK" || echo "FAIL"
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart | reload)
restart
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac
exit $?

View File

@@ -0,0 +1,28 @@
#!/bin/sh
case "$1" in
start | restart | reload)
if [ ! -d /sys/class/gpio/gpio0/ ]; then
echo 0 > /sys/class/gpio/export
echo in > /sys/class/gpio/gpio0/direction
fi
printf "Checking the reset button: "
if [ $(cat /sys/class/gpio/gpio0/value) -eq 0 ]; then
echo "PRESSED"
# Wipe overlay partition and reboot
echo "Let's start wipe overlay partition (/dev/mtd4)"
/usr/sbin/sysupgrade -n -z
else
echo "NOT PRESSED"
fi
exit $?
;;
stop)
exit 0
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac

View File

@@ -0,0 +1,41 @@
#!/bin/sh
AUTONIGHT_ARGS=""
AUTONIGHT_PID_FILE=/var/run/autonight.pid
start() {
printf "Starting automatic night mode changer: "
umask 077
start-stop-daemon -b -m -S -q -p $AUTONIGHT_PID_FILE \
--exec /usr/sbin/autonight.sh -- $AUTONIGHT_ARGS
[ $? = 0 ] && echo "OK" || echo "FAIL"
}
stop() {
printf "Stopping automatic night mode changer: "
start-stop-daemon -K -q -p $AUTONIGHT_PID_FILE
[ $? = 0 ] && echo "OK" || echo "FAIL"
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart | reload)
restart
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac
exit $?

View File

@@ -0,0 +1,94 @@
#!/bin/sh
set_gpio() {
[ "$2" -eq 1 ] && gpio set $1 || gpio clear $1
sleep 1
}
set_mmc() {
mmc=/sys/devices/platform/jzmmc_v1.2.$1/present
[ "$(cat $mmc)" = "N" ] && echo "INSERT" > $mmc
}
# Generic ATBM603X
if [ "$1" = "atbm603x-generic" ]; then
set_mmc 1
cp -f /usr/share/atbm60xx_conf/atbm_txpwer_dcxo_cfg.txt /tmp
cp -f /usr/share/atbm60xx_conf/set_rate_power.txt /tmp
modprobe atbm603x_wifi_sdio
exit 0
fi
# Generic RTL8189FS
if [ "$1" = "rtl8189fs-generic" ]; then
set_mmc 1
modprobe 8189fs
exit 0
fi
# T20 Wyze PanV1
if [ "$1" = "rtl8189es-t20-wyze-pan-v1" ]; then
set_mmc 1
modprobe 8189es rtw_power_mgnt=0 rtw_enusbss=0
exit 0
fi
# T20 Wyze V2
if [ "$1" = "rtl8189ftv-t20-wyze-v2" ]; then
set_mmc 1
modprobe 8189fs rtw_power_mgnt=0 rtw_enusbss=0
exit 0
fi
# T31 Wyze DB3
if [ "$1" = "rtl8189ftv-t31-wyze-db3" ]; then
set_mmc 1
modprobe 8189fs rtw_power_mgnt=0 rtw_enusbss=0
exit 0
fi
# T31 Wyze PanV2
if [ "$1" = "atbm603x-t31-wyze-pan-v2" ]; then
set_gpio 58 0
set_gpio 58 1
set_mmc 1
cp -f /usr/share/atbm60xx_conf/atbm_txpwer_dcxo_cfg.txt /tmp
cp -f /usr/share/atbm60xx_conf/set_rate_power.txt /tmp
modprobe atbm603x_wifi_sdio atbm_printk_mask=0
exit 0
fi
# T31 Wyze V3 / AtomCam 2
if [ "$1" = "atbm603x-t31-wyze-v3" ]; then
set_gpio 57 0
set_gpio 57 1
set_mmc 1
cp -f /usr/share/atbm60xx_conf/atbm_txpwer_dcxo_cfg.txt /tmp
cp -f /usr/share/atbm60xx_conf/set_rate_power.txt /tmp
modprobe atbm603x_wifi_sdio atbm_printk_mask=0
exit 0
fi
# T31 Wyze V3
if [ "$1" = "rtl8189ftv-t31-wyze-v3" ]; then
set_gpio 57 1
set_mmc 1
modprobe 8189fs rtw_power_mgnt=0 rtw_enusbss=0
exit 0
fi
# Hi3518ev300 Xiaomi MJSXJ02HL
if [ "$1" = "rtl8189fs-mjsxj02hl" ]; then
devmem 0x112C0048 32 0x1D54
devmem 0x112C004C 32 0x1174
devmem 0x112C0064 32 0x1174
devmem 0x112C0060 32 0x1174
devmem 0x112C005C 32 0x1174
devmem 0x112C0058 32 0x1174
devmem 0x10020028 32 0x28000000
devmem 0x10020028 32 0x20000000
modprobe 8189fs
exit 0
fi
exit 1

View File

@@ -0,0 +1,60 @@
#!/bin/sh
#
# Automatic LED control for Xiaomi MJSXJ02HL
streamerProcess="majestic"
serviceProcess="sysupgrade"
pollingInterval=1
show_help() {
echo "Usage: $0 [-p process] [-s process] [-i value] [-h]
-p process Name of the monitored streamer process (default = ${streamerProcess}).
-s process Name of the monitored service process (default = ${serviceProcess}).
-i value Polling interval in seconds (default = ${pollingInterval}).
-h Show this help."
exit 0
}
# override config values with command line arguments
while getopts H:L:i:h flag; do
case ${flag} in
p) streamerProcess=${OPTARG} ;;
s) serviceProcess=${OPTARG} ;;
i) pollingInterval=${OPTARG} ;;
h | *) show_help ;;
esac
done
echo "...................."
echo "Name of the monitored streamer process: ${streamerProcess}"
echo "Name of the monitored service process: ${serviceProcess}"
echo "Polling interval: ${pollingInterval} sec"
echo "...................."
led_state=0
/usr/sbin/led_control.sh -o 0 -b 0
echo "...................."
while true; do
if killall -q -0 $serviceProcess; then
if [ $led_state -ne 3 ]; then
echo "Process $serviceProcess is running, turn on the white LED"
/usr/sbin/led_control.sh -o 1 -b 1
led_state=3
echo "...................."
fi
else
if [ $led_state -ne 1 ] && ! killall -q -0 $streamerProcess; then
echo "Process $streamerProcess is not running, turn on the orange LED"
/usr/sbin/led_control.sh -o 1 -b 0
led_state=1
echo "...................."
elif [ $led_state -ne 2 ] && killall -q -0 $streamerProcess; then
echo "Process $streamerProcess is running, turn on the blue LED"
/usr/sbin/led_control.sh -o 0 -b 1
led_state=2
echo "...................."
fi
fi
sleep $pollingInterval
done

View File

@@ -0,0 +1,56 @@
#!/bin/sh
#
# Majestic settinfs for Xiaomi MJSXJ02HL
#
# nightMode:
# enabled: true
# irCutPin1: 70
# irCutPin2: 68
# backlightPin: 54
again_high_target=14000
again_low_target=2000
pollingInterval=5
show_help() {
echo "Usage: $0 [-H value] [-L value] [-i value] [-h]
-H value Again high target (default = ${again_high_target}).
-L value Again low target (default = ${again_low_target}).
-i value Polling interval (default = ${pollingInterval}).
-h Show this help."
exit 0
}
while getopts H:L:i:h flag; do
case ${flag} in
H) again_high_target=${OPTARG} ;;
L) again_low_target=${OPTARG} ;;
i) pollingInterval=${OPTARG} ;;
h | *) show_help ;;
esac
done
echo "...................."
echo "Watching at isp_again > ${again_high_target} to enable night mode"
echo "Watching at isp_again < ${again_low_target} to disable night mode"
echo "Polling interval: ${pollingInterval} sec"
echo "...................."
login=$(cat /etc/httpd.conf | grep cgi-bin | cut -d':' -f2)
pass=$(cat /etc/httpd.conf | grep cgi-bin | cut -d':' -f3)
while true; do
metrics=$(curl -s http://localhost/metrics)
isp_again=$(echo "${metrics}" | awk '/^isp_again/ {print $2}' | grep . || echo 0)
night_enabled=$(echo "${metrics}" | awk '/^night_enabled/ {print $2}' | grep . || echo 0)
if [ $night_enabled -ne 1 ] && [ $isp_again -gt $again_high_target ]; then
curl -s -u $login:$pass http://localhost/night/on
echo "Condition isp_again > ${again_high_target} was met (current value is ${isp_again}), turn on the night mode"
elif [ $night_enabled -ne 0 ] && [ $isp_again -lt $again_low_target ]; then
curl -s -u $login:$pass http://localhost/night/off
echo "Condition isp_again < ${again_low_target} was met (current value is ${isp_again}), turn off the night mode"
fi
sleep $pollingInterval
done

View File

@@ -0,0 +1,34 @@
#!/bin/sh
#
# LED control for Xiaomi MJSXJ02HL
show_help() {
echo "Usage: $0 [-o <0|1>] [-b <0|1>]
-o <0|1> Switch state for orange LED.
-b <0|1> Switch state for blue LED."
exit 0
}
led_control() {
echo "Switching LED with GPIO${1} to state ${2}"
if [ ! -d /sys/class/gpio/gpio${1}/ ]; then
echo ${1} > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio${1}/direction
fi
echo ${2} > /sys/class/gpio/gpio${1}/value
}
if [ $# -eq 0 ]; then show_help; fi
while getopts o:b: flag; do
case ${flag} in
o)
[ ${OPTARG} -eq 0 -o ${OPTARG} -eq 1 ] || show_help
led_control 52 ${OPTARG}
;;
b)
[ ${OPTARG} -eq 0 -o ${OPTARG} -eq 1 ] || show_help
led_control 53 ${OPTARG}
;;
*) show_help ;;
esac
done

View File

@@ -0,0 +1,36 @@
#!/bin/sh
#
# Perform basic settings on a known IP camera
#
#
# Set custom upgrade url
#
fw_setenv upgrade 'https://github.com/OpenIPC/builder/releases/download/latest/hi3518ev300_lite_xiaomi-mjsxj02hl-nor.tgz'
#
#
# Set custom majestic settings
#
cli -s .system.webAdmin disabled
cli -s .system.staticDir /var/www/majestic
cli -s .isp.iqProfile /etc/sensors/iq/f23.ini
cli -s .nightMode.enabled true
cli -s .nightMode.irCutPin1 70
cli -s .nightMode.irCutPin2 68
cli -s .nightMode.backlightPin 54
cli -s .audio.speakerPin 55
cli -s .video0.codec h264
#
#
# Set wlan device and credentials if need
#
fw_setenv wlandev rtl8189fs-mjsxj02hl
#fw_setenv wlanssid Router
#fw_setenv wlanpass 12345678
#
#
# Set osmem and rmem
#
fw_setenv bootargs 'mem=\${osmem} console=ttyAMA0,115200 panic=20 rootfstype=squashfs root=/dev/mtdblock3 init=/init mtdparts=\${mtdparts} mmz_allocator=hisi'
fw_setenv osmem 35M
#
exit 0

View File

@@ -0,0 +1,72 @@
################################################################################
#
# hisilicon-osdrv-hi3516ev200
#
################################################################################
HISILICON_OSDRV_HI3516EV200_VERSION =
HISILICON_OSDRV_HI3516EV200_SITE =
HISILICON_OSDRV_HI3516EV200_LICENSE = MIT
HISILICON_OSDRV_HI3516EV200_LICENSE_FILES = LICENSE
define HISILICON_OSDRV_HI3516EV200_INSTALL_TARGET_CMDS
$(INSTALL) -m 755 -d $(TARGET_DIR)/etc/sensors
$(INSTALL) -m 644 -t $(TARGET_DIR)/etc/sensors $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/sensor/config/*.ini
$(INSTALL) -m 755 -d $(TARGET_DIR)/etc/sensors/WDR
$(INSTALL) -m 644 -t $(TARGET_DIR)/etc/sensors/WDR $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/sensor/config/WDR/*.ini
$(INSTALL) -m 755 -d $(TARGET_DIR)/etc/sensors/iq
$(INSTALL) -m 644 -t $(TARGET_DIR)/etc/sensors/iq $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/sensor/iq/imx307.ini
$(INSTALL) -m 644 -t $(TARGET_DIR)/etc/sensors/iq $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/sensor/iq/imx335.ini
$(INSTALL) -m 644 -t $(TARGET_DIR)/etc/sensors/iq $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/sensor/iq/f23.ini
ln -sf imx307.ini $(TARGET_DIR)/etc/sensors/iq/default.ini
$(INSTALL) -m 755 -d $(TARGET_DIR)/lib/modules/$(LINUX_VERSION_PROBED)/hisilicon
$(INSTALL) -m 644 -t $(TARGET_DIR)/lib/modules/$(LINUX_VERSION_PROBED)/hisilicon $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/kmod/camhi-motor.ko
$(INSTALL) -m 644 -t $(TARGET_DIR)/lib/modules/$(LINUX_VERSION_PROBED)/hisilicon $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/kmod/hi3516ev200_isp.ko
$(INSTALL) -m 755 -d $(TARGET_DIR)/usr/bin
$(INSTALL) -m 755 -t $(TARGET_DIR)/usr/bin $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/script/load*
$(INSTALL) -m 755 -t $(TARGET_DIR)/usr/bin $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/script/ircut_demo
$(INSTALL) -m 755 -t $(TARGET_DIR)/usr/bin $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/script/set_allocator
$(INSTALL) -m 755 -d $(TARGET_DIR)/usr/lib/sensors
$(INSTALL) -m 644 -t $(TARGET_DIR)/usr/lib/sensors $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/sensor/*.so
$(INSTALL) -m 755 -d $(TARGET_DIR)/usr/lib
# $(INSTALL) -m 644 -t $(TARGET_DIR)/usr/lib/ $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/lib/libaaccomm.so
# $(INSTALL) -m 644 -t $(TARGET_DIR)/usr/lib/ $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/lib/libaacdec.so
# $(INSTALL) -m 644 -t $(TARGET_DIR)/usr/lib/ $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/lib/libaacenc.so
# $(INSTALL) -m 644 -t $(TARGET_DIR)/usr/lib/ $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/lib/libaacsbrdec.so
# $(INSTALL) -m 644 -t $(TARGET_DIR)/usr/lib/ $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/lib/libaacsbrenc.so
# $(INSTALL) -m 644 -t $(TARGET_DIR)/usr/lib/ $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/lib/libbcd.so
$(INSTALL) -m 644 -t $(TARGET_DIR)/usr/lib/ $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/lib/libdnvqe.so
$(INSTALL) -m 644 -t $(TARGET_DIR)/usr/lib/ $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/lib/lib_hiae.so
# $(INSTALL) -m 644 -t $(TARGET_DIR)/usr/lib/ $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/lib/lib_hiawb_natura.so
$(INSTALL) -m 644 -t $(TARGET_DIR)/usr/lib/ $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/lib/lib_hiawb.so
# $(INSTALL) -m 644 -t $(TARGET_DIR)/usr/lib/ $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/lib/libhi_cipher.so
$(INSTALL) -m 644 -t $(TARGET_DIR)/usr/lib/ $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/lib/lib_hidehaze.so
$(INSTALL) -m 644 -t $(TARGET_DIR)/usr/lib/ $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/lib/lib_hidrc.so
$(INSTALL) -m 644 -t $(TARGET_DIR)/usr/lib/ $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/lib/lib_hiir_auto.so
$(INSTALL) -m 644 -t $(TARGET_DIR)/usr/lib/ $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/lib/lib_hildci.so
# $(INSTALL) -m 644 -t $(TARGET_DIR)/usr/lib/ $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/lib/libhive_AEC.so
# $(INSTALL) -m 644 -t $(TARGET_DIR)/usr/lib/ $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/lib/libhive_AGC.so
$(INSTALL) -m 644 -t $(TARGET_DIR)/usr/lib/ $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/lib/libhive_ANR.so
$(INSTALL) -m 644 -t $(TARGET_DIR)/usr/lib/ $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/lib/libhive_common.so
# $(INSTALL) -m 644 -t $(TARGET_DIR)/usr/lib/ $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/lib/libhive_EQ.so
$(INSTALL) -m 644 -t $(TARGET_DIR)/usr/lib/ $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/lib/libhive_HPF.so
# $(INSTALL) -m 644 -t $(TARGET_DIR)/usr/lib/ $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/lib/libhive_record.so
$(INSTALL) -m 644 -t $(TARGET_DIR)/usr/lib/ $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/lib/libhive_RES.so
$(INSTALL) -m 644 -t $(TARGET_DIR)/usr/lib/ $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/lib/libisp.so
$(INSTALL) -m 644 -t $(TARGET_DIR)/usr/lib/ $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/lib/libive.so
# $(INSTALL) -m 644 -t $(TARGET_DIR)/usr/lib/ $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/lib/libivp.so
$(INSTALL) -m 644 -t $(TARGET_DIR)/usr/lib/ $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/lib/libmd.so
$(INSTALL) -m 644 -t $(TARGET_DIR)/usr/lib/ $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/lib/libmpi.so
$(INSTALL) -m 644 -t $(TARGET_DIR)/usr/lib/ $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/lib/libsecurec.so
# $(INSTALL) -m 644 -t $(TARGET_DIR)/usr/lib/ $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/lib/libtde.so
$(INSTALL) -m 644 -t $(TARGET_DIR)/usr/lib/ $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/lib/libupvqe.so
$(INSTALL) -m 644 -t $(TARGET_DIR)/usr/lib/ $(HISILICON_OSDRV_HI3516EV200_PKGDIR)/files/lib/libVoiceEngine.so
endef
$(eval $(generic-package))

View File

@@ -0,0 +1,45 @@
etc/sensors/5M_imx335.ini
etc/sensors/camhi_imx307_i2c_4l_1080p.ini
etc/sensors/gc2053_i2c_1080p.ini
etc/sensors/imx307_i2c_2l_1080p.ini
etc/sensors/imx335_i2c_4M.ini
etc/sensors/jxf23_i2c_1080p.ini
etc/sensors/jxf37_i2c_1080p.ini
etc/sensors/sc2231_i2c_1080p.ini
etc/sensors/sc2232h_i2c_1080p.ini
etc/sensors/sc2239_i2c_1080p.ini
etc/sensors/sc2315e_i2c_1080p.ini
etc/sensors/sc3235_i2c_3M.ini
etc/sensors/sc4236_i2c_3M.ini
etc/sensors/sp2305_i2c_1080p.ini
etc/sensors/WDR/5M_imx335.ini
etc/sensors/WDR/imx335_i2c_4M.ini
#
etc/sensors/iq/gc2053.ini
etc/sensors/iq/default.ini
etc/sensors/iq/imx307.ini
etc/sensors/iq/imx335.ini
etc/sensors/iq/sc2232.ini
etc/sensors/iq/sc2335.ini
#
usr/bin/ircut_demo
#
usr/lib/sensors/libsns_f23.so
usr/lib/sensors/libsns_f37.so
usr/lib/sensors/libsns_gc2053.so
usr/lib/sensors/libsns_imx307.so
usr/lib/sensors/libsns_imx307_2l.so
usr/lib/sensors/libsns_imx335.so
usr/lib/sensors/libsns_sc2231.so
usr/lib/sensors/libsns_sc2232h.so
usr/lib/sensors/libsns_sc2239.so
usr/lib/sensors/libsns_sc2315e.so
usr/lib/sensors/libsns_sc3235.so
usr/lib/sensors/libsns_sc4236.so
usr/lib/sensors/libsns_sp2305.so
#
etc/mediatek
lib/modules/4.9.37/hisilicon/camhi-motor.ko
lib/modules/4.9.37/kernel/drivers/net/wireless
lib/modules/4.9.37/kernel/drivers/staging
lib/modules/4.9.37/kernel/fs/f2fs