working alpha version

This commit is contained in:
ali
2026-06-25 08:12:43 +03:00
parent 4ac4be85f4
commit e251d09d1f
12 changed files with 381 additions and 0 deletions

View File

@ -0,0 +1,35 @@
#!/bin/bash
modprobe libcomposite
cd /sys/kernel/config/usb_gadget/
mkdir -p g1 && cd g1
# Standard USB descriptors
echo 0x1d6b > idVendor
echo 0x0104 > idProduct
echo 0x0100 > bcdDevice
echo 0x0200 > bcdUSB
mkdir -p strings/0x409
echo "TALIA003512M" > strings/0x409/serialnumber
echo "Debian" > strings/0x409/manufacturer
echo "EmulatedDrive" > strings/0x409/product
mkdir -p configs/c.1/strings/0x409
echo "Storage and Serial" > configs/c.1/strings/0x409/configuration
echo 500 > configs/c.1/MaxPower
mkdir -p functions/mass_storage.usb0
echo 1 > functions/mass_storage.usb0/stall
echo 1 > functions/mass_storage.usb0/lun.0/removable
# CRITICAL: Forces target PC to treat it as Read-Only
echo 1 > functions/mass_storage.usb0/lun.0/ro
echo /usb_share.img > functions/mass_storage.usb0/lun.0/file
ln -sf functions/mass_storage.usb0 configs/c.1/
# Serial connection
mkdir -p functions/acm.usb0
ln -sf functions/acm.usb0 configs/c.1/
# Bind to the physical controller to make it appear on the reading PC
echo $(ls /sys/class/udc/) > UDC

View File

@ -0,0 +1,18 @@
#!/bin/bash
SERIAL_PORT="/dev/ttyGS0"
stty -F "$SERIAL_PORT" raw
while true
do
if read -r line < "$SERIAL_PORT"
then
# wait for done message
if [ "$line" = "DONE" ]
then
echo "" > /sys/kernel/config/usb_gadget/g1/UDC
exit
fi
fi
sleep 0.5
done

View File

@ -0,0 +1,45 @@
#!/bin/bash
SERIAL_PORT="/dev/ttyGS0"
USB_FILE="/usb_share.img"
USB_MOUNT="/mnt/usb_share/"
LOCAL_DIR="/var/local/talia/"
FTP_DIR="/home/birikim/out/"
while sleep 3
do
if [ -z "$(cat /sys/kernel/config/usb_gadget/g1/UDC)" ] && \
[ -n "$(ls -A $FTP_DIR)" ]
then
mount $USB_FILE $USB_MOUNT
rm -rf $USB_MOUNT/talia-sd
mkdir $USB_MOUNT/talia-sd
# wait writes to be completed
while inotifywait -t 60 -r -e close_write -e moved_to "$FTP_DIR"
do
true
done
# lock dir and mv files to USB storage
chown -R root:root $FTP_DIR
cd $FTP_DIR
for i in $(ls -A $FTP_DIR)
do
mv "$i" $USB_MOUNT/talia-sd/
done
chown -R birikim:birikim $FTP_DIR
cd $USB_MOUNT/talia-sd/
# md5sum
find -type f -exec md5sum {} \; > /tmp/talia-md5sum.txt
sed -i "s/.\///" /tmp/talia-md5sum.txt
cd /tmp
mv talia-md5sum.txt $USB_MOUNT/talia-sd/
umount $USB_MOUNT
# expose USB storage
/root/scripts/expose_usb.sh
# wait serial
systemctl start talia-serial-wait.service
fi
done