summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Marples <dave@marples.net>2020-02-12 22:36:34 +0000
committerDave Marples <dave@marples.net>2020-02-12 22:36:34 +0000
commit4de2a1eb6224dbb218c80f652bf0ed36f2ac29f4 (patch)
tree627d998e0282a79a35aa082866ec6f2cc78c09a9
parentfb8fbbf42e2cc54722631bd79d5f16b8d235b640 (diff)
Fix alignment warning
-rw-r--r--ports/mimxrt10xx/common-hal/microcontroller/Processor.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/ports/mimxrt10xx/common-hal/microcontroller/Processor.c b/ports/mimxrt10xx/common-hal/microcontroller/Processor.c
index 23493f766..6b0a15185 100644
--- a/ports/mimxrt10xx/common-hal/microcontroller/Processor.c
+++ b/ports/mimxrt10xx/common-hal/microcontroller/Processor.c
@@ -58,8 +58,17 @@ void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) {
OCOTP_Init(OCOTP, CLOCK_GetFreq(kCLOCK_IpgClk));
// Reads shadow registers 0x01 - 0x04 (Configuration and Manufacturing Info)
+ // into 8 bit wide destination, avoiding punning.
for (int i = 0; i < 4; ++i)
- ((uint32_t*) raw_id)[i] = OCOTP_ReadFuseShadowRegister(OCOTP, i + 1);
+ {
+ uint32_t wr = OCOTP_ReadFuseShadowRegister(OCOTP, i + 1);
+
+ for (int j = 0; j < 4; j++)
+ {
+ raw_id[i*4+j] = wr&0xff;
+ wr>>=8;
+ }
+ }
OCOTP_Deinit(OCOTP);
}