From 50949eb3b9aa56a38b318f3e568a682e39f4b72e Mon Sep 17 00:00:00 2001 From: HiFiPhile Date: Wed, 17 Sep 2025 22:59:58 +0200 Subject: Fix board_get_unique_id Signed-off-by: HiFiPhile --- hw/bsp/board.c | 12 ++++++++++++ hw/bsp/board_api.h | 10 +--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/hw/bsp/board.c b/hw/bsp/board.c index 1ba5a1b9d..c6982ed8f 100644 --- a/hw/bsp/board.c +++ b/hw/bsp/board.c @@ -140,6 +140,18 @@ __strong_reference(stdin, stdout); __strong_reference(stdin, stderr); #endif +//--------------------------------------------------------------------+ +// Weak board API (to be optionally implemented by board) +//--------------------------------------------------------------------+ +TU_ATTR_WEAK size_t board_get_unique_id(uint8_t id[], size_t max_len) { + (void) max_len; + // fixed serial string is 01234567889ABCDEF + uint32_t* uid32 = (uint32_t*) (uintptr_t)id; + uid32[0] = 0x67452301; + uid32[1] = 0xEFCDAB89; + return 8; +} + //--------------------------------------------------------------------+ // Board API //--------------------------------------------------------------------+ diff --git a/hw/bsp/board_api.h b/hw/bsp/board_api.h index 111829b4f..5ecd7797a 100644 --- a/hw/bsp/board_api.h +++ b/hw/bsp/board_api.h @@ -152,15 +152,7 @@ static inline size_t board_usb_get_serial(uint16_t desc_str1[], size_t max_chars size_t uid_len; // TODO work with make, but not working with esp32s3 cmake - if ( board_get_unique_id ) { - uid_len = board_get_unique_id(uid, sizeof(uid)); - }else { - // fixed serial string is 01234567889ABCDEF - uint32_t* uid32 = (uint32_t*) (uintptr_t) uid; - uid32[0] = 0x67452301; - uid32[1] = 0xEFCDAB89; - uid_len = 8; - } + uid_len = board_get_unique_id(uid, sizeof(uid)); if ( uid_len > max_chars / 2 ) uid_len = max_chars / 2; -- cgit v1.3.1