Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
e17c269
Revert "Removed flash_bootloader example temporarily"
alex-luxonis Jul 23, 2021
7ce7614
Revert "Removed flash_bootloader"
alex-luxonis Jul 23, 2021
eb3defc
Update bootloader: support for more NOR flash chips,
alex-luxonis Jul 28, 2021
c1e4180
Optional env var DEPTHAI_BOOTLOADER_BINARY to override bootloader FW …
alex-luxonis Jul 28, 2021
92a5c0d
Warn when firmware or bootloader binaries are overriden
alex-luxonis Jul 28, 2021
d2946aa
Moved operator<< overloads to global namespace
themarpe Jul 29, 2021
78fdd28
Added an explicit flag to allow flashing bootloader
themarpe Jul 29, 2021
4cac817
Updated flash_bootloader to be a bit more verbose
themarpe Jul 29, 2021
9eedc35
Improved the flash_bootloader example a bit
themarpe Jul 29, 2021
08e6ad7
Updated flash_bootloader example
themarpe Jul 29, 2021
29a3590
Allow to specify which bootloader is overridden by the env var:
alex-luxonis Aug 3, 2021
154203b
Merge branch 'develop' into bootloader_updates
themarpe Aug 4, 2021
819e9e2
Fixed boot_memory bootloader upgrade routine
themarpe Aug 4, 2021
95573fd
Merge branch 'develop' into bootloader_updates
themarpe Aug 13, 2021
f7711f9
WIP: Bootloader configuration
themarpe Aug 16, 2021
02f51a8
Updated bootloader_configuration example
themarpe Aug 16, 2021
5dc961a
Reduced BL check to 0.0.14 and updated FW and BL
themarpe Aug 19, 2021
93df997
Added capability to compress FW and additional BL config helper
themarpe Aug 21, 2021
6a414d4
Updated flash_bootloader example
themarpe Aug 21, 2021
fb57b89
Added versioning to BL requests and refactored
themarpe Aug 23, 2021
2fe25a1
Fixed Windows Platform specific code
themarpe Aug 23, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ add_library(${TARGET_CORE_NAME}
src/pipeline/datatype/FeatureTrackerConfig.cpp
src/utility/Initialization.cpp
src/utility/Resources.cpp
src/utility/Platform.cpp
src/xlink/XLinkConnection.cpp
src/xlink/XLinkStream.cpp
src/openvino/OpenVINO.cpp
Expand Down Expand Up @@ -366,6 +367,7 @@ target_link_libraries(${TARGET_CORE_NAME}
FP16::fp16
archive_static
spdlog::spdlog
ZLIB::zlib
)

# Add compile definitions
Expand Down
6 changes: 4 additions & 2 deletions cmake/Depthai/DepthaiBootloaderConfig.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Maturity level "snapshot" / "release"
set(DEPTHAI_BOOTLOADER_MATURITY "release")
#set(DEPTHAI_BOOTLOADER_MATURITY "release")
set(DEPTHAI_BOOTLOADER_MATURITY "snapshot")

# "version if applicable"
set(DEPTHAI_BOOTLOADER_VERSION "0.0.12")
#set(DEPTHAI_BOOTLOADER_VERSION "0.0.12")
set(DEPTHAI_BOOTLOADER_VERSION "ad1e3d8c3a335c42d17e3b968e5d26e69885d706")
2 changes: 1 addition & 1 deletion cmake/Depthai/DepthaiDeviceSideConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set(DEPTHAI_DEVICE_SIDE_MATURITY "snapshot")

# "full commit hash of device side binary"
set(DEPTHAI_DEVICE_SIDE_COMMIT "a2baa42ba41f7b79dcbee987b34f24da075de196")
set(DEPTHAI_DEVICE_SIDE_COMMIT "b595df452a0366d44b5b921cba31cc87f3596ad4")

# "version if applicable"
set(DEPTHAI_DEVICE_SIDE_VERSION "")
7 changes: 5 additions & 2 deletions cmake/depthaiDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ else()
hunter_add_package(FP16)
hunter_add_package(libarchive-luxonis)
hunter_add_package(spdlog)
hunter_add_package(ZLIB)
endif()

# If library was build as static, find all dependencies
if(NOT CONFIG_MODE OR (CONFIG_MODE AND NOT depthai_SHARED_LIBS))

# BZip2 (for bspatch)
find_package(BZip2 ${_QUIET} CONFIG REQUIRED)

Expand All @@ -26,10 +27,12 @@ if(NOT CONFIG_MODE OR (CONFIG_MODE AND NOT depthai_SHARED_LIBS))
# libarchive for firmware packages
find_package(archive_static ${_QUIET} CONFIG REQUIRED)
find_package(lzma ${_QUIET} CONFIG REQUIRED)
# ZLIB for compressing Apps
find_package(ZLIB CONFIG REQUIRED)

# spdlog for library and device logging
find_package(spdlog ${_QUIET} CONFIG REQUIRED)

endif()

# Add threads (c++)
Expand Down
7 changes: 5 additions & 2 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ target_compile_definitions(object_tracker_video PRIVATE BLOB_PATH="${person_dete
dai_add_example(queue_add_callback src/queue_add_callback.cpp ON)

dai_add_example(bootloader_version src/bootloader_version.cpp ON)
#dai_add_example(flash_bootloader src/flash_bootloader.cpp OFF)
dai_add_example(flash_bootloader src/flash_bootloader.cpp OFF)
dai_add_example(edge_detector src/edge_detector.cpp ON)

dai_add_example(feature_tracker src/feature_tracker.cpp ON)
Expand All @@ -289,4 +289,7 @@ dai_add_example(image_manip_tiling src/image_manip_tiling.cpp ON)

target_compile_definitions(calibration_flash PRIVATE CALIB_PATH="${calib_v6}")
target_compile_definitions(calibration_flash_version5 PRIVATE CALIB_PATH="${calib_v5}" BOARD_PATH="${device_config}")
target_compile_definitions(calibration_load PRIVATE CALIB_PATH="${calib_v6}")
target_compile_definitions(calibration_load PRIVATE CALIB_PATH="${calib_v6}")

# Bootloader configuration example
dai_add_example(bootloader_config src/bootloader_config.cpp OFF)
68 changes: 68 additions & 0 deletions examples/src/bootloader_config.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#include "depthai/depthai.hpp"

int main(int argc, char** argv) {
// Options
bool usage = false, read = true, clear = false;
std::string path = "";
if(argc >= 2) {
std::string op = argv[1];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can add argparser, looks like this is a copy of the python implementation and header only:
https://github.com/jamolnng/argparse

Copy link
Collaborator

@themarpe themarpe Aug 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will leave this as a side task to refactor one day. Good suggestion to match Python, thanks 👍

if(op == "read") {
read = true;
} else if(op == "flash") {
read = false;
if(argc >= 3) {
path = argv[2];
}
} else if(op == "clear") {
clear = true;
read = false;
} else if(op == "clear") {
clear = true;
read = false;
} else {
usage = true;
}
} else {
usage = true;
}
if(usage) {
std::cout << "Usage: " << argv[0] << " [read/flash/clear] [flash: path/to/config/json]" << std::endl;
return -1;
}

// DeviceBootloader configuration
bool res = false;
dai::DeviceInfo info;
std::tie(res, info) = dai::DeviceBootloader::getFirstAvailableDevice();

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

if(read) {
std::cout << "Current flashed configuration\n" << bl.readConfigData().dump(4) << std::endl;
} else {
bool success;
std::string error;
if(clear) {
std::tie(success, error) = bl.flashConfigClear();
} else {
if(path.empty()) {
std::tie(success, error) = bl.flashConfig(dai::DeviceBootloader::Config{});
} else {
std::tie(success, error) = bl.flashConfigFile(path);
}
}
if(success) {
std::cout << "Successfully flashed bootloader configuration\n";
} else {
std::cout << "Error flashing bootloader configuration: " << error;
}
}

} else {
std::cout << "No devices found" << std::endl;
}

return 0;
}
68 changes: 68 additions & 0 deletions examples/src/flash_bootloader.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#include <chrono>
#include <string>

#include "depthai/depthai.hpp"

int main(int argc, char** argv) {
using namespace std::chrono;

dai::DeviceBootloader::Type blType = dai::DeviceBootloader::Type::AUTO;
if(argc > 1) {
std::string blTypeStr(argv[1]);
if(blTypeStr == "usb") {
blType = dai::DeviceBootloader::Type::USB;
} else if(blTypeStr == "network") {
blType = dai::DeviceBootloader::Type::NETWORK;
} else {
std::cout << "Specify either 'usb' or 'network' bootloader type\n";
return 0;
}
}

std::cout << "Warning! Flashing bootloader can potentially soft brick your device and should be done with caution." << std::endl;
std::cout << "Do not unplug your device while the bootloader is flashing." << std::endl;
std::cout << "Type 'y' and press enter to proceed, otherwise exits: ";
if(std::cin.get() != 'y') {
std::cout << "Prompt declined, exiting..." << std::endl;
return -1;
}

bool found = false;
dai::DeviceInfo info;
std::tie(found, info) = dai::DeviceBootloader::getFirstAvailableDevice();
if(!found) {
std::cout << "No device found to flash. Exiting." << std::endl;
return -1;
}

// Open DeviceBootloader and allow flashing bootloader
std::cout << "Booting latest bootloader first, will take a tad longer..." << std::endl;
dai::DeviceBootloader bl(info, true);
auto currentBlType = bl.getType();

// Check if bootloader type is the same
if(blType != dai::DeviceBootloader::Type::AUTO && currentBlType != blType) {
std::cout << "Are you sure you want to flash '" << blType << "' bootloader over current '" << currentBlType << "' bootloader?" << std::endl;
std::cout << "Type 'y' and press enter to proceed, otherwise exits: ";
std::cin.ignore();
if(std::cin.get() != 'y') {
std::cout << "Prompt declined, exiting..." << std::endl;
return -1;
}
}

// Create a progress callback lambda
auto progress = [](float p) { std::cout << "Flashing Progress..." << p * 100 << "%" << std::endl; };

std::cout << "Flashing " << currentBlType << " bootloader..." << std::endl;
auto t1 = steady_clock::now();
bool success = false;
std::string message;
std::tie(success, message) = bl.flashBootloader(dai::DeviceBootloader::Memory::FLASH, currentBlType, progress);
if(success) {
std::cout << "Flashing successful. Took " << duration_cast<milliseconds>(steady_clock::now() - t1).count() << "ms" << std::endl;
} else {
std::cout << "Flashing failed: " << message << std::endl;
}
return 0;
}
2 changes: 1 addition & 1 deletion examples/src/rgb_preview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ int main() {

int key = cv::waitKey(1);
if(key == 'q' || key == 'Q') {
return 0;
break;
}
}
return 0;
Expand Down
15 changes: 6 additions & 9 deletions include/depthai/common/CameraBoardSocket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,21 @@

#include "depthai-shared/common/CameraBoardSocket.hpp"

namespace dai {

inline std::ostream& operator<<(std::ostream& out, const CameraBoardSocket& socket) {
// Global namespace
inline std::ostream& operator<<(std::ostream& out, const dai::CameraBoardSocket& socket) {
switch(socket) {
case CameraBoardSocket::AUTO:
case dai::CameraBoardSocket::AUTO:
out << "AUTO";
break;
case CameraBoardSocket::RGB:
case dai::CameraBoardSocket::RGB:
out << "RGB";
break;
case CameraBoardSocket::LEFT:
case dai::CameraBoardSocket::LEFT:
out << "LEFT";
break;
case CameraBoardSocket::RIGHT:
case dai::CameraBoardSocket::RIGHT:
out << "RIGHT";
break;
}
return out;
}

} // namespace dai
19 changes: 8 additions & 11 deletions include/depthai/common/UsbSpeed.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,27 @@

#include "depthai-shared/common/UsbSpeed.hpp"

namespace dai {

inline std::ostream& operator<<(std::ostream& out, const UsbSpeed& speed) {
// Global namespace
inline std::ostream& operator<<(std::ostream& out, const dai::UsbSpeed& speed) {
switch(speed) {
case UsbSpeed::UNKNOWN:
case dai::UsbSpeed::UNKNOWN:
out << "UNKNOWN";
break;
case UsbSpeed::LOW:
case dai::UsbSpeed::LOW:
out << "LOW";
break;
case UsbSpeed::FULL:
case dai::UsbSpeed::FULL:
out << "FULL";
break;
case UsbSpeed::HIGH:
case dai::UsbSpeed::HIGH:
out << "HIGH";
break;
case UsbSpeed::SUPER:
case dai::UsbSpeed::SUPER:
out << "SUPER";
break;
case UsbSpeed::SUPER_PLUS:
case dai::UsbSpeed::SUPER_PLUS:
out << "SUPER_PLUS";
break;
}
return out;
}

} // namespace dai
Loading