Skip to content

Commit

Permalink
fix bug in the way UID on STM32 is generated, we where reading bits o…
Browse files Browse the repository at this point in the history
…f undefined memory by a wrong cast
  • Loading branch information
glennergeerts committed May 26, 2021
1 parent faa6a79 commit 2666efc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion stack/framework/hal/chips/stm32_common/stm32_common_system.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,11 @@ void hw_enter_lowpower_mode(uint8_t mode)

uint64_t hw_get_unique_id()
{
return (*((uint64_t *)(UID_BASE + 0x04U)) << 32) + *((uint64_t *)(UID_BASE + 0x14U));
// note we are ignoring WAF_NUM and LOT_NUM[55:32] to reduce the 96 bits UID to 64 bits
uint64_t uid = *((uint32_t*)(UID_BASE + 0x04U)); // LOT_NUM[31:0]
uid = uid << 32;
uid += *((uint32_t*)(UID_BASE + 0x14U)); // unique ID
return uid;
}

void hw_busy_wait(int16_t us)
Expand Down

0 comments on commit 2666efc

Please sign in to comment.