STM32H563 hard fault when trying to read UID
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-08-23 8:40 AM
When I'm trying to read Unique device ID register on Nucleo-H563ZI, either by using HAL_GetUIDw0() or by doing
uint32_t uid1 = *((uint32_t*)0x08FFF800);
hard fault occurs.
Solved! Go to Solution.
- Labels:
-
STM32H5 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-08-23 2:08 PM - edited ‎2023-08-24 1:18 AM
Dear @continuum ,
You can refer to this similar case and also same solution. https://community.st.com/t5/stm32-mcu-products/using-dac-of-nucleo-h503rb/m-p/572203/highlight/true#M217994
Therefore, as mentioned by TDK you need to disable cacheability of this region of Read-Only (RO) for unique ID.
“By default, all the AHB memory range is cacheable. For regions where caching is not practical (OTP, RO), MPU has to be used to disable local cacheability.
STM32H563/H573 and STM32H562 Arm<Sup>®</Sup>-based 32-bit MCUs - Reference manual Page 236
Hope it helps,
STOne-32
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-08-23 9:51 AM
Perhaps an MPU access violation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-08-23 10:08 AM
I don't have MPU enabled. I noticed the hard fault happens only when accessing the UID register after enabling instruction cache (ICACHE).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-08-23 11:20 AM
If you don't enable ICACHE, no fault?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-08-23 1:14 PM
yes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-08-23 2:08 PM - edited ‎2023-08-24 1:18 AM
Dear @continuum ,
You can refer to this similar case and also same solution. https://community.st.com/t5/stm32-mcu-products/using-dac-of-nucleo-h503rb/m-p/572203/highlight/true#M217994
Therefore, as mentioned by TDK you need to disable cacheability of this region of Read-Only (RO) for unique ID.
“By default, all the AHB memory range is cacheable. For regions where caching is not practical (OTP, RO), MPU has to be used to disable local cacheability.
STM32H563/H573 and STM32H562 Arm<Sup>®</Sup>-based 32-bit MCUs - Reference manual Page 236
Hope it helps,
STOne-32
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-08-24 12:53 AM - edited ‎2024-10-29 3:17 PM
@STOne-32 Shouldn't things like this be in the errata?
Is this fault caused by loading NX data to ICACHE? kind of "speculative execution" bug on CM7 MCUs?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-08-24 8:27 AM
I have no experience working with MPU but I managed to make it work.
These are the CubeMX settings that worked for me:
If I set something wrong, I would appreciate it if someone could point it out.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-10-29 9:23 AM
// Disable instruction cache prior to internal cacheable memory update
if(HAL_OK != HAL_ICACHE_Disable())
Error_Handler();
// read UID
uint32_t u0 = HAL_GetUIDw0(); // X, Y coordinates
uint32_t u1 = HAL_GetUIDw1(); // Lot number (ASCII encoded)
// Re-enable instruction cache
if(HAL_OK != HAL_ICACHE_Enable())
Error_Handler();
