This document outlines the protocol used during production for testing and the initial provisioning of Trezor devices.
## Commands and Responses
In the production environment, the test equipment sends single-line text commands.
These commands start with the command name and can optionally be followed by parameters separated by spaces.
Command Format:
`COMMAND [INARG1 [INARG2 [INARG3 ...]]]`
Example:
```
CPUID READ
```
The Trezor device responds with single-line text responses that start with either `OK` or `ERROR`, followed by output values separated by spaces.
If the device receives an unrecognized command, it responds with the text `UNKNOWN`.
Device responds with single line text response starting with words `OK` or `ERROR` optionally followed by output values delimited by spaces.
In case of unrecognized command, device responds with text `UNKNOWN`.
Response Format:
`OK [OUTARG1 [OUTARG2 [OUTARG3 ...]]]`
Example:
```
OK 2F0079001951354861125762
```
## List of commands
### PING
The `PING` command serves as a no-operation request, and the device responds with `OK` to acknowledge receipt.
Example:
```
PING
OK
```
### CPUID READ
The `CPUID READ` command reads a 96-bit long unique ID stored in the device's CPU.
The command always returns `OK` followed by a 24-digit hexadecimal value representing the unique ID.
Example:
```
CPUID READ
OK 2F0079001951354861125762
```
### BORDER
The `BORDER` command draws a single white border around the screen on a black background. This command has no input parameters and always returns `OK`.
Example:
```
BORDER
OK
```
### DISP
The `DISP` command draws vertical color bars on the screen based on a list of specified colors provided as a parameter.
Each character in the parameter represents one vertical bar and its color (R - red, B - blue, W - white, any other character - black).
The number of characters corresponds to the number of bars.
Note: On monochromatic displays R, G, B characters are interpreted as the white color.
Example (to draw 6 vertical bars - red, black, green, black, blue and black):
```
DISP RxGxB
```
### BUTTON
The `BUTTON` command tests the functionality of the device's buttons.
It waits for the user to press and release a specified button in a designated timeout period.
The command required two input parameters:
* The first parameter specifies the expected button or combination of buttons, with possible values: LEFT, RIGHT, BOTH.
* The seconds parameter specifies the timeout duration in seconds in range 1 to 9
If the specified button or button combination is not detected within the timeout, the command will return and `ERROR TIMEOUT`.
Example (to wait for 9 seconds for the left button):
The `OTP READ` command is utilized to retrieve a string parameter from the device's OTP memory.
This string typically contains information identifying the model and production batch of the device.
The command always returns OK followed by the read value.
If the OTP memory has not been written yet, it returns a special response: OK (null).
Example:
```
OTP READ
OK (null)
```
### OTP WRITE
The `OTP WRITE` command enables you to store a string parameter (which can be used to identify the model and production batch, for instance) into the device's OTP memory.
The parameter can be up to 31 characters in length.
The standard format is `<internal_model>-<YYMMDD>`, where YYMMDD represents the provisioning date. In case of Model T the `internal_model` is `TREZOR2`.
The `VARIANT` command writes up to 31 decimal values (representing device variant options), each ranging from 0 to 255, and delimited by spaces, into the OTP memory. This command should be called after the `LOCK` command was successfully executed.
The `VARIANT READ` command allows you to read 32 bytes of stored variant data (representing device variant options), each ranging from 0 to 255, and delimited by spaces. The first byte is the format version, followed by the bytes written using the VARIANT command and padded with null bytes.
Returns the x-coordinate of the FIDO attestation public key stored in Optiga. Can be executed only before the LOCK command is called.
This command can be used to verify that the FIDO attestation key was decrypted and stored correctly by verifying that the returned string of bytes appears in the FIDO attestation certificate.
Example:
```
KEYFIDO READ
OK 0D35A613358EDAB4CA04D05DD716546CD97973DE58516AF6A8F69BEE89BEFAA1