CLI gives an error that device is protected if the device is protected.
How to Test
Prepare your device with a device-os branch that returns a device protected error. I used this diff on device-os 5.6.0
diff --git a/services/inc/system_error.h b/services/inc/system_error.h
index 5f3b9252c..8bb781629 100644
--- a/services/inc/system_error.h
+++ b/services/inc/system_error.h
@@ -24,6 +24,7 @@
// List of all defined system errors
#define SYSTEM_ERRORS \
(NONE, "", 0), /* -999 ... 0: Generic result codes */ \
+ (DEVICE_PROTECTED, "Device protected error", -999), \
(UNKNOWN, "Unknown error", -100), \
(BUSY, "Resource busy", -110), \
(NOT_SUPPORTED, "Not supported", -120), \
diff --git a/system/src/control/storage.cpp b/system/src/control/storage.cpp
index d9438eaa9..d6630a681 100644
--- a/system/src/control/storage.cpp
+++ b/system/src/control/storage.cpp
@@ -84,6 +84,7 @@ void firmwareUpdateCompletionHandler(int result, void* data) {
} // namespace
int startFirmwareUpdateRequest(ctrl_request* req) {
+ return SYSTEM_ERROR_DEVICE_PROTECTED;
PB(StartFirmwareUpdateRequest) pbReq = {};
CHECK(decodeRequestMessage(req, PB(StartFirmwareUpdateRequest_fields), &pbReq));
cancelFirmwareUpdate(); // Cancel current transfer
2. Point this `particle-cli` branch to use this `particle-usb` PR - https://github.com/particle-iot/particle-usb/pull/97
3. Attempt to flash a device by running `npm start -- flash --local`
After testing, make sure you flash the device with a "good" device-os branch so you can resume flashing.
## Related Issues / Discussions
<!--
Link to the issue that is fixed by this PR (if there is one)
e.g. Fixes #1234
Link to an issue that is partially addressed by this PR (if there are any)
e.g. Addresses #1234
Link to related issues (if there are any)
e.g. Related to #1234
Link to any relevant community discussions
e.g. As discussed here: https://community.particle.io/
-->
## Completeness
- [x] User is totes amazing for contributing!
- [ ] Contributor has signed [CLA](https://docs.google.com/a/particle.io/forms/d/1_2P-vRKGUFg5bmpcKLHO_qNZWGi5HKYnfrrkd-sbZoA/viewform)
- [ ] Problem and solution clearly stated
- [ ] Tests have been provided
- [ ] Docs have been updated
- [ ] CI is passing
Description
CLI gives an error that device is protected if the device is protected.
How to Test
Prepare your device with a device-os branch that returns a device protected error. I used this diff on device-os
5.6.0
$ npm start -- flash --local --target 5.6.0 /Users/keerthyamisagadda/code/workbench/uhura-tests/
Flashing boron e00fce68623fcff480e85e47 Targeting version: 5.6.0
Including: ../workbench/uhura-tests/project.properties ../workbench/uhura-tests/src/uhura-tests.cpp /Users/keerthyamisagadda/code/workbench/uhura-tests/assets/cat.txt /Users/keerthyamisagadda/code/workbench/uhura-tests/assets/water.txt /Users/keerthyamisagadda/code/workbench/uhura-tests/assets/water2.txt
Compile succeeded and bundle created.
Memory use: Flash RAM 11144 542
[░░░░░░░░░░░░░░░░░░░░░░░░░] 0% | Flash success! Operation could not be completed due to device protection.
keerthyamisagadda@loaners-macbook-pro particle-cli (feature/sc-124322/protected-error) $