-
Notifications
You must be signed in to change notification settings - Fork 167
Bootloader fixes and support for more NOR flash chips #190
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
Closed
Closed
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 7ce7614
Revert "Removed flash_bootloader"
alex-luxonis eb3defc
Update bootloader: support for more NOR flash chips,
alex-luxonis c1e4180
Optional env var DEPTHAI_BOOTLOADER_BINARY to override bootloader FW …
alex-luxonis 92a5c0d
Warn when firmware or bootloader binaries are overriden
alex-luxonis d2946aa
Moved operator<< overloads to global namespace
themarpe 78fdd28
Added an explicit flag to allow flashing bootloader
themarpe 4cac817
Updated flash_bootloader to be a bit more verbose
themarpe 9eedc35
Improved the flash_bootloader example a bit
themarpe 08e6ad7
Updated flash_bootloader example
themarpe 29a3590
Allow to specify which bootloader is overridden by the env var:
alex-luxonis 154203b
Merge branch 'develop' into bootloader_updates
themarpe 819e9e2
Fixed boot_memory bootloader upgrade routine
themarpe 95573fd
Merge branch 'develop' into bootloader_updates
themarpe f7711f9
WIP: Bootloader configuration
themarpe 02f51a8
Updated bootloader_configuration example
themarpe 5dc961a
Reduced BL check to 0.0.14 and updated FW and BL
themarpe 93df997
Added capability to compress FW and additional BL config helper
themarpe 6a414d4
Updated flash_bootloader example
themarpe fb57b89
Added versioning to BL requests and refactored
themarpe 2fe25a1
Fixed Windows Platform specific code
themarpe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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 👍