device-os
device-os copied to clipboard
[boron|bsom] u-blox R510 FOTA over HTTPS support
Feature
- u-blox R510 FOTA over HTTPS upgrade support for Gen 3 Boron & B SoM
Details
- This branch is based on
develop-4.xand reverts the commits which removes FOTA support
R510 FOTA Process
R510 Firmware Update Background Check:
- Baked into sara_ncp_client.cpp init process
- When ATI9 is used to determine the modem version (thus, only when modem is on), check if there is an update firmware version available.
- Set updateAvailable flag appropriately for Cellular.updateStatus() if update unknown/not-available/pending/in-progress.
R510 Firmware Update
- (Blocking Call) Once Cellular.enableUpdates() is called, initialize state_/status_ from Idle to Qualify.
- Check ncpId() == PLATFORM_NCP_SARA_R510
- Check updateAvailable == in-progress
- Reboot into Safe Mode to start the update process
- Particle.connect()
- Publish a "spark/device/ncp/update" system event that Device OS has "started" a modem update.
- Particle.disconnect()
- Disable PPP link and Cellular.connect(), timeout after 10 minutes
- Setup HTTPS security options
- If an existing FOAT file is present, delete it since there is no way to validate what it is after it's present.
- Start the download based our database entry
- Download is only complete when the the MD5SUM URC of the file is received and verified
- Cellular.disconnect()
- Apply the firmware update
- Sit in a tight loop while the modem is updating, it will take about 18 to 20 minutes a. waiting for final INSTALL URC of 128 b. polling for AT/OK every 10 seconds c. monitoring a timeout counter of 40 minutes
- Save the download/install result to be published once connected to the Cloud again
- Re-enable PPP link and Power off the modem
- Particle.connect()
- Publish a "spark/device/ncp/update" system event that Device OS has finished with "success" or "failed"
- Reset the system to exit Safe Mode
- On next init, add result status to device diagnostics
Testing
- Modem must be on 3.15 firmware with hardware (SARA-R510S-01B-00)
- Use the DIFF below to enable logging during Safe Mode
- Run the example app below, and use 3 button clicks to kick off an update to 3.30
- There is also special Dioptra test firmware that has been running for over a week continuously upgrading and downgrading
- For B SoM EVT3 hardware and testing, it is necessary to use in external SIM with the jumper open
- Run tinker-serial1-debugging and switch between Kore AT&T and EtherSIM
- Try cold boot and warm boot, modem should register quickly with 3.15.
- Run normal Dioptra tests
diff --git a/system/src/main.cpp b/system/src/main.cpp
// UNCOMMENT TO DEBUG SAFE MODE
-// #include "debug_output_handler.h"
-// spark::Serial1LogHandler g_logHandlerSerial1(115200, LOG_LEVEL_ALL);
+#include "debug_output_handler.h"
+spark::Serial1LogHandler g_logHandlerSerial1(115200, LOG_LEVEL_ALL);
Example App
#define PARTICLE_USE_UNSTABLE_API
#include "Particle.h"
#include "log_diagnostics.h"
#include "ncp_fw_update_dynalib.h"
Serial1LogHandler logHandler(115200, LOG_LEVEL_ALL);
SYSTEM_MODE(SEMI_AUTOMATIC);
SYSTEM_THREAD(ENABLED);
bool clicks_3 = false;
bool clicks_4 = false;
const SaraNcpFwUpdateConfig saraNcpFwUpdateData1 = {
sizeof(SaraNcpFwUpdateConfig),
31500010,
33000010,
"SARA-R510S-01B-00-IP-0315A0001_SARA-R510S-01B-01-IP-0330A0001.upd",
"d5813d5d36e1400f70e3862362fe98f7"
};
void button_handler(system_event_t event, int clicks)
{
if (event == button_final_click) {
if (clicks == 3) {
clicks_3 = true;
} else if (clicks == 4) {
clicks_4 = true;
}
}
}
void setup() {
System.on(button_final_click, button_handler);
}
void loop() {
if (clicks_3 || clicks_4) {
Log.info("\r\nUpdate Status: %d", Cellular.updateStatus());
if (clicks_3) {
ncp_fw_udpate_config(&ncpFwUpdateData1, nullptr);
} else if (clicks_4) {
Log.info("\r\n\r\nLog Diagnostics\r\n\r\n");
cellular::DVT::logDiagnostics();
Particle.publishVitals();
}
Log.info("\r\nUpdate Status: %d", Cellular.updateStatus());
if (Cellular.updateStatus() == SYSTEM_NCP_FW_UPDATE_STATUS_PENDING) {
Log.info("Enable Updates: %d", Cellular.enableUpdates());
}
clicks_3 = false;
clicks_4 = false;
}
}
References
For the moment I have reverted renaming the files to make viewing changes easier. This is a TODO for me to go back and rename ncp_fw_update.cpp/.h to sara_ncp_fw_update.cpp/.h