Skip to content

prepare NCS update#6817

Open
TychoVrahe wants to merge 10 commits intomainfrom
tychovrahe/pico/upg_prep2
Open

prepare NCS update#6817
TychoVrahe wants to merge 10 commits intomainfrom
tychovrahe/pico/upg_prep2

Conversation

@TychoVrahe
Copy link
Copy Markdown
Contributor

No description provided.

@TychoVrahe TychoVrahe self-assigned this Apr 23, 2026
@github-project-automation github-project-automation Bot moved this to 🔎 Needs review in Firmware Apr 23, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 23, 2026

Walkthrough

This PR updates the t3w1_revA_nrf52832 board configuration and trezor-ble application. Changes include: correcting board metadata (vendor, full_name, and display name); restructuring device tree GPIO bindings by consolidating leds/buttons into outputs/inputs blocks and renaming SPI node labels; removing static partition files and migrating to DTS fixed-partitions via sysbuild configuration; updating build signing logic to derive parameters from Zephyr artifacts instead of hardcoded values; replacing printk logging with Zephyr LOG API throughout application code; converting DK-specific button/LED handling to device-tree GPIO specifications; and adjusting MCUBoot configuration toward single-slot bootloader mode.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is entirely a template scaffold with instructional comments for contributors and developers, containing no functional information about the changes being made. Replace the template scaffold with a substantive description explaining the purpose of the NCS update, key changes (Device Tree migration, pm_static removal, logging updates), and any testing or validation performed.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'prepare NCS update' is vague and generic, using a non-descriptive term that doesn't convey meaningful information about the specific technical changes made. Use a more descriptive title that reflects the main change, such as 'Migrate to Device Tree fixed-partitions and update NCS configuration' or 'Refactor board config and remove partition manager dependency'.
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch tychovrahe/pico/upg_prep2

Warning

Review ran into problems

🔥 Problems

Timed out fetching pipeline failures after 30000ms


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 23, 2026

en main(all)

model device_test click_test persistence_test
T2T1 test(all) main(all) test(all) main(all) test(all) main(all)
T3B1 test(all) main(all) test(all) main(all) test(all) main(all)
T3T1 test(all) main(all) test(all) main(all) test(all) main(all)
T3W1 test(all) main(all) test(all) main(all) test(all) main(all)

Latest CI run: 24880013503

@TychoVrahe TychoVrahe force-pushed the tychovrahe/pico/upg_prep2 branch from c52f0a9 to 8ea1326 Compare April 23, 2026 15:05
Copy link
Copy Markdown

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@core/embed/models/T3W1/boards/trezor_t3w1_revB.h`:
- Around line 240-246: The IRQ macro for the NRF UART is wrong: update the
NRF_UART_IRQN macro in trezor_t3w1_revB.h to use the USART3 IRQ (matching
NRF_UART_INSTANCE and NRF_UART_INTERRUPT_HANDLER) so the NVIC enables the
correct interrupt under USE_SMP; locate the NRF_UART_IRQN definition and replace
the USART1_IRQn reference with the corresponding USART3_IRQn symbol so
USART3_IRQHandler is invoked for UART RX/TX events.

In `@nordic/trezor/scripts/build_sign_flash.sh`:
- Line 156: The flash command hard-codes the sysbuild domain "trezor-ble" which
breaks when the script is invoked with a different application directory via -a;
update the command in build_sign_flash.sh that currently runs 'west flash
--domain trezor-ble --hex-file ./build/zephyr.merged.signed_trz.hex' to use the
APP_DIR variable instead (e.g., --domain "$APP_DIR") and ensure proper quoting;
if the intent was to disallow different apps with -f, add an explicit check that
rejects -a when -f is passed or introduce a separate DOMAIN variable and use
that in the flash command.
- Around line 18-19: The script currently hard-codes partition constants
(HEADER_SIZE, SLOT_ADDR and the -S 0x6c000 size) which can drift from the
authoritative DTS; change build_sign_flash.sh to parse the generated Device Tree
(build/$APP_DIR/zephyr/zephyr.dts) at runtime to extract the fixed-partitions
properties and derive HEADER_SIZE, SLOT_ADDR and the slot size instead of using
literals; update the code paths that reference HEADER_SIZE, SLOT_ADDR and the -S
value so they use the parsed values and add a clear error if the expected
partition node or properties cannot be found.
- Around line 136-137: The dd invocation that creates zephyr_nohdr.bin should be
made robust: quote the variable usages ($APP_DIR and $HEADER_SIZE) in the dd
command, stop discarding stderr (remove 2>/dev/null), and immediately check dd's
exit status so the script fails fast if header stripping fails; on failure
delete any partially-created build/$APP_DIR/zephyr/zephyr_nohdr.bin and exit
with a non-zero status so subsequent signing doesn't operate on a stale file.
Target the dd call that produces build/$APP_DIR/zephyr/zephyr_nohdr.bin and add
the quoted variables, error checking, and cleanup logic around it.

In `@nordic/trezor/trezor-ble/prj.conf`:
- Around line 101-112: The production config currently disables logging via
CONFIG_LOG=n, CONFIG_UART_CONSOLE=n and CONFIG_LOG_BACKEND_UART=n which silences
all LOG_ERR/LOG_WRN calls; either enable the logger and an appropriate backend
in prj.conf (set CONFIG_LOG=y and enable a backend such as
CONFIG_LOG_BACKEND_UART or another transport) or guard the diagnostics so they
only compile when logging is enabled (use Kconfig checks or
IS_ENABLED(CONFIG_LOG) around the LOG_ERR/LOG_WRN sites) — update prj.conf or
the modules emitting LOG_ERR/LOG_WRN (UART/SPI/BLE/GPIO/prodtest) accordingly so
diagnostic messages are actually delivered in production.

In `@nordic/trezor/trezor-ble/src/management/management.c`:
- Around line 158-160: The read_image_sha256 call's return value is not checked
so failures produce an all-zero hash and the code still calls trz_comm_send_msg
with that bogus INFO payload; update the logic around
read_image_sha256(FIXED_PARTITION_ID(slot0_partition), &data[9]) to capture its
return code, and on error avoid sending the success INFO: either log the error
via the existing logging mechanism and return/fail early, or populate data with
an explicit error TLV/status and call trz_comm_send_msg with that error payload
instead of the zero hash; ensure trz_comm_send_msg is only called with a valid
hash when read_image_sha256 succeeded.

In `@nordic/trezor/trezor-ble/src/signals/signals.c`:
- Around line 58-64: signals_set_reserved currently sets the cached out_reserved
before calling gpio_pin_set_dt, so failures are silently ignored; change
signals_set_reserved(bool set) to call gpio_pin_set_dt(&reserved_output, set),
check its return (0 success, negative errno on failure), and only update
out_reserved when gpio_pin_set_dt succeeds; on failure do not update
out_reserved and emit an error log (or otherwise surface the errno) so
signals_out_get_reserved() cannot report a state that wasn't applied to
hardware.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5d233b68-9fd0-4a2b-82cc-abed1234d1cc

📥 Commits

Reviewing files that changed from the base of the PR and between 23dd66d and c52f0a9.

📒 Files selected for processing (28)
  • core/embed/io/ble/stm32/ble.c
  • core/embed/io/nrf/stm32u5/nrf.c
  • core/embed/io/nrf/stm32u5/nrf_spi.c
  • core/embed/io/nrf/stm32u5/nrf_uart.c
  • core/embed/models/T3W1/boards/trezor_t3w1_revA.h
  • core/embed/models/T3W1/boards/trezor_t3w1_revB.h
  • core/embed/models/T3W1/boards/trezor_t3w1_revC.h
  • nordic/trezor/boards/arm/t3w1_revA_nrf52832/Kconfig.defconfig
  • nordic/trezor/boards/arm/t3w1_revA_nrf52832/board.yml
  • nordic/trezor/boards/arm/t3w1_revA_nrf52832/t3w1_revA_nrf52832.dts
  • nordic/trezor/boards/arm/t3w1_revA_nrf52832/t3w1_revA_nrf52832.yaml
  • nordic/trezor/direct_test_mode/pm_static.yml
  • nordic/trezor/direct_test_mode/sysbuild.conf
  • nordic/trezor/radio_test/pm_static.yml
  • nordic/trezor/radio_test/sysbuild.conf
  • nordic/trezor/scripts/build_sign_flash.sh
  • nordic/trezor/trezor-ble/boards/t3w1_revA_nrf52832.overlay
  • nordic/trezor/trezor-ble/pm_static.yml
  • nordic/trezor/trezor-ble/prj.conf
  • nordic/trezor/trezor-ble/src/ble/pairing.c
  • nordic/trezor/trezor-ble/src/main.c
  • nordic/trezor/trezor-ble/src/management/management.c
  • nordic/trezor/trezor-ble/src/signals/signals.c
  • nordic/trezor/trezor-ble/src/trz_comm/spi.c
  • nordic/trezor/trezor-ble/src/trz_comm/uart.c
  • nordic/trezor/trezor-ble/sysbuild.conf
  • nordic/trezor/trezor-ble/sysbuild/mcuboot.conf
  • vendor/libtropic
💤 Files with no reviewable changes (5)
  • nordic/trezor/trezor-ble/sysbuild/mcuboot.conf
  • nordic/trezor/trezor-ble/src/main.c
  • nordic/trezor/radio_test/pm_static.yml
  • nordic/trezor/direct_test_mode/pm_static.yml
  • nordic/trezor/trezor-ble/pm_static.yml

Comment thread core/embed/models/T3W1/boards/trezor_t3w1_revB.h Outdated
Comment thread nordic/trezor/scripts/build_sign_flash.sh Outdated
Comment thread nordic/trezor/scripts/build_sign_flash.sh Outdated
Comment thread nordic/trezor/scripts/build_sign_flash.sh Outdated
Comment thread nordic/trezor/trezor-ble/prj.conf
Comment thread nordic/trezor/trezor-ble/src/management/management.c Outdated
Comment thread nordic/trezor/trezor-ble/src/signals/signals.c Outdated
@TychoVrahe TychoVrahe force-pushed the tychovrahe/pico/upg_prep2 branch from 8ea1326 to d305b97 Compare April 24, 2026 08:27
@TychoVrahe TychoVrahe marked this pull request as ready for review April 24, 2026 09:34
@TychoVrahe TychoVrahe requested a review from bleska April 24, 2026 09:34
Copy link
Copy Markdown

@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.

🧹 Nitpick comments (1)
nordic/trezor/trezor-ble/src/management/management.c (1)

158-162: LGTM — addresses prior feedback on unchecked hash read.

rc is now captured from read_image_sha256, logged, and the INFO response is suppressed on failure, so a partition/read/TLV error no longer produces a zero-hash success response. Partition ID migration to FIXED_PARTITION_ID(slot0_partition) is consistent with the PR's move from pm_static to DTS fixed-partitions.

Minor (optional): the docstring at lines 86–92 still refers to FLASH_AREA_ID(image_0)/image_1 as the expected area_id argument — worth refreshing to FIXED_PARTITION_ID(slot0_partition) / slot1_partition for consistency.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@nordic/trezor/trezor-ble/src/management/management.c` around lines 158 - 162,
Update the docstring that still references FLASH_AREA_ID(image_0)/image_1 to
reflect the move to DTS fixed-partitions: change the expected area_id examples
to use FIXED_PARTITION_ID(slot0_partition) and
FIXED_PARTITION_ID(slot1_partition) (the docstring near the management code
handling read_image_sha256 in management.c); keep wording consistent with the
partition ID migration from pm_static to FIXED_PARTITION_ID(slotX) and ensure
the argument description matches the actual calls to read_image_sha256 and other
partition helpers.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@nordic/trezor/trezor-ble/src/management/management.c`:
- Around line 158-162: Update the docstring that still references
FLASH_AREA_ID(image_0)/image_1 to reflect the move to DTS fixed-partitions:
change the expected area_id examples to use FIXED_PARTITION_ID(slot0_partition)
and FIXED_PARTITION_ID(slot1_partition) (the docstring near the management code
handling read_image_sha256 in management.c); keep wording consistent with the
partition ID migration from pm_static to FIXED_PARTITION_ID(slotX) and ensure
the argument description matches the actual calls to read_image_sha256 and other
partition helpers.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 03728008-eb98-4cc6-a147-faefc0645479

📥 Commits

Reviewing files that changed from the base of the PR and between c52f0a9 and d305b97.

📒 Files selected for processing (20)
  • nordic/trezor/boards/arm/t3w1_revA_nrf52832/Kconfig.defconfig
  • nordic/trezor/boards/arm/t3w1_revA_nrf52832/board.yml
  • nordic/trezor/boards/arm/t3w1_revA_nrf52832/t3w1_revA_nrf52832.dts
  • nordic/trezor/boards/arm/t3w1_revA_nrf52832/t3w1_revA_nrf52832.yaml
  • nordic/trezor/direct_test_mode/pm_static.yml
  • nordic/trezor/direct_test_mode/sysbuild.conf
  • nordic/trezor/radio_test/pm_static.yml
  • nordic/trezor/radio_test/sysbuild.conf
  • nordic/trezor/scripts/build_sign_flash.sh
  • nordic/trezor/trezor-ble/boards/t3w1_revA_nrf52832.overlay
  • nordic/trezor/trezor-ble/pm_static.yml
  • nordic/trezor/trezor-ble/prj.conf
  • nordic/trezor/trezor-ble/src/ble/pairing.c
  • nordic/trezor/trezor-ble/src/main.c
  • nordic/trezor/trezor-ble/src/management/management.c
  • nordic/trezor/trezor-ble/src/signals/signals.c
  • nordic/trezor/trezor-ble/src/trz_comm/spi.c
  • nordic/trezor/trezor-ble/src/trz_comm/uart.c
  • nordic/trezor/trezor-ble/sysbuild.conf
  • nordic/trezor/trezor-ble/sysbuild/mcuboot.conf
💤 Files with no reviewable changes (5)
  • nordic/trezor/trezor-ble/src/main.c
  • nordic/trezor/trezor-ble/sysbuild/mcuboot.conf
  • nordic/trezor/trezor-ble/pm_static.yml
  • nordic/trezor/radio_test/pm_static.yml
  • nordic/trezor/direct_test_mode/pm_static.yml
✅ Files skipped from review due to trivial changes (7)
  • nordic/trezor/boards/arm/t3w1_revA_nrf52832/Kconfig.defconfig
  • nordic/trezor/direct_test_mode/sysbuild.conf
  • nordic/trezor/trezor-ble/sysbuild.conf
  • nordic/trezor/trezor-ble/src/trz_comm/uart.c
  • nordic/trezor/trezor-ble/src/ble/pairing.c
  • nordic/trezor/boards/arm/t3w1_revA_nrf52832/t3w1_revA_nrf52832.yaml
  • nordic/trezor/radio_test/sysbuild.conf
🚧 Files skipped from review as they are similar to previous changes (4)
  • nordic/trezor/trezor-ble/boards/t3w1_revA_nrf52832.overlay
  • nordic/trezor/boards/arm/t3w1_revA_nrf52832/board.yml
  • nordic/trezor/scripts/build_sign_flash.sh
  • nordic/trezor/trezor-ble/prj.conf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🔎 Needs review

Development

Successfully merging this pull request may close these issues.

1 participant