mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2025-05-09 01:15:02 -04:00
fw: Add ERASE_DATA syscall
Erase one or more flash sectors in app storage areas
This commit is contained in:
parent
a9d3dd7242
commit
9c1bb53d7a
2 changed files with 31 additions and 1 deletions
|
@ -145,7 +145,7 @@ int main(void)
|
|||
}
|
||||
puts(IO_CDC, "done.\r\n");
|
||||
|
||||
puts(IO_CDC, "\r\nReading from storage area...");
|
||||
puts(IO_CDC, "\r\nReading data from storage area...");
|
||||
|
||||
uint8_t in_data[14] = {0};
|
||||
if (syscall(TK1_SYSCALL_READ_DATA, 0, (uint32_t)in_data,
|
||||
|
@ -158,6 +158,28 @@ int main(void)
|
|||
}
|
||||
puts(IO_CDC, "done.\r\n");
|
||||
|
||||
puts(IO_CDC, "\r\nErasing written data from storage area...");
|
||||
|
||||
if (syscall(TK1_SYSCALL_ERASE_DATA, 0, 4096, 0) != 0) {
|
||||
failmsg("Failed to erase storage area");
|
||||
}
|
||||
puts(IO_CDC, "done.\r\n");
|
||||
|
||||
puts(IO_CDC, "\r\nVerify erased storage area data...");
|
||||
|
||||
if (syscall(TK1_SYSCALL_READ_DATA, 0, (uint32_t)in_data,
|
||||
sizeof(in_data)) != 0) {
|
||||
failmsg("Failed to write to storage area");
|
||||
}
|
||||
uint8_t check_data[sizeof(in_data)] = {0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff};
|
||||
if (!memeq(in_data, check_data, sizeof(check_data))) {
|
||||
failmsg("Failed to read back data from storage area");
|
||||
anyfailed = 1;
|
||||
}
|
||||
puts(IO_CDC, "done.\r\n");
|
||||
|
||||
puts(IO_CDC, "\r\nDeallocating storage area...");
|
||||
|
||||
if (syscall(TK1_SYSCALL_DEALLOC_AREA, 0, 0, 0) != 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue