Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workaround bootloader-shared var init bug #347

Merged
merged 1 commit into from
Jan 25, 2022
Merged
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
24 changes: 19 additions & 5 deletions src/device/DeviceBootloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,8 @@ std::tuple<bool, std::string> DeviceBootloader::flashDepthaiApplicationPackage(s
// Then wait for response by bootloader
// Wait till FLASH_COMPLETE response
Response::FlashComplete result;
result.success = 0; // TODO remove these inits after fix https://github.com/luxonis/depthai-bootloader-shared/issues/4
result.errorMsg[0] = 0;
do {
std::vector<uint8_t> data;
if(!receiveResponseData(data)) return {false, "Couldn't receive bootloader response"};
Expand Down Expand Up @@ -611,6 +613,8 @@ std::tuple<bool, std::string> DeviceBootloader::flashBootloader(Memory memory, T
// Then wait for response by bootloader
// Wait till FLASH_COMPLETE response
Response::FlashComplete result;
result.success = 0; // TODO remove these inits after fix https://github.com/luxonis/depthai-bootloader-shared/issues/4
result.errorMsg[0] = 0;
do {
std::vector<uint8_t> data;
if(!receiveResponseData(data)) return {false, "Couldn't receive bootloader response"};
Expand Down Expand Up @@ -662,6 +666,8 @@ std::tuple<bool, std::string> DeviceBootloader::flashCustom(Memory memory, uint3
// Then wait for response by bootloader
// Wait till FLASH_COMPLETE response
Response::FlashComplete result;
result.success = 0; // TODO remove these inits after fix https://github.com/luxonis/depthai-bootloader-shared/issues/4
result.errorMsg[0] = 0;
do {
std::vector<uint8_t> data;
if(!receiveResponseData(data)) return {false, "Couldn't receive bootloader response"};
Expand Down Expand Up @@ -704,9 +710,9 @@ nlohmann::json DeviceBootloader::readConfigData(Memory memory, Type type) {

// Get response
Response::GetBootloaderConfig resp;
receiveResponse(resp);
resp.success = 0; // TODO remove these inits after fix https://github.com/luxonis/depthai-bootloader-shared/issues/4

if(resp.success) {
if(receiveResponse(resp) && resp.success) {
// Read back bootloader config (1 packet max)
auto bsonConfig = stream->read();
// Parse from BSON
Expand All @@ -727,11 +733,15 @@ std::tuple<bool, std::string> DeviceBootloader::flashConfigClear(Memory memory,
setConfigReq.numPackets = 0;
setConfigReq.totalSize = 0;
setConfigReq.clearConfig = 1;
if(!sendRequest(setConfigReq)) return {false, "Couldn't send request to flash configuration data"};
if(!sendRequest(setConfigReq)) return {false, "Couldn't send request to flash configuration clear"};

// Read back response
Response::FlashComplete result;
receiveResponse(result);
result.success = 0; // TODO remove these inits after fix https://github.com/luxonis/depthai-bootloader-shared/issues/4
result.errorMsg[0] = 0;
if(!receiveResponse(result)) {
return {false, "Couldn't receive response to flash configuration clear"};
}

// Return if flashing was successful
return {result.success, result.errorMsg};
Expand All @@ -757,7 +767,11 @@ std::tuple<bool, std::string> DeviceBootloader::flashConfigData(nlohmann::json c

// Read back response
Response::FlashComplete result;
receiveResponse(result);
result.success = 0; // TODO remove these inits after fix https://github.com/luxonis/depthai-bootloader-shared/issues/4
result.errorMsg[0] = 0;
if(!receiveResponse(result)) {
return {false, "Couldn't receive response to flash configuration data"};
}

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