Skip to content

Commit

Permalink
Add support for r37gb 2
Browse files Browse the repository at this point in the history
  • Loading branch information
roleoroleo committed Dec 13, 2024
1 parent b87ba2f commit f551492
Show file tree
Hide file tree
Showing 7 changed files with 359 additions and 0 deletions.
1 change: 1 addition & 0 deletions scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ CAMERAS["y213ga"]="y213ga"
CAMERAS["h30ga"]="h30ga"
CAMERAS["r30gb"]="r30gb"
CAMERAS["r35gb"]="r35gb"
CAMERAS["r37gb"]="r37gb"
CAMERAS["h52ga"]="h52ga"
CAMERAS["h51ga"]="h51ga"
CAMERAS["y28ga"]="y28ga"
Expand Down
76 changes: 76 additions & 0 deletions sdhack/r37gb/Factory/config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
echo "############## Starting Firmware Dump ##############"
echo "############## Starting Firmware Dump ##############"
echo "############## Starting Firmware Dump ##############"
echo "############## Starting Firmware Dump ##############"

mkdir -p /tmp/sd/backup

cat /proc/mtd > /tmp/sd/backup/mtd.txt

dd if=/dev/mtdblock0 of=/tmp/sd/backup/mtdblock0.bin
dd if=/dev/mtdblock1 of=/tmp/sd/backup/mtdblock1.bin
dd if=/dev/mtdblock2 of=/tmp/sd/backup/mtdblock2.bin
dd if=/dev/mtdblock3 of=/tmp/sd/backup/mtdblock3.bin
dd if=/dev/mtdblock4 of=/tmp/sd/backup/mtdblock4.bin
dd if=/dev/mtdblock5 of=/tmp/sd/backup/mtdblock5.bin
dd if=/dev/mtdblock6 of=/tmp/sd/backup/mtdblock6.bin
dd if=/dev/mtdblock7 of=/tmp/sd/backup/mtdblock7.bin

cp /home/homever /tmp/sd/backup/homever.txt



echo "############## Starting Hack ##############"
echo "############## Starting Hack ##############"
echo "############## Starting Hack ##############"
echo "############## Starting Hack ##############"


### Check if hack is present
echo "### Hacking"
if [ `grep telnetd /backup/init.sh | grep -c ^` -gt 0 ]; then
echo "Hack already applied"
else
echo "Applying hack"

### Update /backup/init.sh with a more friendly one
echo "### Updating /backup/init.sh"
cp /backup/init.sh /tmp/init.sh
sed -n '1{$!N;$!N;$!N;$!N};$!N;s@\nif \[ \-f \/home\/app\/lower_half_init.sh \];then\n source \/home\/app\/lower_half_init.sh\nelse\n source \/backup\/lower_half_init.sh\nfi@@;P;D' -i /tmp/init.sh
sed -n '1{$!N;$!N;$!N;$!N};$!N;s@\nif \[ \-f \/home\/app\/lower_half_init.sh \];then\n\tsource \/home\/app\/lower_half_init.sh\nelse\n\tsource \/backup\/lower_half_init.sh\nfi@@;P;D' -i /tmp/init.sh
sed -e 's/^source \/home\/app\/lower_half_init.sh//g' -i /tmp/init.sh

echo "# Running telnetd" >> /tmp/init.sh
echo "/usr/sbin/telnetd &" >> /tmp/init.sh
echo "" >> /tmp/init.sh
echo "if [ -f /tmp/sd/lower_half_init.sh ];then" >> /tmp/init.sh
echo " source /tmp/sd/lower_half_init.sh" >> /tmp/init.sh
echo "elif [ -f /home/app/lower_half_init.sh ];then" >> /tmp/init.sh
echo " source /home/app/lower_half_init.sh" >> /tmp/init.sh
echo "else" >> /tmp/init.sh
echo " source /backup/lower_half_init.sh" >> /tmp/init.sh
echo "fi" >> /tmp/init.sh

cp /tmp/init.sh /backup/init.sh
rm /tmp/init.sh
fi

### Set wireless credentials if configure_wifi.cfg exists
if [ -e /tmp/sd/Factory/configure_wifi.cfg ]; then
/tmp/sd/Factory/configure_wifi.sh
fi

### Disable the hack for next reboot
echo "### Disabling hack for next reboot"
if [ -e /tmp/sd/Factory.done ]; then
rm -rf /tmp/sd/Factory.done
fi
if [ -e /tmp/sd/Factory ]; then
mv /tmp/sd/Factory /tmp/sd/Factory.done
fi

sync
sync
sync

reboot
5 changes: 5 additions & 0 deletions sdhack/r37gb/Factory/configure_wifi.cfg.ori
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Don't use backslash char \
# Don't use double quote " around ssid and psk
# Space chars are allowed
wifi_ssid=My AP 2.4GHz
wifi_psk=password$
79 changes: 79 additions & 0 deletions sdhack/r37gb/Factory/configure_wifi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/sh

function print_help {
echo "configure_wifi.sh"
echo "will be used on next boot"
}

CFG_FILE=/tmp/sd/Factory/configure_wifi.cfg
if [ ! -f "$CFG_FILE" ]; then
echo "configure_wifi.cfg not found"
exit 1
fi

TMP=$(cat $CFG_FILE | grep wifi_ssid=)
SSID=$(echo "${TMP:10}")
TMP=$(cat $CFG_FILE | grep wifi_psk=)
KEY=$(echo "${TMP:9}")

if [ -z "$SSID" ]; then
echo "error: ssid has not been set"
print_help
exit 1
fi
if [ ${#SSID} -gt 63 ]; then
echo "error: ssid is too long"
print_help
exit 1
fi

if [ -z "$KEY" ]; then
echo "error: key has not been set"
print_help
exit 1
fi
if [ ${#KEY} -gt 63 ]; then
echo "error: key is too long"
print_help
exit 1
fi

CURRENT_SSID=$(dd bs=1 skip=28 count=64 if=/dev/mtdblock7 2>/dev/null)
CURRENT_KEY=$(dd bs=1 skip=92 count=64 if=/dev/mtdblock7 2>/dev/null)
CURRENT_BIT=$(hexdump -C -s 16 -n 16 /dev/mtdblock7 2>/dev/null | awk 'NR==1 {print}' | cut -d " " -f 12)

echo $SSID ${#SSID} - $CURRENT_SSID ${#CURRENT_SSID}
echo $KEY ${#KEY} - $CURRENT_KEY ${#CURRENT_KEY}
echo $CONNECTED_BIT

if [ "$SSID" == "$CURRENT_SSID" ] && [ "$KEY" == "$CURRENT_KEY" ]; then
echo "ssid and key already configured"
if [ "$CONNECTED_BIT" != "00000000" ]; then
#write "connected" bit
printf "\00\00\00\00" | dd of=/dev/mtdblock7 bs=1 seek=24 count=4 conv=notrunc
sync
sync
sync
reboot
fi
exit
fi

echo "creating partition backup..."
DATE=$(date '+%Y%m%d%H%M%S')
dd if=/dev/mtdblock7 of=/tmp/sd/mtdblock7_$DATE.bin 2>/dev/null

# clear the existing passwords (to ensure we are null terminated)
cat /dev/zero | dd of=/dev/mtdblock7 bs=1 seek=28 count=64 conv=notrunc
cat /dev/zero | dd of=/dev/mtdblock7 bs=1 seek=92 count=64 conv=notrunc
# write SSID
echo -n "$SSID" | dd of=/dev/mtdblock7 bs=1 seek=28 count=64 conv=notrunc
# write key
echo -n "$KEY" | dd of=/dev/mtdblock7 bs=1 seek=92 count=64 conv=notrunc
#write "connected" bit
printf "\00\00\00\00" | dd of=/dev/mtdblock7 bs=1 seek=24 count=4 conv=notrunc

sync
sync
sync
reboot
Empty file.
198 changes: 198 additions & 0 deletions sysroot/r37gb/lower_half_init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
#!/bin/sh

# protect against running this script twice and starting up a bunch of duplicate processes
if [ -f /tmp/init_started ]; then
exit
fi

touch /tmp/init_started

mount -t vfat /dev/mmcblk0 /tmp/sd
if [ "${SUFFIX}" = "y211ga" ] || [ "${SUFFIX}" = "y211ba" ];then
echo "need reset gpio198"
echo 198 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio198/direction
echo 0 > /sys/class/gpio/gpio198/value
sleep 1
echo 1 > /sys/class/gpio/gpio198/value
fi

### wifi 8188 ###
if [ "${enable_4g}" = "y" ];then
echo "4g is running...."
else
if [ -f /home/base/wifi/8188fu.ko ];then
insmod /home/base/wifi/8188fu.ko
elif [ -f /home/base/wifi/8189fs.ko ];then
insmod /home/base/wifi/8189fs.ko
elif [ -f /backup/ko/8188fu.ko ];then
insmod /backup/ko/8188fu.ko
elif [ -f /backup/ko/8189fs.ko ];then
insmod /backup/ko/8189fs.ko
elif [ -f /backup/ko/hi3881.ko ];then
insmod /backup/ko/hi3881.ko
sleep 1
echo 'wlan0 set_sta_pm_on 0' > /sys/hisys/hipriv
echo 'wlan0 alg_cfg tpc_mode 0' > /sys/hisys/hipriv
echo 'wlan0 intrf_mode 0 1 1 1' > /sys/hisys/hipriv
elif [ -f /backup/ko/8192fu.ko ];then
insmod /backup/ko/8192fu.ko
elif [ -f /backup/ko/atbm603x_wifi_usb.ko ];then
insmod /backup/ko/atbm603x_wifi_usb.ko
elif [ -f /backup/ko/rdawfmac.ko ];then
insmod /backup/ko/rdawfmac.ko
elif [ -f /backup/ko/ssv6155.ko ];then
if [ -f /home/base/firmware/ssv6155_jixian/ssv6155-wifi.cfg ];then
insmod /backup/ko/ssv6155.ko stacfgpath="/home/base/firmware/ssv6155_jixian/ssv6155-wifi.cfg" wifi_type=USB
else
echo "not found ssv6155-wifi.cfg"
fi
fi

if [ -f /backup/ko/ssv6x5x.ko ];then
if [ "${SUFFIX}" = "d071qp" ];then
if [ -f /home/base/firmware/ssv6x5x/ssv6152-wifi.cfg ];then
insmod /backup/ko/ssv6x5x.ko stacfgpath="/home/base/firmware/ssv6x5x/ssv6152-wifi.cfg" wifi_type=SDIO
else
echo "not found ssv6x5x-wifi.cfg"
fi
else
if [ -f /home/base/firmware/ssv6x5x/ssv6x5x-wifi.cfg ];then
insmod /backup/ko/ssv6x5x.ko stacfgpath="/home/base/firmware/ssv6x5x/ssv6x5x-wifi.cfg" wifi_type=$SSV_WIFI_TYPE
else
echo "not found ssv6x5x-wifi.cfg"
fi
fi
fi
fi

echo "--------------------------insmod sensor--------------------------"
insmod /home/base/ko/videobuf2-core.ko
insmod /home/base/ko/videobuf2-memops.ko
insmod /home/base/ko/videobuf2-dma-contig.ko
insmod /home/base/ko/videobuf2-v4l2.ko
insmod /home/base/ko/vin_io.ko

#统一版本
if [ "${SUFFIX}" = "b091qp" ];then
insmod /backup/ko/cam_sensor.ko
insmod /home/base/ko/vin_v4l2.ko ccm0=$SENSOR_DRIVE_NAME i2c0_addr=$SENSOR_ADDR
else
insmod /home/base/ko/cam_sensor.ko
insmod /home/base/ko/vin_v4l2.ko
fi


if [ -f /home/base/ko/icplus.ko ];then
insmod /home/base/ko/icplus.ko
elif [ -f /backup/ko/icplus.ko ];then
insmod /backup/ko/icplus.ko
fi

if [ -f /home/base/ko/sunxi_gpadc.ko ];then
insmod /home/base/ko/sunxi_gpadc.ko
fi

#/home/app/script/factory_test.sh

#echo "MTK 7601" > /tmp/MTK
#echo /tmp/sd/core.exe[%e].pid[%p].sig[%s] > /proc/sys/kernel/core_pattern

sleep 1
ifconfig lo up

ifconfig ${NETWORK_IFACE} up
#设置最大功率 wlan0 up之后
#if [ -f /backup/ko/rdawfmac.ko ];then
# /backup/ko/rda5995-usb/firmware/rda_tools wlan0 write_txp 0x4e 0x3a
#fi

ethmac=d2:`ifconfig ${NETWORK_IFACE} |grep HWaddr|cut -d' ' -f10|cut -d: -f2-`
#if [ "${enable_4g}" = "y" ];then
# ifconfig usb0 up
# ethmac=d2:`ifconfig usb0 |grep HWaddr|cut -d' ' -f10|cut -d: -f2-`
#else
# ifconfig wlan0 up
# ethmac=d2:`ifconfig wlan0 |grep HWaddr|cut -d' ' -f10|cut -d: -f2-`
#fi

ifconfig eth0 hw ether $ethmac
a=1
if [ "${SUFFIX}" = "b111qp" ] || [ "${SUFFIX}" = "b101qp" ] || [ "${SUFFIX}" = "b092qp" ] || [ "${SUFFIX}" = "b091qp" ] || [ "${SUFFIX}" = "q321br_aldz_3m" ]; then
while ( ! ifconfig eth0 up)
do
echo "ifconfig eth0 up failed"
let a++
if [ $a -eq 10 ]; then
break
fi
done
else
ifconfig eth0 up
fi

ln -s /home/model/BodyVehicleAnimal3.model /tmp/BodyVehicleAnimal3.model


echo "============================================= home low_half_init.sh... ========================================="
echo "============================================= begin to start app... ========================================="
cd /home/app
if [ -f /home/app/property ];then
./property &
fi
#./log_server &

if [ -f "/tmp/sd/Factory/factory_test.sh" ]; then
/tmp/sd/Factory/config.sh
exit
fi

export LD_LIBRARY_PATH=/home/app/locallib:$LD_LIBRARY_PATH:/tmp
echo $LD_LIBRARY_PATH

if [ -f "/tmp/sd/factory_aging_test.sh" ]; then
#/tmp/sd/factory_aging_test.sh
./dispatch &
sleep 2
./rmm &
sleep 2
./mp4record &
exit
fi

if [ -f "/tmp/sd/log_tools.tar.gz" ];then
echo "run log_tools start."
if [ ! -d /tmp/sd/log_tools ];then
cd /tmp/sd
mkdir log_tools
fi
cd /tmp/sd
tar -zxvf log_tools.tar.gz -C /tmp/sd/log_tools
chmod +x /tmp/sd/log_tools/run_log_app.sh
source /tmp/sd/log_tools/run_log_app.sh
cd -
echo "run log_tools end."
exit
fi

mount --bind /tmp/sd/yi-hack/script/wifidhcp.sh /home/app/script/wifidhcp.sh
mount --bind /tmp/sd/yi-hack/script/wifidhcp.sh /backup/tools/wifidhcp.sh
mount --bind /tmp/sd/yi-hack/script/ethdhcp.sh /home/app/script/ethdhcp.sh
mount --bind /tmp/sd/yi-hack/script/ethdhcp.sh /backup/tools/ethdhcp.sh

LD_PRELOAD=/tmp/sd/yi-hack/lib/ipc_multiplex.so ./dispatch &
#sleep 2
#./rmm &
#sleep 2
#./mp4record &
#./cloud &
#./p2p_tnp &
#./oss &
#./rtmp &
#./watch_process &

chmod 777 /tmp/sd/debug.sh
sh /tmp/sd/debug.sh &

chmod 755 /tmp/sd/yi-hack/script/system.sh
sh /tmp/sd/yi-hack/script/system.sh &
Empty file.

0 comments on commit f551492

Please sign in to comment.