Skip to content

Conversation

@wabicai
Copy link
Member

@wabicai wabicai commented Sep 24, 2025

添加一个单独调用emmcFileWrite的方法,内部使用。只用于用户无法进入board更新boot的情况

Summary by CodeRabbit

  • New Features

    • Introduced EMMC file write capability in the core API and playground, enabling users to upload .bin files to a specified device path.
  • Chores

    • Updated all packages to version 1.1.14-alpha.1 and aligned dependencies across SDKs and transports.
    • Switched the default Connect script URL to the new 1.1.14-alpha.1 endpoint.
    • Minor internal cleanup in utilities (no user-facing impact).

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 24, 2025

Walkthrough

This change introduces a new emmcFileWrite API across core and example apps, adds a reboot helper to the firmware base method, updates a firmware methods preset in the Expo playground, adjusts a fallback Connect URL, removes an unused import, updates a comment, and bumps many package versions to 1.1.14-alpha.1.

Changes

Cohort / File(s) Summary
Core API: new EMMC write method
packages/core/src/api/EmmcFileWrite.ts, packages/core/src/api/index.ts, packages/core/src/inject.ts, packages/core/src/types/api/emmcFileWrite.ts, packages/core/src/types/api/index.ts, packages/core/src/types/api/export.ts
Adds emmcFileWrite method: implementation, central export, injection into CoreApi, and types (params and function signature).
Firmware base enhancement
packages/core/src/api/firmware/FirmwareUpdateBaseMethod.ts
Adds public reboot(rebootType) method and imports RebootType.
Example playground firmware preset
packages/connect-examples/expo-playground/app/data/methods/firmware.ts
Adds emmcFileWrite method config with parameters filePath (string) and payload (file).
Connect source fallback
packages/connect-examples/shared-constants/constants.js
Updates default getConnectSrc URL from ...alpha.0 to ...alpha.1.
Comment/docs and cleanup
packages/core/src/api/BaseMethod.ts, packages/core/src/utils/findDefectiveBatchDevice.ts
Updates allowDeviceMode comment wording; removes an unused import.
Examples: version bumps
packages/connect-examples/electron-example/package.json, packages/connect-examples/expo-example/package.json, packages/connect-examples/expo-playground/package.json, packages/connect-examples/shared-constants/package.json
Bumps versions to 1.1.14-alpha.1 and updates related deps to alpha.1.
Core and shared: version bumps
packages/core/package.json, packages/shared/package.json
Bumps package versions and aligned deps to 1.1.14-alpha.1.
Transports and SDKs: version bumps
packages/hd-ble-sdk/package.json, packages/hd-common-connect-sdk/package.json, packages/hd-transport-electron/package.json, packages/hd-transport-emulator/package.json, packages/hd-transport-http/package.json, packages/hd-transport-lowlevel/package.json, packages/hd-transport-react-native/package.json, packages/hd-transport-web-device/package.json, packages/hd-transport/package.json, packages/hd-web-sdk/package.json
Bumps versions to 1.1.14-alpha.1 and updates internal deps to alpha.1.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor App as App / SDK
  participant Core as Core API (inject)
  participant Method as EmmcFileWrite
  participant FWBase as FirmwareUpdateBaseMethod
  participant Dev as Device Transport

  App->>Core: emmcFileWrite(connectId, { payload, filePath, hash? })
  Core->>Method: call with params
  Note right of Method: Validate payload buffer and filePath string<br/>Allow modes: BOOTLOADER, NOT_INITIALIZE
  Method->>FWBase: ensureBootloader(connectId)
  FWBase->>Dev: Enter bootloader
  Method->>FWBase: emmcCommonUpdateProcess(payload, filePath)
  FWBase->>Dev: Stream EMMC data
  FWBase-->>Method: Update result
  Method->>FWBase: reboot(NORMAL)
  FWBase->>Dev: Reboot (errors ignored)
  Method-->>Core: { filePath }
  Core-->>App: Response
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "feat: support emmcFileWrite" is a short, single-sentence summary that accurately reflects the primary change in the patch (adding emmcFileWrite across core, types, API surface, and examples) and is specific and developer-focused rather than vague.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/emmcFileWrite

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


Comment @coderabbitai help to get the list of available commands and usage tips.

@revan-zhang
Copy link
Contributor

revan-zhang commented Sep 24, 2025

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

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 7

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between a8e18e9 and f17128c.

📒 Files selected for processing (27)
  • packages/connect-examples/electron-example/package.json (2 hunks)
  • packages/connect-examples/expo-example/package.json (2 hunks)
  • packages/connect-examples/expo-playground/app/data/methods/firmware.ts (1 hunks)
  • packages/connect-examples/expo-playground/package.json (2 hunks)
  • packages/connect-examples/shared-constants/constants.js (1 hunks)
  • packages/connect-examples/shared-constants/package.json (1 hunks)
  • packages/core/package.json (2 hunks)
  • packages/core/src/api/BaseMethod.ts (1 hunks)
  • packages/core/src/api/EmmcFileWrite.ts (1 hunks)
  • packages/core/src/api/firmware/FirmwareUpdateBaseMethod.ts (2 hunks)
  • packages/core/src/api/index.ts (1 hunks)
  • packages/core/src/inject.ts (1 hunks)
  • packages/core/src/types/api/emmcFileWrite.ts (1 hunks)
  • packages/core/src/types/api/export.ts (1 hunks)
  • packages/core/src/types/api/index.ts (2 hunks)
  • packages/core/src/utils/findDefectiveBatchDevice.ts (0 hunks)
  • packages/hd-ble-sdk/package.json (2 hunks)
  • packages/hd-common-connect-sdk/package.json (2 hunks)
  • packages/hd-transport-electron/package.json (2 hunks)
  • packages/hd-transport-emulator/package.json (2 hunks)
  • packages/hd-transport-http/package.json (2 hunks)
  • packages/hd-transport-lowlevel/package.json (2 hunks)
  • packages/hd-transport-react-native/package.json (2 hunks)
  • packages/hd-transport-web-device/package.json (2 hunks)
  • packages/hd-transport/package.json (1 hunks)
  • packages/hd-web-sdk/package.json (2 hunks)
  • packages/shared/package.json (1 hunks)
💤 Files with no reviewable changes (1)
  • packages/core/src/utils/findDefectiveBatchDevice.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: release-web
  • GitHub Check: Socket Security: Pull Request Alerts
  • GitHub Check: lint (22)
  • GitHub Check: build (22)
🔇 Additional comments (25)
packages/hd-transport-react-native/package.json (2)

22-23: Deps present — build unverified

Found @onekeyfe/hd-shared@1.1.14-alpha.1 (packages/shared/package.json) and @onekeyfe/hd-transport@1.1.14-alpha.1 (packages/hd-transport/package.json). Validate that packages/hd-transport-react-native builds clean against these (CI or local RN build).


3-3: Confirm version bump & lockfile update.

  • Ensure every package.json is set to 1.1.14-alpha.1 and no package.json still references 1.1.14-alpha.0.
  • Update/dedupe the repo lockfile (pnpm/yarn/npm) and commit the result.
packages/shared/package.json (1)

3-3: Version bump to alpha.1 — LGTM

packages/hd-transport-lowlevel/package.json (1)

3-3: Lockstep version/deps update looks consistent
All bumped to alpha.1 in tandem. Good.

Also applies to: 22-24

packages/hd-transport-web-device/package.json (1)

3-3: Alpha.1 alignment across package and deps — LGTM

Also applies to: 23-24, 27-27

packages/connect-examples/shared-constants/package.json (1)

3-3: Version bump — LGTM

packages/hd-transport-emulator/package.json (1)

3-3: Emulator and deps bumped to alpha.1 — LGTM

Also applies to: 27-28

packages/hd-transport/package.json (1)

3-3: Version bump aligned — no stale alpha.0 references found

Scanned the repo: packages/hd-transport/package.json is 1.1.14-alpha.1 and no occurrences of "1.1.14-alpha.0" or "alpha.0" were found.

packages/hd-web-sdk/package.json (1)

3-3: SDK and deps bumped — emmcFileWrite is present and exposed

Confirmed: hd-core implements and exports emmcFileWrite and the hd-web-sdk default export (HardwareWebSdk) will expose it.

  • packages/core/src/api/index.ts — exports emmcFileWrite
  • packages/core/src/inject.ts — inject maps emmcFileWrite -> call(..., method: 'emmcFileWrite')
  • packages/hd-web-sdk/src/index.ts — imports HardwareSdk from '@onekeyfe/hd-core' and returns HardwareWebSdk
packages/connect-examples/expo-playground/package.json (1)

3-3: Playground deps aligned to alpha.1.

Looks good and consistent with core updates.

Also applies to: 20-22

packages/core/package.json (1)

3-3: Core version and deps bumped correctly.

hd-shared and hd-transport align to alpha.1. No issues spotted.

Also applies to: 28-29

packages/hd-transport-http/package.json (1)

3-3: HTTP transport version alignment LGTM.

Deps updated to alpha.1 as expected.

Also applies to: 27-28

packages/core/src/types/api/export.ts (1)

29-29: Type export added for EmmcFileWriteParams.

Placement alongside firmware types makes sense. Good.

packages/connect-examples/expo-example/package.json (1)

3-3: Expo example deps in sync with alpha.1.

Matches other packages. All good.

Also applies to: 22-25

packages/hd-transport-electron/package.json (1)

3-3: Electron transport version bump OK.

Deps align to alpha.1. No issues spotted.

Also applies to: 28-30

packages/hd-ble-sdk/package.json (1)

3-3: Sweep for leftover alpha.0 references

All three deps align to 1.1.14-alpha.1 — good. Local rg search for '1.1.14-alpha.0' returned no output here; absence can't be confirmed. Run locally: rg -n --glob '**/package.json' '1.1.14-alpha.0' (or broader: rg -n 'alpha.0') and report results.

packages/core/src/api/index.ts (1)

40-40: Approve — emmcFileWrite export wired end-to-end

Implementation, default export, re-export, types, and CoreApi injection are present and correctly wired (packages/core/src/api/EmmcFileWrite.ts, packages/core/src/api/index.ts, packages/core/src/types/api/emmcFileWrite.ts + export.ts, packages/core/src/inject.ts).

packages/core/src/inject.ts (1)

262-262: API wiring looks good

emmcFileWrite is correctly forwarded with connectId and method set.

packages/core/src/api/BaseMethod.ts (1)

61-63: Doc tweak LGTM

The description for allowed device modes reads clearer now.

packages/core/src/api/firmware/FirmwareUpdateBaseMethod.ts (1)

406-416: Reboot helper is a solid addition

Encapsulating Reboot via typedCall keeps flows cleaner and re‑usable.

packages/hd-common-connect-sdk/package.json (1)

3-3: Workspace versions aligned

Version and internal deps bumped to alpha.1 consistently.

Also applies to: 23-29

packages/core/src/api/EmmcFileWrite.ts (1)

1-50: Straightforward and safe flow

Validates input, ensures bootloader, streams chunks with base method, and attempts a reboot. Looks good.

packages/connect-examples/electron-example/package.json (1)

5-5: Version bump looks consistent — no alpha.0 stragglers found

Repo-wide search and package.json scan found no occurrences of "-alpha.0" or "1.1.14-alpha.0".

packages/connect-examples/expo-playground/app/data/methods/firmware.ts (2)

116-121: Confirmed: use '0:boot/...'

Repository examples use '0:boot/bootloader.bin' (packages/core/src/types/api/emmcFileWrite.ts, packages/core/src/api/FirmwareUpdateV3.ts); keep the current placeholder.


124-132: Confirmed — file-to-ArrayBuffer conversion is implemented

convertFilesToArrayBuffers (packages/connect-examples/expo-playground/app/store/hardwareStore.ts) converts top-level File params to ArrayBuffer; useMethodExecution (packages/connect-examples/expo-playground/app/hooks/useMethodExecution.ts) calls it for type === 'firmware'; device-methods route marks firmware.api methods (including emmcFileWrite) as firmware, so payload will be converted before the API call.

@wabicai wabicai enabled auto-merge (squash) September 25, 2025 03:55
@wabicai wabicai requested a review from originalix September 25, 2025 06:03
@wabicai wabicai merged commit f087634 into onekey Sep 25, 2025
17 checks passed
@wabicai wabicai deleted the feat/emmcFileWrite branch September 25, 2025 06:12
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.

4 participants