diff --git a/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-buildroot-tiny/etc/init.d/S91smb b/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-buildroot-tiny/etc/init.d/S91smb new file mode 100644 index 000000000..dc67681a0 --- /dev/null +++ b/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-buildroot-tiny/etc/init.d/S91smb @@ -0,0 +1,10 @@ +#!/bin/sh + +case $1 in + start) + echo "The smb initialization is skipped" + ;; + *) + exit 1 + ;; +esac diff --git a/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-buildroot-tiny/etc/init.d/S99hciinit b/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-buildroot-tiny/etc/init.d/S99hciinit new file mode 100755 index 000000000..abdaac6b3 --- /dev/null +++ b/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-buildroot-tiny/etc/init.d/S99hciinit @@ -0,0 +1,28 @@ +#!/bin/sh + +check_hciconfig() { + if command -v hciattach &> /dev/null; then + if lsmod | grep -q "aic8800_fdrv"; then + hciattach -s 1500000 /dev/ttyS1 any 1500000 flow nosleep& + sleep 2 + if hciconfig -a | grep -q "hci0"; then + hciconfig hci0 up& + else + echo "hci0 not found or not available." + fi + ifconfig wlan0 up && udhcpc -i wlan0 > /dev/null 2>&1 + else + echo "aic8800_fdrv not found." + fi + fi +} + +case $1 in + start) + check_hciconfig & + ;; + *) + exit 1 + ;; +esac + diff --git a/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-buildroot-tiny/etc/init.d/S99rtcinit b/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-buildroot-tiny/etc/init.d/S99rtcinit new file mode 100755 index 000000000..32cc126f3 --- /dev/null +++ b/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-buildroot-tiny/etc/init.d/S99rtcinit @@ -0,0 +1,16 @@ +#!/bin/sh + +case $1 in +start) + if [ "$(hwclock | grep "1969")" ]; then + echo "RTC time calibration" + date -s 2024-01-01 + hwclock -w + else + echo "RTC does not require time calibration" + fi + ;; +*) + exit 1 + ;; +esac diff --git a/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-buildroot-tiny/etc/init.d/S99test b/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-buildroot-tiny/etc/init.d/S99test new file mode 100755 index 000000000..d77252cdf --- /dev/null +++ b/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-buildroot-tiny/etc/init.d/S99test @@ -0,0 +1,13 @@ +#!/bin/sh +[ -f /etc/profile.d/RkEnv.sh ] && source /etc/profile.d/RkEnv.sh +case $1 in + start) + if [ -f /usr/bin/t ] ;then + chmod a+x /usr/bin/t + t & + fi + ;; + *) + exit 1 + ;; +esac diff --git a/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-buildroot-tiny/etc/init.d/S99usb0config b/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-buildroot-tiny/etc/init.d/S99usb0config new file mode 100755 index 000000000..37bf52dc7 --- /dev/null +++ b/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-buildroot-tiny/etc/init.d/S99usb0config @@ -0,0 +1,67 @@ +#!/bin/sh + +TARGET_IP="172.32.0.93" + +USB_KEYWORD="android_work: sent uevent USB_STATE=" +USB_MODE_PATH="/proc/device-tree/usbdrd/usb@ffb00000/dr_mode" + +MAX_RETRIES=10 +retries=0 + +usb0_config() { + if [ "$(cat /proc/device-tree/usbdrd/usb@ffb00000/dr_mode)" == "peripheral" ]; then + current_ip=$(ifconfig usb0 | grep -o 'inet addr:[^ ]*' | awk -F ':' '{print $2}') + echo "current_ip = $current_ip" + echo "TARGET_IP = $TARGET_IP" + + while [[ "$current_ip" != "$TARGET_IP" && $retries -lt $MAX_RETRIES ]]; do + sleep .5 + echo "luckfox : set usb0 ip" + ifconfig usb0 "$TARGET_IP" + current_ip=$(ifconfig usb0 | grep -o 'inet addr:[^ ]*' | awk -F ':' '{print $2}') + echo $current_ip + retries=$((retries + 1)) + done + + if [[ "$current_ip" != "$TARGET_IP" ]]; then + echo "usb0 config error" + else + echo "usb0 config success" + fi + else + echo "usb0 is using host mode" + fi +} + +usb_reset() { + while true; do + last_line=$(dmesg | grep "$USB_KEYWORD" | tail -n 1) + + if [[ "$last_line" == *"DISCONNECTED"* ]]; then + echo "Detected USB DISCONNECTED." + /etc/init.d/S50usbdevice restart + usb0_config + #elif [[ "$last_line" == *"CONFIGURED"* ]]; then + # echo "Detected CONFIGURED. No action required." + #else + # echo "No relevant USB_STATE found." + fi + + sleep 5 + done +} + +case $1 in +start) + # check peripheral + usb_mode="$(cat $USB_MODE_PATH)" + if [ "$usb_mode" = "peripheral" ]; then + usb0_config + usb_reset & + fi + ;; +stop) ;; +*) + exit 1 + ;; +esac diff --git a/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-buildroot-tiny/etc/inittab b/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-buildroot-tiny/etc/inittab new file mode 100644 index 000000000..3801d85fc --- /dev/null +++ b/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-buildroot-tiny/etc/inittab @@ -0,0 +1,41 @@ +# /etc/inittab +# +# Copyright (C) 2001 Erik Andersen +# +# Note: BusyBox init doesn't support runlevels. The runlevels field is +# completely ignored by BusyBox init. If you want runlevels, use +# sysvinit. +# +# Format for each entry: ::: +# +# id == tty to run on, or empty for /dev/console +# runlevels == ignored +# action == one of sysinit, respawn, askfirst, wait, and once +# process == program to run + +# Startup the system +::sysinit:/bin/mount -t proc proc /proc +::sysinit:/bin/mount -o remount,rw / +::sysinit:/bin/mkdir -p /dev/pts /dev/shm +::sysinit:/bin/mount -a +::sysinit:/bin/mkdir -p /run/lock/subsys +::sysinit:/sbin/swapon -a +null::sysinit:/bin/ln -sf /proc/self/fd /dev/fd +null::sysinit:/bin/ln -sf /proc/self/fd/0 /dev/stdin +null::sysinit:/bin/ln -sf /proc/self/fd/1 /dev/stdout +null::sysinit:/bin/ln -sf /proc/self/fd/2 /dev/stderr +::sysinit:/bin/hostname -F /etc/hostname +# now run any rc scripts +::sysinit:/etc/init.d/rcS + +# Put a getty on the serial port +#console::respawn:/sbin/getty -L console 0 vt100 # GENERIC_SERIAL +console::respawn:-/bin/sh + +# Stuff to do for the 3-finger salute +#::ctrlaltdel:/sbin/reboot + +# Stuff to do before rebooting +::shutdown:/etc/init.d/rcK +::shutdown:/sbin/swapoff -a +::shutdown:/bin/umount -a -r \ No newline at end of file diff --git a/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-buildroot-tiny/etc/profile b/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-buildroot-tiny/etc/profile new file mode 100755 index 000000000..d90ab5e34 --- /dev/null +++ b/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-buildroot-tiny/etc/profile @@ -0,0 +1,24 @@ +export PATH="/bin:/sbin:/usr/bin:/usr/sbin" + +export EDITOR='/bin/vi' + +#export PS1='[\u@\h \W]# ' +if [ "$PS1" ]; then + if [ "`id -u`" -eq 0 ]; then + #export PS1='# ' + export PS1='[\u@\h \W]# ' + else + #export PS1='$ ' + export PS1='[\u@\h \W]$ ' + fi +fi + +# Source configuration files from /etc/profile.d +for i in /etc/profile.d/*.sh ; do + if [ -r "$i" ]; then + . $i + fi +done +unset i + + diff --git a/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-buildroot-tiny/usr/bin/iomux b/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-buildroot-tiny/usr/bin/iomux new file mode 100755 index 000000000..f31c9dd86 Binary files /dev/null and b/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-buildroot-tiny/usr/bin/iomux differ