Issue #18: Check error memory entries at safety ram init

This commit is contained in:
2020-09-05 17:37:56 +02:00
parent 77c88c69cd
commit ea26f56545
4 changed files with 44 additions and 5 deletions

View File

@@ -239,6 +239,35 @@ int safety_memory_set_boot_status(const struct safety_memory_boot_status *status
return 0;
}
static int safety_memory_check_error_entries()
{
struct safety_memory_header header;
uint32_t addr;
uint32_t data;
int ret = 0;
int res;
if (safety_memory_get_header(&header) != SAFETY_MEMORY_INIT_VALID_MEMORY) {
return -2000;
}
for (addr = header.err_memory_offset; addr < header.err_memory_end; addr++) {
res = backup_ram_get_data(addr, &data, 1UL);
if (res)
return -100;
/* Valid flag entry */
if ((data & 0xFF) == 0x51)
continue;
if (data == SAFETY_MEMORY_NOP_ENTRY)
continue;
ret--;
}
return ret;
}
int safety_memory_get_error_entry_count(uint32_t *count);
int safety_memory_check(void)
@@ -246,6 +275,10 @@ int safety_memory_check(void)
int res;
res = safety_memory_check_crc();
if (!res) {
res |= safety_memory_check_error_entries();
}
return -!!res;
}