feat(core/prodtest): Update haptic-test command with optional amplitude parameter.
What changed, and why it matters
This commit updates a factory-testing command used only in Trezor's internal production-test firmware. It adds an optional amplitude parameter (0-100) to the haptic-test command so testers can vary vibration strength. There is no user-facing change, no normal wallet firmware impact, and no security relevance visible in the commit.
No security action required. Treat as a normal feature update to production-test tooling.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change is confined to core/embed/projects/prodtest/cmd/prodtest_haptic.c and its README. It changes the CLI argument parsing for the haptic-test command: previously the command accepted exactly one argument (duration_ms) and called haptic_play_custom(100, duration_ms). Now it accepts an optional second argument, validates it as a uint32 in the range 0-100, defaults to 100, and passes it as the amplitude to haptic_play_custom. Argument-count validation is updated to reject more than two arguments. The haptic_play_custom function and its amplitude semantics are not shown in the diff, but the new parameter is range-checked.
Changed components
core/embed/projects/prodtest/cmd/prodtest_haptic.ccore/embed/projects/prodtest/README.mdInspect captured patch +16 / −7
diff --git a/core/embed/projects/prodtest/README.md b/core/embed/projects/prodtest/README.md
index c7da4811..1395e051 100644
--- a/core/embed/projects/prodtest/README.md
+++ b/core/embed/projects/prodtest/README.md
@@ -374,14 +374,14 @@ OK 2F0079001951354861125762
```
### haptic-test
-Test the functionality of the device's haptic actuator. It takes one input parameter, representing the duration of the vibration in milliseconds.
+Test the functionality of the device's haptic actuator. It takes one mandatory input parameter, representing the duration of the vibration in milliseconds and second optional parameter setting the vibration amplitude
The device only vibrates if there is motor connected to the haptic driver, otherwise the effect needs to be measured by an oscilloscope.
Example (runs the driver for 3s):
```
-haptic-test 3000
-# Running haptic feedback test for 3000 ms...
+haptic-test 3000 50
+# Running haptic feedback test for 3000 ms with amplitude 50 ...
OK
```
diff --git a/core/embed/projects/prodtest/cmd/prodtest_haptic.c b/core/embed/projects/prodtest/cmd/prodtest_haptic.c
index 503b6d6f..d3f71722 100644
--- a/core/embed/projects/prodtest/cmd/prodtest_haptic.c
+++ b/core/embed/projects/prodtest/cmd/prodtest_haptic.c
@@ -26,6 +26,7 @@
static void prodtest_haptic_test(cli_t* cli) {
uint32_t duration_ms = 0; // ms
+ uint32_t amplitude = 100; // default amplitude
ts_t status;
@@ -34,7 +35,14 @@ static void prodtest_haptic_test(cli_t* cli) {
return;
}
- if (cli_arg_count(cli) > 1) {
+ if (cli_arg_count(cli) == 2) {
+ if (!cli_arg_uint32(cli, "amplitude", &litude) || amplitude > 100) {
+ cli_error_arg(cli, "Expecting amplitude value in range 0-100.");
+ return;
+ }
+ }
+
+ if (cli_arg_count(cli) > 3) {
cli_error_arg_count(cli);
return;
}
@@ -45,9 +53,10 @@ static void prodtest_haptic_test(cli_t* cli) {
return;
}
- cli_trace(cli, "Running haptic feedback test for %d ms...", duration_ms);
+ cli_trace(cli, "Running haptic feedback test for %d ms with amplitude %d ...",
+ duration_ms, amplitude);
- status = haptic_play_custom(100, duration_ms);
+ status = haptic_play_custom(amplitude, duration_ms);
if (ts_error(status)) {
cli_error(cli, CLI_ERROR, "Haptic feedback test failed.");
return;
@@ -62,7 +71,7 @@ PRODTEST_CLI_CMD(
.name = "haptic-test",
.func = prodtest_haptic_test,
.info = "Test the haptic feedback actuator",
- .args = "<duration>"
+ .args = "<duration>[<amplitude>]"
);
#endif // USE_HAPTIC
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.