arch/arm/src/stm32l4: if SRAM3 is used as heap, do not power it off in stop 2 mode.

This commit is contained in:
Juha Niskanen 2019-06-13 05:52:40 -06:00 committed by Gregory Nutt
parent e69471ba2f
commit abc49a6a13
9 changed files with 42 additions and 33 deletions

View File

@ -124,7 +124,7 @@
#if CONFIG_MM_REGIONS != LPC31_NEXT_REGIONS
# if CONFIG_MM_REGIONS < LPC31_NEXT_REGIONS
# error "CONFIG_MM_REGIONS is large enough for the selected memory regions"
# error "CONFIG_MM_REGIONS is not large enough for the selected memory regions"
# else
# error "CONFIG_MM_REGIONS is too large for the selected memory regions"
# endif

View File

@ -1,5 +1,5 @@
/****************************************************************************
* arch/arm/src/stm32f7/up_allocateheap.c
* arch/arm/src/stm32f7/stm32_allocateheap.c
*
* Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -383,7 +383,7 @@ void up_addregion(void)
{
#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_MM_KERNEL_HEAP)
/* Allow user-mode access to the STM32F20xxx/STM32F40xxx SRAM2 heap */
/* Allow user-mode access to the SRAM2 heap */
stm32_mpu_uheap((uintptr_t)SRAM2_START, SRAM2_END-SRAM2_START);
@ -393,7 +393,7 @@ void up_addregion(void)
up_heap_color((FAR void *)SRAM2_START, SRAM2_END-SRAM2_START);
/* Add the STM32F20xxx/STM32F40xxx SRAM2 user heap region. */
/* Add the SRAM2 user heap region. */
kumm_addregion((FAR void *)SRAM2_START, SRAM2_END-SRAM2_START);

View File

@ -1,5 +1,5 @@
/****************************************************************************
* arch/arm/src/stm32h7/up_allocateheap.c
* arch/arm/src/stm32h7/stm32_allocateheap.c
*
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>

View File

@ -857,7 +857,7 @@ config STM32L4_IO_CONFIG_A
bool
default n
comment "STM32L4 SRAM2 Options"
comment "STM32L4 SRAM2 and SRAM3 Options"
config STM32L4_SRAM2_HEAP
bool "SRAM2 is used for heap"
@ -885,6 +885,15 @@ config STM32L4_SRAM2_INIT
case, the board should handle the initialization itself at the appropriate
time.
config STM32L4_SRAM3_HEAP
bool "SRAM3 is used for heap"
depends on STM32L4_STM32L4XR
default y
---help---
Add the STM32L4 SRAM3 to the heap for use by malloc().
NOTE: you must also select an appropriate number of memory regions in the
'Memory Management' section.
comment "STM32L4 Peripherals"
menu "STM32L4 Peripheral Support"

View File

@ -600,6 +600,7 @@
#define RCC_AHB2SMENR_GPIOHSMEN (1 << 7) /* Bit 7: IO port H enable during Sleep mode */
#define RCC_AHB2SMENR_GPIOISMEN (1 << 8) /* Bit 8: IO port I enable during Sleep mode */
#define RCC_AHB2SMENR_SRAM2SMEN (1 << 9) /* Bit 9: SRAM2 enable during Sleep mode */
#define RCC_AHB2SMENR_SRAM3SMEN (1 << 10) /* Bit 10: SRAM3 enable during Sleep mode */
#define RCC_AHB2SMENR_OTGFSSMEN (1 << 12) /* Bit 12: USB OTG FS module enable during Sleep mode */
#define RCC_AHB2SMENR_ADCSMEN (1 << 13) /* Bit 13: ADC interface enable during Sleep mode (common to all ADCs) */
#define RCC_AHB2SMENR_DCMISMEN (1 << 14) /* Bit 14: DCMI interface enable during Sleep mode */

View File

@ -1,5 +1,5 @@
/****************************************************************************
* arch/arm/src/stm32l4/up_allocateheap.c
* arch/arm/src/stm32l4/stm32l4_allocateheap.c
*
* Copyright (C) 2011-2013, 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -122,30 +122,23 @@
#ifdef STM32L4_SRAM3_SIZE
# define SRAM3_START STM32L4_SRAM3_BASE
# define SRAM3_END (SRAM3_START + STM32L4_SRAM3_SIZE)
# define CONFIG_STM32L4_SRAM3_HEAP
#endif
#if defined(CONFIG_STM32L4_SRAM3_HEAP)
/* TODO: better check here */
# if CONFIG_MM_REGIONS < 3
# error you need at least 3 memory manager regions to support SRAM2 and SRAM3
# endif
/* Some sanity checking. If multiple memory regions are defined, verify
* that CONFIG_MM_REGIONS is set to match the number of memory regions
* that we have been asked to add to the heap.
*/
#if CONFIG_MM_REGIONS < defined(CONFIG_STM32L4_SRAM2_HEAP) + \
defined(CONFIG_STM32L4_SRAM3_HEAP) + \
defined(CONFIG_STM32L4_FSMC_SRAM_HEAP) + 1
# error "You need more memory manager regions to support selected heap components"
#endif
#if defined(CONFIG_STM32L4_SRAM2_HEAP) && defined(CONFIG_STM32L4_FSMC_SRAM_HEAP)
# if CONFIG_MM_REGIONS < 3
# error you need at least 3 memory manager regions to support SRAM2 and FSMC
# endif
#endif
#if defined(CONFIG_STM32L4_SRAM2_HEAP) || defined(CONFIG_STM32L4_FSMC_SRAM_HEAP)
# if CONFIG_MM_REGIONS < 2
# error you need at least 2 memory manager regions to support SRAM2 or FSMC
# endif
#endif
#if CONFIG_MM_REGIONS < 1
# warning you have no heap; malloc() will fail. are you sure?
#if CONFIG_MM_REGIONS > defined(CONFIG_STM32L4_SRAM2_HEAP) + \
defined(CONFIG_STM32L4_SRAM3_HEAP) + \
defined(CONFIG_STM32L4_FSMC_SRAM_HEAP) + 1
# warning "CONFIG_MM_REGIONS large enough but I do not know what some of the region(s) are"
#endif
/* If FSMC SRAM is going to be used as heap, then verify that the starting
@ -259,7 +252,7 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size)
/* Allow user-mode access to the user heap memory */
stm32l4_mpu_uheap((uintptr_t)ubase, usize);
stm32l4_mpu_uheap((uintptr_t)ubase, usize);
#else
/* Return the heap settings */

View File

@ -146,9 +146,15 @@ int stm32l4_pmstop2(void)
{
uint32_t regval;
regval = getreg32(STM32L4_PWR_CR1);
#ifdef CONFIG_STM32L4_SRAM3_HEAP
/* SRAM3 is used as heap, so it must not be powered off in Stop 2 mode. */
regval |= PWR_CR1_RRSTP;
#endif
/* Select Stop 2 mode in power control register 1. */
regval = getreg32(STM32L4_PWR_CR1);
regval &= ~PWR_CR1_LPMS_MASK;
regval |= PWR_CR1_LPMS_STOP2;
putreg32(regval, STM32L4_PWR_CR1);

View File

@ -330,7 +330,7 @@ static int local_set_policy(FAR struct file *filep, unsigned long policy)
ret = file_ioctl(filep, PIPEIOC_POLICY, policy);
if (ret < 0)
{
nerr("ERROR: Failed to set FIFO buffer policty: %d\n", ret);
nerr("ERROR: Failed to set FIFO buffer policy: %d\n", ret);
}
return ret;

View File

@ -489,11 +489,11 @@ config TASK_NAME_SIZE
int "Maximum task name size"
default 31
---help---
Spcifies that maximum size of a task name to save in the TCB.
Specifies the maximum size of a task name to save in the TCB.
Useful if scheduler instrumentation is selected. Set to zero to
disable. Excludes the NUL terminator; the actual allocated size
willl be TASK_NAME_SIZE + 1. The default of 31 then results in
a align-able 32-byte allocation.::
will be TASK_NAME_SIZE + 1. The default of 31 then results in
a align-able 32-byte allocation.
config MAX_TASKS
int "Max number of tasks"