Skip to content

Commit 87c62d1

Browse files
authored
Merge pull request #1474 from NickeZ/nickez/fix-u2f-safari
Nickez/fix u2f safari
2 parents 7046fa3 + f40ea15 commit 87c62d1

File tree

14 files changed

+154
-182
lines changed

14 files changed

+154
-182
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ customers cannot upgrade their bootloader, its changes are recorded separately.
88

99
### [Unreleased]
1010
- EVM: add HyperEVM (HYPE) and SONIC (S) to known networks
11+
- U2F: fix macos/safari macos/firefox support
1112

1213
### 9.23.0
1314
- Ethereum: add confirmation screen for known networks, change base unit to ETH for Arbitrum and Optimism

Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,15 @@
1414

1515
# This makefile is used as a command runner and not for tracking dependencies between recipies
1616

17+
UNAME_S := $(shell uname -s)
18+
1719
.DEFAULT_GOAL := firmware
18-
SANITIZE ?= ON
20+
# asan/ubsan is not supported on darwin, default to off
21+
ifeq ($(UNAME_S),Darwin)
22+
SANITIZE ?= OFF
23+
else
24+
SANITIZE ?= ON
25+
endif
1926
simulator: SANITIZE = OFF
2027

2128
bootstrap:

src/firmware.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,13 @@
2525
#include "screen.h"
2626
#include "ui/screen_stack.h"
2727
#include "usb/usb_processing.h"
28+
#include <hww.h>
2829
#include <memory/memory_spi.h>
2930

31+
#if APP_U2F == 1
32+
#include <u2f.h>
33+
#endif
34+
3035
uint32_t __stack_chk_guard = 0;
3136

3237
int main(void)
@@ -44,6 +49,11 @@ int main(void)
4449
da14531_protocol_init();
4550
}
4651
usb_processing_init();
52+
// Setup usb_processing handlers
53+
hww_setup();
54+
#if APP_U2F == 1
55+
u2f_device_setup();
56+
#endif
4757
firmware_main_loop();
4858
return 0;
4959
}

src/firmware_main_loop.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ void firmware_main_loop(void)
103103
}
104104
if (!u2f_data) {
105105
u2f_data = queue_pull(queue_u2f_queue());
106+
// If USB stack was locked and there is no more messages to send out, time to
107+
// unlock it.
108+
if (!u2f_data && usb_processing_locked(usb_processing_u2f())) {
109+
usb_processing_unlock();
110+
}
106111
}
107112
#endif
108113
// Do USB Input
@@ -120,6 +125,7 @@ void firmware_main_loop(void)
120125
}
121126
#if APP_U2F == 1
122127
if (!u2f_data && hid_u2f_read(&u2f_frame[0])) {
128+
util_log("u2f data %s", util_dbg_hex((void*)u2f_frame, 16));
123129
u2f_packet_process((const USB_FRAME*)u2f_frame);
124130
if (communication_mode_ble_enabled()) {
125131
// Enqueue a power down command to the da14531
@@ -152,6 +158,7 @@ void firmware_main_loop(void)
152158
#if APP_U2F == 1
153159
if (!communication_mode_ble_enabled() && u2f_data) {
154160
if (hid_u2f_write_poll(u2f_data)) {
161+
util_log("u2f wrote %s", util_dbg_hex(u2f_data, 16));
155162
u2f_data = NULL;
156163
}
157164
}

0 commit comments

Comments
 (0)