refactor(nordic): dts cleanup and DK gpio driver removal
What changed, and why it matters
This commit is a routine cleanup of the Nordic board configuration and Bluetooth Low Energy firmware for a Trezor hardware wallet. It removes the generic Nordic 'DK buttons and LEDs' driver and replaces it with direct GPIO (general-purpose input/output) definitions tied to the actual Trezor board pins. It also fixes a typo in the board name and renames some device-tree labels for clarity. There is no security-relevant change visible in the diff.
No security action required. Treat as normal refactoring/code-quality change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change refactors the t3w1_revA_nrf52832 device tree: it drops the DK LED/buttons library (CONFIG_DK_LIBRARY, dk_buttons_and_leds.h), renames ‘leds’/’buttons’ nodes to generic ‘outputs’/’inputs’, removes the unused input-event-codes include, and updates aliases accordingly. signals.c now uses Zephyr’s gpio_dt_spec API directly against the device-tree aliases. spi.c updates the chip-select GPIO reference from the old reg_my_spi_master node label to the new trezor_spi_dev label. The board vendor string is corrected from ‘vendor’ to ‘trezor’ and a typo in the board YAML name is fixed. No functional security behavior is altered.
Changed components
nordic/trezor/boards/arm/t3w1_revA_nrf52832 device tree and board metadatanordic/trezor/trezor-ble/src/signals/signals.c GPIO initializationnordic/trezor/trezor-ble/src/trz_comm/spi.c chip-select configurationInspect captured patch +42 / −73
diff --git a/nordic/trezor/boards/arm/t3w1_revA_nrf52832/Kconfig.defconfig b/nordic/trezor/boards/arm/t3w1_revA_nrf52832/Kconfig.defconfig
index d9c7264f..cabb0f15 100644
--- a/nordic/trezor/boards/arm/t3w1_revA_nrf52832/Kconfig.defconfig
+++ b/nordic/trezor/boards/arm/t3w1_revA_nrf52832/Kconfig.defconfig
@@ -1,4 +1,4 @@
-# T3W1 REVA NRF52833 board configuration
+# T3W1 REVA NRF52832 board configuration
# Copyright (c) 2019 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
diff --git a/nordic/trezor/boards/arm/t3w1_revA_nrf52832/board.yml b/nordic/trezor/boards/arm/t3w1_revA_nrf52832/board.yml
index 787481d9..ae3dd299 100644
--- a/nordic/trezor/boards/arm/t3w1_revA_nrf52832/board.yml
+++ b/nordic/trezor/boards/arm/t3w1_revA_nrf52832/board.yml
@@ -4,6 +4,6 @@
board:
name: t3w1_revA_nrf52832
full_name: t3w1_revA_nrf52832
- vendor: vendor
+ vendor: trezor
socs:
- name: nrf52832
diff --git a/nordic/trezor/boards/arm/t3w1_revA_nrf52832/t3w1_revA_nrf52832.dts b/nordic/trezor/boards/arm/t3w1_revA_nrf52832/t3w1_revA_nrf52832.dts
index 4b7d86e9..85c895f0 100644
--- a/nordic/trezor/boards/arm/t3w1_revA_nrf52832/t3w1_revA_nrf52832.dts
+++ b/nordic/trezor/boards/arm/t3w1_revA_nrf52832/t3w1_revA_nrf52832.dts
@@ -7,7 +7,6 @@
/dts-v1/;
#include <nordic/nrf52832_ciaa.dtsi>
#include "t3w1_revA_nrf52832-pinctrl.dtsi"
-#include <zephyr/dt-bindings/input/input-event-codes.h>
/ {
model = "T3W1 REVA NRF52832";
@@ -22,52 +21,33 @@
zephyr,code-partition = &slot0_partition;
};
- leds {
+ outputs {
compatible = "gpio-leds";
-
- led0: led_0 {
+ output_0: output_0 {
gpios = <&gpio0 25 GPIO_ACTIVE_HIGH>;
- label = "Reserved";
};
-
- };
-
- buttons {
- compatible = "gpio-keys";
-
- button0: button_0 {
- gpios = <&gpio0 14 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>;
- label = "Stay in bootloader";
- zephyr,code = <INPUT_KEY_0>;
+ output_1: output_1 {
+ gpios = <&gpio0 29 (GPIO_ACTIVE_HIGH)>;
};
};
- spi_sync_in
- {
+ inputs {
compatible = "gpio-keys";
- spi_ready: spi_ready {
- gpios = <&gpio0 12 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>;
- label = "Trezor has data ready";
+ input_0: input_0 {
+ gpios = <&gpio0 14 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>;
};
- };
- spi_sync_out
- {
- compatible = "gpio-leds";
- spi_request: spi_request {
- gpios = <&gpio0 29 (GPIO_ACTIVE_HIGH)>;
- label = "NRF is requesting to send data to trezor";
+ input_1: input_1 {
+ gpios = <&gpio0 12 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>;
};
};
- /* These aliases are provided for compatibility with samples */
aliases {
- led0 = &led0;
- sw0 = &button0;
- bootloader-botton0 = &button0;
- mcuboot-button0 = &button0;
+ mcuboot-button0 = &input_0;
watchdog0 = &wdt0;
- spi-ready = &spi_ready;
- spi-request = &spi_request;
+ spi-ready = &input_1;
+ spi-request = &output_1;
+ stay-in-bootloader = &input_0;
+ reserved-output = &output_0;
};
};
@@ -106,7 +86,7 @@
pinctrl-1 = <&spi0_sleep>;
pinctrl-names = "default", "sleep";
cs-gpios = <&gpio0 0 GPIO_ACTIVE_LOW>;
- reg_my_spi_master: spi-dev-a@0 {
+ trezor_spi_dev: spi-dev-a@0 {
reg = <0>;
};
};
diff --git a/nordic/trezor/boards/arm/t3w1_revA_nrf52832/t3w1_revA_nrf52832.yaml b/nordic/trezor/boards/arm/t3w1_revA_nrf52832/t3w1_revA_nrf52832.yaml
index 6ce3429f..5e792d98 100644
--- a/nordic/trezor/boards/arm/t3w1_revA_nrf52832/t3w1_revA_nrf52832.yaml
+++ b/nordic/trezor/boards/arm/t3w1_revA_nrf52832/t3w1_revA_nrf52832.yaml
@@ -1,5 +1,5 @@
identifier: t3w1_revA_nrf52832
-name: tw31-revA-NRF52832
+name: t3w1-revA-NRF52832
type: mcu
arch: arm
ram: 64
diff --git a/nordic/trezor/trezor-ble/prj.conf b/nordic/trezor/trezor-ble/prj.conf
index 2e1aa2cc..3b1d6362 100644
--- a/nordic/trezor/trezor-ble/prj.conf
+++ b/nordic/trezor/trezor-ble/prj.conf
@@ -91,9 +91,6 @@ CONFIG_NVS=y
CONFIG_SETTINGS=y
CONFIG_SETTINGS_RUNTIME=y
-# Enable DK LED and Buttons library
-CONFIG_DK_LIBRARY=y
-
# This example requires more stack
CONFIG_MAIN_STACK_SIZE=1152
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
diff --git a/nordic/trezor/trezor-ble/src/main.c b/nordic/trezor/trezor-ble/src/main.c
index 9ad90efe..2b23edc3 100644
--- a/nordic/trezor/trezor-ble/src/main.c
+++ b/nordic/trezor/trezor-ble/src/main.c
@@ -32,8 +32,6 @@
#include <zephyr/bluetooth/hci.h>
#include <zephyr/bluetooth/uuid.h>
-#include <dk_buttons_and_leds.h>
-
#include <zephyr/settings/settings.h>
#include <zephyr/logging/log.h>
diff --git a/nordic/trezor/trezor-ble/src/signals/signals.c b/nordic/trezor/trezor-ble/src/signals/signals.c
index e4d76c43..3616514f 100644
--- a/nordic/trezor/trezor-ble/src/signals/signals.c
+++ b/nordic/trezor/trezor-ble/src/signals/signals.c
@@ -16,57 +16,56 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+
+#include <zephyr/drivers/gpio.h>
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
-#include <zephyr/settings/settings.h>
-#include <zephyr/types.h>
#include <signals/signals.h>
-#include <dk_buttons_and_leds.h>
-
#define LOG_MODULE_NAME signals
LOG_MODULE_REGISTER(LOG_MODULE_NAME);
-#define OUT_RESERVED DK_LED1
-
-#define IN_STAY_IN_BOOTLOADER DK_BTN1_MSK
+static const struct gpio_dt_spec stay_in_bootloader_btn =
+ GPIO_DT_SPEC_GET(DT_ALIAS(stay_in_bootloader), gpios);
+static const struct gpio_dt_spec reserved_output =
+ GPIO_DT_SPEC_GET(DT_ALIAS(reserved_output), gpios);
static K_SEM_DEFINE(signals_ok, 0, 1);
static bool out_reserved = false;
-void button_changed(uint32_t button_state, uint32_t has_changed) {}
-
-static void configure_gpio(void) {
+bool signals_init(void) {
int err;
- err = dk_buttons_init(button_changed);
+ err = gpio_pin_configure_dt(&stay_in_bootloader_btn, GPIO_INPUT);
if (err) {
- LOG_ERR("Cannot init INPUT (err: %d)", err);
+ LOG_ERR("Cannot configure bootloader button (err: %d)", err);
+ return false;
}
- err = dk_leds_init();
+ err = gpio_pin_configure_dt(&reserved_output, GPIO_OUTPUT_INACTIVE);
if (err) {
- LOG_ERR("Cannot init OUTPUT (err: %d)", err);
+ LOG_ERR("Cannot configure reserved output (err: %d)", err);
+ return false;
}
-}
-
-bool signals_is_stay_in_bootloader(void) {
- return (dk_get_buttons() & IN_STAY_IN_BOOTLOADER) != 0;
-}
-
-bool signals_init(void) {
- configure_gpio();
k_sem_give(&signals_ok);
return true;
}
+bool signals_is_stay_in_bootloader(void) {
+ return gpio_pin_get_dt(&stay_in_bootloader_btn) > 0;
+}
+
void signals_set_reserved(bool set) {
+ int rc = gpio_pin_set_dt(&reserved_output, set);
+ if (rc < 0) {
+ LOG_ERR("Failed to set reserved output: %d", rc);
+ return;
+ }
out_reserved = set;
- dk_set_led(OUT_RESERVED, set);
}
bool signals_out_get_reserved(void) { return out_reserved; }
diff --git a/nordic/trezor/trezor-ble/src/trz_comm/spi.c b/nordic/trezor/trezor-ble/src/trz_comm/spi.c
index 8063ee78..10a1b082 100644
--- a/nordic/trezor/trezor-ble/src/trz_comm/spi.c
+++ b/nordic/trezor/trezor-ble/src/trz_comm/spi.c
@@ -46,18 +46,13 @@ const struct device *spi_dev;
static struct k_poll_signal spi_done_sig =
K_POLL_SIGNAL_INITIALIZER(spi_done_sig);
-struct spi_cs_control spim_cs = {
- .gpio = SPI_CS_GPIOS_DT_SPEC_GET(DT_NODELABEL(reg_my_spi_master)),
- .delay = 0,
-};
-
static const struct spi_config spi_cfg = {
.operation = SPI_WORD_SET(8) | SPI_TRANSFER_MSB,
.frequency = 8000000,
.slave = 0,
.cs =
{
- .gpio = SPI_CS_GPIOS_DT_SPEC_GET(DT_NODELABEL(reg_my_spi_master)),
+ .gpio = SPI_CS_GPIOS_DT_SPEC_GET(DT_NODELABEL(trezor_spi_dev)),
.delay = 0,
},
};
@@ -109,7 +104,7 @@ void spi_init(void) {
if (!device_is_ready(spi_dev)) {
LOG_WRN("SPI master device not ready!");
}
- if (!device_is_ready(spim_cs.gpio.port)) {
+ if (!device_is_ready(spi_cfg.cs.gpio.port)) {
LOG_WRN("SPI master chip select device not ready!");
}
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.