Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
3634db3
WIP: Device configuration
themarpe May 15, 2021
00d4dc4
Refactored and added preboot config
themarpe May 28, 2021
2f8ba37
Merge branch 'develop' into device_config
themarpe May 28, 2021
7dd586a
Updated example
themarpe May 28, 2021
068728e
Merge branch 'develop' into device_config
themarpe May 31, 2021
0df668c
Removed deprecated OpenVINO versions
themarpe May 31, 2021
7d863ef
Merge branch 'develop' into device_config
themarpe Jul 21, 2021
e37fd32
Updated preboot and added watchdog configuration
themarpe Jul 22, 2021
64f1aba
Modified watchdog to use a separate stream
themarpe Jul 22, 2021
d6d95e2
Fixed patching
themarpe Jul 22, 2021
cec733a
Merge branch 'develop' into device_config
themarpe Jul 24, 2021
23319c3
Updated FW and a catch clause
themarpe Jul 24, 2021
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
5dd1ec3
Updated FW for UsbSpeed handling
themarpe Aug 23, 2021
8071ddb
Fixed Super Speed mode and added a test
themarpe Aug 23, 2021
2fe25a1
Fixed Windows Platform specific code
themarpe Aug 23, 2021
ea7e4bf
Merge branch 'bootloader_updates' into develop_embedded
themarpe Aug 24, 2021
8460ce7
Merge branch 'device_config' into develop_embedded
themarpe Aug 24, 2021
24499d0
Added flash booted state and handling
themarpe Aug 24, 2021
5a36121
Updated FW with GPIO and SPI improvements
themarpe Aug 25, 2021
03bde90
Added Backward library to print stacktraces on crash
themarpe Aug 26, 2021
e9d9eea
Fixed style
themarpe Aug 26, 2021
8c13909
Updated FW to allow for graceful resets
themarpe Sep 2, 2021
f375e95
Added capability to not install signal handlers
themarpe Sep 2, 2021
35e163a
Updated FW - fixed cache coherency issue
themarpe Sep 6, 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
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ HunterGate(
LOCAL # Local config for dependencies
)

# TODO(themarpe) - might be more applicable to set as a target property
# Additional function information for 'backward' stacktrace
set(CMAKE_ENABLE_EXPORTS ON)

# Move binary dir if windows, to shorten the path
if(WIN32)
set(HUNTER_BINARY_DIR "${HUNTER_GATE_ROOT}/_bin" CACHE STRING "Hunter binary directory")
Expand Down Expand Up @@ -181,6 +185,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 +371,8 @@ target_link_libraries(${TARGET_CORE_NAME}
FP16::fp16
archive_static
spdlog::spdlog
ZLIB::zlib
Backward::Backward
)

# 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 "870bec4ca0ef026ddb9c490a38dfe9d097614554")
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 "1928f3407397272cc9736aedcca667c6c7419057")
set(DEPTHAI_DEVICE_SIDE_COMMIT "6793bd877ae334ac468b884ad1c9db22667da5b8")

# "version if applicable"
set(DEPTHAI_DEVICE_SIDE_VERSION "")
16 changes: 13 additions & 3 deletions cmake/Hunter/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ hunter_config(

hunter_config(
XLink
VERSION "luxonis-2021.3-master"
URL "https://github.com/luxonis/XLink/archive/2c6cdb857f3d21088b34ec172a0ea8df16528d00.tar.gz"
SHA1 "736da6528515d9c969008e2334f1387428f91a3b"
VERSION "luxonis-2021.3-develop"
URL "https://github.com/luxonis/XLink/archive/4c149080d22c35a17ce285f5bca99f2b2fe05e46.tar.gz"
SHA1 "64b0a8bfeb1a91f909df88ea8b1d0b17885b92ff"
)

hunter_config(
Expand Down Expand Up @@ -74,4 +74,14 @@ hunter_config(
CMAKE_ARGS
FP16_BUILD_BENCHMARKS=OFF
FP16_BUILD_TESTS=OFF
)

# Backward - Stacktrace printer
hunter_config(
Backward
VERSION "1.6"
URL "https://github.com/bombela/backward-cpp/archive/refs/tags/v1.6.tar.gz"
SHA1 "4ecb711eabfd15bc88ff9dd9342907fc5da46b62"
CMAKE_ARGS
BACKWARD_TESTS=OFF
)
11 changes: 9 additions & 2 deletions cmake/depthaiDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ else()
hunter_add_package(FP16)
hunter_add_package(libarchive-luxonis)
hunter_add_package(spdlog)
hunter_add_package(ZLIB)
hunter_add_package(Backward)
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 +28,15 @@ 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)


# Backward
find_package(Backward ${_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];
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;
}
5 changes: 2 additions & 3 deletions examples/src/rgb_preview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ int main() {
camRgb->preview.link(xoutRgb->input);

// Connect to device and start pipeline
dai::Device device(pipeline);
dai::Device device(pipeline, dai::UsbSpeed::SUPER);

cout << "Connected cameras: ";
for(const auto& cam : device.getConnectedCameras()) {
cout << static_cast<int>(cam) << " ";
cout << cam << " ";
}
cout << endl;
Expand All @@ -48,7 +47,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