summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiFiPhile <[email protected]>2025-09-17 22:59:58 +0200
committerHiFiPhile <[email protected]>2025-09-17 23:20:52 +0200
commit50949eb3b9aa56a38b318f3e568a682e39f4b72e (patch)
tree27f724940db12202f1ea348442f8e448721c1554
parent73f3900b2da5d00e707078a591067f0329118dcb (diff)
Fix board_get_unique_id
Signed-off-by: HiFiPhile <[email protected]>
-rw-r--r--hw/bsp/board.c12
-rw-r--r--hw/bsp/board_api.h10
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
@@ -141,6 +141,18 @@ __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
//--------------------------------------------------------------------+
int board_getchar(void) {
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;