DepthAI Tutorials
DepthAI API References

ON THIS PAGE

  • Flash User Bootloader
  • Demo
  • Setup
  • Source code

Flash User Bootloader

This script will flash user bootloader <Factory and User bootloader> to the connected OAK camera. Bootloader can only be flashed to devices that have on-board flash memory.

Demo

Example script output
Command Line
1~/depthai-python/examples/bootloader$ python3 flash_user_bootloader.py
2    [0] 1844301041C83D0E00 [X_LINK_USB_VSC] current bootloader: 0.0.26
3    Which DepthAI device to flash User Bootloader for (Note: Only NETWORK supported) [0..0]: 0
4    User Bootloader version to flash: 0.0.26
5    Flashing User Bootloader...
6    Flashing progress: 0.0%
7    Flashing progress: 18.8%
8    Flashing progress: 31.2%
9    Flashing progress: 48.2%
10    Flashing progress: 94.2%
11    Flashing progress: 100.0%
12    Flashing successful. Took 7.55600329185836 seconds

Setup

Please run the install script to download all required dependencies. Please note that this script must be ran from git context, so you have to download the depthai-python repository first and then run the script
Command Line
1git clone https://github.com/luxonis/depthai-python.git
2cd depthai-python/examples
3python3 install_requirements.py
For additional information, please follow the installation guide.

Source code

Python
C++
Python
GitHub
1#!/usr/bin/env python3
2
3import depthai as dai
4import sys
5import time
6
7deviceInfos = dai.DeviceBootloader.getAllAvailableDevices()
8if len(deviceInfos) == 0:
9    print("No device found to flash. Exiting.")
10    exit(-1)
11else:
12    for i, di in enumerate(deviceInfos):
13        print(f'[{i}] {di.getMxId()} [{di.protocol.name}]', end='')
14        if di.state == dai.XLinkDeviceState.X_LINK_BOOTLOADER:
15            with dai.DeviceBootloader(di) as bl:
16                print(f' current bootloader: {bl.getVersion()}', end='')
17        print()
18    selected = input(f'Which DepthAI device to flash User Bootloader for (Note: Only NETWORK supported) [0..{len(deviceInfos)-1}]: ')
19    info = deviceInfos[int(selected)]
20
21# Open DeviceBootloader and allow flashing bootloader
22with dai.DeviceBootloader(info) as bl:
23    print("User Bootloader version to flash:", bl.getVersion())
24
25    # Create a progress callback lambda
26    progress = lambda p : print(f'Flashing progress: {p*100:.1f}%')
27
28    print(f"Flashing User Bootloader...")
29    startTime = time.monotonic()
30    (res, message) = bl.flashUserBootloader(progress)
31    if res:
32        print("Flashing successful. Took", time.monotonic() - startTime, "seconds")
33    else:
34        print("Flashing failed:", message)

Need assistance?

Head over to Discussion Forum for technical support or any other questions you might have.