Add TRNG to testfw, document

This commit is contained in:
Daniel Lublin 2022-09-30 15:41:16 +02:00
parent c52f7d52cd
commit 65f2272a45
No known key found for this signature in database
GPG key ID: 75BD0FEB8D3E7830
2 changed files with 20 additions and 5 deletions

View file

@ -21,6 +21,8 @@ volatile uint32_t *timer = (volatile uint32_t *)MTA1_MKDF_MMIO_TIMER_T
volatile uint32_t *timer_prescaler = (volatile uint32_t *)MTA1_MKDF_MMIO_TIMER_PRESCALER;
volatile uint32_t *timer_status = (volatile uint32_t *)MTA1_MKDF_MMIO_TIMER_STATUS;
volatile uint32_t *timer_ctrl = (volatile uint32_t *)MTA1_MKDF_MMIO_TIMER_CTRL;
volatile uint32_t *trng_status = (volatile uint32_t *)MTA1_MKDF_MMIO_TRNG_STATUS;
volatile uint32_t *trng_entropy = (volatile uint32_t *)MTA1_MKDF_MMIO_TRNG_ENTROPY;
// clang-format on
// TODO Real UDA is 4 words (16 bytes)
@ -232,6 +234,21 @@ int main()
test_puts("All tests passed.\r\n");
}
test_puts("\r\nHere are 256 bytes from the TRNG:\r\n");
for (int j = 0; j < 8; j++) {
for (int i = 0; i < 8; i++) {
while ((*trng_status &
(1 << MTA1_MKDF_MMIO_TRNG_STATUS_READY_BIT)) ==
0) {
}
uint32_t rnd = *trng_entropy;
test_puthexn((uint8_t *)&rnd, 4);
test_puts(" ");
}
test_puts("\r\n");
}
test_puts("\r\n");
test_puts("Now echoing what you type...\r\n");
for (;;) {
in = readbyte(); // blocks