Browse Source

Fix iram/irom section contents (#1566)

Yury Popov 7 years ago
parent
commit
83eec61874
4 changed files with 77 additions and 69 deletions
  1. 1 1
      app/driver/pwm.c
  2. 2 2
      app/include/sections.h
  3. 1 1
      app/modules/perf.c
  4. 73 65
      ld/nodemcu.ld

+ 1 - 1
app/driver/pwm.c

@@ -180,7 +180,7 @@ pwm_start(void)
         // yeah, if all channels' duty is 0 or 255, don't need to start timer, otherwise start...
         if (*local_channel != 1) {
 	  PWM_DBG("Need to setup timer\n");
-	  if (!platform_hw_timer_init(TIMER_OWNER, NMI_SOURCE, FALSE)) {
+	  if (!platform_hw_timer_init(TIMER_OWNER, FRC1_SOURCE, FALSE)) {
 	    return FALSE;
 	  }
 	  pwm_timer_down = 0;

+ 2 - 2
app/include/sections.h

@@ -1,7 +1,7 @@
 #ifndef _SECTIONS_H_
 #define _SECTIONS_H_
 
-#define TEXT_SECTION_ATTR __attribute__((section(".text")))
-#define RAM_CONST_SECTION_ATTR __attribute((section(".data")))
+#define TEXT_SECTION_ATTR __attribute__((section(".iram0.text")))
+#define RAM_CONST_SECTION_ATTR __attribute((section(".rodata.dram")))
 
 #endif

+ 1 - 1
app/modules/perf.c

@@ -93,7 +93,7 @@ static int perf_start(lua_State *L)
   data = d;
 
   // Start the timer
-  if (!platform_hw_timer_init(TIMER_OWNER, NMI_SOURCE, TRUE)) {
+  if (!platform_hw_timer_init(TIMER_OWNER, FRC1_SOURCE, TRUE)) {
     // Failed to init the timer
     data = NULL;
     lua_unref(L, d->ref);

+ 73 - 65
ld/nodemcu.ld

@@ -5,7 +5,7 @@ MEMORY
   dport0_0_seg :                        org = 0x3FF00000, len = 0x10
   dram0_0_seg :                         org = 0x3FFE8000, len = 0x14000
   iram1_0_seg :                         org = 0x40100000, len = 0x8000
-  irom0_0_seg :                         org = 0x40210000, len = 0x80000
+  irom0_0_seg :                         org = 0x40210000, len = 0xD0000
 }
 
 PHDRS
@@ -71,33 +71,50 @@ SECTIONS
     _dport0_data_end = ABSOLUTE(.);
   } >dport0_0_seg :dport0_0_phdr
 
-  .irom0.text : ALIGN(0x1000)
+  .text : ALIGN(4)
   {
-    _irom0_text_start = ABSOLUTE(.);
-    *(.servercert.flash)
-    *(.clientcert.flash)
-    *(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text)
-    *(.literal.* .text.*)
-    *(.rodata*)
-    *(.sdk.version)
-
-    /* Link-time arrays containing the defs for the included modules */
-    . = ALIGN(4);
-    lua_libs = ABSOLUTE(.);
-    /* Allow either empty define or defined-to-1 to include the module */
-    KEEP(*(.lua_libs))
-    LONG(0) LONG(0) /* Null-terminate the array */
-    lua_rotable = ABSOLUTE(.);
-    KEEP(*(.lua_rotable))
-    LONG(0) LONG(0) /* Null-terminate the array */
+    _stext = .;
+    _text_start = ABSOLUTE(.);
+    *(.UserEnter.text)
+    . = ALIGN(16);
+    *(.DebugExceptionVector.text)
+    . = ALIGN(16);
+    *(.NMIExceptionVector.text)
+    . = ALIGN(16);
+    *(.KernelExceptionVector.text)
+    LONG(0)
+    LONG(0)
+    LONG(0)
+    LONG(0)
+    . = ALIGN(16);
+    *(.UserExceptionVector.text)
+    LONG(0)
+    LONG(0)
+    LONG(0)
+    LONG(0)
+    . = ALIGN(16);
+    *(.DoubleExceptionVector.text)
+    LONG(0)
+    LONG(0)
+    LONG(0)
+    LONG(0)
+    . = ALIGN (16);
+    *(.entry.text)
+    *(.init.literal)
+    *(.init)
+    
+    *sdk/esp_iot_sdk_*lib/lib*.a:*(.literal .text)
 
-    /* SDK doesn't use libc functions, and are therefore safe to put in flash */
-    */libc.a:*.o(.text* .literal*)
-    /* end libc functions */
+    *(.iram.text .iram0.text)
 
-    _irom0_text_end = ABSOLUTE(.);
-    _flash_used_end = ABSOLUTE(.);
-  } >irom0_0_seg :irom0_0_phdr =0xffffffff
+    *(.stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
+    
+    *(.fini.literal)
+    *(.fini)
+    *(.gnu.version)
+    _text_end = ABSOLUTE(.);
+    _etext = .;
+  } >iram1_0_seg :iram1_0_phdr
 
   .data : ALIGN(4)
   {
@@ -119,6 +136,9 @@ SECTIONS
   .rodata : ALIGN(4)
   {
     _rodata_start = ABSOLUTE(.);
+
+    *(.rodata.dram .rodata.dram*)
+
     *(.gnu.linkonce.r.*)
     __XT_EXCEPTION_TABLE__ = ABSOLUTE(.);
     *(.xt_except_table)
@@ -175,46 +195,6 @@ SECTIONS
   } >dram0_0_seg :dram0_0_bss_phdr
 /* __stack = 0x3ffc8000; */
 
-  .text : ALIGN(4)
-  {
-    _stext = .;
-    _text_start = ABSOLUTE(.);
-    *(.UserEnter.text)
-    . = ALIGN(16);
-    *(.DebugExceptionVector.text)
-    . = ALIGN(16);
-    *(.NMIExceptionVector.text)
-    . = ALIGN(16);
-    *(.KernelExceptionVector.text)
-    LONG(0)
-    LONG(0)
-    LONG(0)
-    LONG(0)
-    . = ALIGN(16);
-    *(.UserExceptionVector.text)
-    LONG(0)
-    LONG(0)
-    LONG(0)
-    LONG(0)
-    . = ALIGN(16);
-    *(.DoubleExceptionVector.text)
-    LONG(0)
-    LONG(0)
-    LONG(0)
-    LONG(0)
-    . = ALIGN (16);
-    *(.entry.text)
-    *(.init.literal)
-    *(.init)
-    *(.literal .text .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
-    *(.iram0.text)
-    *(.fini.literal)
-    *(.fini)
-    *(.gnu.version)
-    _text_end = ABSOLUTE(.);
-    _etext = .;
-  } >iram1_0_seg :iram1_0_phdr
-
   .lit4 : ALIGN(4)
   {
     _lit4_start = ABSOLUTE(.);
@@ -224,6 +204,34 @@ SECTIONS
     _lit4_end = ABSOLUTE(.);
   } >iram1_0_seg :iram1_0_phdr
 
+  .irom0.text : ALIGN(0x1000)
+  {
+    _irom0_text_start = ABSOLUTE(.);
+    *(.servercert.flash)
+    *(.clientcert.flash)
+    *(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text)
+    *(.literal .text .literal.* .text.*)
+    *(.rodata*)
+    *(.sdk.version)
+
+    /* Link-time arrays containing the defs for the included modules */
+    . = ALIGN(4);
+    lua_libs = ABSOLUTE(.);
+    /* Allow either empty define or defined-to-1 to include the module */
+    KEEP(*(.lua_libs))
+    LONG(0) LONG(0) /* Null-terminate the array */
+    lua_rotable = ABSOLUTE(.);
+    KEEP(*(.lua_rotable))
+    LONG(0) LONG(0) /* Null-terminate the array */
+
+    /* SDK doesn't use libc functions, and are therefore safe to put in flash */
+    */libc.a:*.o(.text* .literal*)
+    /* end libc functions */
+
+    _irom0_text_end = ABSOLUTE(.);
+    _flash_used_end = ABSOLUTE(.);
+  } >irom0_0_seg :irom0_0_phdr =0xffffffff
+
 }
 
 /* get ROM code address */