1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-12 08:20:56 +00:00

feat(core/prodtest): add RGB LED test

[no changelog]
This commit is contained in:
tychovrahe 2025-01-06 13:24:59 +01:00 committed by TychoVrahe
parent cbfbd48e3a
commit 43721ab396
3 changed files with 53 additions and 1 deletions

View File

@ -9,7 +9,7 @@ PRODUCTION = ARGUMENTS.get('PRODUCTION', '0') == '1'
BOOTLOADER_DEVEL = ARGUMENTS.get('BOOTLOADER_DEVEL', '0') == '1'
HW_REVISION = ARGUMENTS.get('HW_REVISION', None)
FEATURES_WANTED = ["input", "sbu", "sd_card", "rdb_led", "usb", "consumption_mask", "optiga", "haptic"]
FEATURES_WANTED = ["input", "sbu", "sd_card", "rgb_led", "usb", "consumption_mask", "optiga", "haptic"]
CCFLAGS_MOD = ''
CPPPATH_MOD = []

View File

@ -243,6 +243,19 @@ HAPTIC 3000
OK
```
### RGB_LED
The `RGB_LED` command allows you to test the functionality of the device's RGB LED.
It takes three input parameters, representing the intensity of the red, green, and blue color components.
Each component is a decimal value between 0 and 255.
Example:
```
// sets the RGB LED to red
RGB_LED 255 0 0
OK
```
### OTP READ
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.

View File

@ -71,6 +71,10 @@
#include <io/haptic.h>
#endif
#ifdef USE_RGB_LED
#include <io/rgb_led.h>
#endif
#ifdef USE_HASH_PROCESSOR
#include <sec/hash_processor.h>
#endif
@ -731,6 +735,33 @@ static void test_haptic(const char *args) {
}
#endif
#ifdef USE_RGB_LED
static void test_rgb_led(const char *args) {
static const int expected_params = 3;
int params[expected_params];
int num_params = 0;
extract_params(args, params, &num_params, expected_params);
if (num_params != expected_params) {
vcp_println("ERROR PARAM");
return;
}
if (params[0] > 255 || params[1] > 255 || params[2] > 255) {
vcp_println("ERROR RGB VALUE");
return;
}
uint32_t color = params[0] << 16 | params[1] << 8 | params[2];
rgb_led_set_color(color);
vcp_println("OK");
}
#endif
static void test_otp_read(void) {
uint8_t data[FLASH_OTP_BLOCK_SIZE + 1];
memzero(data, sizeof(data));
@ -1130,6 +1161,10 @@ int main(void) {
#ifdef USE_HAPTIC
haptic_init();
#endif
#ifdef USE_RGB_LED
rgb_led_init();
#endif
usb_init_all();
uint32_t bootloader_version = read_bootloader_version();
@ -1216,6 +1251,10 @@ int main(void) {
} else if (startswith(line, "HAPTIC ")) {
test_haptic(line + 7);
#endif
#ifdef USE_RGB_LED
} else if (startswith(line, "RGB_LED ")) {
test_rgb_led(line + 8);
#endif
#ifdef USE_OPTIGA
} else if (startswith(line, "OPTIGAID READ")) {
optigaid_read();