Skip to content

Commit

Permalink
feat(ble): integrate MCU boot into trezor-ble app, add stay in bootlo…
Browse files Browse the repository at this point in the history
…ader pin

[no changelog]
  • Loading branch information
TychoVrahe committed Dec 18, 2024
1 parent 2dbdd0b commit 2b030ae
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 33 deletions.
21 changes: 6 additions & 15 deletions west/trezor/boards/arm/t3w1_revA_nrf52832/t3w1_revA_nrf52832.dts
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
};
Expand All @@ -59,9 +55,8 @@
led0 = &led0;
led1 = &led1;
sw0 = &button0;
bootloader-led0 = &led0;
bootloader-botton0 = &button0;
mcuboot-button0 = &button0;
mcuboot-led0 = &led0;
watchdog0 = &wdt0;
};
};
Expand Down Expand Up @@ -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";
Expand Down
1 change: 1 addition & 0 deletions west/trezor/trezor-ble/mcuboot.conf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,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
Expand Down
13 changes: 13 additions & 0 deletions west/trezor/trezor-ble/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,16 @@ CONFIG_LOG_PRINTK=n

CONFIG_NANOPB=n
CONFIG_ASSERT=y


# bootloader
#CONFIG_SECURE_BOOT=y
CONFIG_BOOTLOADER_MCUBOOT=y
#CONFIG_SB_SIGNING_OPENSSL=y
#CONFIG_SB_SIGNING_KEY_FILE="/home/ondro/work/satoshilabs/repos/ncs/mcuboot_priv.pem"
#CONFIG_SB_SIGNING_KEY_FILE="/home/ondro/work/satoshilabs/repos/ncs/mcuboot_priv.pem"
#CONFIG_SB_PUBLIC_KEY_FILES="/home/ondro/work/satoshilabs/repos/ncs/mcuboot_pub.pem"
#CONFIG_MCUBOOT_SIGNATURE_KEY_FILE="/home/ondro/work/satoshilabs/repos/ncs/mcuboot_priv.pem"
#CONFIG_MCUBOOT_SIGNATURE_KEY_FILE="/home/ondro/work/satoshilabs/repos/ncs/mcuboot_priv.pem"
#CONFIG_BOOT_SIGNATURE_KEY_FILE="/home/ondro/work/satoshilabs/repos/ncs/mcuboot_priv.pem"
CONFIG_MCUBOOT_BOOTLOADER_MODE_SINGLE_APP=y
27 changes: 13 additions & 14 deletions west/trezor/trezor-ble/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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));
}
Expand Down
4 changes: 0 additions & 4 deletions west/trezor/west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 2b030ae

Please sign in to comment.