mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
Kinetis:Disable MPU when not in protected mode.
The hardware reset state of the the MPU precludes any bus masters other then DMA access to memory. Unfortunately USB and SDHC have there own DMA and will not have access to memory in the default reset state. This change disabled the MPU if present on system startup.
This commit is contained in:
@@ -116,6 +116,7 @@ CHIP_CSRCS += kinetis_lowputc.c kinetis_pin.c kinetis_pingpio.c
|
||||
CHIP_CSRCS += kinetis_serialinit.c kinetis_serial.c
|
||||
CHIP_CSRCS += kinetis_start.c kinetis_uid.c kinetis_wdog.c
|
||||
CHIP_CSRCS += kinetis_cfmconfig.c
|
||||
CHIP_CSRCS += kinetis_mpuinit.c
|
||||
|
||||
# Configuration-dependent Kinetis files
|
||||
|
||||
@@ -124,7 +125,7 @@ CHIP_CSRCS += kinetis_timerisr.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_BUILD_PROTECTED),y)
|
||||
CHIP_CSRCS += kinetis_userspace.c kinetis_mpuinit.c
|
||||
CHIP_CSRCS += kinetis_userspace.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_KINETIS_GPIOIRQ),y)
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
|
||||
#include "mpu.h"
|
||||
#include "kinetis_mpuinit.h"
|
||||
#include "chip/kinetis_mpu.h"
|
||||
|
||||
#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_ARM_MPU)
|
||||
|
||||
@@ -120,5 +121,24 @@ void kinetis_mpu_uheap(uintptr_t start, size_t size)
|
||||
mpu_user_intsram(start, size);
|
||||
}
|
||||
|
||||
#elif defined(KINETIS_MPU)
|
||||
|
||||
/****************************************************************************
|
||||
* Name: kinetis_mpudisable
|
||||
*
|
||||
* Description:
|
||||
* Configure the MPU to permit All buss masters access to all resources.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void kinetis_mpudisable(void)
|
||||
{
|
||||
uint32_t regval;
|
||||
|
||||
regval = getreg32(KINETIS_MPU_CESR);
|
||||
regval &= ~MPU_CESR_VLD;
|
||||
putreg32(regval, KINETIS_MPU_CESR);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BUILD_PROTECTED && CONFIG_ARM_MPU */
|
||||
|
||||
|
||||
@@ -61,6 +61,18 @@ void kinetis_mpuinitialize(void);
|
||||
# define kinetis_mpuinitialize()
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: kinetis_mpudisable
|
||||
*
|
||||
* Description:
|
||||
* Configure the MPU to permit All buss masters access to all resources.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if !defined(CONFIG_BUILD_PROTECTED) && defined(KINETIS_MPU)
|
||||
void kinetis_mpudisable(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: kinetis_mpu_uheap
|
||||
*
|
||||
|
||||
@@ -341,6 +341,12 @@ void __start(void)
|
||||
|
||||
#ifdef CONFIG_BUILD_PROTECTED
|
||||
kinetis_userspace();
|
||||
#else
|
||||
# ifdef KINETIS_MPU
|
||||
/* Disable the MPU so that all master may access all buses */
|
||||
|
||||
kinetis_mpudisable();
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Initialize other on-board resources */
|
||||
|
||||
Reference in New Issue
Block a user