-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·96 lines (82 loc) · 2.25 KB
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash
set -e
DEFAULT_REPO_PATH="../zmk/app"
SIDE=""
BOOTLOADER=true
FLASH=false
LOG=false
SETTINGS=false
POSITIONAL=()
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-l | --left)
SIDE="left"
export SHIELD_NAME="dactyl_manuform_$SIDE"
shift # past arg
;;
-r | --right)
SIDE="right"
export SHIELD_NAME="dactyl_manuform_$SIDE"
shift # past arg
;;
-n | --noboot)
BOOTLOADER=false
shift # past arg
;;
-f | --flash)
FLASH=true
shift # past arg
;;
-d | --debug)
LOG=true
shift # past arg
;;
-s | --settings)
export SHIELD_NAME="settings_reset_particle"
shift # past arg
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
(
cd $DEFAULT_REPO_PATH
if [ -n "$SHIELD_NAME" ]; then
# clean up
rm -rf build
echo "Building $SHIELD_NAME"
west build -p always -b particle_xenon -- -DSHIELD=$SHIELD_NAME -DZMK_CONFIG="$PWD/../../zmk-config/config"
fi
if $BOOTLOADER; then
FLASH_IMG=$(find build/zephyr -name "$SHIELD_NAME*.hex")
echo "Gen package for Adafruit bootloader from $FLASH_IMG"
rm -rf dfu-package.zip
adafruit-nrfutil dfu genpkg --dev-type 0x0052 --application "$FLASH_IMG" dfu-package.zip
else
FLASH_IMG=$(find build/zephyr -name "zmk*.elf")
fi
if $FLASH; then
echo "Flashing $FLASH_IMG"
if $BOOTLOADER; then
latestDevice=$(ls /dev/ttyACM* -1tr | tail -n1)
echo "Flashing device $latestDevice"
adafruit-nrfutil dfu serial --package dfu-package.zip -p "$latestDevice" -b 115200
else
openocd -f interface/ftdi/jtag-lock-pick_tiny_2.cfg \
-c "transport select swd" \
-f target/nrf52.cfg \
-c "init; reset; halt" \
-c "nrf5 mass_erase" \
-c "program $FLASH_IMG verify reset exit"
fi
fi
)
(
if $LOG; then
./log.py
fi
)