Skip to content

feat: add legacy firmware update flow for web/extension platforms#9886

Draft
wabicai wants to merge 17 commits intoxfrom
feat/integrated-firmware-upgrade
Draft

feat: add legacy firmware update flow for web/extension platforms#9886
wabicai wants to merge 17 commits intoxfrom
feat/integrated-firmware-upgrade

Conversation

@wabicai
Copy link
Copy Markdown
Member

@wabicai wabicai commented Jan 26, 2026

Summary

Add an independent firmware update flow for legacy devices on Web and Extension platforms. This feature handles devices with firmware versions below the minimum required limit, providing a dedicated upgrade path separate from the standard firmware update flow.

Latest Changes (2026-02-03)

Classic Series Unified Flow

  • Removed version restrictions for Classic, Classic1s, ClassicPure devices
  • All Classic series devices now use the normal startUpdateWorkflow
  • SDK handles all firmware versions internally

Mini USB Restriction

  • Added UI warning on Native platforms (iOS/Android)
  • Mini devices have no Bluetooth and must use USB connection
  • Users are informed they need to use desktop/web for Mini firmware updates

Legacy Flow Auto-Continue

  • After Legacy firmware update completes, UI automatically transitions to normal ChangeLog modal
  • Seamlessly continues to remaining updates (bootloader, BLE, etc.)
  • 3-second delay shows completion message before transitioning

Legacy Device Criteria

Devices will use the legacy firmware update flow when their version is below the minimum required version:

Device Type Min Firmware Min Bootloader Notes
Touch 4.1.0 2.4.2 Only 4.1.0+ supports bootloader update via App
Classic 3.0.0 (removed) 2.0.0 (removed) Now uses normal flow
Classic 1S 3.0.0 (removed) 2.0.0 (removed) Now uses normal flow
Classic Pure 3.0.0 (removed) 2.0.0 (removed) Now uses normal flow
Mini 3.0.0 2.0.0 Requires manual bootloader mode entry, USB only

Note: OneKey Pro devices do NOT use the legacy update flow - they always use the standard flow.

Hardware Compatibility Notes

Based on 硬件兼容变更文档:

Device Key Constraint Impact
Mini Cannot call RebootToBootloader Must manually enter bootloader mode (implemented)
Mini No Bluetooth USB connection required, cannot update on Native platforms
Classic/Mini boot < 2.0.0 Must first upgrade to boot 2.0.0 before newer firmware
Classic1s Switching to btc-only with firmware < 3.15.0 Need to upgrade boot 2.1.0 first
Touch boot 2.4.5+ Uses new upgrade method (EmmcFileWrite + FirmwareUpdateEmmc)

Changes

Service Layer:

  • ServiceLegacyFirmwareUpdate - Main service with device type detection and workflow management
  • Device handlers for Touch, Mini, and Classic series devices
  • Utility functions for legacy firmware download and bootloader pre-check

State Management:

  • Jotai atoms for legacy firmware update step tracking and progress

UI Components:

  • PageLegacyFirmwareUpdate - Main page component
  • LegacyFirmwareInstallingView - Unified progress view (same as normal flow)
  • LegacyUpdateCheckList - Pre-update checklist with device info and confirmation items
  • LegacyUpdateResult - Success/failure result display with retry option
  • MiniBootloaderModeGuide - Instructions for manually entering bootloader mode (Mini devices)
  • WebUsbDeviceReselectPrompt - USB device reselection prompt

Routing:

  • New modal route for legacy firmware update
  • Integration with existing firmware update actions for automatic flow detection

Test Plan

  • Verify legacy firmware detection logic on Web platform
  • Verify legacy firmware detection logic on Extension platform
  • Test Touch device upgrade flow (firmware < 4.1.0)
  • Test Mini device upgrade flow (including manual bootloader mode)
  • Test Classic device upgrade flow (now uses normal flow)
  • Verify Mini shows USB warning on iOS/Android
  • Verify progress display and step transitions
  • Test auto-continue to normal flow after Legacy update completes
  • Test error handling and retry functionality

🤖 Generated with Claude Code

Add independent firmware update flow for legacy devices (firmware versions
below minimum limit) on Web and Extension platforms.

Changes:
- Add ServiceLegacyFirmwareUpdate with device-specific handlers (Touch, Mini, Classic)
- Add Jotai atoms for legacy firmware update state management
- Add LegacyFirmwareUpdate page with UI components:
  - LegacyUpdateStepIndicator (progress steps display)
  - LegacyUpdateCheckList (pre-update checklist)
  - LegacyUpdateProgress (progress bar and status)
  - LegacyUpdateResult (success/failure result)
  - MiniBootloaderModeGuide (bootloader mode instructions)
  - WebUsbDeviceReselectPrompt (USB device reselect prompt)
- Add route configuration for legacy firmware update modal
- Integrate with existing firmware update actions
@socket-security
Copy link
Copy Markdown

socket-security Bot commented Jan 26, 2026

No dependency changes detected. Learn more about Socket for GitHub.

👍 No dependency changes detected in pull request

@revan-zhang
Copy link
Copy Markdown
Contributor

revan-zhang commented Jan 26, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@wabicai wabicai enabled auto-merge (squash) January 26, 2026 16:37
@wabicai wabicai marked this pull request as draft January 26, 2026 16:38
auto-merge was automatically disabled January 26, 2026 16:38

Pull request was converted to draft

wabicai and others added 3 commits January 27, 2026 00:56
- Remove platform restriction in shouldUseLegacyFlow() to support iOS/Android
- Add platform-aware bootloader mode instructions in MiniBootloaderModeGuide
  - Mobile: power off → hold button → power on flow
  - Web/Extension: disconnect USB → hold button → connect USB flow
- Add platform-aware device reselect UI in WebUsbDeviceReselectPrompt
  - Mobile: shows spinner with Bluetooth search status
  - Web/Extension: shows USB icon with reselect button
- LegacyUpdateStepIndicator: Add spring animation for step dots (scale 1.25x
  when active) and smooth progress bar fill animation
- LegacyUpdateProgress: Add useSmoothProgress hook for fluid progress
  interpolation, enable animated prop on Progress component
- LegacyUpdateResult: Add entrance animations for success/error states
  (scale from 0.5, fade in, slide up)
- LegacyUpdateCheckList: Add card entrance animations (fade + slide)
- MiniBootloaderModeGuide: Add layered entrance animations
- WebUsbDeviceReselectPrompt: Add unified entrance animations for both
  native and web platforms

Animation types used:
- quick: Fast spring (damping: 20, mass: 0.1)
- medium: Balanced spring (damping: 10, mass: 0.9)
- slow: Smooth spring (damping: 20, stiffness: 60)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Copy Markdown
Member Author

@wabicai wabicai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Code Review - Legacy Firmware Update

Issues Found

1. ⚠️ README.md Deletion (High Priority)

File: packages/kit/src/views/LegacyFirmwareUpdate/README.md

The entire README documentation has been replaced with just # ., effectively deleting all documentation for this feature module. This appears to be accidental.

Recommendation: Restore the original README content or create proper documentation for the Legacy Firmware Update feature.


2. 🔧 Missing Transport Type Locking Pattern (Medium Priority)

File: packages/kit-bg/src/services/ServiceLegacyFirmwareUpdate.ts

The ServiceLegacyFirmwareUpdate service doesn't implement the setForceTransportType pattern that ensures consistent transport layer usage during firmware updates. This pattern is used in the existing ServiceFirmwareUpdate to lock the transport type (USB/Bluetooth) during the update process, preventing connection switching mid-update.

Reference: See ServiceFirmwareUpdate.ts for the existing pattern implementation.

Recommendation: Consider adding transport type locking to ensure stable connections during legacy firmware updates, especially important when dealing with bootloader mode transitions.


Summary

Priority Issue Status
High README deletion ⚠️ Needs fix
Medium Transport type locking 📋 Consider adding

🤖 Automated code review by Claude Code

wabicai and others added 11 commits January 27, 2026 11:51
…e update

- Add transport type locking pattern to ServiceLegacyFirmwareUpdate
  to prevent auto-switching during firmware updates
- Lock transport type at start, clear in finally block
- Emit BeginFirmwareUpdate/FinishFirmwareUpdate events
- Create proper README.md documentation for the feature module

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…riction

- Remove firmware/bootloader version restrictions for Classic, Classic1s, ClassicPure
  devices so they all use normal startUpdateWorkflow
- Add Mini USB-only warning on Native platforms (iOS/Android) since Mini has no Bluetooth
- Auto-continue to normal ChangeLog modal after Legacy firmware update completes
  for remaining updates (bootloader, BLE, etc.)
- Fix version parameter passing in Legacy firmware handlers (TouchFirmwareHandler,
  MiniFirmwareHandler, ClassicFirmwareHandler)
- Remove upfront bootloader mode check in MiniFirmwareHandler
- Let SDK handle bootloader mode detection and throw FirmwareUpdateManuallyEnterBoot error
- Catch the error and show bootloader mode guidance UI
- Fix startLegacyUpdate to not set done state when needsBootloaderMode is true
- Add cleanupAfterUpdate method to properly cleanup on success/error only
- Keep running state and transport lock when waiting for bootloader mode

This follows the same pattern as firmware-updater-web - rely on SDK's
automatic handling rather than implementing custom pre-checks.
… guide

- Add illustration image (enter-boot-guide-mini.png) to MiniBootloaderModeGuide
- Add device polling (5s interval) when waiting for bootloader mode
- Auto-restart firmware update when device is detected in bootloader mode
- Show "Detecting device in bootloader mode..." status during polling
- Replace deprecated 'space' prop with 'gap' for consistency
- Add isRestartingRef to prevent multiple restart attempts
- Check if update still needs bootloader mode after restart attempt
- If device not in bootloader mode yet, reset flag and continue polling
- Remove immediate first poll to give user time to enter bootloader mode
- Only stop polling when update actually succeeds or is in progress
- Remove redundant Alert component to simplify UI and avoid text overflow
- Add bootloader mode verification in polling logic
- Only start firmware update when device.features.bootloader_mode is true
- Prevents flicker by not entering installing state until confirmed
The firmware update modal will be shown instead, so the toast is redundant.
This prevents showing both a toast and a modal at the same time.
The firmware update modal will be shown instead of a toast.
Similar to how DefectiveFirmware errors are handled.
Toast suppression should only apply during firmware update flow,
not globally for all scenarios where this error might occur.
In all scenarios (firmware update, signing, etc.), the firmware update
modal will be shown via ShowFirmwareUpdateForce event, so toast is redundant.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants