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 authored and dragonmux committed Jan 7, 2024
1 parent 5211104 commit 6261eb5
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 6261eb5

Please sign in to comment.