File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -211,6 +211,35 @@ static void sdram_init_seq(SDRAM_HandleTypeDef
211211 */
212212 #define REFRESH_COUNT (MICROPY_HW_SDRAM_REFRESH_RATE * 90000 / 8192 - 20)
213213 HAL_SDRAM_ProgramRefreshRate (hsdram , REFRESH_COUNT );
214+
215+ #if defined(STM32F7 )
216+ /* Enable MPU for the SDRAM Memory Region to allow non-aligned
217+ accesses (hard-fault otherwise)
218+ */
219+
220+ MPU_Region_InitTypeDef MPU_InitStruct ;
221+
222+ /* Disable the MPU */
223+ HAL_MPU_Disable ();
224+
225+ /* Configure the MPU attributes for SDRAM */
226+ MPU_InitStruct .Enable = MPU_REGION_ENABLE ;
227+ MPU_InitStruct .BaseAddress = SDRAM_START_ADDRESS ;
228+ MPU_InitStruct .Size = MPU_REGION_SIZE_4MB ;
229+ MPU_InitStruct .AccessPermission = MPU_REGION_FULL_ACCESS ;
230+ MPU_InitStruct .IsBufferable = MPU_ACCESS_NOT_BUFFERABLE ;
231+ MPU_InitStruct .IsCacheable = MPU_ACCESS_NOT_CACHEABLE ;
232+ MPU_InitStruct .IsShareable = MPU_ACCESS_NOT_SHAREABLE ;
233+ MPU_InitStruct .Number = MPU_REGION_NUMBER0 ;
234+ MPU_InitStruct .TypeExtField = MPU_TEX_LEVEL1 ;
235+ MPU_InitStruct .SubRegionDisable = 0x00 ;
236+ MPU_InitStruct .DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE ;
237+
238+ HAL_MPU_ConfigRegion (& MPU_InitStruct );
239+
240+ /* Enable the MPU */
241+ HAL_MPU_Enable (MPU_PRIVILEGED_DEFAULT );
242+ #endif
214243}
215244
216245bool __attribute__((optimize ("O0" ))) sdram_test (bool fast ) {
You can’t perform that action at this time.
0 commit comments