Skip to content

new bootloader support upgrading multiple files && adjust touchscreen sensitivity. #287

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 11, 2025

Conversation

lihuanhuan
Copy link
Contributor

@lihuanhuan lihuanhuan commented Apr 11, 2025

Summary by CodeRabbit

  • New Features

    • Enhanced firmware update progress feedback with more accurate percent reporting and smoother display transitions.
    • Introduced double-tap wake functionality on the lock screen with updated, multilingual instructions.
    • Improved device responsiveness through refined USB, Bluetooth, and boot processes.
    • Added a new DoubleClickDetector class for better handling of double-click events.
  • User Interface

    • Refined homescreen and app drawer layouts with adjusted animations and container sizes for a more streamlined user experience.

@lihuanhuan lihuanhuan requested a review from a team as a code owner April 11, 2025 12:56
Copy link

coderabbitai bot commented Apr 11, 2025

Walkthrough

This pull request introduces numerous enhancements and updates across the codebase. It adds new functions and variables for progress tracking and user feedback in the bootloader modules. USB communication and firmware update procedures have been revised with added timeout and error handling logic. Several configuration parameters, version constants, and interface macros were updated. New structures and enumerations improve firmware update support. User interface strings and interaction instructions have been modified in multiple localization files to require a double-tap instead of a single tap. Additionally, a double-click detector class and various UI layout adjustments have been added to enhance user experience.

Changes

File(s) Change Summary
core/embed/bootloader/bootui.c, bootui.h Added current_progress_value and new functions (get_current_progress_value, format_progress_value, ui_screen_progress_bar_init, ui_show_version_info, ui_update_info_show); updated ui_screen_install_confirm_newvendor_or_downgrade_wipe and modified progress calculations in update functions.
core/embed/bootloader/main.c Added bootloader_usb_loop_tiny, enable_usb_tiny_task, disable_usb_tiny_task, and enter_boot_forced; modified main loop for forced boot.
core/embed/bootloader/messages.c, messages.h Added send_msg_features_simple; removed delay in USB write flush.
core/embed/bootloader/version.h Updated version constants: VERSION_MINOR from 7 to 8 and VERSION_PATCH from 1 to 0.
core/embed/emmc_wrapper/emmc_commands.c, emmc_commands.h Updated error handling with iface_num checks; added delete_bootloader_update and check_firmware_from_file; restructured firmware update processing.
core/embed/emmc_wrapper/emmc_fs.c, emmc_fs.h Added new function emmc_fs_path_type and enum PathType for file/directory classification.
core/embed/extmod/…/display.c Simplified progress calculations by removing unnecessary scaling in _display_progress.
core/embed/trezorhal/ble.c, ble.h Added ble_get_version_with_timeout and updated existing BLE version retrieval logic.
core/embed/trezorhal/fatfs/ffconf.h Enabled relative path support by changing FF_FS_RPATH from 0 to 1.
core/embed/trezorhal/gt911.c, gt911.h Modified sleep register (now using GTP_REG_COMMAND); added gt911_set_config, new configuration constants, struct GT911_Config_t, and IRQ functions.
core/embed/trezorhal/image.c, image.h Updated install_firmware to include percent_start and weights parameters and progress calculation; added version copy in header; introduced new update enums and structures.
core/embed/trezorhal/nordic_dfu.c, nordic_dfu.h Changed progress scaling from 1000 to 100; updated bluetooth_update signature with percent_start and weights and simplified callback parameter.
core/embed/trezorhal/spi_legacy.c Added a call to fifo_flush(&spi_fifo_in) at the end of _spi_slave_poll_ex.
core/embed/trezorhal/systick.h Renamed enum value from SYSTICK_DISPATCH_DMA to SYSTICK_DISPATCH_USB_TINY.
core/embed/trezorhal/thd89_boot.c, thd89_boot.h Updated se_update_firmware signature to include percent_start and weights; adjusted progress calculation accordingly.
core/embed/trezorhal/usb.h Added macros USB_IFACE_NUM 0 and USB_IFACE_NULL 0xFF for USB interface management.
core/src/all_modules.py Added import statements for the doubleclick component.
core/src/trezor/lvglui/i18n/(keys.py, locales files) Updated UI text and comments in multiple localization files to change instructions from "tap" to "double-tap" the screen.
core/src/trezor/lvglui/scrs/components/doubleclick.py Added the new DoubleClickDetector class for detecting double-click events.
core/src/trezor/lvglui/scrs/homescreen.py Added new animation timing constants and adjusted container sizes and element alignment for UI layout.
core/src/trezor/lvglui/scrs/lockscreen.py Integrated DoubleClickDetector by adding a double_click instance to handle double-click events on the lock screen.

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@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: 6

🔭 Outside diff range comments (1)
core/embed/trezorhal/thd89_boot.c (1)

156-170: ⚠️ Potential issue

Fix potential division by zero in progress calculation.

Progress calculation doesn't handle zero data_len.

 bool se_update_firmware(uint8_t *data, uint32_t data_len, uint8_t percent_start,
                         uint8_t weights, void (*ui_callback)(int progress)) {
   uint32_t offset_len = 0;
   while (data_len) {
     uint32_t packet_len = data_len > 512 ? 512 : data_len;

     if (!se_update(2, data + offset_len, packet_len)) {
       return false;
     }
     data_len -= packet_len;
     offset_len += packet_len;
     if (ui_callback) {
-      ui_callback(percent_start +
-                  weights * offset_len / (offset_len + data_len));
+      ui_callback(percent_start + 
+                  (data_len + offset_len > 0 ? weights * offset_len / (offset_len + data_len) : weights));
     }
   }
🧹 Nitpick comments (12)
core/src/trezor/lvglui/scrs/homescreen.py (1)

321-326: Remove debug print statement.

Print statement logs button coordinates. Should be removed before production.

-            btn.align(lv.ALIGN.TOP_MID, 0, 0)
-
-            coords = lv.area_t()
-            btn.get_coords(coords)
-            print(f"btn_coords: {coords.x1}, {coords.y1}, {coords.x2}, {coords.y2}")
+            btn.align(lv.ALIGN.TOP_MID, 0, 0)
core/embed/emmc_wrapper/emmc_commands.h (1)

199-199: Missing function documentation.

The new firmware check function lacks comments.

Add comment explaining what this function does, its return values, and error cases.

core/embed/bootloader/messages.h (1)

46-46: Undocumented function.

New function has no description.

Add comment explaining what "features_simple" means and how it differs from other feature messages.

core/embed/trezorhal/usb.h (1)

27-29: Ambiguous constant purpose.

New USB interface constants lack explanatory comments.

Add comments explaining the purpose of these constants and why 0xFF was chosen for NULL.

core/embed/trezorhal/ble.h (1)

136-136: Add missing documentation for new function.

The function purpose is unclear from declaration alone.

core/embed/emmc_wrapper/emmc_fs.c (1)

225-232: Fix potentially confusing code order.

Put null check before doing work.

-    if ( file_info.fattrib & AM_DIR )
-    {
-        *path_type = PATH_DIR;
-    }
-    else
-    {
-        *path_type = PATH_FILE;
-    }
+    *path_type = (file_info.fattrib & AM_DIR) ? PATH_DIR : PATH_FILE;
core/embed/trezorhal/systick.h (1)

39-39: Update comments for renamed enum.

Rename changed but docs stay same.

core/embed/emmc_wrapper/emmc_fs.h (1)

71-75: Fix enum name style.

Use CAPS_STYLE for enum values like other code.

 typedef enum
 {
-    PATH_FILE,
-    PATH_DIR
+    PATH_FILE_TYPE,
+    PATH_DIR_TYPE
 } PathType;
core/embed/trezorhal/gt911.c (1)

138-163: Add touchscreen sensitivity configuration.

Config changes adjust touchscreen sensitivity parameters but lack comments.

 void gt911_set_config(void) {
   uint8_t config_data[sizeof(GT911_Config_t)] = {0};
   GT911_Config_t *p_config = (GT911_Config_t *)config_data;

   gt911_read(GTP_REG_CONFIG_DATA, (uint8_t *)config_data, 1);
   if (config_data[0] == 0x4F) {
     return;
   }

   gt911_read(GTP_REG_CONFIG_DATA, (uint8_t *)config_data, sizeof(config_data));

   p_config->config_version = 0x4F;  // 'O'

+  // Increase touch stability
   p_config->shake_count = 0x22;
+  // Reduce interference from noise
   p_config->noise_reduction = 10;
+  // Adjust touch sensitivity
   p_config->screen_touch_level = 0xA0;

   p_config->check_sum = 0;
   for (int i = 0; i < sizeof(config_data) - 2; i++) {
     p_config->check_sum += config_data[i];
   }
   p_config->check_sum = (~p_config->check_sum) + 1;
   p_config->config_refresh = 0x01;

   gt911_write(GTP_REG_CONFIG_DATA, (uint8_t *)config_data, sizeof(config_data));
 }
core/embed/trezorhal/thd89_boot.h (1)

27-28: Updated function signature lacks parameter documentation.

Function now has progress tracking parameters without comments.

-bool se_update_firmware(uint8_t *data, uint32_t data_len, uint8_t percent_start,
-                        uint8_t weights, void (*ui_callback)(int progress));
+// Updates the firmware with progress tracking
+// @param data: Firmware data pointer
+// @param data_len: Length of firmware data
+// @param percent_start: Starting percentage for progress (0-100)
+// @param weights: Weight factor for progress calculation
+// @param ui_callback: Callback function for progress updates
+bool se_update_firmware(uint8_t *data, uint32_t data_len, uint8_t percent_start,
+                        uint8_t weights, void (*ui_callback)(int progress));
core/embed/trezorhal/ble.c (1)

97-119: Added duplicate version fetching with timeout.

New function duplicates code from old function.

+bool ble_get_version_with_timeout(char **ver) {
+  if (get_ble_ver) {
+    *ver = ble_ver;
+    return true;
+  }
+  ble_cmd_req(BLE_INFO, BLE_INFO_VER_FW);
+  uint8_t counter = 0;
+  while (1) {
+    ble_uart_poll();
+    if (get_ble_ver) {
+      *ver = ble_ver;
+      break;
+    }
+    counter++;
+    hal_delay(100);
+    if (counter > 20) {
+      return false;
+    }
+    ble_cmd_req(BLE_INFO, BLE_INFO_VER_FW);
+  }
+
+  return true;
+}

Consider refactoring both functions to use a common helper with a timeout parameter.

core/embed/trezorhal/nordic_dfu.c (1)

287-287: Typo
‘totol_len’ is misspelled.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 09b3718 and a736e52.

📒 Files selected for processing (41)
  • core/embed/bootloader/bootui.c (10 hunks)
  • core/embed/bootloader/bootui.h (3 hunks)
  • core/embed/bootloader/main.c (4 hunks)
  • core/embed/bootloader/messages.c (1 hunks)
  • core/embed/bootloader/messages.h (1 hunks)
  • core/embed/bootloader/version.h (1 hunks)
  • core/embed/emmc_wrapper/emmc_commands.c (9 hunks)
  • core/embed/emmc_wrapper/emmc_commands.h (1 hunks)
  • core/embed/emmc_wrapper/emmc_fs.c (1 hunks)
  • core/embed/emmc_wrapper/emmc_fs.h (2 hunks)
  • core/embed/extmod/modtrezorui/display.c (1 hunks)
  • core/embed/trezorhal/ble.c (1 hunks)
  • core/embed/trezorhal/ble.h (1 hunks)
  • core/embed/trezorhal/fatfs/ffconf.h (1 hunks)
  • core/embed/trezorhal/gt911.c (2 hunks)
  • core/embed/trezorhal/gt911.h (1 hunks)
  • core/embed/trezorhal/image.c (3 hunks)
  • core/embed/trezorhal/image.h (2 hunks)
  • core/embed/trezorhal/nordic_dfu.c (3 hunks)
  • core/embed/trezorhal/nordic_dfu.h (1 hunks)
  • core/embed/trezorhal/spi_legacy.c (1 hunks)
  • core/embed/trezorhal/systick.h (1 hunks)
  • core/embed/trezorhal/thd89_boot.c (2 hunks)
  • core/embed/trezorhal/thd89_boot.h (1 hunks)
  • core/embed/trezorhal/usb.h (1 hunks)
  • core/src/all_modules.py (1 hunks)
  • core/src/trezor/lvglui/i18n/keys.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/de.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/en.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/es.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/fr.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/it.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/ja.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/ko.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/pt_br.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/ru.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/zh_cn.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/zh_hk.py (1 hunks)
  • core/src/trezor/lvglui/scrs/components/doubleclick.py (1 hunks)
  • core/src/trezor/lvglui/scrs/homescreen.py (6 hunks)
  • core/src/trezor/lvglui/scrs/lockscreen.py (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (11)
core/embed/emmc_wrapper/emmc_fs.c (1)
core/embed/emmc_wrapper/emmc_fs.h (1)
  • emmc_fs_path_type (125-125)
core/embed/bootloader/messages.c (3)
core/embed/bootloader/messages.h (1)
  • send_msg_features_simple (46-46)
core/src/trezor/messages.py (1)
  • Features (2919-3093)
python/src/trezorlib/messages.py (1)
  • Features (4331-4588)
core/src/trezor/lvglui/scrs/components/doubleclick.py (3)
crypto/tests/test_curves.py (1)
  • point (159-168)
core/embed/rust/src/micropython/time.rs (1)
  • ticks_ms (5-7)
core/embed/rust/src/ui/geometry.rs (3)
  • abs (74-76)
  • x (52-54)
  • y (56-58)
core/embed/trezorhal/ble.c (3)
core/embed/trezorhal/ble.h (3)
  • ble_get_version_with_timeout (136-136)
  • ble_cmd_req (106-106)
  • ble_uart_poll (108-108)
core/embed/trezorhal/common.c (1)
  • hal_delay (292-292)
core/embed/trezorhal/common.h (1)
  • hal_delay (107-107)
core/embed/trezorhal/gt911.c (1)
core/embed/trezorhal/gt911.h (1)
  • gt911_init (124-124)
core/embed/trezorhal/thd89_boot.h (1)
core/embed/trezorhal/flash.h (1)
  • progress (76-76)
core/embed/bootloader/main.c (9)
core/embed/trezorhal/spi_legacy.h (1)
  • spi_slave_poll (37-37)
core/embed/bootloader/messages.c (1)
  • send_msg_features_simple (326-338)
core/embed/bootloader/messages.h (1)
  • send_msg_features_simple (46-46)
core/embed/emmc_wrapper/emmc_commands.c (1)
  • check_firmware_from_file (1311-1328)
core/embed/trezorhal/usb.h (1)
  • usb_start (148-148)
core/embed/trezorhal/systick.h (4)
  • systick_enable_dispatch (49-51)
  • systick_enable_dispatch (49-49)
  • systick_disable_dispatch (53-55)
  • systick_disable_dispatch (53-53)
core/embed/emmc_wrapper/emmc_commands.h (1)
  • check_firmware_from_file (199-199)
core/embed/trezorhal/touch.h (1)
  • touch_read (60-60)
core/embed/trezorhal/common.h (1)
  • hal_delay (107-107)
core/embed/trezorhal/thd89_boot.c (2)
core/embed/trezorhal/thd89_boot.h (2)
  • se_update_firmware (27-28)
  • ui_callback (28-28)
core/embed/trezorhal/flash.h (1)
  • progress (76-76)
core/embed/emmc_wrapper/emmc_commands.c (9)
core/embed/bootloader/messages.c (1)
  • send_failure (312-317)
core/embed/bootloader/messages.h (1)
  • send_failure (41-41)
core/embed/trezorhal/se_thd89.h (1)
  • se01_get_version (54-54)
core/embed/trezorhal/ble.h (1)
  • ble_get_version_with_timeout (136-136)
core/embed/trezorhal/ble.c (1)
  • ble_get_version_with_timeout (97-119)
core/embed/emmc_wrapper/emmc_fs.h (1)
  • emmc_fs_file_delete (138-138)
core/embed/emmc_wrapper/emmc_fs.c (1)
  • emmc_fs_file_delete (476-516)
core/embed/trezorhal/thd89_boot.h (1)
  • se_update_firmware (27-28)
core/embed/trezorhal/thd89_boot.c (1)
  • se_update_firmware (156-174)
core/embed/trezorhal/image.c (2)
core/embed/trezorhal/image.h (2)
  • progress_callback (190-190)
  • progress_callback (201-201)
crypto/cardano.h (1)
  • progress_callback (45-45)
core/embed/bootloader/bootui.c (1)
core/embed/bootloader/bootui.h (12)
  • format_progress_value (27-27)
  • ui_screen_install_confirm_newvendor_or_downgrade_wipe (47-47)
  • ui_screen_progress_bar_init (54-54)
  • ui_statusbar_update (83-83)
  • ui_screen_progress_bar_prepare (55-55)
  • ui_screen_progress_bar_update (56-56)
  • ui_screen_install_progress_upload (50-50)
  • ui_screen_install_title_clear (91-91)
  • ui_show_version_info (90-90)
  • ui_update_info_show (96-96)
  • ui_bootloader_first (87-87)
  • format_ver (29-29)
🪛 Cppcheck (2.10-2)
core/embed/emmc_wrapper/emmc_commands.c

[error] 881-881: failed to expand 'ExecuteCheck_MSGS_ADV', it is invalid to use a preprocessor directive as macro parameter

(preprocessorErrorDirective)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Defs check
  • GitHub Check: Gen check
  • GitHub Check: Style check
🔇 Additional comments (82)
core/src/trezor/lvglui/i18n/locales/ja.py (1)

360-361: Updated wake screen instruction to double-tap

core/src/trezor/lvglui/i18n/locales/zh_hk.py (1)

360-361: Updated wake screen instruction to double-tap

core/src/trezor/lvglui/i18n/locales/en.py (1)

360-361: Updated wake screen instruction to double-tap

core/src/trezor/lvglui/i18n/locales/de.py (1)

360-361: Updated wake screen instruction to double-tap

core/src/trezor/lvglui/i18n/locales/pt_br.py (1)

360-361: Update to double-tap gesture looks good.

The instructions now clearly tell users to double-tap the screen instead of a single tap, matching the new touchscreen sensitivity adjustment.

core/src/trezor/lvglui/i18n/locales/ru.py (1)

360-361: Russian translation properly updated for double-tap.

Text now correctly indicates double-tap gesture requirement.

core/src/trezor/lvglui/i18n/locales/zh_cn.py (1)

360-361: Chinese double-tap instructions correctly implemented.

Good update to match new gesture requirement.

core/src/trezor/lvglui/i18n/locales/es.py (1)

360-361: Spanish double-tap instructions look good.

Text properly updated from single to double-tap gesture.

core/src/all_modules.py (1)

216-217: Clean addition of required imports for the double-click detector.

The new imports enable the double-click functionality used in the lock screen.

core/src/trezor/lvglui/i18n/keys.py (1)

788-790: User instruction updated to match new double-tap behavior.

Updated comment and label text correctly reflect the new double-tap requirement.

core/src/trezor/lvglui/scrs/lockscreen.py (3)

7-7: Added import for the new DoubleClickDetector.

The import is correctly placed with other component imports.


27-27: Added double-click detector with appropriate timeout and distance settings.

The detector is initialized with sensible parameters for recognizing intentional double taps.


159-169: Implemented double-tap check logic in the click event handler.

The code now properly requires a double-tap to wake the screen when the display is off, while preserving other click handling behavior.

core/src/trezor/lvglui/i18n/locales/ko.py (1)

360-361: Korean translation updated to reflect double-tap requirement.

The translated text now correctly instructs users to double-tap to wake.

core/src/trezor/lvglui/i18n/locales/it.py (1)

360-361: LGTM - Translation updated to specify double tap instead of single tap.

The string changes correctly instruct users to double-tap the screen instead of a single tap.

core/src/trezor/lvglui/i18n/locales/fr.py (1)

360-361: LGTM - French translation updated for double tap functionality.

The French strings are correctly updated to indicate double-tap interaction.

core/src/trezor/lvglui/scrs/components/doubleclick.py (1)

1-44: New double-click detection class looks good.

Clean implementation of a double-click detector with appropriate timeout and distance threshold parameters.

core/src/trezor/lvglui/scrs/homescreen.py (5)

55-58: Move constants outside debug block.

Constants for app drawer animation timing now work in non-debug builds too.


260-260: Increased main container height.

Main container height increased from 550 to 575 pixels.


298-308: Taller app drawer items.

Container height increased from 256 to 280 pixels.


341-342: Repositioned label below button.

Label now aligns to button bottom with 8px spacing.


375-377: Animation constants directly used.

No more conditional checks for debug mode in animation setup.

core/embed/bootloader/version.h (1)

2-3: Version update for new release.

Version changed from 2.7.1 to 2.8.0, indicating a new minor release.

core/embed/trezorhal/spi_legacy.c (1)

358-358: Added buffer cleanup for unhandled communication cases.

Adding FIFO flush prevents data accumulation when communication patterns don't match expected formats.

core/embed/bootloader/messages.c (1)

326-338: New helper function for simplified feature reporting.

Function provides essential device information without requiring firmware header parsing.

core/embed/trezorhal/gt911.c (2)

172-172: Add config setup to initialization.


114-114:

❌ Incorrect review comment

Fix register address used for sleep mode.

The change from GTP_REG_SLEEP to GTP_REG_COMMAND may affect sleep mode behavior.


🏁 Script executed:

#!/bin/bash
# Check if GTP_REG_COMMAND is the correct register for sleep command
grep -r "GTP_REG_COMMAND" --include="*.h" .
grep -r "GTP_REG_SLEEP" --include="*.h" .

Length of output: 215


Register for sleep mode is correct.
Verification confirms that only GTP_REG_COMMAND is defined. There is no sign of GTP_REG_SLEEP in the codebase.

Likely an incorrect or invalid review comment.

core/embed/bootloader/bootui.h (5)

27-27: No issues


47-47: No issues


54-54: No issues


90-91: No issues


96-96: No issues

core/embed/trezorhal/image.c (3)

152-152: No issues


537-538: No issues


717-717: No issues

core/embed/emmc_wrapper/emmc_commands.c (24)

448-451: No issues


459-462: No issues


470-473: No issues


503-503: No issues


536-541: No issues


542-542: No issues


551-557: No issues


561-565: No issues


567-567: No issues


570-576: No issues


577-628: No issues


631-664: No issues


666-682: No issues


688-688: No issues


690-727: No issues


732-732: No issues


735-741: No issues


743-748: No issues


750-781: No issues


790-796: No issues


798-851: No issues


856-1310: No issues

🧰 Tools
🪛 Cppcheck (2.10-2)

[error] 881-881: failed to expand 'ExecuteCheck_MSGS_ADV', it is invalid to use a preprocessor directive as macro parameter

(preprocessorErrorDirective)


1311-1328: No issues


1330-1416: No issues

core/embed/trezorhal/image.h (5)

97-103: No issue


105-107: No issue


108-113: No issue


114-123: No issue


199-200: No issue

core/embed/trezorhal/gt911.h (4)

8-8: No issue


11-12: No issue


15-21: No issue


25-120: No issue

core/embed/bootloader/bootui.c (14)

121-122: No issue


126-130: No issue


266-266: No issue


284-285: No issue


304-304: No issue


336-344: No issue


352-361: No issue


382-382: No issue


385-388: No issue


419-419: No issue


674-677: No issue


679-686: No issue


753-823: No issue


830-834: No issue

Copy link

@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: 2

🧹 Nitpick comments (1)
core/embed/trezorhal/image.h (1)

106-106: Comment needed for clarity.

No explanation of "MCU, 4 SE, BLE" = 6 count. Add code comment explaining calculation.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between a736e52 and 85b1ba7.

📒 Files selected for processing (2)
  • core/embed/emmc_wrapper/emmc_commands.c (9 hunks)
  • core/embed/trezorhal/image.h (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
core/embed/emmc_wrapper/emmc_commands.c (12)
core/embed/bootloader/messages.h (1)
  • send_failure (41-41)
core/embed/bootloader/messages.c (1)
  • send_failure (312-317)
core/embed/bootloader/bootui.h (6)
  • ui_fadeout (68-68)
  • ui_update_info_show (96-96)
  • ui_fadein (67-67)
  • ui_screen_progress_bar_init (54-54)
  • ui_screen_install_progress_upload (50-50)
  • ui_screen_install_confirm_newvendor_or_downgrade_wipe (47-47)
core/embed/bootloader/bootui.c (6)
  • ui_fadeout (493-496)
  • ui_update_info_show (753-823)
  • ui_fadein (491-491)
  • ui_screen_progress_bar_init (336-344)
  • ui_screen_install_progress_upload (385-388)
  • ui_screen_install_confirm_newvendor_or_downgrade_wipe (266-308)
core/embed/trezorhal/se_thd89.h (2)
  • se01_get_version (54-54)
  • se_reset_storage (45-45)
core/embed/trezorhal/se_thd89.c (2)
  • se01_get_version (680-690)
  • se_reset_storage (612-616)
core/embed/trezorhal/ble.h (1)
  • ble_get_version_with_timeout (136-136)
core/embed/trezorhal/ble.c (1)
  • ble_get_version_with_timeout (97-119)
core/embed/emmc_wrapper/emmc_fs.c (1)
  • emmc_fs_file_delete (476-516)
core/embed/emmc_wrapper/emmc_fs.h (1)
  • emmc_fs_file_delete (138-138)
core/embed/trezorhal/common.c (1)
  • hal_delay (292-292)
core/embed/trezorhal/common.h (1)
  • hal_delay (107-107)
🪛 Cppcheck (2.10-2)
core/embed/emmc_wrapper/emmc_commands.c

[error] 881-881: failed to expand 'ExecuteCheck_MSGS_ADV', it is invalid to use a preprocessor directive as macro parameter

(preprocessorErrorDirective)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Gen check
  • GitHub Check: Defs check
  • GitHub Check: Style check

Copy link

@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: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 85b1ba7 and 1d160b5.

📒 Files selected for processing (41)
  • core/embed/bootloader/bootui.c (10 hunks)
  • core/embed/bootloader/bootui.h (3 hunks)
  • core/embed/bootloader/main.c (4 hunks)
  • core/embed/bootloader/messages.c (1 hunks)
  • core/embed/bootloader/messages.h (1 hunks)
  • core/embed/bootloader/version.h (1 hunks)
  • core/embed/emmc_wrapper/emmc_commands.c (9 hunks)
  • core/embed/emmc_wrapper/emmc_commands.h (1 hunks)
  • core/embed/emmc_wrapper/emmc_fs.c (1 hunks)
  • core/embed/emmc_wrapper/emmc_fs.h (2 hunks)
  • core/embed/extmod/modtrezorui/display.c (1 hunks)
  • core/embed/trezorhal/ble.c (1 hunks)
  • core/embed/trezorhal/ble.h (1 hunks)
  • core/embed/trezorhal/fatfs/ffconf.h (1 hunks)
  • core/embed/trezorhal/gt911.c (2 hunks)
  • core/embed/trezorhal/gt911.h (1 hunks)
  • core/embed/trezorhal/image.c (3 hunks)
  • core/embed/trezorhal/image.h (2 hunks)
  • core/embed/trezorhal/nordic_dfu.c (3 hunks)
  • core/embed/trezorhal/nordic_dfu.h (1 hunks)
  • core/embed/trezorhal/spi_legacy.c (1 hunks)
  • core/embed/trezorhal/systick.h (1 hunks)
  • core/embed/trezorhal/thd89_boot.c (2 hunks)
  • core/embed/trezorhal/thd89_boot.h (1 hunks)
  • core/embed/trezorhal/usb.h (1 hunks)
  • core/src/all_modules.py (1 hunks)
  • core/src/trezor/lvglui/i18n/keys.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/de.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/en.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/es.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/fr.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/it.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/ja.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/ko.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/pt_br.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/ru.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/zh_cn.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/zh_hk.py (1 hunks)
  • core/src/trezor/lvglui/scrs/components/doubleclick.py (1 hunks)
  • core/src/trezor/lvglui/scrs/homescreen.py (6 hunks)
  • core/src/trezor/lvglui/scrs/lockscreen.py (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (34)
  • core/embed/bootloader/messages.h
  • core/embed/emmc_wrapper/emmc_commands.h
  • core/embed/emmc_wrapper/emmc_fs.h
  • core/src/trezor/lvglui/i18n/locales/de.py
  • core/src/trezor/lvglui/i18n/locales/es.py
  • core/src/trezor/lvglui/i18n/keys.py
  • core/embed/emmc_wrapper/emmc_fs.c
  • core/embed/trezorhal/usb.h
  • core/src/trezor/lvglui/i18n/locales/en.py
  • core/embed/extmod/modtrezorui/display.c
  • core/src/trezor/lvglui/i18n/locales/zh_cn.py
  • core/embed/trezorhal/ble.h
  • core/embed/bootloader/version.h
  • core/src/trezor/lvglui/i18n/locales/ru.py
  • core/src/trezor/lvglui/scrs/lockscreen.py
  • core/embed/trezorhal/systick.h
  • core/src/all_modules.py
  • core/embed/trezorhal/spi_legacy.c
  • core/embed/bootloader/messages.c
  • core/embed/trezorhal/fatfs/ffconf.h
  • core/src/trezor/lvglui/scrs/components/doubleclick.py
  • core/embed/trezorhal/thd89_boot.h
  • core/src/trezor/lvglui/i18n/locales/pt_br.py
  • core/src/trezor/lvglui/i18n/locales/fr.py
  • core/src/trezor/lvglui/i18n/locales/it.py
  • core/embed/trezorhal/nordic_dfu.h
  • core/src/trezor/lvglui/i18n/locales/ja.py
  • core/embed/trezorhal/thd89_boot.c
  • core/embed/bootloader/bootui.h
  • core/src/trezor/lvglui/i18n/locales/ko.py
  • core/src/trezor/lvglui/i18n/locales/zh_hk.py
  • core/embed/trezorhal/image.c
  • core/src/trezor/lvglui/scrs/homescreen.py
  • core/embed/trezorhal/gt911.h
🧰 Additional context used
🧬 Code Graph Analysis (5)
core/embed/trezorhal/gt911.c (1)
core/embed/trezorhal/gt911.h (1)
  • gt911_init (124-124)
core/embed/bootloader/main.c (8)
core/embed/trezorhal/spi_legacy.h (1)
  • spi_slave_poll (37-37)
core/embed/bootloader/messages.h (2)
  • send_msg_features_simple (46-46)
  • send_failure (41-41)
core/embed/bootloader/bootui.h (1)
  • format_progress_value (27-27)
core/embed/trezorhal/usb.h (1)
  • usb_start (148-148)
core/embed/trezorhal/systick.h (4)
  • systick_enable_dispatch (49-51)
  • systick_enable_dispatch (49-49)
  • systick_disable_dispatch (53-55)
  • systick_disable_dispatch (53-53)
core/embed/emmc_wrapper/emmc_commands.h (1)
  • check_firmware_from_file (199-199)
core/embed/trezorhal/touch.h (1)
  • touch_read (60-60)
core/embed/trezorhal/common.h (1)
  • hal_delay (107-107)
core/embed/trezorhal/nordic_dfu.c (1)
core/embed/trezorhal/nordic_dfu.h (1)
  • ui_display_progressBar (56-56)
core/embed/emmc_wrapper/emmc_commands.c (9)
core/embed/bootloader/messages.h (1)
  • send_failure (41-41)
core/embed/bootloader/messages.c (1)
  • send_failure (312-317)
core/embed/trezorhal/image.h (2)
  • load_vendor_header (165-167)
  • load_image_header (150-153)
core/embed/trezorhal/image.c (2)
  • load_vendor_header (213-238)
  • load_image_header (59-107)
core/embed/trezorhal/se_thd89.h (1)
  • se_reset_storage (45-45)
core/embed/trezorhal/ble.c (1)
  • ble_get_version_with_timeout (97-119)
core/embed/trezorhal/ble.h (1)
  • ble_get_version_with_timeout (136-136)
core/embed/trezorhal/thd89_boot.h (1)
  • se_update_firmware (27-28)
core/embed/trezorhal/thd89_boot.c (1)
  • se_update_firmware (156-174)
core/embed/bootloader/bootui.c (1)
core/embed/bootloader/bootui.h (12)
  • format_progress_value (27-27)
  • ui_screen_install_confirm_newvendor_or_downgrade_wipe (47-47)
  • ui_screen_progress_bar_init (54-54)
  • ui_statusbar_update (83-83)
  • ui_screen_progress_bar_prepare (55-55)
  • ui_screen_progress_bar_update (56-56)
  • ui_screen_install_progress_upload (50-50)
  • ui_screen_install_title_clear (91-91)
  • ui_show_version_info (90-90)
  • ui_update_info_show (96-96)
  • ui_bootloader_first (87-87)
  • format_ver (29-29)
🪛 Cppcheck (2.10-2)
core/embed/emmc_wrapper/emmc_commands.c

[error] 888-888: failed to expand 'ExecuteCheck_MSGS_ADV', it is invalid to use a preprocessor directive as macro parameter

(preprocessorErrorDirective)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Defs check
  • GitHub Check: Style check
  • GitHub Check: Gen check
🔇 Additional comments (15)
core/embed/trezorhal/gt911.c (3)

114-114: Changed sleep register address.

Register address changed from GTP_REG_SLEEP to GTP_REG_COMMAND for entering sleep mode.


138-163: Added touchscreen sensitivity configuration.

New function adjusts touchscreen parameters including shake_count, noise_reduction, and screen_touch_level.


172-172: Set config added to initialization flow.

Configuration now applied during device initialization.

core/embed/trezorhal/ble.c (1)

97-119: Added version retrieval with timeout.

New function implements robust timeout mechanism for BLE version retrieval.

core/embed/trezorhal/nordic_dfu.c (3)

287-287: Progress scale changed from 0-1000 to 0-100.

Progress percentage calculation updated to standard 0-100 scale.


336-337: Function signature changed for weighted progress.

Added percent_start and weights parameters improve progress tracking for multi-file updates.


359-361: Enhanced progress calculation.

Progress now uses starting percentage and weighted proportion.

core/embed/bootloader/main.c (6)

310-340: Added lightweight USB command loop.

New function implements basic USB command processing on a timer.


342-348: USB tiny task management function added.

Enable function initializes and registers USB command loop.


350-352: Disable function for USB tiny task.

Clean unregistration of command loop from system timer.


640-642: Added forced boot check.

New function checks boot target flag for forced bootloader entry.


802-804: Skip firmware check on forced boot.

Prevents unnecessary firmware verification when bootloader is explicitly requested.


853-860: Added touch timeout for boot screen.

Prevents infinite wait by limiting touch check iterations to 200.

core/embed/trezorhal/image.h (1)

90-123: No issues.

core/embed/bootloader/bootui.c (1)

121-823: No issues.

somebodyLi
somebodyLi previously approved these changes Apr 11, 2025
Copy link

@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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 1d160b5 and 22b50ac.

📒 Files selected for processing (41)
  • core/embed/bootloader/bootui.c (10 hunks)
  • core/embed/bootloader/bootui.h (3 hunks)
  • core/embed/bootloader/main.c (4 hunks)
  • core/embed/bootloader/messages.c (1 hunks)
  • core/embed/bootloader/messages.h (1 hunks)
  • core/embed/bootloader/version.h (1 hunks)
  • core/embed/emmc_wrapper/emmc_commands.c (9 hunks)
  • core/embed/emmc_wrapper/emmc_commands.h (1 hunks)
  • core/embed/emmc_wrapper/emmc_fs.c (1 hunks)
  • core/embed/emmc_wrapper/emmc_fs.h (2 hunks)
  • core/embed/extmod/modtrezorui/display.c (1 hunks)
  • core/embed/trezorhal/ble.c (1 hunks)
  • core/embed/trezorhal/ble.h (1 hunks)
  • core/embed/trezorhal/fatfs/ffconf.h (1 hunks)
  • core/embed/trezorhal/gt911.c (2 hunks)
  • core/embed/trezorhal/gt911.h (1 hunks)
  • core/embed/trezorhal/image.c (3 hunks)
  • core/embed/trezorhal/image.h (2 hunks)
  • core/embed/trezorhal/nordic_dfu.c (3 hunks)
  • core/embed/trezorhal/nordic_dfu.h (1 hunks)
  • core/embed/trezorhal/spi_legacy.c (1 hunks)
  • core/embed/trezorhal/systick.h (1 hunks)
  • core/embed/trezorhal/thd89_boot.c (2 hunks)
  • core/embed/trezorhal/thd89_boot.h (1 hunks)
  • core/embed/trezorhal/usb.h (1 hunks)
  • core/src/all_modules.py (1 hunks)
  • core/src/trezor/lvglui/i18n/keys.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/de.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/en.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/es.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/fr.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/it.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/ja.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/ko.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/pt_br.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/ru.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/zh_cn.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/zh_hk.py (1 hunks)
  • core/src/trezor/lvglui/scrs/components/doubleclick.py (1 hunks)
  • core/src/trezor/lvglui/scrs/homescreen.py (6 hunks)
  • core/src/trezor/lvglui/scrs/lockscreen.py (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (34)
  • core/embed/trezorhal/ble.h
  • core/src/trezor/lvglui/i18n/locales/en.py
  • core/src/trezor/lvglui/i18n/locales/de.py
  • core/src/trezor/lvglui/i18n/locales/es.py
  • core/embed/trezorhal/usb.h
  • core/embed/emmc_wrapper/emmc_fs.c
  • core/src/trezor/lvglui/i18n/locales/ru.py
  • core/src/trezor/lvglui/i18n/locales/zh_cn.py
  • core/src/trezor/lvglui/i18n/locales/zh_hk.py
  • core/src/trezor/lvglui/i18n/locales/ja.py
  • core/embed/extmod/modtrezorui/display.c
  • core/src/trezor/lvglui/i18n/locales/it.py
  • core/src/all_modules.py
  • core/embed/trezorhal/gt911.c
  • core/embed/bootloader/messages.h
  • core/embed/trezorhal/nordic_dfu.h
  • core/embed/trezorhal/systick.h
  • core/embed/emmc_wrapper/emmc_commands.h
  • core/embed/emmc_wrapper/emmc_fs.h
  • core/embed/bootloader/version.h
  • core/embed/trezorhal/spi_legacy.c
  • core/embed/trezorhal/nordic_dfu.c
  • core/src/trezor/lvglui/i18n/keys.py
  • core/src/trezor/lvglui/i18n/locales/ko.py
  • core/embed/trezorhal/fatfs/ffconf.h
  • core/embed/trezorhal/thd89_boot.h
  • core/src/trezor/lvglui/i18n/locales/fr.py
  • core/embed/trezorhal/image.c
  • core/src/trezor/lvglui/scrs/lockscreen.py
  • core/src/trezor/lvglui/scrs/homescreen.py
  • core/src/trezor/lvglui/scrs/components/doubleclick.py
  • core/embed/bootloader/bootui.h
  • core/embed/trezorhal/thd89_boot.c
  • core/src/trezor/lvglui/i18n/locales/pt_br.py
🧰 Additional context used
🧬 Code Graph Analysis (5)
core/embed/bootloader/messages.c (3)
core/embed/bootloader/messages.h (1)
  • send_msg_features_simple (46-46)
core/src/trezor/messages.py (1)
  • Features (2919-3093)
python/src/trezorlib/messages.py (1)
  • Features (4331-4588)
core/embed/trezorhal/ble.c (3)
core/embed/trezorhal/ble.h (3)
  • ble_get_version_with_timeout (136-136)
  • ble_cmd_req (106-106)
  • ble_uart_poll (108-108)
core/embed/trezorhal/common.c (1)
  • hal_delay (292-292)
core/embed/trezorhal/common.h (1)
  • hal_delay (107-107)
core/embed/bootloader/main.c (8)
core/embed/trezorhal/spi_legacy.h (1)
  • spi_slave_poll (37-37)
core/embed/bootloader/messages.h (2)
  • send_msg_features_simple (46-46)
  • send_failure (41-41)
core/embed/bootloader/bootui.c (1)
  • format_progress_value (126-130)
core/embed/trezorhal/usb.h (1)
  • usb_start (148-148)
core/embed/trezorhal/systick.h (4)
  • systick_enable_dispatch (49-51)
  • systick_enable_dispatch (49-49)
  • systick_disable_dispatch (53-55)
  • systick_disable_dispatch (53-53)
core/embed/emmc_wrapper/emmc_commands.h (1)
  • check_firmware_from_file (199-199)
core/embed/trezorhal/touch.h (1)
  • touch_read (60-60)
core/embed/trezorhal/common.h (1)
  • hal_delay (107-107)
core/embed/bootloader/bootui.c (1)
core/embed/bootloader/bootui.h (12)
  • format_progress_value (27-27)
  • ui_screen_install_confirm_newvendor_or_downgrade_wipe (47-47)
  • ui_screen_progress_bar_init (54-54)
  • ui_statusbar_update (83-83)
  • ui_screen_progress_bar_prepare (55-55)
  • ui_screen_progress_bar_update (56-56)
  • ui_screen_install_progress_upload (50-50)
  • ui_screen_install_title_clear (91-91)
  • ui_show_version_info (90-90)
  • ui_update_info_show (96-96)
  • ui_bootloader_first (87-87)
  • format_ver (29-29)
core/embed/emmc_wrapper/emmc_commands.c (7)
core/embed/bootloader/messages.h (1)
  • send_failure (41-41)
core/embed/bootloader/messages.c (1)
  • send_failure (312-317)
core/embed/trezorhal/se_thd89.h (1)
  • se_reset_storage (45-45)
core/embed/trezorhal/ble.c (1)
  • ble_get_version_with_timeout (97-119)
core/embed/trezorhal/ble.h (1)
  • ble_get_version_with_timeout (136-136)
core/embed/trezorhal/thd89_boot.c (1)
  • se_update_firmware (156-174)
core/embed/trezorhal/thd89_boot.h (1)
  • se_update_firmware (27-28)
🪛 Cppcheck (2.10-2)
core/embed/emmc_wrapper/emmc_commands.c

[error] 888-888: failed to expand 'ExecuteCheck_MSGS_ADV', it is invalid to use a preprocessor directive as macro parameter

(preprocessorErrorDirective)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Defs check
  • GitHub Check: Style check
  • GitHub Check: Gen check
🔇 Additional comments (40)
core/embed/bootloader/messages.c (1)

326-338: New function to simplify feature message sending.

The new send_msg_features_simple function creates a trimmed-down version of the features message with just the essential device information. It's properly implemented and follows the established pattern for message sending functions.

core/embed/trezorhal/ble.c (1)

97-119: Robust BLE version retrieval with timeout handling.

This new function properly handles timeouts when retrieving the BLE version. The implementation includes appropriate error checking, timeout management, and retry logic.

core/embed/bootloader/main.c (5)

310-340: Lightweight USB communication handler for firmware updates.

The bootloader_usb_loop_tiny function provides a simplified USB communication loop that only checks for commands periodically. This is a good optimization for firmware update scenarios where full USB functionality isn't needed.


342-352: Task management functions for USB tiny loop.

These helper functions properly handle the enabling and disabling of the USB tiny task using the systick dispatcher system.


640-642: Added check for forced boot mode.

Simple but effective function to determine if bootloader mode was explicitly requested.


802-804: Added conditional firmware check from file.

Good improvement to avoid unnecessary file checks when boot was forced.


853-860: Improved touch input handling with timeout.

Added timeout logic prevents potential infinite loops if touch input fails.

core/embed/emmc_wrapper/emmc_commands.c (10)

448-452: Added NULL interface check to prevent unnecessary message sending.

Good defensive programming to avoid sending messages when no interface is available.


459-462: Added NULL interface check to no-check variant.

Consistent with the previous change, applying the same check to the no-check variant.


470-473: Added NULL interface check to detailed failure reporting.

Completes the set of NULL interface checks for all failure reporting functions.


538-541: Added constants for firmware type identification.

Clear naming improves readability when checking firmware types.


551-552: Initialized update_info at function start.

Good practice to initialize the structure at the beginning of the function.


561-565: Added check for maximum item count.

Important validation to prevent buffer overflows when processing updates with too many items.


749-778: Improved BLE version handling.

Better error handling for BLE version retrieval with fallback to "unknown" when version can't be determined.


797-803: Added function to clean up bootloader update files.

Useful utility function that ensures proper cleanup of bootloader update files from both legacy and current paths.


1065-1070: Add USB tiny task during firmware updates.

Good enhancement that enables minimal USB functionality during updates, with conditional USB initialization.


1318-1335: Added function to check and apply firmware updates from file.

Well-structured function that handles firmware updates from files with proper error checking.

core/embed/trezorhal/gt911.h (4)

8-8: No issues


11-12: No issues


15-21: No issues


25-120: No issues

core/embed/trezorhal/image.h (6)

90-95: No issues


97-103: No issues


105-105: No issues


108-113: No issues


114-123: No issues


199-200: No issues

core/embed/bootloader/bootui.c (13)

121-122: No issues


126-130: No issues


266-266: No issues


284-285: No issues


304-304: No issues


336-344: No issues


352-361: No issues


382-382: No issues


385-388: No issues


420-420: No issues


674-678: No issues


679-686: No issues


753-823: No issues

@lihuanhuan lihuanhuan enabled auto-merge (squash) April 11, 2025 14:07
@lihuanhuan lihuanhuan merged commit cd4c4cc into OneKeyHQ:main Apr 11, 2025
7 checks passed
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.

3 participants