|
16 | 16 | */ |
17 | 17 |
|
18 | 18 | /* |
19 | | - R510 Firmware Update: |
| 19 | + R510 Firmware Update Background Check: |
20 | 20 | ===================== |
| 21 | + 1. Baked into sara_ncp_client.cpp init process |
| 22 | + 2. When ATI9 is used to determine the modem version (thus, only when modem is on), |
| 23 | + check if there is an update firmware version available. |
| 24 | + 3. Set a flag for Cellular.updatePending() if update available. |
| 25 | +
|
| 26 | +
|
| 27 | + R510 Firmware Update |
| 28 | + ===================== |
| 29 | + 0. (Blocking Call) Once Cellular.startUpdate() is called, initialize state_/status_ from Idle to Qualify. |
21 | 30 | 1. Check ncpId() == PLATFORM_NCP_SARA_R510 |
22 | 31 | 2. Is System.enableUpdates() == true? |
23 | 32 | 3. Check modem firmware version - compatible upgrade version will be baked into Device OS with MD5 sum. |
24 | 33 | 4. Reboot into Safe Mode to start the update process |
25 | | - 5. Is Particle.connected()? |
26 | | - 6. Setup HTTPS security options |
27 | | - 7. When ready to start update process, publish a "spark/device/ncp/update" system event that Device OS has "started" a modem update. |
28 | | - Only try to update once per hour if something should fail the first time, so we're not stuck in a hard |
29 | | - loop offline? |
30 | | - 8. Disconnect the Cloud |
31 | | - 9. If an existing FOAT file is present, delete it since there is no way to validate what it is after it's present. |
32 | | - 10. Start the download based on step 3, keep track of update version |
33 | | - 11. Download is only complete when the the MD5SUM URC of the file is received and verified |
34 | | - 12. Disconnect from the Cellular network |
35 | | - 13. Apply the firmware update |
36 | | - 14. Sit in a tight loop it will take about 18 to 20 minutes |
| 34 | + 5. Particle.connect() |
| 35 | + 6. Publish a "spark/device/ncp/update" system event that Device OS has "started" a modem update. |
| 36 | + 7. Particle.disconnect() |
| 37 | + 8. Disable PPP link and Cellular.connect(), timeout after 10 minutes |
| 38 | + 9. Setup HTTPS security options |
| 39 | + 10. If an existing FOAT file is present, delete it since there is no way to validate what it is after it's present. |
| 40 | + 11. Start the download based our database entry |
| 41 | + 12. Download is only complete when the the MD5SUM URC of the file is received and verified |
| 42 | + 13. Cellular.disconnect() |
| 43 | + 14. Apply the firmware update |
| 44 | + 15. Sit in a tight loop while the modem is updating, it will take about 18 to 20 minutes |
37 | 45 | a. waiting for final INSTALL URC of 128 |
38 | 46 | b. polling for AT/OK every 10 seconds |
39 | 47 | c. monitoring a timeout counter of 40 minutes |
40 | | - 15. Save the download/install result to be published once connected to the Cloud again |
41 | | - 16. Power cycle the modem by switching it off, and.. |
42 | | - 17. Connect to the Cloud |
43 | | - 18. Publish a "spark/device/ncp/update" system event that Device OS has finished with "success" or "failed" |
44 | | - 19. Reset the system to exit Safe Mode |
45 | | - 20. Add result status to device diagnostics |
| 48 | + 16. Save the download/install result to be published once connected to the Cloud again |
| 49 | + 17. Re-enable PPP link and Power off the modem |
| 50 | + 18. Particle.connect() |
| 51 | + 19. Publish a "spark/device/ncp/update" system event that Device OS has finished with "success" or "failed" |
| 52 | + 20. Reset the system to exit Safe Mode |
| 53 | + 21. On next init, add result status to device diagnostics |
46 | 54 |
|
47 | 55 | TODO: |
48 | 56 | ==================== |
|
52 | 60 | Done - Move ncp_fw_update.cpp to services/ instead of system/ since we have more space available there |
53 | 61 | Done - Add correct cipher settings |
54 | 62 | Done - Save state_, status_, firmwareVersion_ variables in retained system memory to ensure |
55 | | - Done - we complete step 11/12 |
| 63 | + Done - we complete step INSTALL/WAITING |
56 | 64 | Done - we do enter and exit safe mode fw updating cleanly |
57 | 65 | Done - we do not get stuck in a fail-retry loop |
58 | 66 | Done - Refactor retained structure to use systemCache instead |
|
61 | 69 | Done - Gen 3, extends timer 5 minutes for every received URC. |
62 | 70 | Done - When do we retry failures? Quick loops can retry a few times, but long ones shouldn't |
63 | 71 | Done - Create a database of starting firmware version / desired firmware version / filename / MD5SUM value, similar to APN DB. |
64 | | - - Minimize logging output, move some statements to LOG_DEBUG |
65 | 72 | Done - Make sure there is a final status log |
66 | 73 | Done - Allow user firmware to pass a database entry that overrides the system firmware update database |
67 | 74 | Done - Add final status to Device Diagnostics |
68 | | - - add modem version to Device Diagnostics? |
69 | | - - Make publishEvent's an async call with timeout? |
70 | | - - When do we clear the g_ncpFwUpdateRetained.state == FW_UPDATE_FINISHED_IDLE_STATE to kickoff a new update attempt? |
| 75 | + ? - add modem version to Device Diagnostics |
71 | 76 | Done - Remove callbacks |
72 | 77 | Done - Remove Gen 2 code |
73 | 78 | Done - Gen 3 |
74 | | - Done - allow normal connection at first for publishing |
75 | | - Done - avoid connecting PPP for downloading |
76 | | - Done - enable PDP context with a few AT commands for downloading |
| 79 | + Done - allow normal connection first |
| 80 | + Done - optionally avoid connecting PPP |
| 81 | + Done - enable PDP context with a few AT commands |
77 | 82 | Done - Remove System feature flag |
78 | 83 | - implement background update check, only perform checks if modem is on. |
79 | 84 | - ncp_fw_udpate_check should drive an update check, implement no argument as system check |
80 | 85 | - implement Cellular.updatesPending() API |
81 | 86 | - implement Cellular.startUpdate() API |
82 | | -
|
| 87 | + - add 10 minute cellular connect timeout when PPP link disabled |
| 88 | + - add URC handler for +CGEV: ME PDN DEACT 1 or +CGEV: ME DETACH or +UUPSDD: 0 to wait for cellular disconnected |
83 | 89 | */ |
84 | 90 |
|
85 | 91 | #include "logging.h" |
@@ -337,13 +343,6 @@ int NcpFwUpdate::process() { |
337 | 343 | break; |
338 | 344 | } |
339 | 345 | LOG(INFO, "PLATFORM_NCP == SARA_R510"); |
340 | | - // Check system feature is enabled |
341 | | - if (!HAL_Feature_Get(FEATURE_NCP_FW_UPDATES)) { |
342 | | - LOG(ERROR, "FEATURE_NCP_FW_UPDATES disabled"); |
343 | | - ncpFwUpdateState_ = FW_UPDATE_IDLE_STATE; |
344 | | - break; |
345 | | - } |
346 | | - LOG(INFO, "FEATURE_NCP_FW_UPDATES enabled"); |
347 | 346 | // Check if System.updatesEnabled() |
348 | 347 | uint8_t updatesEnabled = 0; |
349 | 348 | ncpFwUpdateCallbacks_->system_get_flag(SYSTEM_FLAG_OTA_UPDATE_ENABLED, &updatesEnabled, nullptr); |
@@ -483,6 +482,7 @@ int NcpFwUpdate::process() { |
483 | 482 |
|
484 | 483 | case FW_UPDATE_DOWNLOAD_CELL_CONNECTING_STATE: |
485 | 484 | { |
| 485 | + // TODO: Add 10 minute timeout here |
486 | 486 | if (!network_ready(0, 0, 0)) { // Cellular.ready() |
487 | 487 | LOG(INFO, "Connecting Cellular..."); |
488 | 488 | cellular_start_ncp_firmware_update(true, nullptr); // ensure we don't connect PPP |
|
0 commit comments