2023-08-23 08: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.
2023-08-23 02:08 PM - edited 2023-08-24 01: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
2023-08-23 09:51 AM
Perhaps an MPU access violation.
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).
2023-08-23 11:20 AM
If you don't enable ICACHE, no fault?
2023-08-23 01:14 PM
yes
2023-08-23 02:08 PM - edited 2023-08-24 01: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
2023-08-24 12:53 AM - edited 2023-08-24 12:55 AM
@STOne-32 Shouldn't things like this be in the errata?
Is this fault caused by loading NX data to ICACHE? king of "speculative execution" bug on CM7 MCUs?
2023-08-24 08: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.