From 62fbc019b9bbbccd3b5dcc906f16e257f8806ccb Mon Sep 17 00:00:00 2001 From: tychovrahe Date: Thu, 26 Jun 2025 21:05:44 +0200 Subject: [PATCH] fix(core): improve reliability of nrf update [no changelog] --- core/embed/io/nrf/stm32u5/nrf_update.c | 11 +++++++++-- core/embed/rust/src/smp/upload.rs | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/core/embed/io/nrf/stm32u5/nrf_update.c b/core/embed/io/nrf/stm32u5/nrf_update.c index d934ddfd2c..ae3fca04b8 100644 --- a/core/embed/io/nrf/stm32u5/nrf_update.c +++ b/core/embed/io/nrf/stm32u5/nrf_update.c @@ -139,11 +139,18 @@ bool nrf_update(const uint8_t *image_ptr, size_t image_len) { sha256_Update(&ctx, image_ptr, image_len); sha256_Final(&ctx, sha256); - smp_upload_app_image(image_ptr, image_len, sha256, SHA256_DIGEST_LENGTH); + uint8_t try_cntr = 0; + + bool result = false; + do { + result = smp_upload_app_image(image_ptr, image_len, sha256, + SHA256_DIGEST_LENGTH); + try_cntr++; + } while (!result && try_cntr < 3); smp_reset(); - return true; + return result; } #endif diff --git a/core/embed/rust/src/smp/upload.rs b/core/embed/rust/src/smp/upload.rs index 9e731e0383..9f51b5ab6c 100644 --- a/core/embed/rust/src/smp/upload.rs +++ b/core/embed/rust/src/smp/upload.rs @@ -50,7 +50,7 @@ pub fn upload_image(image_data: &[u8], image_hash: &[u8]) -> bool { if wait_for_response( MsgType::ImageUploadResponse, &mut resp_buffer, - Duration::from_millis(100), + Duration::from_millis(500), ) .is_err() { @@ -87,7 +87,7 @@ pub fn upload_image(image_data: &[u8], image_hash: &[u8]) -> bool { if wait_for_response( MsgType::ImageUploadResponse, &mut resp_buffer, - Duration::from_millis(100), + Duration::from_millis(500), ) .is_err() {