forked from luxonis/depthai-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootloader_config.py
More file actions
executable file
·57 lines (52 loc) · 1.54 KB
/
bootloader_config.py
File metadata and controls
executable file
·57 lines (52 loc) · 1.54 KB
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
#!/usr/bin/env python3
import depthai as dai
import sys
import json
usage = False
read = True
clear = False
path = ''
if len(sys.argv) >= 2:
op = sys.argv[1]
if op == 'read':
read = True
elif op == 'flash':
read = False
if len(sys.argv) >= 3:
path = sys.argv[2]
elif op == 'clear':
clear = True
read = False
else:
usage = True
else:
usage = True
if usage:
print(f'Usage: {sys.argv[0]} [read/flash/clear] [flash: path/to/config/json]')
exit(-1)
(res, info) = dai.DeviceBootloader.getFirstAvailableDevice()
if res:
print(f'Found device with name: {info.name}');
with dai.DeviceBootloader(info) as bl:
try:
if read:
print('Current flashed configuration')
print(json.dumps(bl.readConfigData()))
else:
success = None
error = None
if clear:
(success, error) = bl.flashConfigClear()
else:
if path == '':
(success, error) = bl.flashConfig(dai.DeviceBootloader.Config())
else:
(success, error) = bl.flashConfigFile(path)
if success:
print('Successfully flashed bootloader configuration')
else:
print(f'Error flashing bootloader configuration: {error}')
except Exception as ex:
print(f'Error accessing config: {ex}')
else:
print('No devices found')