Skip to content

Commit

Permalink
serialno: Replace siprintf with utoa_upper
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ALTracer committed Jan 7, 2024
1 parent 732cd17 commit 7e57aa0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/platforms/common/stm32/serialno.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7e57aa0

Please sign in to comment.