Fixed logs corruption and app reset on FDS write, added logs flush on sleep

Bug when NRF_LOG_DEFERRED=0
due to a userland NRF_LOG_INFO after FDS record update was initiated, interrupted by FDS record IRQ handler and its own NRF_LOG_INFO
resulting in
<error> app: Fatal error
<warning> app: System reset

Added a few more NRF_LOG in FDS module as well.
Added NRF_LOG_FLUSH in system_off_enter to not miss last messages.
This commit is contained in:
Philippe Teuwen
2023-08-25 13:15:43 +02:00
parent 727cd5e6fa
commit ef46b22d69
3 changed files with 21 additions and 8 deletions
+1
View File
@@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
## [unreleased][unreleased]
- Fixed logs corruption and app reset on FDS write, added logs flush on sleep (@doegox)
- Added support for long-press of buttons (@nemanjan00)
- Changed `hw slot delete`, now it can always delete from slot. (@augustozanellato)
- Refactor CI pipeline. (@augustozanellato)
+3
View File
@@ -351,6 +351,9 @@ static void system_off_enter(void) {
return;
};
// Last call, gate is closing
NRF_LOG_FLUSH();
// Go to system-off mode (this function will not return; wakeup will cause a reset).
// Note that if you insert jlink or drive a Debug, you may report an error when entering the low power consumption.
// When starting debugging, we should disable low power consumption state values, or simply not enter low power consumption
+17 -8
View File
@@ -84,16 +84,18 @@ static ret_code_t fds_write_record_nogc(uint16_t id, uint16_t key, uint16_t data
};
if (fds_find_record(id, key, &record_desc)) { // Find a record with specified characteristics
//If you can find this record, we can perform the update operation
NRF_LOG_INFO("Search FileID: 0x%04x, FileKey: 0x%04x is found, will update.", id, key);
err_code = fds_record_update(&record_desc, &record);
if (err_code == NRF_SUCCESS) {
NRF_LOG_INFO("Search FileID: 0x%04x, FileKey: 0x%04x is found, will update.", id, key);
}
if (err_code != NRF_SUCCESS) {
NRF_LOG_INFO("Record update request failed!");
} // Don't NRF_LOG if request succeeded, it would be interrupted by NRF_LOG in record handler
} else {
// Unable to find effective records, we will write for the first time
NRF_LOG_INFO("Search FileID: 0x%04x, FileKey: 0x%04x no found, will create.", id, key);
err_code = fds_record_write(&record_desc, &record);
if (err_code == NRF_SUCCESS) {
NRF_LOG_INFO("Search FileID: 0x%04x, FileKey: 0x%04x no found, will create.", id, key);
}
if (err_code != NRF_SUCCESS) {
NRF_LOG_INFO("Record creation request failed!");
} // Don't NRF_LOG if request succeeded, it would be interrupted by NRF_LOG in record handler
}
return err_code;
}
@@ -179,6 +181,7 @@ static void fds_evt_handler(fds_evt_t const *p_evt) {
if (p_evt->result == NRF_SUCCESS) {
NRF_LOG_INFO("NRF52 FDS libraries init success.");
} else {
NRF_LOG_INFO("NRF52 FDS libraries init failed");
APP_ERROR_CHECK(p_evt->result);
}
}
@@ -189,9 +192,11 @@ static void fds_evt_handler(fds_evt_t const *p_evt) {
NRF_LOG_INFO("Record change: FileID 0x%04x, RecordKey 0x%04x", p_evt->write.file_id, p_evt->write.record_key);
if (p_evt->write.file_id == fds_operation_info.id && p_evt->write.record_key == fds_operation_info.key) {
// The logic above has ensured that the task we are currently writing is completed!
NRF_LOG_INFO("Record change success");
fds_operation_info.success = true;
}
} else NRF_LOG_INFO("Record change mismatch");
} else {
NRF_LOG_INFO("Record change failed");
APP_ERROR_CHECK(p_evt->result);
}
}
@@ -205,17 +210,21 @@ static void fds_evt_handler(fds_evt_t const *p_evt) {
if (p_evt->del.record_id == fds_operation_info.record_id) {
// Only check record id because fileID and recordKey aren't available
// if deleting via fds_record_iterate. record id is guaranteed to be unique.
NRF_LOG_INFO("Record delete success");
fds_operation_info.success = true;
}
} else NRF_LOG_INFO("Record delete mismatch");
} else {
NRF_LOG_INFO("Record delete failed");
APP_ERROR_CHECK(p_evt->result);
}
}
break;
case FDS_EVT_GC: {
if (p_evt->result == NRF_SUCCESS) {
NRF_LOG_INFO("FDS gc success");
fds_operation_info.success = true;
} else {
NRF_LOG_INFO("FDS gc failed");
APP_ERROR_CHECK(p_evt->result);
}
}