Skip to content

Commit

Permalink
Revert "fix(connect): rebootToBootloader misbehaviour"
Browse files Browse the repository at this point in the history
This reverts commit 6b01416.

(cherry picked from commit 094b11f)
  • Loading branch information
mroz22 authored and komret committed Feb 14, 2024
1 parent 45af096 commit fe72b45
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
9 changes: 5 additions & 4 deletions packages/connect/src/core/index.ts
Expand Up @@ -668,16 +668,17 @@ const onCall = async (message: IFrameCallMessage) => {
const response = messageResponse;

if (response) {
// Wait for device to switch to bootloader
// This delay is crucial see https://github.com/trezor/trezor-firmware/issues/1983
if (method.device.isT1() && method.name === 'rebootToBootloader' && response.success) {
if (method.name === 'rebootToBootloader' && response.success) {
// Wait for device to switch to bootloader
// This delay is crucial see https://github.com/trezor/trezor-firmware/issues/1983
await resolveAfter(1000).promise;
// call Device.run with empty function to fetch new Features
// (acquire > Initialize > nothing > release)
try {
await device.run(() => Promise.resolve(), { skipFinalReload: true });
} catch (err) {
// empty
// ignore. on model T, this block of code is probably not needed at all. but I am keeping it here for
// backwards compatibility
}
}

Expand Down
8 changes: 7 additions & 1 deletion packages/suite/src/hooks/firmware/useRebootRequest.ts
Expand Up @@ -8,6 +8,7 @@ import { getFirmwareVersion } from '@trezor/device-utils';
import type { TrezorDevice } from 'src/types/suite';
import { useDispatch, useSelector } from 'src/hooks/suite';
import { SUITE } from 'src/actions/suite/constants';
import { isWebUsb } from 'src/utils/suite/transport';

export type RebootRequestedMode = 'bootloader' | 'normal';
export type RebootPhase = 'initial' | 'wait-for-confirm' | 'disconnected' | 'done';
Expand All @@ -23,11 +24,16 @@ export const useRebootRequest = (
): RebootRequest => {
const [phase, setPhase] = useState<RebootPhase>('initial');

const transport = useSelector(state => state.suite.transport);

const isWebUsbTransport = isWebUsb(transport);

// Default reboot method is 'manual'. If the device is connected when
// the hook is first called and fw version is sufficient,
// then the 'automatic' method is enabled.
// Automatic reboot to bootloader not working properly with WebUSB so it's disabled for now.
const [method, setMethod] = useState<RebootMethod>(() => {
if (!device?.connected || !device?.features) return 'manual';
if (!device?.connected || !device?.features || isWebUsbTransport) return 'manual';

const deviceFwVersion = getFirmwareVersion(device);

Expand Down

0 comments on commit fe72b45

Please sign in to comment.