Bootloader Version

This example shows basic bootloader interaction, retrieving the version of bootloader running on the device.

Click on Bootloader for more information.

Note

We suggest using Device Manager, a GUI tool for interfacing with the bootloader and its configurations.

Demo

Example script output

~/depthai-python/examples$ python3 bootloader_version.py
Found device with name: 1.1
Version: 0.0.26
USB Bootloader - supports only Flash memory
Memory 'Memory.FLASH' size: 33554432, info: JEDEC ID: 01 02 19

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

git clone https://github.com/luxonis/depthai-python.git
cd depthai-python/examples
python3 install_requirements.py

For additional information, please follow installation guide

Source code

Also available on GitHub

 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
#!/usr/bin/env python3

import depthai as dai

(res, info) = dai.DeviceBootloader.getFirstAvailableDevice()

if res == True:
    print(f'Found device with name: {info.name}')
    bl = dai.DeviceBootloader(info)
    print(f'Version: {bl.getVersion()}')

    supportedMemTypes = [dai.DeviceBootloader.Memory.FLASH, dai.DeviceBootloader.Memory.EMMC]
    if bl.getType() == dai.DeviceBootloader.Type.USB:
        print("USB Bootloader - supports only Flash memory")
        supportedMemTypes = [dai.DeviceBootloader.Memory.FLASH];
    else:
        print(f"NETWORK Bootloader, is User Bootloader: {bl.isUserBootloader()}")

    try:
        for mem in supportedMemTypes:
            memInfo = bl.getMemoryInfo(mem)
            if memInfo.available:
                print(f"Memory '{mem}' size: {memInfo.size}, info: {memInfo.info}")
                appInfo = bl.readApplicationInfo(mem)
                if appInfo.hasApplication:
                    print(f"Application name: {appInfo.applicationName}, firmware version: {appInfo.firmwareVersion}")
            else:
                print(f"Memory '{mem.name}' not available...")
    except Exception as ex:
        print(f"Couldn't retrieve memory details: {ex}")
else:
    print('No devices found')

Also available on GitHub

 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
#include "depthai/depthai.hpp"

int main(int argc, char** argv) {
    bool res = false;
    dai::DeviceInfo info;
    std::tie(res, info) = dai::DeviceBootloader::getFirstAvailableDevice();

    if(res) {
        std::cout << "Found device with name: " << info.name << std::endl;
        dai::DeviceBootloader bl(info);
        std::cout << "Version: " << bl.getVersion().toString() << std::endl;

        std::list<dai::DeviceBootloader::Memory> supportedMemTypes = {dai::DeviceBootloader::Memory::FLASH, dai::DeviceBootloader::Memory::EMMC};
        if(bl.getType() == dai::DeviceBootloader::Type::USB) {
            std::cout << "USB Bootloader - supports only Flash memory" << std::endl;
            supportedMemTypes = {dai::DeviceBootloader::Memory::FLASH};
        } else {
            std::cout << "NETWORK Bootloader, is User Bootloader: " << bl.isUserBootloader() << std::endl;
        }

        try {
            for(const auto& mem : supportedMemTypes) {
                std::cout << std::endl;
                auto memoryInfo = bl.getMemoryInfo(mem);
                if(memoryInfo.available) {
                    std::cout << "Memory '" << mem << "' size: " << memoryInfo.size << ", info: " << memoryInfo.info << std::endl;

                    auto appInfo = bl.readApplicationInfo(mem);
                    std::cout << "Application, flashed: " << appInfo.hasApplication << " firmware version: " << appInfo.firmwareVersion
                              << " application name: " << appInfo.applicationName << std::endl;
                } else {
                    std::cout << "Memory '" << mem << "' not available..." << std::endl;
                }
            }
        } catch(const std::exception& ex) {
            std::cout << "Couldn't retrieve memory details: " << ex.what() << std::endl;
        }
    } else {
        std::cout << "No devices found" << std::endl;
    }

    return 0;
}

Got questions?

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