|
25 | 25 | with dai.DeviceBootloader(di) as bl: |
26 | 26 | print(f' current bootloader: {bl.getVersion()}', end='') |
27 | 27 | print() |
28 | | - selected = input(f'Which DepthAI device to flash bootloader for [0..{len(deviceInfos)-1}]: ') |
| 28 | + selected = input(f'Which OAK device to flash factory bootloader for [0..{len(deviceInfos)-1}]: ') |
29 | 29 | info = deviceInfos[int(selected)] |
30 | 30 |
|
31 | 31 | hasBootloader = (info.state == dai.XLinkDeviceState.X_LINK_BOOTLOADER) |
32 | 32 | if hasBootloader: |
33 | | - print("Warning! Flashing bootloader can potentially soft brick your device and should be done with caution.") |
| 33 | + print("Warning! Flashing factory bootloader can potentially soft brick your device and should be done with caution.") |
34 | 34 | print("Do not unplug your device while the bootloader is flashing.") |
35 | 35 | print("Type 'y' and press enter to proceed, otherwise exits: ") |
36 | 36 | if input() != 'y': |
|
54 | 54 | print("Prompt declined, exiting...") |
55 | 55 | exit(-1) |
56 | 56 |
|
| 57 | + try: |
| 58 | + # Clears out user bootloader |
| 59 | + configJson = bl.readConfigData() |
| 60 | + configJson["userBlSize"] = 0 |
| 61 | + bl.flashConfigData(configJson) |
| 62 | + except: |
| 63 | + print('No config found, skipping erasing user bootloader') |
| 64 | + |
57 | 65 | # Create a progress callback lambda |
58 | 66 | progress = lambda p : print(f'Flashing progress: {p*100:.1f}%') |
| 67 | + |
| 68 | + print(f"Flashing {blType.name} bootloader...") |
59 | 69 | startTime = time.monotonic() |
60 | | - is_user_bl = bl.isUserBootloaderSupported() |
61 | | - print(f"Flashing {blType.name} {'USER' if is_user_bl else 'FACTORY'} bootloader...") |
62 | | - if is_user_bl: |
63 | | - (res, message) = bl.flashUserBootloader(progress) |
64 | | - else: # Factory bootloader |
65 | | - (res, message) = bl.flashBootloader(dai.DeviceBootloader.Memory.FLASH, blType, progress) |
| 70 | + (res, message) = bl.flashBootloader(dai.DeviceBootloader.Memory.FLASH, blType, progress) |
66 | 71 | if res: |
67 | 72 | print("Flashing successful. Took", time.monotonic() - startTime, "seconds") |
68 | 73 | else: |
|
0 commit comments