mirror of
https://github.com/apache/nuttx.git
synced 2026-05-24 07:46:16 +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)
|
list(APPEND SRCS stm32_hsem.c)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(CONFIG_RPTUN)
|
||||||
|
list(APPEND SRCS stm32_rptun.c)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(CONFIG_SCHED_TICKLESS)
|
if(CONFIG_SCHED_TICKLESS)
|
||||||
list(APPEND SRCS stm32_tickless.c)
|
list(APPEND SRCS stm32_tickless.c)
|
||||||
else()
|
else()
|
||||||
@@ -55,8 +59,12 @@ if(CONFIG_STM32H7_ONESHOT)
|
|||||||
list(APPEND SRCS stm32_oneshot.c stm32_oneshot_lowerhalf.c)
|
list(APPEND SRCS stm32_oneshot.c stm32_oneshot_lowerhalf.c)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(CONFIG_ARM_MPU)
|
||||||
|
list(APPEND SRCS stm32_mpuinit.c)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(CONFIG_BUILD_PROTECTED)
|
if(CONFIG_BUILD_PROTECTED)
|
||||||
list(APPEND SRCS stm32_userspace.c stm32_mpuinit.c)
|
list(APPEND SRCS stm32_userspace.c)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CONFIG_ARMV7M_DTCM)
|
if(CONFIG_ARMV7M_DTCM)
|
||||||
|
|||||||
@@ -522,13 +522,13 @@ endif
|
|||||||
|
|
||||||
config STM32H7_CORTEXM7_FLASH_SIZE
|
config STM32H7_CORTEXM7_FLASH_SIZE
|
||||||
int "Flash reserved for M7 core"
|
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
|
default 2097152
|
||||||
|
|
||||||
config STM32H7_CORTEXM7_SHMEM
|
config STM32H7_CORTEXM7_SHMEM
|
||||||
bool
|
bool
|
||||||
select ARM_MPU if ARCH_CHIP_STM32H7_CORTEXM7
|
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
|
default n
|
||||||
|
|
||||||
config STM32H7_SHMEM_SRAM3
|
config STM32H7_SHMEM_SRAM3
|
||||||
@@ -2156,6 +2156,7 @@ config STM32H7_CUSTOM_CLOCKCONFIG
|
|||||||
|
|
||||||
config STM32H7_SRAM4EXCLUDE
|
config STM32H7_SRAM4EXCLUDE
|
||||||
bool "Exclude SRAM4 from the heap"
|
bool "Exclude SRAM4 from the heap"
|
||||||
|
default y if RPTUN
|
||||||
default n
|
default n
|
||||||
---help---
|
---help---
|
||||||
Exclude SRAM4 from the HEAP in order to use this 64 KB region
|
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
|
CHIP_CSRCS += stm32_hsem.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_RPTUN),y)
|
||||||
|
CHIP_CSRCS += stm32_rptun.c
|
||||||
|
endif
|
||||||
|
|
||||||
# Required STM32H7 files
|
# Required STM32H7 files
|
||||||
|
|
||||||
CHIP_CSRCS += stm32_allocateheap.c stm32_exti_gpio.c stm32_gpio.c stm32_irq.c
|
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
|
CHIP_CSRCS += stm32_oneshot.c stm32_oneshot_lowerhalf.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_ARM_MPU),y)
|
||||||
|
CHIP_CSRCS += stm32_mpuinit.c
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_BUILD_PROTECTED),y)
|
ifeq ($(CONFIG_BUILD_PROTECTED),y)
|
||||||
CHIP_CSRCS += stm32_userspace.c stm32_mpuinit.c
|
CHIP_CSRCS += stm32_userspace.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_ARMV7M_DTCM),y)
|
ifeq ($(CONFIG_ARMV7M_DTCM),y)
|
||||||
|
|||||||
@@ -57,7 +57,7 @@
|
|||||||
#if defined(CONFIG_ARCH_CHIP_STM32H7_CORTEXM7) && \
|
#if defined(CONFIG_ARCH_CHIP_STM32H7_CORTEXM7) && \
|
||||||
!defined(CONFIG_STM32H7_CORTEXM4_ENABLED)
|
!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
|
/* At startup the kernel will invoke arm_addregion() so that platform code
|
||||||
* may register available memories for use as part of system heap.
|
* may register available memories for use as part of system heap.
|
||||||
@@ -117,7 +117,7 @@
|
|||||||
#elif defined(CONFIG_ARCH_CHIP_STM32H7_CORTEXM7) && \
|
#elif defined(CONFIG_ARCH_CHIP_STM32H7_CORTEXM7) && \
|
||||||
defined(CONFIG_STM32H7_CORTEXM4_ENABLED)
|
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_START STM32_AXISRAM_BASE
|
||||||
# define SRAM_END (SRAM_START + STM32H7_SRAM_SIZE)
|
# define SRAM_END (SRAM_START + STM32H7_SRAM_SIZE)
|
||||||
|
|||||||
@@ -27,12 +27,28 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
|
||||||
#include <nuttx/userspace.h>
|
#ifdef CONFIG_BUILD_PROTECTED
|
||||||
|
# include <nuttx/userspace.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "mpu.h"
|
#include "mpu.h"
|
||||||
|
#include "hardware/stm32_memorymap.h"
|
||||||
#include "stm32_mpuinit.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
|
* Public Functions
|
||||||
@@ -42,18 +58,25 @@
|
|||||||
* Name: stm32_mpuinitialize
|
* Name: stm32_mpuinitialize
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Configure the MPU to permit user-space access to only restricted SAM3U
|
* Configure the MPU.
|
||||||
* resources.
|
*
|
||||||
|
* If PROTECTED build:
|
||||||
|
* - permit user-space access to only restricted STM32 resources.
|
||||||
|
*
|
||||||
|
* If RPTUN:
|
||||||
|
* - configure shared memory as non-cacheable
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void stm32_mpuinitialize(void)
|
void stm32_mpuinitialize(void)
|
||||||
{
|
{
|
||||||
|
#ifdef CONFIG_BUILD_PROTECTED
|
||||||
uintptr_t datastart = MIN(USERSPACE->us_datastart, USERSPACE->us_bssstart);
|
uintptr_t datastart = MIN(USERSPACE->us_datastart, USERSPACE->us_bssstart);
|
||||||
uintptr_t dataend = MAX(USERSPACE->us_dataend, USERSPACE->us_bssend);
|
uintptr_t dataend = MAX(USERSPACE->us_dataend, USERSPACE->us_bssend);
|
||||||
|
|
||||||
DEBUGASSERT(USERSPACE->us_textend >= USERSPACE->us_textstart &&
|
DEBUGASSERT(USERSPACE->us_textend >= USERSPACE->us_textstart &&
|
||||||
dataend >= datastart);
|
dataend >= datastart);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Show MPU information */
|
/* Show MPU information */
|
||||||
|
|
||||||
@@ -63,18 +86,27 @@ void stm32_mpuinitialize(void)
|
|||||||
|
|
||||||
mpu_reset();
|
mpu_reset();
|
||||||
|
|
||||||
|
#ifdef CONFIG_BUILD_PROTECTED
|
||||||
/* Configure user flash and SRAM space */
|
/* Configure user flash and SRAM space */
|
||||||
|
|
||||||
mpu_user_flash(USERSPACE->us_textstart,
|
mpu_user_flash(USERSPACE->us_textstart,
|
||||||
USERSPACE->us_textend - USERSPACE->us_textstart);
|
USERSPACE->us_textend - USERSPACE->us_textstart);
|
||||||
|
|
||||||
mpu_user_intsram(datastart, dataend - datastart);
|
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 */
|
/* Then enable the MPU */
|
||||||
|
|
||||||
mpu_control(true, false, true);
|
mpu_control(true, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_BUILD_PROTECTED
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: stm32_mpu_uheap
|
* Name: stm32_mpu_uheap
|
||||||
*
|
*
|
||||||
@@ -89,5 +121,6 @@ void stm32_mpu_uheap(uintptr_t start, size_t size)
|
|||||||
{
|
{
|
||||||
mpu_user_intsram(start, 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
|
#define __ARCH_ARM_SRC_STM32H7_STM32_MPUINIT_H
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: stm32_mpuinitialize
|
|
||||||
* Included Files
|
* Included Files
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
@@ -31,28 +30,8 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: stm32_mpuinitialize
|
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: stm32_mpuinitialize
|
|
||||||
* Public Types
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: stm32_mpuinitialize
|
|
||||||
* Inline Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef __ASSEMBLY__
|
#ifndef __ASSEMBLY__
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: stm32_mpuinitialize
|
|
||||||
* Public Data
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
#define EXTERN extern "C"
|
#define EXTERN extern "C"
|
||||||
@@ -70,12 +49,11 @@ extern "C"
|
|||||||
* Name: stm32_mpuinitialize
|
* Name: stm32_mpuinitialize
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Configure the MPU to permit user-space access to only unrestricted
|
* Configure the MPU.
|
||||||
* STM32H7 resources.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_BUILD_PROTECTED
|
#ifdef CONFIG_ARM_MPU
|
||||||
void stm32_mpuinitialize(void);
|
void stm32_mpuinitialize(void);
|
||||||
#else
|
#else
|
||||||
# define stm32_mpuinitialize()
|
# 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 "barriers.h"
|
||||||
#include "nvic.h"
|
#include "nvic.h"
|
||||||
#include "mpu.h"
|
#include "mpu.h"
|
||||||
|
#ifdef CONFIG_ARM_MPU
|
||||||
|
# include "stm32_mpuinit.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "stm32_rcc.h"
|
#include "stm32_rcc.h"
|
||||||
#include "stm32_userspace.h"
|
#include "stm32_userspace.h"
|
||||||
@@ -282,6 +285,12 @@ void __start(void)
|
|||||||
#ifdef CONFIG_BUILD_PROTECTED
|
#ifdef CONFIG_BUILD_PROTECTED
|
||||||
stm32_userspace();
|
stm32_userspace();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARM_MPU
|
||||||
|
/* Configure the MPU */
|
||||||
|
|
||||||
|
stm32_mpuinitialize();
|
||||||
|
#endif
|
||||||
showprogress('E');
|
showprogress('E');
|
||||||
|
|
||||||
/* Then start NuttX */
|
/* Then start NuttX */
|
||||||
|
|||||||
@@ -87,10 +87,6 @@ void stm32_userspace(void)
|
|||||||
{
|
{
|
||||||
*dest++ = *src++;
|
*dest++ = *src++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Configure the MPU to permit user-space access to its FLASH and RAM */
|
|
||||||
|
|
||||||
stm32_mpuinitialize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_BUILD_PROTECTED */
|
#endif /* CONFIG_BUILD_PROTECTED */
|
||||||
|
|||||||
Reference in New Issue
Block a user