Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.

Commit

Permalink
Don't flash over usbs at the same time.
Browse files Browse the repository at this point in the history
  • Loading branch information
kareltucek committed Oct 8, 2024
1 parent c0ca2f6 commit fd3e67f
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ usage: ./build DEVICE1 DEVICE2 ... ACTION1 ACTION2 ...
DEVICE is in { uhk-80-left | uhk-80-right | uhk-60-right | uhk-dongle }
there are also these aliases: { left | right | dongle | all }
ACTION is in { clean | setup | update | build | make | flash | shell | uart }
ACTION is in { clean | setup | update | build | make | flash | flashUsb | shell | uart }
setup initialize submodules and set up zephyr environment
clean removes zephyr libraries
Expand Down Expand Up @@ -93,6 +93,17 @@ function processArguments() {
fi
}

mutex() {
local lockfile="/tmp/uhk_build_lockfile"
if [ "$1" == "lock" ]; then
exec 200>"$lockfile" # Open file descriptor 200 for the lockfile
flock 200 # Block until lock is acquired
elif [ "$1" == "unlock" ]; then
flock -u 200 # Unlock the file descriptor
rm -f "$lockfile" # Remove lockfile
fi
}

function determineUsbDeviceArg() {
DEVICE=$1
DEVICEUSBID=""
Expand Down Expand Up @@ -249,7 +260,9 @@ END
USB_SCRIPT_DIR=$ROOT/lib/agent/packages/usb/
cd $USB_SCRIPT_DIR
echo "running $USB_SCRIPT_DIR$ ./update-device-firmware.ts $USBDEVICEARG $ROOT/device/build/$DEVICE/zephyr/app_update.bin $OTHER_ARGS"
mutex lock
./update-device-firmware.ts $USBDEVICEARG $ROOT/device/build/$DEVICE/zephyr/app_update.bin $OTHER_ARGS
mutex unlock
cd $ROOT
;;
release)
Expand Down Expand Up @@ -278,7 +291,6 @@ function performActions() {
eval $POSTBUILD
}


function runPerDevice() {
SESSION_NAME=$TARGET_TMUX_SESSION
establishSession $SESSION_NAME `echo $DEVICES | wc -w`
Expand Down

0 comments on commit fd3e67f

Please sign in to comment.