-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflash.py
29 lines (23 loc) · 832 Bytes
/
flash.py
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
'''
./ST-LINK_CLI.exe -c SWD -P ~/dev/hoverbot/hoverboard-firmware-hack/build/hover.bin 0x08000000
'''
import os, sys, subprocess, time
which = sys.argv[1] # orig or foc
if which == 'orig':
os.chdir('hoverboard-firmware-hack')
elif which == 'foc':
os.chdir('hoverboard-firmware-hack-FOC')
else:
assert 0, 'orig or foc'
stLinkExe = '/mnt/c/Program Files (x86)/STMicroelectronics/STM32 ST-LINK Utility/ST-LINK Utility/ST-LINK_CLI.exe'
assert os.path.exists(stLinkExe), 'Cannot find ST-Link utility'
ret = os.system('make')
if ret != 0:
print('BUILD FAILED')
hoverBin = 'build/hover.bin'
assert os.path.exists(hoverBin)
input('Press ENTER to reset')
ret = os.system('"%s" -c SWD -Rst' % stLinkExe)
input('Press ENTER to flash')
ret = os.system('"%s" -c SWD -P "%s" 0x08000000' % (stLinkExe, hoverBin))
print(ret)