Skip to content

Commit

Permalink
Create SD card test
Browse files Browse the repository at this point in the history
SD card test checks for the presence of a microSD card in the
slot, reads and reports the card properties and then proceeds
to check the contents of a test file `LOREM.IPS` in the root
directory of a FAT32-formatted card against its internal
reference.

See the source for directions on how to set up a microSD card
with a suitable file; set 'emitText' to true on the first run
and it will emit the sample text with instructions.

Support for Long FileNames.
  • Loading branch information
alees24 committed Nov 29, 2024
1 parent b5305cd commit 90b98b6
Show file tree
Hide file tree
Showing 5 changed files with 1,260 additions and 1 deletion.
15 changes: 14 additions & 1 deletion sw/cheri/common/console.hh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ using Log = reisfmt::Fmt<WriteUart>;
}

// Dump out a sequence of bytes as hexadecimal and ASCII text.
[[maybe_unused]] static void dump_bytes(Log& log, const uint8_t *buf, size_t blkBytes) {
[[maybe_unused]] static void dump_bytes(Log& log, const uint8_t* buf, size_t blkBytes) {
for (size_t off = 0u; off < blkBytes; ++off) {
log.print("{:02x}", buf[off]);
if ((off & 0xfu) == 0xfu) {
Expand All @@ -59,3 +59,16 @@ using Log = reisfmt::Fmt<WriteUart>;
}
}
}

// Emit the UCS-2 long filename in a readable form; we cannot do this properly; we're just
// handling ASCII in practice.
[[maybe_unused]] static void write_str_ucs2(Log& log, const uint16_t* ucs, size_t ucs_max = ~0u) {
size_t idx = 0u;
char str[2];
str[1] = '\0';
while (idx < ucs_max && ucs[idx]) {
str[0] = (ucs[idx] >= 0x20u && ucs[idx] < 0x80u) ? ucs[idx] : '.';
log.print(str);
idx++;
}
}
Loading

0 comments on commit 90b98b6

Please sign in to comment.