-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflash.sh
executable file
·62 lines (48 loc) · 931 Bytes
/
flash.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
#!/bin/bash
# wykys 2021
# Lazy Firmware Update
RESET_PIN=25
BOOT0_PIN=23
GPIO_DRIVER="./wiringOP/gpio/gpio"
DEVICE="0483:df11"
FIRMWARE="/home/wcube/klipper/out/klipper.bin"
###############################################################################
delay () {
sleep 0.5
}
gpio_init() {
$GPIO_DRIVER mode $RESET_PIN OUTPUT
$GPIO_DRIVER mode $BOOT0_PIN OUTPUT
delay
}
reset_mcu () {
$GPIO_DRIVER write $RESET_PIN 0
delay
}
run_mcu () {
$GPIO_DRIVER write $RESET_PIN 1
delay
}
boot_dfu () {
$GPIO_DRIVER write $BOOT0_PIN 1
delay
}
boot_flash () {
$GPIO_DRIVER write $BOOT0_PIN 0
delay
}
flash () {
dfu-util --device $DEVICE -D $FIRMWARE --alt 0 -s 0x08000000
}
main () {
gpio_init
reset_mcu
boot_dfu
run_mcu
flash
reset_mcu
boot_flash
run_mcu
}
###############################################################################
main