mirror of
https://github.com/apache/nuttx.git
synced 2026-05-23 23:28:29 +08:00
arch/stm32h7: add RPTUN support
This commit is contained in:
@@ -45,6 +45,10 @@ if(CONFIG_STM32H7_HSEM)
|
||||
list(APPEND SRCS stm32_hsem.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_RPTUN)
|
||||
list(APPEND SRCS stm32_rptun.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_SCHED_TICKLESS)
|
||||
list(APPEND SRCS stm32_tickless.c)
|
||||
else()
|
||||
@@ -55,8 +59,12 @@ if(CONFIG_STM32H7_ONESHOT)
|
||||
list(APPEND SRCS stm32_oneshot.c stm32_oneshot_lowerhalf.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_ARM_MPU)
|
||||
list(APPEND SRCS stm32_mpuinit.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_BUILD_PROTECTED)
|
||||
list(APPEND SRCS stm32_userspace.c stm32_mpuinit.c)
|
||||
list(APPEND SRCS stm32_userspace.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_ARMV7M_DTCM)
|
||||
|
||||
@@ -522,13 +522,13 @@ endif
|
||||
|
||||
config STM32H7_CORTEXM7_FLASH_SIZE
|
||||
int "Flash reserved for M7 core"
|
||||
default 1048576 if STM32_CORTEXM4_ENABLED || ARCH_CHIP_STM32H7_CORTEXM4
|
||||
default 1048576 if STM32H7_CORTEXM4_ENABLED || ARCH_CHIP_STM32H7_CORTEXM4
|
||||
default 2097152
|
||||
|
||||
config STM32H7_CORTEXM7_SHMEM
|
||||
bool
|
||||
select ARM_MPU if ARCH_CHIP_STM32H7_CORTEXM7
|
||||
default y if STM32H7_CORTEXM4_ENABLED
|
||||
default y if STM32H7_CORTEXM4_ENABLED || ARCH_CHIP_STM32H7_CORTEXM4
|
||||
default n
|
||||
|
||||
config STM32H7_SHMEM_SRAM3
|
||||
@@ -2156,6 +2156,7 @@ config STM32H7_CUSTOM_CLOCKCONFIG
|
||||
|
||||
config STM32H7_SRAM4EXCLUDE
|
||||
bool "Exclude SRAM4 from the heap"
|
||||
default y if RPTUN
|
||||
default n
|
||||
---help---
|
||||
Exclude SRAM4 from the HEAP in order to use this 64 KB region
|
||||
|
||||
@@ -37,6 +37,10 @@ ifeq ($(CONFIG_STM32H7_HSEM),y)
|
||||
CHIP_CSRCS += stm32_hsem.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_RPTUN),y)
|
||||
CHIP_CSRCS += stm32_rptun.c
|
||||
endif
|
||||
|
||||
# Required STM32H7 files
|
||||
|
||||
CHIP_CSRCS += stm32_allocateheap.c stm32_exti_gpio.c stm32_gpio.c stm32_irq.c
|
||||
@@ -53,8 +57,12 @@ ifeq ($(CONFIG_STM32H7_ONESHOT),y)
|
||||
CHIP_CSRCS += stm32_oneshot.c stm32_oneshot_lowerhalf.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ARM_MPU),y)
|
||||
CHIP_CSRCS += stm32_mpuinit.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_BUILD_PROTECTED),y)
|
||||
CHIP_CSRCS += stm32_userspace.c stm32_mpuinit.c
|
||||
CHIP_CSRCS += stm32_userspace.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ARMV7M_DTCM),y)
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
#if defined(CONFIG_ARCH_CHIP_STM32H7_CORTEXM7) && \
|
||||
!defined(CONFIG_STM32H7_CORTEXM4_ENABLED)
|
||||
|
||||
/* Configuration for M7 core and M4 core support disabled */
|
||||
/* Configuration for M7 core when M4 core support disabled */
|
||||
|
||||
/* At startup the kernel will invoke arm_addregion() so that platform code
|
||||
* may register available memories for use as part of system heap.
|
||||
@@ -117,7 +117,7 @@
|
||||
#elif defined(CONFIG_ARCH_CHIP_STM32H7_CORTEXM7) && \
|
||||
defined(CONFIG_STM32H7_CORTEXM4_ENABLED)
|
||||
|
||||
/* Configuration for M7 core and M4 core support enabled */
|
||||
/* Configuration for M7 core when M4 core support enabled */
|
||||
|
||||
# define SRAM_START STM32_AXISRAM_BASE
|
||||
# define SRAM_END (SRAM_START + STM32H7_SRAM_SIZE)
|
||||
|
||||
@@ -27,12 +27,28 @@
|
||||
#include <assert.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/userspace.h>
|
||||
#ifdef CONFIG_BUILD_PROTECTED
|
||||
# include <nuttx/userspace.h>
|
||||
#endif
|
||||
|
||||
#include "mpu.h"
|
||||
#include "hardware/stm32_memorymap.h"
|
||||
#include "stm32_mpuinit.h"
|
||||
|
||||
#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_ARM_MPU)
|
||||
#ifdef CONFIG_ARM_MPU
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_RPTUN
|
||||
# ifdef CONFIG_STM32H7_SHMEM_SRAM3
|
||||
# define STM32_SHMEM_BASE STM32_SRAM3_BASE
|
||||
# define STM32_SHMEM_SIZE STM32H7_SRAM3_SIZE
|
||||
# else
|
||||
# error missing shmem MPU configuration
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
@@ -42,18 +58,25 @@
|
||||
* Name: stm32_mpuinitialize
|
||||
*
|
||||
* Description:
|
||||
* Configure the MPU to permit user-space access to only restricted SAM3U
|
||||
* resources.
|
||||
* Configure the MPU.
|
||||
*
|
||||
* If PROTECTED build:
|
||||
* - permit user-space access to only restricted STM32 resources.
|
||||
*
|
||||
* If RPTUN:
|
||||
* - configure shared memory as non-cacheable
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void stm32_mpuinitialize(void)
|
||||
{
|
||||
#ifdef CONFIG_BUILD_PROTECTED
|
||||
uintptr_t datastart = MIN(USERSPACE->us_datastart, USERSPACE->us_bssstart);
|
||||
uintptr_t dataend = MAX(USERSPACE->us_dataend, USERSPACE->us_bssend);
|
||||
|
||||
DEBUGASSERT(USERSPACE->us_textend >= USERSPACE->us_textstart &&
|
||||
dataend >= datastart);
|
||||
#endif
|
||||
|
||||
/* Show MPU information */
|
||||
|
||||
@@ -63,18 +86,27 @@ void stm32_mpuinitialize(void)
|
||||
|
||||
mpu_reset();
|
||||
|
||||
#ifdef CONFIG_BUILD_PROTECTED
|
||||
/* Configure user flash and SRAM space */
|
||||
|
||||
mpu_user_flash(USERSPACE->us_textstart,
|
||||
USERSPACE->us_textend - USERSPACE->us_textstart);
|
||||
|
||||
mpu_user_intsram(datastart, dataend - datastart);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_RPTUN
|
||||
/* Configure shared memory as non-cacheable */
|
||||
|
||||
mpu_priv_shmem((uintptr_t)STM32_SHMEM_BASE, STM32_SHMEM_SIZE);
|
||||
#endif
|
||||
|
||||
/* Then enable the MPU */
|
||||
|
||||
mpu_control(true, false, true);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_BUILD_PROTECTED
|
||||
/****************************************************************************
|
||||
* Name: stm32_mpu_uheap
|
||||
*
|
||||
@@ -89,5 +121,6 @@ void stm32_mpu_uheap(uintptr_t start, size_t size)
|
||||
{
|
||||
mpu_user_intsram(start, size);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_BUILD_PROTECTED && CONFIG_ARM_MPU */
|
||||
#endif /* CONFIG_ARM_MPU */
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#define __ARCH_ARM_SRC_STM32H7_STM32_MPUINIT_H
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_mpuinitialize
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
@@ -31,28 +30,8 @@
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_mpuinitialize
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_mpuinitialize
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_mpuinitialize
|
||||
* Inline Functions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_mpuinitialize
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
@@ -70,12 +49,11 @@ extern "C"
|
||||
* Name: stm32_mpuinitialize
|
||||
*
|
||||
* Description:
|
||||
* Configure the MPU to permit user-space access to only unrestricted
|
||||
* STM32H7 resources.
|
||||
* Configure the MPU.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_BUILD_PROTECTED
|
||||
#ifdef CONFIG_ARM_MPU
|
||||
void stm32_mpuinitialize(void);
|
||||
#else
|
||||
# define stm32_mpuinitialize()
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,61 @@
|
||||
/****************************************************************************
|
||||
* arch/arm/src/stm32h7/stm32_rptun.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ARCH_ARM_SRC_STM32H7_STM32_RPTUN_H
|
||||
#define __ARCH_ARM_SRC_STM32H7_STM32_RPTUN_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_rptun_init
|
||||
****************************************************************************/
|
||||
|
||||
int stm32_rptun_init(const char *shmemname, const char *cpuname);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __ARCH_ARM_SRC_STM32H7_STM32_RPTUN_H */
|
||||
@@ -36,6 +36,9 @@
|
||||
#include "barriers.h"
|
||||
#include "nvic.h"
|
||||
#include "mpu.h"
|
||||
#ifdef CONFIG_ARM_MPU
|
||||
# include "stm32_mpuinit.h"
|
||||
#endif
|
||||
|
||||
#include "stm32_rcc.h"
|
||||
#include "stm32_userspace.h"
|
||||
@@ -282,6 +285,12 @@ void __start(void)
|
||||
#ifdef CONFIG_BUILD_PROTECTED
|
||||
stm32_userspace();
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ARM_MPU
|
||||
/* Configure the MPU */
|
||||
|
||||
stm32_mpuinitialize();
|
||||
#endif
|
||||
showprogress('E');
|
||||
|
||||
/* Then start NuttX */
|
||||
|
||||
@@ -87,10 +87,6 @@ void stm32_userspace(void)
|
||||
{
|
||||
*dest++ = *src++;
|
||||
}
|
||||
|
||||
/* Configure the MPU to permit user-space access to its FLASH and RAM */
|
||||
|
||||
stm32_mpuinitialize();
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BUILD_PROTECTED */
|
||||
|
||||
Reference in New Issue
Block a user