xtensa/esp32s3: Disable psram as task stack

1. Disable psram as task stack to avoid system blocking.
2. Add some function comments.
This commit is contained in:
chenwen@espressif.com 2023-11-01 16:44:49 +08:00 committed by Alan Carvalho de Assis
parent 8d94c1b3cb
commit 5239d01dba
8 changed files with 135 additions and 16 deletions

View File

@ -255,6 +255,13 @@ config XTENSA_INTBACKTRACE
---help---
Add necessary logic to be able to have a full backtrace from an interrupt context.
config XTENSA_USE_SPIRAM_HEAP
bool "Enable SPI RAM heap"
default n
---help---
If enabled, SPIRAM can be selected as the heap, of course, the premise is that
the device needs to support SPIRAM.
config XTENSA_IMEM_USE_SEPARATE_HEAP
bool "Use a separate heap for internal memory"
select ARCH_HAVE_EXTRA_HEAPS

View File

@ -68,6 +68,12 @@ struct mallinfo; /* Forward reference, see malloc.h */
* Description:
* Initialize the internal heap.
*
* Input Parameters:
* None.
*
* Returned Value:
* None.
*
****************************************************************************/
void xtensa_imm_initialize(void);
@ -78,6 +84,12 @@ void xtensa_imm_initialize(void);
* Description:
* Allocate memory from the internal heap.
*
* Input Parameters:
* size - Size (in bytes) of the memory region to be allocated.
*
* Return Value:
* Adress of the allocated memory space. NULL, if allocation fails.
*
****************************************************************************/
void *xtensa_imm_malloc(size_t size);
@ -89,6 +101,13 @@ void *xtensa_imm_malloc(size_t size);
* Calculates the size of the allocation and
* allocate memory the internal heap.
*
* Input Parameters:
* n - Size (in types) of the memory region to be allocated.
* elem_size - Size (in bytes) of the type to be allocated.
*
* Return Value:
* Adress of the allocated memory space. NULL, if allocation fails.
*
****************************************************************************/
void *xtensa_imm_calloc(size_t n, size_t elem_size);
@ -99,6 +118,13 @@ void *xtensa_imm_calloc(size_t n, size_t elem_size);
* Description:
* Reallocate memory from the internal heap.
*
* Input Parameters:
* ptr - Adress to be reallocate.
* size - Size (in bytes) to be reallocate.
*
* Return Value:
* Adress of the possibly moved memory space. NULL, if allocation fails.
*
****************************************************************************/
void *xtensa_imm_realloc(void *ptr, size_t size);
@ -109,6 +135,12 @@ void *xtensa_imm_realloc(void *ptr, size_t size);
* Description:
* Allocate and zero memory from the internal heap.
*
* Input Parameters:
* size - Size (in bytes) of the memory region to be allocated.
*
* Return Value:
* Adress of the allocated memory space. NULL, if allocation fails.
*
****************************************************************************/
void *xtensa_imm_zalloc(size_t size);
@ -119,6 +151,12 @@ void *xtensa_imm_zalloc(size_t size);
* Description:
* Free memory from the internal heap.
*
* Input Parameters:
* mem - Adress to be freed.
*
* Returned Value:
* None.
*
****************************************************************************/
void xtensa_imm_free(void *mem);
@ -131,9 +169,16 @@ void xtensa_imm_free(void *mem);
* within that chunk that meets the alignment request and then frees any
* leading or trailing space.
*
* The alignment argument must be a power of two (not checked). 8-byte
* The alignment argument must be a power of two (not checked). 8-byte
* alignment is guaranteed by normal malloc calls.
*
* Input Parameters:
* alignment - Requested alignment.
* size - Size (in bytes) of the memory region to be allocated.
*
* Return Value:
* Adress of the allocated adress. NULL, if allocation fails.
*
****************************************************************************/
void *xtensa_imm_memalign(size_t alignment, size_t size);
@ -144,11 +189,11 @@ void *xtensa_imm_memalign(size_t alignment, size_t size);
* Description:
* Check if an address lies in the internal heap.
*
* Parameters:
* mem - The address to check
* Input Parameters:
* mem - The address to check.
*
* Return Value:
* true if the address is a member of the internal heap. false if not
* True if the address is a member of the internal heap. False if not.
*
****************************************************************************/
@ -161,6 +206,12 @@ bool xtensa_imm_heapmember(void *mem);
* mallinfo returns a copy of updated current heap information for the
* user heap.
*
* Input Parameters:
* None.
*
* Return Value:
* info - Where memory information will be copied.
*
****************************************************************************/
struct mallinfo xtensa_imm_mallinfo(void);

View File

@ -72,8 +72,8 @@
*/
#ifdef CONFIG_MM_KERNEL_HEAP
#define HEAP_REGION1_END 0x3fccfff0
#define HEAP_REGION2_START 0x3fcd0000
# define HEAP_REGION1_END 0x3fccfff0
# define HEAP_REGION2_START 0x3fcd0000
#endif
#ifdef CONFIG_XTENSA_IMEM_USE_SEPARATE_HEAP

View File

@ -40,10 +40,18 @@
# define UMM_FREE(p) xtensa_imm_free(p)
# define UMM_HEAPMEMEBER(p) xtensa_imm_heapmember(p)
#else
# define UMM_MALLOC(s) kumm_malloc(s)
# define UMM_MEMALIGN(a,s) kumm_memalign(a,s)
# define UMM_FREE(p) kumm_free(p)
# define UMM_HEAPMEMEBER(p) umm_heapmember(p)
#endif
# ifdef CONFIG_XTENSA_USE_SPIRAM_HEAP
# define UMM_MALLOC(s) kmm_malloc(s)
# define UMM_MEMALIGN(a,s) kmm_memalign(a,s)
# define UMM_FREE(p) kmm_free(p)
# define UMM_HEAPMEMEBER(p) mm_heapmember(p)
# else
# define UMM_MALLOC(s) kumm_malloc(s)
# define UMM_MEMALIGN(a,s) kumm_memalign(a,s)
# define UMM_FREE(p) kumm_free(p)
# define UMM_HEAPMEMEBER(p) umm_heapmember(p)
# endif /* CONFIG_XTENSA_USE_SPIRAM_HEAP */
#endif /* CONFIG_XTENSA_IMEM_USE_SEPARATE_HEAP */
#endif /* __ARCH_XTENSA_SRC_COMMON_XTENSA_MM_H */

View File

@ -875,10 +875,12 @@ choice ESP32S3_SPIRAM_HEAP
config ESP32S3_SPIRAM_COMMON_HEAP
bool "Additional region to kernel heap"
select XTENSA_USE_SPIRAM_HEAP
config ESP32S3_SPIRAM_USER_HEAP
bool "Separated userspace heap"
select MM_KERNEL_HEAP
select XTENSA_USE_SPIRAM_HEAP
endchoice # ESP32S3_SPIRAM_HEAP

View File

@ -51,6 +51,12 @@ struct mm_heap_s *g_iheap;
* Description:
* Initialize the internal heap.
*
* Input Parameters:
* None.
*
* Returned Value:
* None.
*
****************************************************************************/
void xtensa_imm_initialize(void)
@ -69,6 +75,12 @@ void xtensa_imm_initialize(void)
* Description:
* Allocate memory from the internal heap.
*
* Input Parameters:
* size - Size (in bytes) of the memory region to be allocated.
*
* Return Value:
* Adress of the allocated memory space. NULL, if allocation fails.
*
****************************************************************************/
void *xtensa_imm_malloc(size_t size)
@ -83,6 +95,13 @@ void *xtensa_imm_malloc(size_t size)
* Calculates the size of the allocation and
* allocate memory the internal heap.
*
* Input Parameters:
* n - Size (in types) of the memory region to be allocated.
* elem_size - Size (in bytes) of the type to be allocated.
*
* Return Value:
* Adress of the allocated memory space. NULL, if allocation fails.
*
****************************************************************************/
void *xtensa_imm_calloc(size_t n, size_t elem_size)
@ -96,6 +115,13 @@ void *xtensa_imm_calloc(size_t n, size_t elem_size)
* Description:
* Reallocate memory from the internal heap.
*
* Input Parameters:
* ptr - Adress to be reallocate.
* size - Size (in bytes) to be reallocate.
*
* Return Value:
* Adress of the possibly moved memory space. NULL, if allocation fails.
*
****************************************************************************/
void *xtensa_imm_realloc(void *ptr, size_t size)
@ -109,6 +135,12 @@ void *xtensa_imm_realloc(void *ptr, size_t size)
* Description:
* Allocate and zero memory from the internal heap.
*
* Input Parameters:
* size - Size (in bytes) of the memory region to be allocated.
*
* Return Value:
* Adress of the allocated memory space. NULL, if allocation fails.
*
****************************************************************************/
void *xtensa_imm_zalloc(size_t size)
@ -122,6 +154,12 @@ void *xtensa_imm_zalloc(size_t size)
* Description:
* Free memory from the internal heap.
*
* Input Parameters:
* mem - Adress to be freed.
*
* Returned Value:
* None.
*
****************************************************************************/
void xtensa_imm_free(void *mem)
@ -140,6 +178,13 @@ void xtensa_imm_free(void *mem)
* The alignment argument must be a power of two (not checked). 8-byte
* alignment is guaranteed by normal malloc calls.
*
* Input Parameters:
* alignment - Requested alignment.
* size - Size (in bytes) of the memory region to be allocated.
*
* Return Value:
* Adress of the allocated adress. NULL, if allocation fails.
*
****************************************************************************/
void *xtensa_imm_memalign(size_t alignment, size_t size)
@ -153,11 +198,11 @@ void *xtensa_imm_memalign(size_t alignment, size_t size)
* Description:
* Check if an address lies in the internal heap.
*
* Parameters:
* mem - The address to check
* Input Parameters:
* mem - The address to check.
*
* Return Value:
* true if the address is a member of the internal heap. false if not
* True if the address is a member of the internal heap. False if not.
*
****************************************************************************/
@ -173,6 +218,12 @@ bool xtensa_imm_heapmember(void *mem)
* mallinfo returns a copy of updated current heap information for the
* user heap.
*
* Input Parameters:
* None.
*
* Return Value:
* info - Where memory information will be copied.
*
****************************************************************************/
struct mallinfo xtensa_imm_mallinfo(void)

View File

@ -423,7 +423,7 @@ config ARCH_BOARD_FRANZININHO_WIFI
config ARCH_BOARD_ESP32S3_DEVKIT
bool "Espressif ESP32-S3 DevKit"
depends on ARCH_CHIP_ESP32S3WROOM1 || ARCH_CHIP_ESP32S3MINI1
depends on ARCH_CHIP_ESP32S3WROOM1 || ARCH_CHIP_ESP32S3MINI1 || ARCH_CHIP_ESP32S3WROOM2
select ARCH_HAVE_LEDS
select ARCH_HAVE_BUTTONS
select ARCH_HAVE_IRQBUTTONS if ESP32S3_GPIO_IRQ

View File

@ -14,7 +14,7 @@ CONFIG_ARCH_BOARD_COMMON=y
CONFIG_ARCH_BOARD_ESP32S3_DEVKIT=y
CONFIG_ARCH_CHIP="esp32s3"
CONFIG_ARCH_CHIP_ESP32S3=y
CONFIG_ARCH_CHIP_ESP32S3WROOM1=y
CONFIG_ARCH_CHIP_ESP32S3WROOM2=y
CONFIG_ARCH_INTERRUPTSTACK=2048
CONFIG_ARCH_STACKDUMP=y
CONFIG_ARCH_XTENSA=y