-
-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework MPU config for unaligned access to external memory
- Add MPU config to ORGPAL3 and ORGPALX to allow unaligned access to external memory. - Remove MPU config for non cached memory in ChibiOS mcu config for ORGPAL3 and ORGPALX. Now are in Target_ConfigNonCacheableMemory(). - Rework call to MPU config in ORGPAL3 and ORGPALX. - Migrate ST_STM32F769I_DISCOVERY MPU config to use ST HAL API.
- Loading branch information
1 parent
9498e56
commit 05317aa
Showing
14 changed files
with
190 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// Copyright (c) .NET Foundation and Contributors | ||
// See LICENSE file in the project root for full license information. | ||
// | ||
|
||
#include <ch.h> | ||
#include <hal.h> | ||
#include <stm32_registry.h> | ||
#include <hal_nf_community.h> | ||
|
||
extern void Target_ExternalMemoryConfigMPU(); | ||
|
||
// SRAM1 base address | ||
#define SRAM1_BASE 0x20000000U | ||
#define SRAM1_SIZE_128K (1UL << 16) // 2^17 bytes | ||
#define MPU_REGION_SRAM1 MPU_REGION_1 | ||
|
||
void Target_ConfigNonCacheableMemory() | ||
{ | ||
// region | ||
MPU->RNR = MPU_REGION_SRAM1; | ||
|
||
// base address | ||
MPU->RBAR = SRAM1_BASE; | ||
|
||
// size and other configs | ||
MPU->RASR = | ||
((uint32_t)MPU_RASR_ATTR_AP_RW_RW | MPU_RASR_ATTR_NON_CACHEABLE | MPU_RASR_ATTR_S | MPU_RASR_SIZE_128K | | ||
MPU_RASR_ENABLE); | ||
} | ||
|
||
void Target_ConfigMPU() | ||
{ | ||
// disable MPU | ||
HAL_MPU_Disable(); | ||
|
||
// config MPU for external memory | ||
Target_ExternalMemoryConfigMPU(); | ||
|
||
// config MPU for non cacheable memory | ||
Target_ConfigNonCacheableMemory(); | ||
|
||
// enable MPU | ||
HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// Copyright (c) .NET Foundation and Contributors | ||
// See LICENSE file in the project root for full license information. | ||
// | ||
|
||
#include <ch.h> | ||
#include <hal.h> | ||
#include <stm32_registry.h> | ||
#include <hal_nf_community.h> | ||
|
||
extern void Target_ExternalMemoryConfigMPU(); | ||
|
||
// SRAM1 base address | ||
#define SRAM1_BASE 0x20000000U | ||
#define SRAM1_SIZE_128K (1UL << 16) // 2^17 bytes | ||
#define MPU_REGION_SRAM1 MPU_REGION_1 | ||
|
||
void Target_ConfigNonCacheableMemory() | ||
{ | ||
// region | ||
MPU->RNR = MPU_REGION_SRAM1; | ||
|
||
// base address | ||
MPU->RBAR = SRAM1_BASE; | ||
|
||
// size and other configs | ||
MPU->RASR = | ||
((uint32_t)MPU_RASR_ATTR_AP_RW_RW | MPU_RASR_ATTR_NON_CACHEABLE | MPU_RASR_ATTR_S | MPU_RASR_SIZE_128K | | ||
MPU_RASR_ENABLE); | ||
} | ||
|
||
void Target_ConfigMPU() | ||
{ | ||
// disable MPU | ||
HAL_MPU_Disable(); | ||
|
||
// config MPU for external memory | ||
Target_ExternalMemoryConfigMPU(); | ||
|
||
// config MPU for non cacheable memory | ||
Target_ConfigNonCacheableMemory(); | ||
|
||
// enable MPU | ||
HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.