You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
130 lines
2.8 KiB
130 lines
2.8 KiB
6 years ago
|
test
|
||
|
|
||
|
sudo apt install inotify-tools
|
||
|
|
||
|
sudo dd if=/dev/zero of=/usbdisk.img bs=1M count=128
|
||
|
|
||
|
fdisk new primary partition type b
|
||
|
|
||
|
|
||
|
fdisk -lu /usbdisk.img #=> offset
|
||
|
|
||
|
losetup -o $((2048*512)) /dev/loop0 /usbdisk.img
|
||
|
mkfs -t vfat -v /dev/loop0 -n raspberry
|
||
|
losetup -d /dev/loop0
|
||
|
|
||
|
|
||
|
sudo modprobe g_mass_storage file=/usbdisk.img stall=0 removable=1 iSerialNumber=1234567890
|
||
|
(modinfo g_mass_storage)
|
||
|
|
||
|
mount -o loop,ro,offset=$((2048*512)) -t vfat /usbdisk.img /mnt
|
||
|
|
||
|
umount /mnt
|
||
|
|
||
|
sudo modprobe -r g_mass_storage
|
||
|
|
||
|
|
||
|
|
||
|
echo "dtoverlay=dwc2" >> /boot/config.txt
|
||
|
echo "g_mass_storage file=/usbdisk.img stall=0 removable=1 iSerialNumber=1234567890" >> /etc/modules
|
||
|
|
||
|
|
||
|
script:
|
||
|
#!/bin/bash
|
||
|
set -e -u
|
||
|
|
||
|
[ -f /usr/bin/inotifywait ] || apt -y install inotify-tools
|
||
|
[ -f /usr/bin/fim ] || apt -y install fim
|
||
|
|
||
|
#tvservice -p
|
||
|
# tvservice -e "DMT 82"
|
||
|
# fbset -g 1920 1080 1920 1080 16
|
||
|
|
||
|
echo "18" > /sys/class/gpio/export || echo "gpio already set up"
|
||
|
echo "23" > /sys/class/gpio/export || echo "gpio already set up"
|
||
|
sleep 1
|
||
|
echo "out" > /sys/class/gpio/gpio18/direction
|
||
|
echo "0" > /sys/class/gpio/gpio18/value
|
||
|
echo "out" > /sys/class/gpio/gpio23/direction
|
||
|
echo "0" > /sys/class/gpio/gpio23/value
|
||
|
|
||
|
declare -g latest=""
|
||
|
|
||
|
getnewestfile() {
|
||
|
#unset -v latest
|
||
|
shopt -s nullglob
|
||
|
for f in /mnt/*; do
|
||
|
[[ "$f" -nt "$latest" ]] && latest="$f"
|
||
|
done
|
||
|
echo "$latest"
|
||
|
}
|
||
|
|
||
|
cleanup () {
|
||
|
echo "0" > /sys/class/gpio/gpio18/value
|
||
|
echo "0" > /sys/class/gpio/gpio23/value
|
||
|
killall fim
|
||
|
umount /mnt || echo ""
|
||
|
modprobe -r g_mass_storage || echo ""
|
||
|
exit
|
||
|
}
|
||
|
|
||
|
trap cleanup INT TERM EXIT
|
||
|
|
||
|
modprobe g_mass_storage file=/usbdisk.img stall=0 removable=1 iSerialNumber=1234567890
|
||
|
|
||
|
echo "1" > /sys/class/gpio/gpio18/value
|
||
|
|
||
|
inotifywait -mq -e modify --format %w%f /usbdisk.img | while read FILE
|
||
|
do
|
||
|
echo "1" > /sys/class/gpio/gpio23/value
|
||
|
echo "new screenshot"
|
||
|
mount -o loop,ro,offset=$((2048*512)) -t vfat /usbdisk.img /mnt
|
||
|
latest=$(getnewestfile)
|
||
|
if [ -n "$latest" ] && [ -f "$latest" ]; then
|
||
|
killall fim
|
||
|
cp "$latest" /latestimage
|
||
|
fim -d /dev/fb0 -T 1 --autozoom --quiet /latestimage &
|
||
|
fi
|
||
|
umount /mnt
|
||
|
echo "0" > /sys/class/gpio/gpio23/value
|
||
|
done
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
examples:
|
||
|
|
||
|
FILE=/usbdisk.img
|
||
|
mkdir -p ${FILE/img/d}
|
||
|
mount -o loop,offset=$((2048*512)) -t vfat $FILE ${FILE/img/d}
|
||
|
|
||
|
|
||
|
inotifywait -mq -e close_write --format %w%f /usbdisk.img | while read FILE
|
||
|
do
|
||
|
echo "Die Datei $FILE wurde modifiziert."
|
||
|
echo "1" > /sys/class/gpio/gpio23/value
|
||
|
mount -o loop,ro,offset=$((2048*512)) -t vfat /usbdisk.img /mnt
|
||
|
|
||
|
umount /mnt
|
||
|
echo "0" > /sys/class/gpio/gpio23/value
|
||
|
done
|
||
|
|
||
|
|
||
|
while inotifywait -e modify /usbdisk.img
|
||
|
do
|
||
|
...
|
||
|
done
|
||
|
|
||
|
|
||
|
|
||
|
ToDo:
|
||
|
recreate image on boot
|
||
|
|
||
6 years ago
|
repartition for usbimage?
|
||
|
memory split? (hdmi ausgabe u framebuffer beachten!)
|
||
6 years ago
|
readonly-root
|
||
6 years ago
|
dritte led für boot?
|
||
6 years ago
|
|
||
6 years ago
|
screenshot-tool option für sofortigen screenshot
|