Skip to content

Commit c960d0c

Browse files
committed
Removes System feature FEATURE_NCP_FW_UPDATES
1 parent 205acd7 commit c960d0c

File tree

8 files changed

+45
-139
lines changed

8 files changed

+45
-139
lines changed

hal/inc/core_hal.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,7 @@ typedef enum HAL_Feature {
223223
FEATURE_RESET_INFO, // [read/write] enables handling of last reset info (may affect backup registers)
224224
FEATURE_WIFI_POWERSAVE_CLOCK, // [write only] enables/disables the WiFi powersave clock on the TESTMODE pin. This setting is persisted to the DCT.
225225
FEATURE_ETHERNET_DETECTION, // [read/write] enables Ethernet FeatherWing detection on boot
226-
FEATURE_LED_OVERRIDDEN, // [read/write] override system RGB signaling on boot.
227-
FEATURE_NCP_FW_UPDATES, // [read/write] enables/disables NCP FW updates
226+
FEATURE_LED_OVERRIDDEN // [read/write] override system RGB signaling on boot.
228227
} HAL_Feature;
229228

230229
int HAL_Feature_Set(HAL_Feature feature, bool enabled);

hal/network/ncp_client/sara/sara_ncp_client.cpp

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ int SaraNcpClient::init(const NcpClientConfig& conf) {
181181
registeredTime_ = 0;
182182
memoryIssuePresent_ = true; // default to safe state until we determine modem firmware version
183183
oldFirmwarePresent_ = true; // default to safe state until we determine modem firmware version
184-
savedNVMR510_ = false; // R510: Save connection state to NVM for fast cold boot registration times
185184
parserError_ = 0;
186185
ready_ = false;
187186
firmwareUpdateR510_ = false;
@@ -745,9 +744,6 @@ int SaraNcpClient::getCellularGlobalIdentity(CellularGlobalIdentity* cgi) {
745744
} else {
746745
CHECK_PARSER_OK(parser_.execCommand("AT+CEREG?"));
747746
}
748-
// FIXME: CREG is not set to verbose mode for Cat-M1/Cat-1 devices, can we really
749-
// "fallback to CSD" here for gathering LAC and CID?
750-
CHECK_PARSER_OK(parser_.execCommand("AT+CREG?"));
751747

752748
switch (cgi->version)
753749
{
@@ -1145,7 +1141,7 @@ int SaraNcpClient::selectNetworkProf(ModemState& state) {
11451141
if (r == 1 && (static_cast<UbloxSaraUmnoprof>(curProf) == UbloxSaraUmnoprof::SW_DEFAULT ||
11461142
(netConf_.netProv() == CellularNetworkProvider::TWILIO && static_cast<UbloxSaraUmnoprof>(curProf) != UbloxSaraUmnoprof::STANDARD_EUROPE) ||
11471143
(conf_.ncpIdentifier() == PLATFORM_NCP_SARA_R410 && netConf_.netProv() == CellularNetworkProvider::KORE_ATT && static_cast<UbloxSaraUmnoprof>(curProf) != UbloxSaraUmnoprof::ATT) ||
1148-
(conf_.ncpIdentifier() == PLATFORM_NCP_SARA_R510 && netConf_.netProv() == CellularNetworkProvider::KORE_ATT && static_cast<UbloxSaraUmnoprof>(curProf) != UbloxSaraUmnoprof::STANDARD_EUROPE)) ) {
1144+
(conf_.ncpIdentifier() == PLATFORM_NCP_SARA_R510 && netConf_.netProv() == CellularNetworkProvider::KORE_ATT && static_cast<UbloxSaraUmnoprof>(curProf) != UbloxSaraUmnoprof::ATT)) ) {
11491145
int newProf = static_cast<int>(UbloxSaraUmnoprof::SIM_SELECT);
11501146
// TWILIO Super SIM
11511147
if (netConf_.netProv() == CellularNetworkProvider::TWILIO) {
@@ -1163,11 +1159,8 @@ int SaraNcpClient::selectNetworkProf(ModemState& state) {
11631159
}
11641160
// KORE AT&T or 3rd Party SIM
11651161
else {
1166-
if (conf_.ncpIdentifier() == PLATFORM_NCP_SARA_R510) {
1167-
newProf = static_cast<int>(UbloxSaraUmnoprof::STANDARD_EUROPE);
1168-
}
1169-
// Hard code ATT for 05.12 firmware versions
1170-
if (fwVersion_ == UBLOX_NCP_R4_APP_FW_VERSION_0512) {
1162+
// Hard code ATT for R410 05.12 firmware versions or R510 Kore AT&T SIMs
1163+
if (fwVersion_ == UBLOX_NCP_R4_APP_FW_VERSION_0512 || conf_.ncpIdentifier() == PLATFORM_NCP_SARA_R510) {
11711164
if (netConf_.netProv() == CellularNetworkProvider::KORE_ATT) {
11721165
newProf = static_cast<int>(UbloxSaraUmnoprof::ATT);
11731166
}
@@ -1198,11 +1191,10 @@ int SaraNcpClient::selectNetworkProf(ModemState& state) {
11981191
char ubandStr[24] = {};
11991192
auto retBand = CHECK_PARSER(respBand.scanf("+UBANDMASK: 0,%23[^,]", ubandStr));
12001193
CHECK_PARSER_OK(respBand.readResult());
1201-
if (retBand == 1 && ((netConf_.netProv() == CellularNetworkProvider::TWILIO) ||
1202-
(netConf_.netProv() == CellularNetworkProvider::KORE_ATT && conf_.ncpIdentifier() == PLATFORM_NCP_SARA_R510)) ) {
1194+
if (netConf_.netProv() == CellularNetworkProvider::TWILIO && retBand == 1) {
12031195
char* pEnd = &ubandStr[0];
12041196
ubandUint64 = strtoull(ubandStr, &pEnd, 10);
1205-
// Only update if not set to correct bands
1197+
// Only update if Twilio Super SIM and not set to correct bands
12061198
if (pEnd - ubandStr > 0 && ubandUint64 != 6170) {
12071199
// Enable Cat-M1 bands 2,4,5,12 (AT&T), 13 (VZW) = 6170
12081200
parser_.execCommand(UBLOX_UBANDMASK_TIMEOUT, "AT+UBANDMASK=0,6170");
@@ -2152,25 +2144,14 @@ void SaraNcpClient::resetRegistrationState() {
21522144
regCheckTime_ = regStartTime_;
21532145
imsiCheckTime_ = regStartTime_;
21542146
registrationInterventions_ = 0;
2155-
savedNVMR510_ = false;
21562147
}
21572148

2158-
int SaraNcpClient::checkRegistrationState() {
2149+
void SaraNcpClient::checkRegistrationState() {
21592150
if (connState_ != NcpConnectionState::DISCONNECTED) {
21602151
if ((csd_.registered() && psd_.registered()) || eps_.registered()) {
21612152
if (memoryIssuePresent_ && connState_ != NcpConnectionState::CONNECTED) {
21622153
registeredTime_ = millis(); // start registered timer for memory issue power off delays
21632154
}
2164-
// FIXME: Workaround for R510S NVM issue, avoid this step with updated firmware.
2165-
// Switch to airplane mode / full functionality to save connection details for fast cold connection times.
2166-
// This will skip setting the CONNECTED state and stay CONNECTING, since that's what will happen on the modem.
2167-
if (conf_.ncpIdentifier() == PLATFORM_NCP_SARA_R510 && !savedNVMR510_) {
2168-
// TODO: Completely remove CFUN=4/1 toggle after registration
2169-
// CHECK_PARSER(parser_.execCommand(UBLOX_CFUN_TIMEOUT, "AT+CFUN=4,0"));
2170-
// CHECK_PARSER(parser_.execCommand(UBLOX_CFUN_TIMEOUT, "AT+CFUN=1,0"));
2171-
savedNVMR510_ = true;
2172-
return SYSTEM_ERROR_NONE;
2173-
}
21742155
connectionState(NcpConnectionState::CONNECTED);
21752156
} else if (connState_ == NcpConnectionState::CONNECTED) {
21762157
// FIXME: potentially go back into connecting state only when getting into
@@ -2179,7 +2160,6 @@ int SaraNcpClient::checkRegistrationState() {
21792160
connectionState(NcpConnectionState::CONNECTING);
21802161
}
21812162
}
2182-
return SYSTEM_ERROR_NONE;
21832163
}
21842164

21852165
int SaraNcpClient::interveneRegistration() {

hal/network/ncp_client/sara/sara_ncp_client.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ class SaraNcpClient: public CellularNcpClient {
113113
unsigned int fwVersion_ = 0;
114114
bool memoryIssuePresent_;
115115
bool oldFirmwarePresent_;
116-
bool savedNVMR510_ = false;
117116
unsigned registrationTimeout_;
118117
unsigned registrationInterventions_;
119118
volatile bool inFlowControl_ = false;
@@ -146,7 +145,7 @@ class SaraNcpClient: public CellularNcpClient {
146145
void connectionState(NcpConnectionState state);
147146
void parserError(int error);
148147
void resetRegistrationState();
149-
int checkRegistrationState();
148+
void checkRegistrationState();
150149
int interveneRegistration();
151150
int checkRunningImsi();
152151
int processEventsImpl();

hal/src/nRF52840/core_hal.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -801,9 +801,6 @@ int HAL_Feature_Set(HAL_Feature feature, bool enabled) {
801801
case FEATURE_LED_OVERRIDDEN: {
802802
return Write_Feature_Flag(FEATURE_FLAG_LED_OVERRIDDEN, enabled, NULL);
803803
}
804-
case FEATURE_NCP_FW_UPDATES: {
805-
return Write_Feature_Flag(FEATURE_FLAG_NCP_FW_UPDATES, enabled, NULL);
806-
}
807804
}
808805

809806
return -1;
@@ -825,10 +822,6 @@ bool HAL_Feature_Get(HAL_Feature feature) {
825822
bool value = false;
826823
return (Read_Feature_Flag(FEATURE_FLAG_LED_OVERRIDDEN, &value) == 0) ? value : false;
827824
}
828-
case FEATURE_NCP_FW_UPDATES: {
829-
bool value = false;
830-
return (Read_Feature_Flag(FEATURE_FLAG_NCP_FW_UPDATES, &value) == 0) ? value : false;
831-
}
832825
}
833826
return false;
834827
}

modules/electron/system-part1/src/cellular_hal.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
#include "../src/electron/inet_hal_new.cpp"
99
#include "../src/electron/socket_hal.cpp"
1010
#include "../shared/cellular_sig_perc_mapping.cpp"
11-
#include "../src/electron/platform_ncp_electron.cpp"
11+
#include "../src/electron/platform_ncp_electron.cpp"

platform/MCU/nRF52840/inc/dct.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ PARTICLE_STATIC_ASSERT(static_ip_config_size, sizeof(static_ip_config_t)==24);
7272
typedef enum Feature_Flag {
7373
FEATURE_FLAG_RESET_INFO = 0x01,
7474
FEATURE_FLAG_ETHERNET_DETECTION = 0x02,
75-
FEATURE_FLAG_LED_OVERRIDDEN = 0x04,
76-
FEATURE_FLAG_NCP_FW_UPDATES = 0x08,
75+
FEATURE_FLAG_LED_OVERRIDDEN = 0x04
7776
} Feature_Flag;
7877

7978
/**

services/src/ncp_fw_update.cpp

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,41 @@
1616
*/
1717

1818
/*
19-
R510 Firmware Update:
19+
R510 Firmware Update Background Check:
2020
=====================
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.
2130
1. Check ncpId() == PLATFORM_NCP_SARA_R510
2231
2. Is System.enableUpdates() == true?
2332
3. Check modem firmware version - compatible upgrade version will be baked into Device OS with MD5 sum.
2433
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
3745
a. waiting for final INSTALL URC of 128
3846
b. polling for AT/OK every 10 seconds
3947
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
4654
4755
TODO:
4856
====================
@@ -52,7 +60,7 @@
5260
Done - Move ncp_fw_update.cpp to services/ instead of system/ since we have more space available there
5361
Done - Add correct cipher settings
5462
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
5664
Done - we do enter and exit safe mode fw updating cleanly
5765
Done - we do not get stuck in a fail-retry loop
5866
Done - Refactor retained structure to use systemCache instead
@@ -61,25 +69,23 @@
6169
Done - Gen 3, extends timer 5 minutes for every received URC.
6270
Done - When do we retry failures? Quick loops can retry a few times, but long ones shouldn't
6371
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
6572
Done - Make sure there is a final status log
6673
Done - Allow user firmware to pass a database entry that overrides the system firmware update database
6774
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
7176
Done - Remove callbacks
7277
Done - Remove Gen 2 code
7378
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
7782
Done - Remove System feature flag
7883
- implement background update check, only perform checks if modem is on.
7984
- ncp_fw_udpate_check should drive an update check, implement no argument as system check
8085
- implement Cellular.updatesPending() API
8186
- 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
8389
*/
8490

8591
#include "logging.h"
@@ -337,13 +343,6 @@ int NcpFwUpdate::process() {
337343
break;
338344
}
339345
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");
347346
// Check if System.updatesEnabled()
348347
uint8_t updatesEnabled = 0;
349348
ncpFwUpdateCallbacks_->system_get_flag(SYSTEM_FLAG_OTA_UPDATE_ENABLED, &updatesEnabled, nullptr);
@@ -483,6 +482,7 @@ int NcpFwUpdate::process() {
483482

484483
case FW_UPDATE_DOWNLOAD_CELL_CONNECTING_STATE:
485484
{
485+
// TODO: Add 10 minute timeout here
486486
if (!network_ready(0, 0, 0)) { // Cellular.ready()
487487
LOG(INFO, "Connecting Cellular...");
488488
cellular_start_ncp_firmware_update(true, nullptr); // ensure we don't connect PPP

services/src/ncp_fw_update_db.cpp

Lines changed: 0 additions & 64 deletions
This file was deleted.

0 commit comments

Comments
 (0)