|
| 1 | +# AXI driven Caliptra recovery flow |
| 2 | + |
| 3 | +This chapter discusses the implementation of AXI based recovery flow, which is an alternative to the standard I3C based flow (see {doc}`recovery_flow`). |
| 4 | +This feature allows driving the recovery data from within the SoC integrating the I3C core over the AXI bus, bypassing I3C communication. |
| 5 | + |
| 6 | +## AXI Recovery flow implementation |
| 7 | + |
| 8 | +The AXI recovery flow reuses the logic already present in the I3C core used in the Caliptra-SS design, with a runtime option essentially bypassing most of the I3C core communication logic (including the I3C recovery flow logic). |
| 9 | + |
| 10 | +The loopback functionality is configurable via a CSR, with the I3C mode set as the default. |
| 11 | + |
| 12 | +Recovery CSRs are accessible from the internal AXI bus. |
| 13 | +The transactions to the core may be filtered using the AXI ID field (see {doc}`axi_id_filtering`) |
| 14 | + |
| 15 | +The logic is implemented so that the recovery firmware in the Caliptra RoT ROM can operate without any changes. |
| 16 | + |
| 17 | +### AXI-based recovery procedure |
| 18 | + |
| 19 | +The Caliptra MCU RISC-V core is responsible for driving the data copied from an external memory (e.g. QSPI interface) to the recovery FIFOs. |
| 20 | +The ROM running on the MCU core monitors the recovery block registers and performs the recovery flow. |
| 21 | +During the boot procedure the ROM will have to follow the following procedure: |
| 22 | + |
| 23 | +1. Set the I3C block to the "direct AXI" mode |
| 24 | +2. Poll the `DEVICE_STATUS` register and wait for the recovery to be enabled by the Caliptra core |
| 25 | +3. Read the `RECOVERY_STATUS` register and check if the recovery flow started |
| 26 | +4. Write to the `RECOVERY_CONTROL` register to set the recovery image configuration |
| 27 | +5. Write to the `INDIRECT_FIFO_CTRL` register to set the recovery image size |
| 28 | +6. Push the recovery image to the recovery interface FIFOs: |
| 29 | + |
| 30 | + a. Read the `INDIRECT_FIFO_STATUS` register to determine remaining space in the indirect FIFO |
| 31 | + b. If the indirect FIFO is not full, write a chunk of data to the `INDIRECT_FIFO_DATA` register |
| 32 | + c. The above steps should be repeated until the whole recovery image is written to the FIFO |
| 33 | + |
| 34 | +7. Activate the new image by writing to the `RECOVERY_CTRL` register |
| 35 | +8. Read the `RECOVERY_STATUS` register to ensure the image has been activated |
| 36 | + |
| 37 | +The recovery image will be written in chunks with length equal to or less than `Max transfer size` defined in the `INDIRECT_FIFO_STATUS` register. |
| 38 | +Once the last data chunk is written to the FIFO, the Caliptra MCU ROM will write a CSR in the Secure Firmware Recovery register file indicating the transfer is complete. |
| 39 | + |
| 40 | +## Recovery Handler bypass |
| 41 | + |
| 42 | +In the regular (I3C) mode of the core, the Recovery Handler strongly relies on communication with the I3C Core internal logic by interfacing with TTI Queues. |
| 43 | +The bypass implementation modifies the I3C Core logic to allow direct access over the AXI bus to the structures specified by the OCP Secure Firmware Recovery for compliance with the [Caliptra Subsystem Recovery Sequence](https://github.com/chipsalliance/Caliptra/blob/main/doc/Caliptra.md#caliptra-subsystem-recovery-interface-hardware). |
| 44 | + |
| 45 | +The default design of the Recovery Handler includes many blocks specifically designed to translate I3C bus traffic into recovery messages. |
| 46 | +It also automatically responds to the I3C commands by writing transaction descriptors and data for the TTI Queues. |
| 47 | +Such a recovery flow is presented in the diagram below. |
| 48 | + |
| 49 | +:::{figure-md} recovery_handler |
| 50 | + |
| 51 | + |
| 52 | +Recovery Handler in the I3C Core |
| 53 | +::: |
| 54 | + |
| 55 | +In order enable an alternative recovery mechanism while reusing the existing logic and keeping compliance with Caliptra, the I3C core provides a custom bypass feature allowing direct communication with the Recovery Handler via the AXI bus. |
| 56 | +The bypass disables the I3C communication logic. |
| 57 | +Data is routed from the TTI TX Queue to the Recovery Executor block, and written directly to the Indirect Data FIFO. |
| 58 | +The Caliptra ROM can access the data from the Indirect FIFO over the AXI bus (the same way it does in the regular I3C recovery flow). |
| 59 | +Data flow in bypass mode, marked with green arrows, is depicted in the diagram below. |
| 60 | + |
| 61 | +:::{figure-md} recovery_handler_with_bypass |
| 62 | + |
| 63 | + |
| 64 | +Recovery Handler with the I3C Core logic bypass |
| 65 | +::: |
| 66 | + |
| 67 | +## Secure Firmware Recovery CSRs |
| 68 | + |
| 69 | +With the bypass feature enabled, the FIFO status CSRs in the Secure Firmware Recovery CSR file will be updated by the Recovery Handler module. |
| 70 | +However, some registers like e.g. `INDIRECT_FIFO_CTRL` which are updated by I3C commands in a standard recovery flow, will have to be accessed and configured properly from the software running on the Caliptra MCU via the AXI bus. |
| 71 | +All configurable registers are writable from software, read only registers provide status information about Recovery Handler internals, e.g. details about size and fill level of the Indirect FIFO. |
0 commit comments