Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Pi4 and 3B+ #72

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions circlean_fs/root_partition/etc/udev/rules.d/10-usb.rules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# The purpose of this rules file is to ensure that the top left usb port and its partitions have a symlink to /dev/source_key[num], and the other ports to /dev/dest_key[num]
KERNEL=="sd*", KERNELS=="1-1.2", SUBSYSTEMS=="usb", SYMLINK+="source_key%n"
KERNEL=="sd*", KERNELS=="1-1.[3-5]", SUBSYSTEMS=="usb", SYMLINK+="dest_key%n"
KERNEL=="sd*", KERNELS=="1-1.[1-5]", SUBSYSTEMS=="usb", PROGRAM="/usr/local/bin/identifyusbport.sh %p %k add", SYMLINK+="%c%n"
ACTION=="remove", KERNELS=="1-1.[1-5]", SUBSYSTEMS=="usb", PROGRAM="/usr/local/bin/identifyusbport.sh %p %k remove"
56 changes: 56 additions & 0 deletions circlean_fs/root_partition/usr/local/bin/identifyusbport.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash

DEBUG_FILE=/dev/shm/identifyusbport.txt
ACTION="connected"
DEVPATH="$1"
USBPORT="$2"

function FoundSource(){
echo "upper left connected, source_key '${USBPORT}' ${ACTION}" >> ${DEBUG_FILE}
echo source_key
}

echo -e "\nStart" >> ${DEBUG_FILE}
echo "Parameter 1: $1" >> ${DEBUG_FILE}
echo "Parameter 2: $2" >> ${DEBUG_FILE}
echo "Parameter 3: $3" >> ${DEBUG_FILE}

if (echo "$3" | grep -q "remove") ; then
if (echo "$2" | grep -v -q "1-1.") ; then
echo "ignore unknown remove $2" >> ${DEBUG_FILE}
exit 0
fi
if (echo "$2" | grep -q ":") ; then
echo "ignore remove subpath $2" >> ${DEBUG_FILE}
exit 0
fi
ACTION="disconnected"
DEVPATH="${2}/"
fi

MODEL=$(cat /proc/device-tree/model | tr -d '\000')
echo Device model: ${MODEL} >> ${DEBUG_FILE}
echo Devpath: ${DEVPATH} >> ${DEBUG_FILE}

if (echo "$MODEL" | grep -q "Raspberry Pi 3 Model B Plus") ; then
echo "found Raspberry Pi 3 B+ with special assignment" >> ${DEBUG_FILE}
if (echo "${DEVPATH}" | grep -q "1-1.1.2/") ; then
FoundSource
exit 0
fi
elif (echo "$MODEL" | grep -q "Raspberry Pi 4 Model B") ; then
echo "found Raspberry Pi 4 B with special assignment" >> ${DEBUG_FILE}
if (echo "${DEVPATH}" | grep -q "1-1.3/") ; then
FoundSource
exit 0
fi
else
echo "unsing default mapping" >> ${DEBUG_FILE}
if (echo "${DEVPATH}" | egrep -q "1-1.1/|1-1.2/") ; then
FoundSource
exit 0
fi
fi
echo "dest_key $2 $ACTION" >> ${DEBUG_FILE}
echo dest_key