# Production Test Firmware This document outlines the production test firmware (prodtest) and its protocol. The prodtest serves two primary purposes: * Testing and initial provisioning of Trezor devices during production. * Device bring-up and testing during development. ## Command Line Interface The prodtest includes a simple text-based command-line interface that can be controlled either by automatic test equipment in a production environment or manually via a terminal application. Pressing the ENTER key twice switches the interface to interactive mode, enabling basic line editing, autocomplete functionality (using the TAB key), and text coloring. To exit from interactive mode type `.+ENTER`. ### Commands These commands begin with the command name and may optionally include parameters separated by spaces. Command Format: `command ...` Example: ``` haptic-test 500 ``` To retrieve a list of all available commands, type `help`. ### Final Responses The Trezor device responds to all commands with single-line text responses, which start with either `OK` or `ERROR`. An `OK` response may include additional parameters separated by spaces. The number and type of parameters depend on the specific command. Example: ``` OK 2.1.7 ``` An `ERROR` response includes an error code and an optional error description enclosed in quotation marks. Example: ``` ERROR invalid-arg "Expecting x-coordinate." ``` #### Predefined Error Codes: While commands may define custom error codes as needed, the following are predefined: * `error` - Unspecified error; additional details may be provided in the error description. * `invalid-cmd` - The command name is invalid. * `invalid-arg` - Invalid command argument. * `abort` - Operation aborted by the user (e.g., pressing CTRL+C). * `timeout` - The command execution timed out. ### Progress response When a command needs to send structured data that does not fit within `OK` messages, it can use the `PROGRESS` response. A progress response line starts with `PROGRESS`, followed by any number of parameters separated by spaces. Example: ``` PROGRESS move 107 164 24824185 PROGRESS move 107 170 24824195 PROGRESS move 107 176 24824204 PROGRESS move 107 180 24824213 PROGRESS move 107 184 24824222 ``` ### Debug Messages In addition to lines beginning with `OK`, `ERROR`, or `PROGRESS`, the prodtest firmware may issue lines starting with `#`. These lines contain debug or informational traces and should be ignored by automation scripts in a production environment. Example: ``` rgbled-set 0 255 0 # Setting the RGB LED color to [0, 255, 0]... OK ``` ## List of commands ### help Displays a list of available commands. The command optionally accepts a prefix to filter and display only commands starting with the specified characters. Example: ``` help otp # Available commands (filtered): # otp-batch-write - Write the device batch info into OTP memory # otp-batch-read - Read the device batch info from OTP memory # otp-variant-write - Write the device variant info into OTP memory # otp-variant-read - Read the device variant info from OTP memory OK ``` ### ping The `ping` command serves as a no-operation request, and the device responds with `OK` to acknowledge receipt. Example: ``` ping OK ``` ### reboot This command initiates device reboot. Example: ``` reboot OK ``` ### boardloader-version Retrieves the version of the boardloader. The command returns `OK` followed by the version in the format `..`. Example: ``` boardloader-version OK 0.2.6 ``` ### bootloader-version Retrives the version of the bootlaoder. The command returns `OK` followed by the version in the format `..`. Example: ``` bootloader-version OK 2.1.7 ``` ### button-test The `button-test` command tests the functionality of the device's hardware buttons. It waits for the user to press and release a specified button in a designated timeout period. `button-test