mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2024-12-18 12:24:31 -05:00
Add TRNG to testfw, document
This commit is contained in:
parent
c52f7d52cd
commit
65f2272a45
@ -160,8 +160,6 @@ Available commands/reponses:
|
|||||||
#### `FW_{CMD,RSP}_RUN_APP`
|
#### `FW_{CMD,RSP}_RUN_APP`
|
||||||
#### `FW_{CMD,RSP}_NAME_VERSION`
|
#### `FW_{CMD,RSP}_NAME_VERSION`
|
||||||
#### `FW_{CMD,RSP}_UID`
|
#### `FW_{CMD,RSP}_UID`
|
||||||
#### `FW_{CMD,RSP}_TRNG_DATA`
|
|
||||||
#### `FW_{CMD,RSP}_TRNG_STATUS`
|
|
||||||
|
|
||||||
#### `FW_{CMD,RSP}_VERIFY_DEVICE`
|
#### `FW_{CMD,RSP}_VERIFY_DEVICE`
|
||||||
|
|
||||||
@ -308,8 +306,8 @@ Assigned core prefixes:
|
|||||||
|
|
||||||
| *name* | *fw* | *app | *size* | *type* | *content* | *description* |
|
| *name* | *fw* | *app | *size* | *type* | *content* | *description* |
|
||||||
|--------------------|------|------------|--------|---------|-----------|-----------------------------------------------------------------------|
|
|--------------------|------|------------|--------|---------|-----------|-----------------------------------------------------------------------|
|
||||||
| `TRNG_STATUS` | r | r | | | | Non-zero when an entropy word is available. |
|
| `TRNG_STATUS` | r | r | | | | STATUS_READY_BIT is set when an entropy word is available. |
|
||||||
| `TRNG_ENTROPY` | r | r | 4B | | | Entropy word. Reading a word will clear status. |
|
| `TRNG_ENTROPY` | r | r | 4B | u32 | | Entropy word. Reading a word will clear status. |
|
||||||
| `TIMER_CTRL` | r/w | r/w | | | | If bit 0 in TIMER_STATUS is set then writing here starts the timer. |
|
| `TIMER_CTRL` | r/w | r/w | | | | If bit 0 in TIMER_STATUS is set then writing here starts the timer. |
|
||||||
| | | | | | | If bit 0 in TIMER_STATUS is unset then writing here stops the timer. |
|
| | | | | | | If bit 0 in TIMER_STATUS is unset then writing here stops the timer. |
|
||||||
| `TIMER_STATUS` | r | r | | | | If bit 0 is set, the timer is ready to start running. |
|
| `TIMER_STATUS` | r | r | | | | If bit 0 is set, the timer is ready to start running. |
|
||||||
@ -324,7 +322,7 @@ Assigned core prefixes:
|
|||||||
| `UART_RX_DATA` | r | r | 1B | u8 | | Data to read. Only LSB contains data |
|
| `UART_RX_DATA` | r | r | 1B | u8 | | Data to read. Only LSB contains data |
|
||||||
| `UART_TX_STATUS` | r | r | 1B | u8 | | Non-zero when it's OK to write data |
|
| `UART_TX_STATUS` | r | r | 1B | u8 | | Non-zero when it's OK to write data |
|
||||||
| `UART_TX_DATA` | w | w | 1B | u8 | | Data to send. Only LSB contains data |
|
| `UART_TX_DATA` | w | w | 1B | u8 | | Data to send. Only LSB contains data |
|
||||||
| `TOUCH_STATUS` | r/w | r/w | | | | STATUS_EVENT_BIT set 1 when touched; write to it after |
|
| `TOUCH_STATUS` | r/w | r/w | | | | STATUS_EVENT_BIT is set when touched; write to it after |
|
||||||
| `UDA` | r | | 16B | u8[16] | | Unique Device Authentication key. |
|
| `UDA` | r | | 16B | u8[16] | | Unique Device Authentication key. |
|
||||||
| `UDI` | r | | 8B | u64 | | Unique Device ID (UDI). |
|
| `UDI` | r | | 8B | u64 | | Unique Device ID (UDI). |
|
||||||
| `QEMU_DEBUG` | w | w | | u8 | | Debug console (only in QEMU) |
|
| `QEMU_DEBUG` | w | w | | u8 | | Debug console (only in QEMU) |
|
||||||
|
@ -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_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_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 *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
|
// clang-format on
|
||||||
|
|
||||||
// TODO Real UDA is 4 words (16 bytes)
|
// TODO Real UDA is 4 words (16 bytes)
|
||||||
@ -232,6 +234,21 @@ int main()
|
|||||||
test_puts("All tests passed.\r\n");
|
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");
|
test_puts("Now echoing what you type...\r\n");
|
||||||
for (;;) {
|
for (;;) {
|
||||||
in = readbyte(); // blocks
|
in = readbyte(); // blocks
|
||||||
|
Loading…
Reference in New Issue
Block a user