You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ya...@apache.org on 2021/03/23 07:39:35 UTC

[incubator-nuttx] branch master updated (b2563b9 -> fcafacb)

This is an automated email from the ASF dual-hosted git repository.

yamamoto pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git.


    from b2563b9  fs/littlefs: Suppport the duplication function
     new cc23bde  boards/xtensa/esp32: Add a section in external memory to hold some BSS data.
     new fcafacb  esp32_allocateheap.c: Adjust the region of the heap coming from the external memory when a BSS section is allowed to reside there.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 arch/xtensa/Kconfig                                        |  7 +++++++
 arch/xtensa/src/common/xtensa.h                            |  2 ++
 arch/xtensa/src/common/xtensa_attr.h                       | 14 ++++++++++++++
 arch/xtensa/src/esp32/esp32_allocateheap.c                 | 13 +++++++++----
 arch/xtensa/src/esp32/esp32_start.c                        |  8 ++++++++
 .../xtensa/esp32/esp32-devkitc/scripts/esp32.template.ld   |  4 ++++
 boards/xtensa/esp32/esp32-devkitc/scripts/esp32_flash.ld   | 10 ++++++++++
 .../esp32/esp32-ethernet-kit/scripts/esp32.template.ld     |  4 ++++
 .../xtensa/esp32/esp32-ethernet-kit/scripts/esp32_flash.ld | 10 ++++++++++
 .../esp32/esp32-wrover-kit/scripts/esp32.template.ld       |  4 ++++
 .../xtensa/esp32/esp32-wrover-kit/scripts/esp32_flash.ld   | 10 ++++++++++
 11 files changed, 82 insertions(+), 4 deletions(-)

[incubator-nuttx] 01/02: boards/xtensa/esp32: Add a section in external memory to hold some BSS data.

Posted by ya...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

yamamoto pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit cc23bdeca4333fa78ffcb9b0dd2334b9ed577d70
Author: Abdelatif Guettouche <ab...@espressif.com>
AuthorDate: Fri Mar 5 12:24:23 2021 +0100

    boards/xtensa/esp32: Add a section in external memory to hold some BSS
    data.
    
    Signed-off-by: Abdelatif Guettouche <ab...@espressif.com>
---
 arch/xtensa/Kconfig                                          |  7 +++++++
 arch/xtensa/src/common/xtensa.h                              |  2 ++
 arch/xtensa/src/common/xtensa_attr.h                         | 12 ++++++++++++
 arch/xtensa/src/esp32/esp32_start.c                          |  8 ++++++++
 boards/xtensa/esp32/esp32-devkitc/scripts/esp32.template.ld  |  4 ++++
 boards/xtensa/esp32/esp32-devkitc/scripts/esp32_flash.ld     | 10 ++++++++++
 .../esp32/esp32-ethernet-kit/scripts/esp32.template.ld       |  4 ++++
 .../xtensa/esp32/esp32-ethernet-kit/scripts/esp32_flash.ld   | 10 ++++++++++
 .../xtensa/esp32/esp32-wrover-kit/scripts/esp32.template.ld  |  4 ++++
 boards/xtensa/esp32/esp32-wrover-kit/scripts/esp32_flash.ld  | 10 ++++++++++
 10 files changed, 71 insertions(+)

diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index 6de6e8c..d626703 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -131,6 +131,13 @@ config XTENSA_IMEM_REGION_SIZE
 	depends on XTENSA_IMEM_USE_SEPARATE_HEAP
 	default 0x18000
 
+config XTENSA_EXTMEM_BSS
+	bool "Allow BSS section in external memory"
+	default n
+	help
+		Adds a section and an attribute that allows to force variables into
+		the external memory.
+
 source arch/xtensa/src/lx6/Kconfig
 if ARCH_CHIP_ESP32
 source arch/xtensa/src/esp32/Kconfig
diff --git a/arch/xtensa/src/common/xtensa.h b/arch/xtensa/src/common/xtensa.h
index 88e70eb..eca3dbd 100644
--- a/arch/xtensa/src/common/xtensa.h
+++ b/arch/xtensa/src/common/xtensa.h
@@ -216,6 +216,8 @@ extern uint32_t _sbss;              /* Start of .bss */
 extern uint32_t _ebss;              /* End+1 of .bss */
 extern uint32_t _sheap;             /* Start of heap */
 extern uint32_t _eheap;             /* End+1 of heap */
+extern uint32_t _sbss_extmem;       /* start of external memory bss */
+extern uint32_t _ebss_extmem;       /* End+1 of external memory bss */
 
 /****************************************************************************
  * Inline Functions
diff --git a/arch/xtensa/src/common/xtensa_attr.h b/arch/xtensa/src/common/xtensa_attr.h
index b7f218c..fa67cbb 100644
--- a/arch/xtensa/src/common/xtensa_attr.h
+++ b/arch/xtensa/src/common/xtensa_attr.h
@@ -28,6 +28,12 @@
 #define __ARCH_XTENSA_SRC_COMMON_XTENSA_ATTR_H
 
 /****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+/****************************************************************************
  * Pre-processor Definitions
  ****************************************************************************/
 
@@ -63,4 +69,10 @@
 
 #define RTC_RODATA_ATTR __attribute__((section(".rtc.rodata")))
 
+/* Forces bss variable into external memory. */
+
+#ifdef CONFIG_XTENSA_EXTMEM_BSS
+#  define EXT_RAM_ATTR __attribute__((section(".extmem.bss")))
+#endif
+
 #endif /* __ARCH_XTENSA_SRC_COMMON_XTENSA_ATTR_H */
diff --git a/arch/xtensa/src/esp32/esp32_start.c b/arch/xtensa/src/esp32/esp32_start.c
index f00e109..1115cf3 100644
--- a/arch/xtensa/src/esp32/esp32_start.c
+++ b/arch/xtensa/src/esp32/esp32_start.c
@@ -157,6 +157,14 @@ void IRAM_ATTR __start(void)
       PANIC();
 #  endif
     }
+
+  /* Set external memory bss section to zero */
+
+#  ifdef CONFIG_XTENSA_EXTMEM_BSS
+     memset(&_sbss_extmem, 0,
+            (&_ebss_extmem - &_sbss_extmem) * sizeof(_sbss_extmem));
+#  endif
+
 #endif
 
   /* Initialize onboard resources */
diff --git a/boards/xtensa/esp32/esp32-devkitc/scripts/esp32.template.ld b/boards/xtensa/esp32/esp32-devkitc/scripts/esp32.template.ld
index 199380e..22d8226 100644
--- a/boards/xtensa/esp32/esp32-devkitc/scripts/esp32.template.ld
+++ b/boards/xtensa/esp32/esp32-devkitc/scripts/esp32.template.ld
@@ -68,6 +68,10 @@ MEMORY
 
   rtc_slow_seg(RW)  :    org = 0x50000000 + CONFIG_ESP32_ULP_COPROC_RESERVE_MEM,
                          len = 0x1000 - CONFIG_ESP32_ULP_COPROC_RESERVE_MEM
+
+  /* External memory, including data and text */
+
+  extmem_seg(RWX)  :  org = 0x3f800000, len = 0x400000
 }
 
 /* Heap ends at top of dram0_0_seg */
diff --git a/boards/xtensa/esp32/esp32-devkitc/scripts/esp32_flash.ld b/boards/xtensa/esp32/esp32-devkitc/scripts/esp32_flash.ld
index 31dd3fa..e4fffee 100644
--- a/boards/xtensa/esp32/esp32-devkitc/scripts/esp32_flash.ld
+++ b/boards/xtensa/esp32/esp32-devkitc/scripts/esp32_flash.ld
@@ -123,6 +123,16 @@ SECTIONS
     _sheap = ABSOLUTE(.);
   } >dram0_0_seg
 
+  /* External memory bss, from any global variable with EXT_RAM_ATTR attribute */
+
+  .extmem.bss (NOLOAD) :
+  {
+    _sbss_extmem = ABSOLUTE(.);
+    *(.extmem.bss .extmem.bss.*)
+    . = ALIGN(4);
+    _ebss_extmem = ABSOLUTE(.);
+  } > extmem_seg
+
   .flash.rodata :
   {
     _srodata = ABSOLUTE(.);
diff --git a/boards/xtensa/esp32/esp32-ethernet-kit/scripts/esp32.template.ld b/boards/xtensa/esp32/esp32-ethernet-kit/scripts/esp32.template.ld
index e029925..63024c0 100644
--- a/boards/xtensa/esp32/esp32-ethernet-kit/scripts/esp32.template.ld
+++ b/boards/xtensa/esp32/esp32-ethernet-kit/scripts/esp32.template.ld
@@ -68,6 +68,10 @@ MEMORY
 
   rtc_slow_seg(RW)  :    org = 0x50000000 + CONFIG_ESP32_ULP_COPROC_RESERVE_MEM,
                          len = 0x1000 - CONFIG_ESP32_ULP_COPROC_RESERVE_MEM
+
+  /* External memory, including data and text */
+
+  extmem_seg(RWX)  :  org = 0x3f800000, len = 0x400000
 }
 
 /* Heap ends at top of dram0_0_seg */
diff --git a/boards/xtensa/esp32/esp32-ethernet-kit/scripts/esp32_flash.ld b/boards/xtensa/esp32/esp32-ethernet-kit/scripts/esp32_flash.ld
index 1e3ccda..8e4cd2e 100644
--- a/boards/xtensa/esp32/esp32-ethernet-kit/scripts/esp32_flash.ld
+++ b/boards/xtensa/esp32/esp32-ethernet-kit/scripts/esp32_flash.ld
@@ -125,6 +125,16 @@ SECTIONS
     _sheap = ABSOLUTE(.);
   } >dram0_0_seg
 
+  /* External memory bss, from any global variable with EXT_RAM_ATTR attribute */
+
+  .extmem.bss (NOLOAD) :
+  {
+    _sbss_extmem = ABSOLUTE(.);
+    *(.extmem.bss .extmem.bss.*)
+    . = ALIGN(4);
+    _ebss_extmem = ABSOLUTE(.);
+  } > extmem_seg
+
   .flash.rodata :
   {
     _srodata = ABSOLUTE(.);
diff --git a/boards/xtensa/esp32/esp32-wrover-kit/scripts/esp32.template.ld b/boards/xtensa/esp32/esp32-wrover-kit/scripts/esp32.template.ld
index 4a7204a..f5ea00b 100644
--- a/boards/xtensa/esp32/esp32-wrover-kit/scripts/esp32.template.ld
+++ b/boards/xtensa/esp32/esp32-wrover-kit/scripts/esp32.template.ld
@@ -68,6 +68,10 @@ MEMORY
 
   rtc_slow_seg(RW)  :    org = 0x50000000 + CONFIG_ESP32_ULP_COPROC_RESERVE_MEM,
                          len = 0x1000 - CONFIG_ESP32_ULP_COPROC_RESERVE_MEM
+
+  /* External memory, including data and text */
+
+  extmem_seg(RWX)  :  org = 0x3f800000, len = 0x400000
 }
 
 /* Heap ends at top of dram0_0_seg */
diff --git a/boards/xtensa/esp32/esp32-wrover-kit/scripts/esp32_flash.ld b/boards/xtensa/esp32/esp32-wrover-kit/scripts/esp32_flash.ld
index 8103d22..b62887b 100644
--- a/boards/xtensa/esp32/esp32-wrover-kit/scripts/esp32_flash.ld
+++ b/boards/xtensa/esp32/esp32-wrover-kit/scripts/esp32_flash.ld
@@ -125,6 +125,16 @@ SECTIONS
     _sheap = ABSOLUTE(.);
   } >dram0_0_seg
 
+  /* External memory bss, from any global variable with EXT_RAM_ATTR attribute */
+
+  .extmem.bss (NOLOAD) :
+  {
+    _sbss_extmem = ABSOLUTE(.);
+    *(.extmem.bss .extmem.bss.*)
+    . = ALIGN(4);
+    _ebss_extmem = ABSOLUTE(.);
+  } > extmem_seg
+
   .flash.rodata :
   {
     _srodata = ABSOLUTE(.);

[incubator-nuttx] 02/02: esp32_allocateheap.c: Adjust the region of the heap coming from the external memory when a BSS section is allowed to reside there.

Posted by ya...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

yamamoto pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit fcafacb9a3a872957a0dd9044e943a6370b42782
Author: Abdelatif Guettouche <ab...@espressif.com>
AuthorDate: Thu Mar 11 15:19:02 2021 +0100

    esp32_allocateheap.c: Adjust the region of the heap coming from the
    external memory when a BSS section is allowed to reside there.
    
    Signed-off-by: Abdelatif Guettouche <ab...@espressif.com>
---
 arch/xtensa/src/common/xtensa_attr.h       |  4 +++-
 arch/xtensa/src/esp32/esp32_allocateheap.c | 13 +++++++++----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/arch/xtensa/src/common/xtensa_attr.h b/arch/xtensa/src/common/xtensa_attr.h
index fa67cbb..9b9e82d 100644
--- a/arch/xtensa/src/common/xtensa_attr.h
+++ b/arch/xtensa/src/common/xtensa_attr.h
@@ -69,10 +69,12 @@
 
 #define RTC_RODATA_ATTR __attribute__((section(".rtc.rodata")))
 
-/* Forces bss variable into external memory. */
+/* Allow bss variables into external memory. */
 
 #ifdef CONFIG_XTENSA_EXTMEM_BSS
 #  define EXT_RAM_ATTR __attribute__((section(".extmem.bss")))
+#else
+#  define EXT_RAM_ATTR
 #endif
 
 #endif /* __ARCH_XTENSA_SRC_COMMON_XTENSA_ATTR_H */
diff --git a/arch/xtensa/src/esp32/esp32_allocateheap.c b/arch/xtensa/src/esp32/esp32_allocateheap.c
index d040771..12502b9 100644
--- a/arch/xtensa/src/esp32/esp32_allocateheap.c
+++ b/arch/xtensa/src/esp32/esp32_allocateheap.c
@@ -148,11 +148,16 @@ void xtensa_add_region(void)
   umm_addregion(start, size);
 #endif
 
-#if defined(CONFIG_ESP32_SPIRAM)
-  /* Check for any additional memory regions */
-
+#ifdef CONFIG_ESP32_SPIRAM
 #  if defined(CONFIG_HEAP2_BASE) && defined(CONFIG_HEAP2_SIZE)
-    umm_addregion((FAR void *)CONFIG_HEAP2_BASE, CONFIG_HEAP2_SIZE);
+#    ifdef CONFIG_XTENSA_EXTMEM_BSS
+      start = (FAR void *)(&_ebss_extmem);
+      size = CONFIG_HEAP2_SIZE - (size_t)(&_ebss_extmem - &_sbss_extmem);
+#    else
+      start = (FAR void *)CONFIG_HEAP2_BASE;
+      size = CONFIG_HEAP2_SIZE;
+#    endif
+    umm_addregion(start, size);
 #  endif
 #endif
 }