Skip to content

Commit 39fd8eb

Browse files
committed
stm32/mphalport: Support unique ID on H5.
It must be read 32-bits at a time from the ROM address. Signed-off-by: Damien George <damien@micropython.org>
1 parent c517d17 commit 39fd8eb

File tree

5 files changed

+15
-1
lines changed

5 files changed

+15
-1
lines changed

ports/stm32/main.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,13 @@ void stm32_main(uint32_t reset_mode) {
393393
MICROPY_BOARD_EARLY_INIT();
394394

395395
// basic sub-system init
396+
#if defined(STM32H5)
397+
volatile uint32_t *src = (volatile uint32_t *)UID_BASE;
398+
uint32_t *dest = (uint32_t *)&mp_hal_unique_id_address[0];
399+
dest[0] = src[0];
400+
dest[1] = src[1];
401+
dest[2] = src[2];
402+
#endif
396403
#if defined(STM32WB)
397404
rfcore_init();
398405
#endif

ports/stm32/mpconfigboard_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@
342342
// Configuration for STM32H5 series
343343
#elif defined(STM32H5)
344344

345-
#define MP_HAL_UNIQUE_ID_ADDRESS (0x20000000) // TODO
345+
#define MP_HAL_UNIQUE_ID_ADDRESS (mp_hal_unique_id_address)
346346
#define PYB_EXTI_NUM_VECTORS (58)
347347
#define MICROPY_HW_MAX_I2C (2) // TODO check
348348
#define MICROPY_HW_MAX_TIMER (17)

ports/stm32/mphalport.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ const byte mp_hal_status_to_errno_table[4] = {
1616
[HAL_TIMEOUT] = MP_ETIMEDOUT,
1717
};
1818

19+
#if defined(STM32H5)
20+
uint8_t mp_hal_unique_id_address[12];
21+
#endif
22+
1923
NORETURN void mp_hal_raise(HAL_StatusTypeDef status) {
2024
mp_raise_OSError(mp_hal_status_to_errno_table[status]);
2125
}

ports/stm32/mphalport.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#include STM32_HAL_H
33
#include "pin.h"
44

5+
extern uint8_t mp_hal_unique_id_address[12];
6+
57
// F0-1.9.0+F4-1.16.0+F7-1.7.0+G0-1.5.1+G4-1.3.0+H7-1.6.0+L0-1.11.2+L4-1.17.0+WB-1.10.0+WL-1.1.0
68
#if defined(STM32F0)
79
#define MICROPY_PLATFORM_VERSION "HAL1.9.0"

ports/stm32/rng.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
* THE SOFTWARE.
2525
*/
2626

27+
#include "py/mphal.h"
2728
#include "rtc.h"
2829
#include "rng.h"
2930

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy