From 7e57aa0f284809d05ceb688e0864b8df945303d1 Mon Sep 17 00:00:00 2001 From: ALTracer Date: Sun, 7 Jan 2024 14:28:00 +0300 Subject: [PATCH] serialno: Replace siprintf with utoa_upper * STM32F4 case with 12-byte serial numbers simply relied on sprintf() * Use three calls to `utoa_upper()` to build the `serial_no[]` instead * This drastically reduces F4 usbdfu BMPBootloader binary size --- src/platforms/common/stm32/serialno.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/platforms/common/stm32/serialno.c b/src/platforms/common/stm32/serialno.c index 085d696cb26..d732faddd6e 100644 --- a/src/platforms/common/stm32/serialno.c +++ b/src/platforms/common/stm32/serialno.c @@ -50,7 +50,9 @@ void read_serial_number(void) #elif defined(STM32L0) || defined(STM32F0) || defined(STM32F3) int offset = 5; #endif - sprintf(serial_no, "%04X%04X%04X", uid[1] + uid[5], uid[0] + uid[4], uid[offset]); + utoa_upper(uid[1] + uid[5], serial_no, 16); + utoa_upper(uid[0] + uid[4], serial_no + 4, 16); + utoa_upper(uid[offset], serial_no + 8, 16); #elif DFU_SERIAL_LENGTH == 25 const volatile uint32_t *const unique_id_p = (uint32_t *)DESIG_UNIQUE_ID_BASE; uint32_t unique_id = 0;