mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2024-12-18 04:14:25 -05:00
Clarify switch_app reads and writes; add read test to testfw
This commit is contained in:
parent
4b4f014d38
commit
85ef93cd3c
@ -165,9 +165,9 @@ Procedure:
|
||||
|
||||
1. The host sends `FW_CMD_RUN_APP` to the device.
|
||||
2. The firmware responds with `FW_RSP_RUN_APP`
|
||||
3. The firmware writes a non-zero to `SWITCH_APP`, and executes
|
||||
assembler code that writes zeros to stack and data of the
|
||||
firmware, then jumps to what's in APP_ADDR.
|
||||
3. The firmware writes to `SWITCH_APP`, and executes assembler code
|
||||
that writes zeros to stack and data of the firmware, then jumps
|
||||
to what's in APP_ADDR.
|
||||
4. The device is now in application mode and is executing the
|
||||
application.
|
||||
|
||||
@ -324,15 +324,15 @@ Assigned core prefixes:
|
||||
*Nota bene*: MMIO accesses should be 32 bit wide, e.g use `lw` and
|
||||
`sw`. Exceptions are `FW_RAM` and `QEMU_DEBUG`.
|
||||
|
||||
| *name* | *fw* | *app | *size* | *type* | *content* | *description* |
|
||||
|-------------------|-------|------------|--------|----------|-----------|-----------------------------------------------------------------------|
|
||||
| *name* | *fw* | *app* | *size* | *type* | *content* | *description* |
|
||||
|-------------------|-------|-----------|--------|----------|-----------|------------------------------------------------------------------------|
|
||||
| `TRNG_STATUS` | r | r | | | | TRNG_STATUS_READY_BIT is 1 when an entropy word is available. |
|
||||
| `TRNG_ENTROPY` | r | r | 4B | u32 | | Entropy word. Reading a word will clear status. |
|
||||
| `TIMER_CTRL` | r/w | r/w | | | | If TIMER_STATUS_READY_BIT in TIMER_STATUS is 1 then writing here |
|
||||
| `TIMER_CTRL` | r/w | r/w | | | | If TIMER_STATUS_READY_BIT in TIMER_STATUS is 1, writing anything here |
|
||||
| | | | | | | starts the timer. If the same bit is 0 then writing stops the timer. |
|
||||
| `TIMER_STATUS` | r | r | | | | TIMER_STATUS_READY_BIT is 1 when timer is ready to start running. |
|
||||
| `TIMER_PRESCALER` | r/w | r/w | 4B | | | Prescaler init value. Write blocked when running. |
|
||||
| `TIMER_TIMER` | r/w | r/w | 4B | | | Timer init or current value while running. Write blocked when running.|
|
||||
| `TIMER_TIMER` | r/w | r/w | 4B | | | Timer init or current value while running. Write blocked when running. |
|
||||
| `UDS_FIRST` | r[^3] | invisible | 4B | u8[32] | | First word of Unique Device Secret key. |
|
||||
| `UDS_LAST` | | invisible | | | | The last word of the UDS |
|
||||
| `UART_BITRATE` | r/w | | | | | TBD |
|
||||
@ -351,7 +351,8 @@ Assigned core prefixes:
|
||||
| `NAME0` | r | r | 4B | char[4] | "tk1 " | ID of core/stick |
|
||||
| `NAME1` | r | r | 4B | char[4] | "mkdf" | ID of core/stick |
|
||||
| `VERSION` | r | r | 4B | u32 | 1 | Current version. |
|
||||
| `SWITCH_APP` | w | invisible? | 1B | u8 | | Switch to application mode. Write non-zero to trigger. |
|
||||
| `SWITCH_APP` | r/w | r | 1B | u8 | | Write anything here to trigger the switch to application mode. Reading |
|
||||
| | | | | | | returns 0 if device is in firmware mode, 0xffffffff if in app mode. |
|
||||
| `LED` | w | w | 1B | u8 | | |
|
||||
| `GPIO` | | | | | | |
|
||||
| `APP_ADDR` | r/w | r | 4B | u32 | | Application address (0x4000_0000) |
|
||||
|
@ -151,10 +151,22 @@ int main()
|
||||
anyfailed = 1;
|
||||
}
|
||||
|
||||
uint32_t sw = *switch_app;
|
||||
if (sw != 0) {
|
||||
test_puts("FAIL: switch_app is not 0 in fw mode\r\n");
|
||||
anyfailed = 1;
|
||||
}
|
||||
|
||||
// Turn on application mode.
|
||||
// -------------------------
|
||||
*switch_app = 1;
|
||||
|
||||
sw = *switch_app;
|
||||
if (sw != 0xffffffff) {
|
||||
test_puts("FAIL: switch_app is not 0xffffffff in app mode\r\n");
|
||||
anyfailed = 1;
|
||||
}
|
||||
|
||||
// Should NOT be able to read from UDS in app-mode.
|
||||
wordcpy(uds_local, (void *)uds, 8);
|
||||
if (!memeq(uds_local, uds_zeros, 8 * 4)) {
|
||||
|
Loading…
Reference in New Issue
Block a user