cancel
Showing results for 
Search instead for 
Did you mean: 

A BUG when generate code for toolchain `makefile` or `cmake`.

jmjoy
Associate

A BUG when generate code for toolchain `makefile` or `cmake`.

My develop environment: Linux PC

 

After generated code, I run `make` and got errors:

```

/usr/lib/gcc/arm-none-eabi/7.3.1/../../../arm-none-eabi/bin/ld:STM32F103C8Tx_FLASH.ld:56: syntax error
collect2: error: ld returned 1 exit status

```

 

After my investigation, I found that the reason was that all the RAM symbols in this file were replaced with empty!

 

For example:

 

Line 56:    _estack = ORIGIN() + LENGTH(); /* end of RAM */

Should be:    _estack = ORIGIN(RAM) + LENGTH(RAM); /* end of RAM */

 

Line 146:     } > AT> FLASH

Should be:     } >RAM AT> FLASH

 

Here is the patch will fix the BUG:

 

 

diff --git a/STM32F103C8Tx_FLASH.ld b/STM32F103C8Tx_FLASH.ld
index 42d7927..05df42a 100644
--- a/STM32F103C8Tx_FLASH.ld
+++ b/STM32F103C8Tx_FLASH.ld
@@ -53,7 +53,7 @@
 ENTRY(Reset_Handler)
 
 /* Highest address of the user mode stack */
-_estack = ORIGIN() + LENGTH();    /* end of RAM */
+_estack = ORIGIN(RAM) + LENGTH(RAM);    /* end of RAM */
 /* Generate a link error if heap and stack don't fit into RAM */
 _Min_Heap_Size = 0x200;      /* required amount of heap  */
 _Min_Stack_Size = 0x400; /* required amount of stack */
@@ -143,7 +143,7 @@ SECTIONS
 
     . = ALIGN(4);
     _edata = .;        /* define a global symbol at data end */
-  } > AT> FLASH
+  } >RAM AT> FLASH
 
   
   /* Uninitialized data section */
@@ -160,7 +160,7 @@ SECTIONS
     . = ALIGN(4);
     _ebss = .;         /* define a global symbol at bss end */
     __bss_end__ = _ebss;
-  } >
+  } >RAM
 
   /* User_heap_stack section, used to check that there is enough RAM left */
   ._user_heap_stack :
@@ -171,7 +171,7 @@ SECTIONS
     . = . + _Min_Heap_Size;
     . = . + _Min_Stack_Size;
     . = ALIGN(8);
-  } >
+  } >RAM
 
   
 
@@ -184,5 +184,3 @@ SECTIONS
   }
 
 }

 

 

1 REPLY 1