Skip to content

Commit 2063867

Browse files
authored
Merge pull request #2618 from mubes/alignment-warning
Fix alignment warning
2 parents 850e655 + 77ad9af commit 2063867

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

ports/mimxrt10xx/common-hal/microcontroller/Processor.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,13 @@ void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) {
5858
OCOTP_Init(OCOTP, CLOCK_GetFreq(kCLOCK_IpgClk));
5959

6060
// Reads shadow registers 0x01 - 0x04 (Configuration and Manufacturing Info)
61-
for (int i = 0; i < 4; ++i)
62-
((uint32_t*) raw_id)[i] = OCOTP_ReadFuseShadowRegister(OCOTP, i + 1);
63-
61+
// into 8 bit wide destination, avoiding punning.
62+
for (int i = 0; i < 4; ++i) {
63+
uint32_t wr = OCOTP_ReadFuseShadowRegister(OCOTP, i + 1);
64+
for (int j = 0; j < 4; j++) {
65+
raw_id[i*4+j] = wr & 0xff;
66+
wr >>= 8;
67+
}
68+
}
6469
OCOTP_Deinit(OCOTP);
6570
}

0 commit comments

Comments
 (0)