-
Notifications
You must be signed in to change notification settings - Fork 511
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
[msom] Support burnin tests #2704
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 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 |
---|---|---|
|
@@ -55,6 +55,10 @@ BurninTest::BurninTest() { | |
&particle::BurninTest::testSram, | ||
&particle::BurninTest::testSpiFlash, | ||
&particle::BurninTest::testCpuLoad, | ||
#if PLATFORM_ID == PLATFORM_MSOM | ||
&particle::BurninTest::testCellularModem, | ||
&particle::BurninTest::testGnss, | ||
#endif | ||
}; | ||
|
||
test_names_ = { | ||
|
@@ -63,7 +67,11 @@ BurninTest::BurninTest() { | |
"BLE_SCAN", | ||
"SRAM", | ||
"SPI_FLASH", | ||
"CPU_LOAD" | ||
"CPU_LOAD", | ||
#if PLATFORM_ID == PLATFORM_MSOM | ||
"CELL_MODEM", | ||
"GNSS" | ||
#endif | ||
}; | ||
} | ||
|
||
|
@@ -77,7 +85,7 @@ BurninTest* BurninTest::instance() { | |
|
||
void BurninTest::setup(bool forceEnable) { | ||
if (!forceEnable) { | ||
hal_pin_t trigger_pin = D7; // PA27 aka SWD | ||
hal_pin_t trigger_pin = SWD_DAT; // PA27 P2: D7 MSOM: D27 | ||
// Read the trigger pin for a 1khz pulse. If present, enter burnin mode. | ||
pinMode(trigger_pin, INPUT); | ||
uint32_t pulse_width_micros = pulseIn(trigger_pin, HIGH); | ||
|
@@ -94,7 +102,13 @@ void BurninTest::setup(bool forceEnable) { | |
} | ||
} | ||
|
||
logger_ = std::make_unique<Serial1LogHandler>(115200, LOG_LEVEL_INFO); | ||
Particle.disconnect(); | ||
|
||
LogCategoryFilters burninFilters = { | ||
{ "ncp.at", LOG_LEVEL_TRACE }, | ||
{ "app", LOG_LEVEL_INFO } | ||
}; | ||
logger_ = std::make_unique<Serial1LogHandler>(115200, LOG_LEVEL_INFO, burninFilters); | ||
|
||
// Detect if backup SRAM has a failed test in it (IE state is "TEST FAILED") | ||
Log.info("BURN IN START: ResetReason: %d State: %d ErrorMessage: %s", System.resetReason(), (int)BurninState, BurninErrorMessage); | ||
|
@@ -459,5 +473,147 @@ bool BurninTest::testCpuLoad() { | |
return true; | ||
} | ||
|
||
#if PLATFORM_ID == PLATFORM_MSOM | ||
|
||
static bool turnModemOn() { | ||
Cellular.on(); | ||
waitFor(Cellular.isOn, 30000); | ||
|
||
if (!Cellular.isOn()) { | ||
strcpy(BurninErrorMessage, "Cell modem failed to turn on after 30s"); | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
bool BurninTest::testCellularModem() { | ||
if (!turnModemOn()) { | ||
return false; | ||
} | ||
|
||
CellularDevice device = {}; | ||
device.size = sizeof(device); | ||
if (cellular_device_info(&device, NULL)) { | ||
strcpy(BurninErrorMessage, "Failed to get cellular info"); | ||
return false; | ||
} | ||
|
||
Log.info("Cell modem ICCID: %s IMEI: %s FW: %s", device.iccid, device.imei, device.radiofw); | ||
|
||
Cellular.off(); | ||
waitFor(Cellular.isOff, 30000); | ||
return true; | ||
} | ||
|
||
static int callbackGPSGGA(int type, const char* buf, int len, bool* gnssLocked) { | ||
// EXAMPLE: | ||
// $<TalkerID>GGA,<UTC>,<Lat>,<N/S>,<Lon>,<E/W>,<Quality>,<NumSatUsed>,<HDOP>,<Alt>,M,<Sep>,M,<DiffAge>,<DiffStation>*<Checksum><CR><LF> | ||
// +QGPSGNMEA: $GPGGA,213918.00,3804.405282,N,12209.922544,W,1,05,3.0,145.9,M,-26.4,M,,*5E | ||
|
||
//Log.info("%s", buf); | ||
|
||
*gnssLocked = false; | ||
|
||
const int MAX_GPGGA_STR_LEN = 256; | ||
char gpggaSentence[MAX_GPGGA_STR_LEN] = {}; | ||
scott-brust marked this conversation as resolved.
Show resolved
Hide resolved
|
||
strlcpy(gpggaSentence, buf, MAX_GPGGA_STR_LEN); | ||
|
||
String lattitudeLongitude("LAT/LONG:"); | ||
int numberSattelites = 0; | ||
|
||
const char * delimiters = ","; | ||
char * token = strtok(gpggaSentence, delimiters); | ||
int i = 1; | ||
while (token) { | ||
//Log.trace("%d %s", i, token); | ||
token = strtok(NULL, delimiters); | ||
i++; | ||
|
||
switch (i) { | ||
case 3: // Lattitude or checksum if no lock and field is empty | ||
if (strlen(token) > 5) { | ||
lattitudeLongitude.concat(" "); | ||
lattitudeLongitude.concat(token); | ||
} | ||
break; | ||
case 4: // N/S | ||
case 5: // Longitude | ||
case 6: // E/W | ||
lattitudeLongitude.concat(" "); | ||
lattitudeLongitude.concat(token); | ||
break; | ||
case 8: // Number satellites | ||
numberSattelites = (int)String(token).toInt(); | ||
if (numberSattelites > 0) { | ||
*gnssLocked = true; | ||
Log.info("%s Satellites: %d", lattitudeLongitude.c_str(), numberSattelites); | ||
} | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
return 1; | ||
} | ||
|
||
bool BurninTest::testGnss() { | ||
// Turn on GNSS + Modem | ||
pinMode(GNSS_ANT_PWR, OUTPUT); | ||
digitalWrite(GNSS_ANT_PWR, HIGH); | ||
|
||
if (!turnModemOn()) { | ||
return false; | ||
} | ||
|
||
// Enable GNSS. It can take some time after the modem AT interface comes up for the GNSS engine to start | ||
const int RETRIES = 10; | ||
int r = 0; | ||
for (int i = 0; i < RETRIES && r != RESP_OK; i++) { | ||
r = Cellular.command("AT+QGPS=1\r\n"); | ||
delay(1000); | ||
} | ||
|
||
if (r != RESP_OK) { | ||
strcpy(BurninErrorMessage, "AT+QGPS=1 failed, GNSS not enabled"); | ||
return false; | ||
} | ||
|
||
// Configure antenna for GNSS priority | ||
for (int i = 0; i < RETRIES && r != RESP_OK; i++) { | ||
r = Cellular.command("AT+QGPSCFG=\"priority\",0"); | ||
delay(1000); | ||
} | ||
|
||
if (r != RESP_OK) { | ||
strcpy(BurninErrorMessage, "AT+QGPSCFG=\"priority\",0 failed, GNSS not prioritized"); | ||
return false; | ||
} | ||
|
||
// Poll NMEA GGA sentence | ||
// Parse for satellite lock bit, parse rough lat/long + print it | ||
bool gnssLocked = false; | ||
const int GNSS_POLL_TIMEOUT_MS = 90000; | ||
auto timeout = millis() + GNSS_POLL_TIMEOUT_MS; | ||
while (millis() < timeout && !gnssLocked) { | ||
Cellular.command(callbackGPSGGA, &gnssLocked, 1000, "AT+QGPSGNMEA=\"GGA\""); | ||
Log.info("gnssLocked %d", gnssLocked); | ||
delay(1000); | ||
} | ||
|
||
// If no lock in X minutes, fail | ||
if (!gnssLocked) { | ||
strcpy(BurninErrorMessage, "No GNSS lock after 90s"); | ||
} | ||
|
||
// Turn off Cell modem + GNSS antenna | ||
digitalWrite(GNSS_ANT_PWR, LOW); | ||
Cellular.off(); | ||
waitFor(Cellular.isOff, 30000); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
return gnssLocked; | ||
} | ||
|
||
#endif | ||
|
||
} // particle | ||
#endif // HAL_PLATFORM_RTL872X |
This file contains 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 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
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.
Do we want to check if it turns off? Maybe add
turnModemOff()
? It could also not explicitly fail the test withfalse
if it doesn't turn off.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.
Its not required that the modem be off for the test to be considered successful. This is just an attempt to maintain state after the test is complete. If the modem fails to power on for subsequent cell/gnss tests, that is a legitimate failure though.