You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/06/04 06:40:47 UTC

[incubator-nuttx] 03/03: arch: cxd56xx: Fix address mapping in cxd56_modtext.c

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

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

commit 386946ee5427bbc7cb6510daa09bb3fa48c1d80e
Author: Masayuki Ishikawa <ma...@gmail.com>
AuthorDate: Fri Jun 4 10:54:46 2021 +0900

    arch: cxd56xx: Fix address mapping in cxd56_modtext.c
    
    Summary:
    - I noticed that DEBUGASSERTION() happens when executing
      an ELF application
    - This commit fixes this issue by re-mapping the address
      to SYSBUS in up_module_text_free()
    
    Impact:
    - None
    
    Testing:
    - Tested with spresense (both DEBUG_ASSERTIONS=n and y)
    
    Signed-off-by: Masayuki Ishikawa <Ma...@jp.sony.com>
---
 arch/arm/src/cxd56xx/cxd56_modtext.c | 36 +++++++++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)

diff --git a/arch/arm/src/cxd56xx/cxd56_modtext.c b/arch/arm/src/cxd56xx/cxd56_modtext.c
index b58fcb3..f17faba 100644
--- a/arch/arm/src/cxd56xx/cxd56_modtext.c
+++ b/arch/arm/src/cxd56xx/cxd56_modtext.c
@@ -34,6 +34,12 @@
 #include <nuttx/kmalloc.h>
 
 /****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define SYSBUS_ADDRESS_OFFSET 0x20000000
+
+/****************************************************************************
  * Public Functions
  ****************************************************************************/
 
@@ -55,7 +61,19 @@ FAR void *up_module_text_memalign(size_t align, size_t size)
   ret = (FAR void *)kmm_malloc(size);
 
 #ifdef CONFIG_CXD56_USE_SYSBUS
-  ret -= 0x20000000;
+  if (ret)
+    {
+      binfo("** ret=%p \n", ret);
+
+      /* NOTE:
+       * kmm_malloc() will return the address in SYSBUS.
+       * So convert the address to I/D BUS.
+       */
+
+      ret -= SYSBUS_ADDRESS_OFFSET;
+
+      binfo("** mapped to %p \n", ret);
+    }
 #endif
 
   return ret;
@@ -67,5 +85,21 @@ FAR void *up_module_text_memalign(size_t align, size_t size)
 
 void up_module_text_free(FAR void *p)
 {
+#ifdef CONFIG_CXD56_USE_SYSBUS
+  if (p)
+    {
+      binfo("** p=%p \n", p);
+
+      /* NOTE:
+       * The address p will be in I/D BUS.
+       * So convert the address to SYSBUS.
+       */
+
+      p += SYSBUS_ADDRESS_OFFSET;
+
+      binfo("** mapped to %p \n", p);
+    }
+#endif
+
   kmm_free(p);
 }