Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions cmake/Depthai/DepthaiBootloaderConfig.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Maturity level "snapshot" / "release"
set(DEPTHAI_BOOTLOADER_MATURITY "release")
set(DEPTHAI_BOOTLOADER_MATURITY "snapshot")

# "version if applicable"
set(DEPTHAI_BOOTLOADER_VERSION "0.0.11")
set(DEPTHAI_BOOTLOADER_VERSION "eb6701e5b053da5609f2c23a915969247603bc6b")
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 "b71584129b101b30e4632678c19d33b020c04c36")
set(DEPTHAI_DEVICE_SIDE_COMMIT "7417ecc8b275931ce2eb8635e854ded05a9c3c6d")

# "version if applicable"
set(DEPTHAI_DEVICE_SIDE_VERSION "")
11 changes: 11 additions & 0 deletions include/depthai/device/DeviceBootloader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,17 @@ class DeviceBootloader {
*/
std::tuple<bool, std::string> flashBootloader(std::function<void(float)> progressCallback, std::string path = "");

/**
* Flashes a boot header that does USB boot (as if setting the boot switches to 0x16). Currently this overwrites the bootloader
* @param progressCallback Callback that sends back a value between 0..1 which signifies current flashing progress
*/
std::tuple<bool, std::string> flashUsbBoot(std::function<void(float)> progressCallback);

/**
* Sends a command to switch to USB boot. Cleared by a hard-reset/power-cycle
*/
std::tuple<bool, std::string> switchToUsbBoot();

/**
* @returns Version of current running bootloader
*/
Expand Down
59 changes: 59 additions & 0 deletions src/device/DeviceBootloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,65 @@ std::tuple<bool, std::string> DeviceBootloader::flashBootloader(std::function<vo
return {result.success, result.errorMsg};
}

// TODO reduce some code duplication (with the above functions flashBootloader, flashDepthaiApplicationPackage)
std::tuple<bool, std::string> DeviceBootloader::flashUsbBoot(std::function<void(float)> progressCb) {
// get streamId
streamId_t streamId = stream->getStreamId();

// send request to flash BOOT_HEADER with USB boot
dai::bootloader::request::UpdateFlash updateFlash;
updateFlash.storage = dai::bootloader::request::UpdateFlash::BOOT_HEADER;
updateFlash.bootHeader = dai::bootloader::request::UpdateFlash::BootHeader::USB;
updateFlash.totalSize = 0;
updateFlash.numPackets = 0;
if(!sendBootloaderRequest(streamId, updateFlash)) return {false, "Couldn't send bootloader flash request"};

// Then wait for response by bootloader
// Wait till FLASH_COMPLETE response
dai::bootloader::response::FlashComplete result;
do {
std::vector<uint8_t> data;
if(!receiveBootloaderResponseData(streamId, data)) return {false, "Couldn't receive bootloader response"};

dai::bootloader::response::FlashStatusUpdate update;
if(parseBootloaderResponse(data, update)) {
// if progress callback is set
if(progressCb != nullptr) {
progressCb(update.progress);
}
// if flash complete response arrived, break from while loop
} else if(parseBootloaderResponse(data, result)) {
break;
} else {
// Unknown response, shouldn't happen
return {false, "Unknown response from bootloader while flashing"};
}

} while(true);

// Return if flashing was successful
return {result.success, result.errorMsg};
}

std::tuple<bool, std::string> DeviceBootloader::switchToUsbBoot() {
// get streamId
streamId_t streamId = stream->getStreamId();

// send request to switch to USB boot, and don't let app reset again to bootloader
dai::bootloader::request::UsbRomBoot usbBootRequest;
usbBootRequest.keepUsbBootAfterAppRestart = true;

if(!sendBootloaderRequest(streamId, usbBootRequest)) {
return {false, "Couldn't send bootloader USB boot request"};
}

// Dummy read, until link falls down and it returns an error
streamPacketDesc_t* pPacket;
XLinkReadData(streamId, &pPacket);

return {true, ""};
}

bool DeviceBootloader::isEmbeddedVersion() {
return isEmbedded;
}
Expand Down