mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2025-08-03 04:06:22 -04:00
Reset USB controller endpoints when starting
When starting, reset the USB controller to only enable the USB CDC endpoint and the internal command channel. If the app resets firmware, but had differend endpoints enabled, we want to go back to a known state.
This commit is contained in:
parent
daa7807c0f
commit
8965fea947
4 changed files with 15 additions and 7 deletions
|
@ -318,18 +318,22 @@ Firmware then proceeds to:
|
|||
|
||||
1. Read the partition table from flash and store in FW\_RAM.
|
||||
|
||||
2. Check the special resetinfo area in FW\_RAM for reset type. Type
|
||||
2. Reset the CH552 USB controller to a known state, only allowing the
|
||||
CDC USB endpoint and the internal command channel between the CPU
|
||||
and the CH552.
|
||||
|
||||
3. Check the special resetinfo area in FW\_RAM for reset type. Type
|
||||
zero means default behaviour, load from flash app slot 0, expecting
|
||||
the app there to have a specific hardcoded BLAKE2s digest.
|
||||
|
||||
3. Load app data from flash slot 0 into RAM.
|
||||
4. Load app data from flash slot 0 into RAM.
|
||||
|
||||
4. Compute a BLAKE2s digest of the loaded app.
|
||||
5. Compute a BLAKE2s digest of the loaded app.
|
||||
|
||||
5. Compare the computed digest against the allowed app digest
|
||||
6. Compare the computed digest against the allowed app digest
|
||||
hardcoded in the firmware. If it's not equal, halt CPU.
|
||||
|
||||
6. [Start the device app](#start-the-device-app).
|
||||
7. [Start the device app](#start-the-device-app).
|
||||
|
||||
### Start the device app
|
||||
|
||||
|
|
|
@ -525,6 +525,10 @@ int main(void)
|
|||
assert(1 == 2);
|
||||
}
|
||||
|
||||
// Reset the USB controller to only enable the USB CDC
|
||||
// endpoint and the internal command channel.
|
||||
config_endpoints(IO_CDC | IO_CH552);
|
||||
|
||||
led_set(LED_WHITE);
|
||||
|
||||
#if defined(SIMULATION)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue