1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-19 03:40:59 +00:00

feat(ble): integrate MCU boot into trezor-ble app, add stay in bootloader pin

[no changelog]
This commit is contained in:
tychovrahe 2024-12-18 09:58:06 +01:00
parent 8392bad9a2
commit 2a1bf197e1
8 changed files with 32 additions and 59 deletions

View File

@ -61,7 +61,7 @@ west update
Build the application for the t3w1_revA_nrf52832 board:
```sh
cd trezor
west build ./trezor-ble -b t3w1_revA_nrf52832
west build ./trezor-ble -b t3w1_revA_nrf52832 --sysbuild
```

View File

@ -27,28 +27,24 @@
leds {
compatible = "gpio-leds";
led0: led_0 {
gpios = <&gpio0 12 GPIO_ACTIVE_LOW>;
gpios = <&gpio0 25 GPIO_ACTIVE_HIGH>;
label = "Green LED 0";
};
led1: led_1 {
gpios = <&gpio0 14 GPIO_ACTIVE_LOW>;
gpios = <&gpio0 12 GPIO_ACTIVE_HIGH>;
label = "Green LED 1";
};
out0: out_0 {
gpios = <&gpio0 25 GPIO_ACTIVE_HIGH>;
label = "FW Running";
};
};
buttons {
compatible = "gpio-keys";
button0: button_0 {
gpios = <&gpio0 27 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
gpios = <&gpio0 14 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>;
label = "Push button switch 0";
zephyr,code = <INPUT_KEY_0>;
};
trezor_ready: trezor_ready {
gpios = <&gpio0 29 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>;
gpios = <&gpio0 29 ( GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>;
label = "Trezor ready";
zephyr,code = <INPUT_KEY_1>;
};
@ -59,9 +55,8 @@
led0 = &led0;
led1 = &led1;
sw0 = &button0;
bootloader-led0 = &led0;
bootloader-botton0 = &button0;
mcuboot-button0 = &button0;
mcuboot-led0 = &led0;
watchdog0 = &wdt0;
};
};
@ -118,11 +113,7 @@
};
slot0_partition: partition@c000 {
label = "image-0";
reg = <0x0000C000 0x37000>;
};
slot1_partition: partition@43000 {
label = "image-1";
reg = <0x00043000 0x37000>;
reg = <0x0000C000 0x7A000>;
};
storage_partition: partition@7a000 {
label = "storage";

View File

@ -1,25 +0,0 @@
#CONFIG_PM_PARTITION_SIZE_MCUBOOT=0x10000
#CONFIG_SERIAL=y
#CONFIG_UART_LINE_CTRL=y
#CONFIG_UART_NRFX=y
#CONFIG_UART_INTERRUPT_DRIVEN=n
# MCUBoot serial
CONFIG_GPIO=y
CONFIG_GPIO_NRFX_INTERRUPT=n
#CONFIG_MCUBOOT_SERIAL=y
#CONFIG_BOOT_SERIAL_CDC_ACM=y
#CONFIG_BOOT_SERIAL_UART=y
#CONFIG_LOG_BACKEND_UART=y
#CONFIG_BOOT_SERIAL_DETECT_PIN=11
#CONFIG_MCUMGR_SMP_UART=y
CONFIG_MCUBOOT_BOOTLOADER_MODE_SINGLE_APP=y
CONFIG_SINGLE_APPLICATION_SLOT=y
CONFIG_RTT_CONSOLE=y
CONFIG_USE_SEGGER_RTT=y
CONFIG_UART_CONSOLE=n

View File

@ -89,3 +89,8 @@ CONFIG_LOG_PRINTK=n
CONFIG_NANOPB=n
CONFIG_ASSERT=y
# bootloader
#CONFIG_SECURE_BOOT=y
CONFIG_BOOTLOADER_MCUBOOT=y

View File

@ -46,8 +46,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
#define RUN_STATUS_LED DK_LED1
#define RUN_LED_BLINK_INTERVAL 1000
#define FW_RUNNING_SIG DK_LED3
#define CON_STATUS_LED DK_LED2
#define FW_RUNNING_SIG DK_LED2
static K_SEM_DEFINE(ble_init_ok, 0, 1);
static K_SEM_DEFINE(led_init_ok, 0, 1);
@ -231,7 +230,7 @@ void ble_write_thread(void) {
}
void led_thread(void) {
bool connected = false;
// bool connected = false;
int blink_status = 0;
/* Don't go any further until BLE is initialized */
k_sem_take(&led_init_ok, K_FOREVER);
@ -240,17 +239,17 @@ void led_thread(void) {
blink_status++;
dk_set_led(RUN_STATUS_LED, (blink_status) % 2);
connected = is_connected();
if (connected) {
dk_set_led_on(CON_STATUS_LED);
} else {
if (is_advertising() && !is_advertising_whitelist()) {
dk_set_led(CON_STATUS_LED, (blink_status) % 2);
} else {
dk_set_led_off(CON_STATUS_LED);
}
}
// connected = is_connected();
//
// if (connected) {
// dk_set_led_on(CON_STATUS_LED);
// } else {
// if (is_advertising() && !is_advertising_whitelist()) {
// dk_set_led(CON_STATUS_LED, (blink_status) % 2);
// } else {
// dk_set_led_off(CON_STATUS_LED);
// }
// }
k_sleep(K_MSEC(RUN_LED_BLINK_INTERVAL));
}

View File

@ -0,0 +1,5 @@
# Sysbuild configuration file.
# Enable MCUboot
SB_CONFIG_BOOTLOADER_MCUBOOT=y
SB_CONFIG_MCUBOOT_MODE_SINGLE_APP=y

View File

@ -9,6 +9,7 @@ CONFIG_UART_NRFX=y
CONFIG_GPIO=y
CONFIG_GPIO_NRFX_INTERRUPT=n
CONFIG_MCUBOOT_SERIAL=y
CONFIG_BOOT_MGMT_ECHO=y
CONFIG_BOOT_SERIAL_CDC_ACM=y
CONFIG_BOOT_SERIAL_UART=y
@ -18,6 +19,7 @@ CONFIG_BOOT_SERIAL_UART=y
#CONFIG_MCUMGR_SMP_UART=y
CONFIG_MCUBOOT_BOOTLOADER_MODE_SINGLE_APP=y
CONFIG_SINGLE_APPLICATION_SLOT=y
CONFIG_BOOT_VALIDATE_SLOT0=y
CONFIG_RTT_CONSOLE=y
CONFIG_USE_SEGGER_RTT=y

View File

@ -15,7 +15,3 @@ manifest:
repo-path: sdk-nrf
revision: v2.7.0
import: true
- name: mcuboot
url: https://github.com/hiviah/mcuboot
path: bootloader/mcuboot
revision: edfe1e1465dbc698bf9a195816247913490ab391