Przeglądaj źródła

adapt stm32wl cmsis for rtt

zhangshuxun 8 miesięcy temu
rodzic
commit
d496e5a475
34 zmienionych plików z 201 dodań i 32 usunięć
  1. 38 0
      SConscript
  2. 1 1
      Source/Templates/arm/startup_stm32wl54xx_cm0plus.s
  3. 1 1
      Source/Templates/arm/startup_stm32wl54xx_cm4.s
  4. 1 1
      Source/Templates/arm/startup_stm32wl55xx_cm0plus.s
  5. 1 1
      Source/Templates/arm/startup_stm32wl55xx_cm4.s
  6. 1 1
      Source/Templates/arm/startup_stm32wl5mxx_cm0plus.s
  7. 1 1
      Source/Templates/arm/startup_stm32wl5mxx_cm4.s
  8. 1 1
      Source/Templates/arm/startup_stm32wle4xx.s
  9. 1 1
      Source/Templates/arm/startup_stm32wle5xx.s
  10. 1 1
      Source/Templates/gcc/startup_stm32wl54xx_cm0plus.s
  11. 1 1
      Source/Templates/gcc/startup_stm32wl54xx_cm4.s
  12. 1 1
      Source/Templates/gcc/startup_stm32wl55xx_cm0plus.s
  13. 1 1
      Source/Templates/gcc/startup_stm32wl55xx_cm4.s
  14. 1 1
      Source/Templates/gcc/startup_stm32wl5mxx_cm0plus.s
  15. 1 1
      Source/Templates/gcc/startup_stm32wl5mxx_cm4.s
  16. 1 1
      Source/Templates/gcc/startup_stm32wle4xx.s
  17. 1 1
      Source/Templates/gcc/startup_stm32wle5xx.s
  18. 1 1
      Source/Templates/iar/linker/stm32wl54xx_flash_cm0plus.icf
  19. 1 1
      Source/Templates/iar/linker/stm32wl54xx_flash_cm4.icf
  20. 1 1
      Source/Templates/iar/linker/stm32wl54xx_sram_cm0plus.icf
  21. 1 1
      Source/Templates/iar/linker/stm32wl54xx_sram_cm4.icf
  22. 1 1
      Source/Templates/iar/linker/stm32wl55xx_flash_cm0plus.icf
  23. 1 1
      Source/Templates/iar/linker/stm32wl55xx_flash_cm4.icf
  24. 1 1
      Source/Templates/iar/linker/stm32wl55xx_sram_cm0plus.icf
  25. 1 1
      Source/Templates/iar/linker/stm32wl55xx_sram_cm4.icf
  26. 1 1
      Source/Templates/iar/linker/stm32wl5mxx_flash_cm0plus.icf
  27. 1 1
      Source/Templates/iar/linker/stm32wl5mxx_flash_cm4.icf
  28. 1 1
      Source/Templates/iar/linker/stm32wl5mxx_sram_cm0plus.icf
  29. 1 1
      Source/Templates/iar/linker/stm32wl5mxx_sram_cm4.icf
  30. 1 1
      Source/Templates/iar/linker/stm32wle4xx_flash.icf
  31. 1 1
      Source/Templates/iar/linker/stm32wle4xx_sram.icf
  32. 1 1
      Source/Templates/iar/linker/stm32wle5xx_flash.icf
  33. 1 1
      Source/Templates/iar/linker/stm32wle5xx_sram.icf
  34. 131 0
      stm32_update.py

+ 38 - 0
SConscript

@@ -0,0 +1,38 @@
+from building import *
+import os
+
+# Import environment variables
+Import('env')
+
+# Get the current working directory
+cwd = GetCurrentDir()
+
+# Initialize include paths and source files list
+path = [os.path.join(cwd, 'Include')]
+src = [os.path.join(cwd, 'Source', 'Templates', 'system_stm32wlxx.c')]
+
+# Map microcontroller units (MCUs) to their corresponding startup files
+mcu_startup_files = {
+    'STM32WL55xx': 'startup_stm32wle5xx.s',
+    'STM32WLE5xx': 'startup_stm32wle5xx.s',
+    'STM32WL54xx': 'startup_stm32wle4xx.s',
+    'STM32WLE4xx': 'startup_stm32wle4xx.s',
+
+}
+
+# Check each defined MCU, match the platform and append the appropriate startup file
+for mcu, startup_file in mcu_startup_files.items():
+    if mcu in env.get('CPPDEFINES', []):
+        if rtconfig.PLATFORM in ['gcc', 'llvm-arm']:
+            src += [os.path.join(cwd, 'Source', 'Templates', 'gcc', startup_file)]
+        elif rtconfig.PLATFORM in ['armcc', 'armclang']:
+            src += [os.path.join(cwd, 'Source', 'Templates', 'arm', startup_file)]
+        elif rtconfig.PLATFORM in ['iccarm']:
+            src += [os.path.join(cwd, 'Source', 'Templates', 'iar', startup_file)]
+        break
+
+# Define the build group
+group = DefineGroup('STM32WL-CMSIS', src, depend=['PKG_USING_STM32WL_CMSIS_DRIVER'], CPPPATH=path)
+
+# Return the build group
+Return('group')

+ 1 - 1
Source/Templates/arm/startup_stm32wl54xx_cm0plus.s

@@ -40,7 +40,7 @@ __initial_sp
 ;   <o>  Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
 ; </h>
 
-Heap_Size       EQU     0x00000200
+Heap_Size       EQU     0x00000000
 
                 AREA    HEAP, NOINIT, READWRITE, ALIGN=3
 __heap_base

+ 1 - 1
Source/Templates/arm/startup_stm32wl54xx_cm4.s

@@ -40,7 +40,7 @@ __initial_sp
 ;   <o>  Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
 ; </h>
 
-Heap_Size       EQU     0x00000200
+Heap_Size       EQU     0x00000000
 
                 AREA    HEAP, NOINIT, READWRITE, ALIGN=3
 __heap_base

+ 1 - 1
Source/Templates/arm/startup_stm32wl55xx_cm0plus.s

@@ -40,7 +40,7 @@ __initial_sp
 ;   <o>  Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
 ; </h>
 
-Heap_Size       EQU     0x00000200
+Heap_Size       EQU     0x00000000
 
                 AREA    HEAP, NOINIT, READWRITE, ALIGN=3
 __heap_base

+ 1 - 1
Source/Templates/arm/startup_stm32wl55xx_cm4.s

@@ -40,7 +40,7 @@ __initial_sp
 ;   <o>  Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
 ; </h>
 
-Heap_Size       EQU     0x00000200
+Heap_Size       EQU     0x00000000
 
                 AREA    HEAP, NOINIT, READWRITE, ALIGN=3
 __heap_base

+ 1 - 1
Source/Templates/arm/startup_stm32wl5mxx_cm0plus.s

@@ -40,7 +40,7 @@ __initial_sp
 ;   <o>  Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
 ; </h>
 
-Heap_Size       EQU     0x00000200
+Heap_Size       EQU     0x00000000
 
                 AREA    HEAP, NOINIT, READWRITE, ALIGN=3
 __heap_base

+ 1 - 1
Source/Templates/arm/startup_stm32wl5mxx_cm4.s

@@ -40,7 +40,7 @@ __initial_sp
 ;   <o>  Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
 ; </h>
 
-Heap_Size       EQU     0x00000200
+Heap_Size       EQU     0x00000000
 
                 AREA    HEAP, NOINIT, READWRITE, ALIGN=3
 __heap_base

+ 1 - 1
Source/Templates/arm/startup_stm32wle4xx.s

@@ -40,7 +40,7 @@ __initial_sp
 ;   <o>  Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
 ; </h>
 
-Heap_Size       EQU     0x00000200
+Heap_Size       EQU     0x00000000
 
                 AREA    HEAP, NOINIT, READWRITE, ALIGN=3
 __heap_base

+ 1 - 1
Source/Templates/arm/startup_stm32wle5xx.s

@@ -40,7 +40,7 @@ __initial_sp
 ;   <o>  Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
 ; </h>
 
-Heap_Size       EQU     0x00000200
+Heap_Size       EQU     0x00000000
 
                 AREA    HEAP, NOINIT, READWRITE, ALIGN=3
 __heap_base

+ 1 - 1
Source/Templates/gcc/startup_stm32wl54xx_cm0plus.s

@@ -97,7 +97,7 @@ LoopFillZerobss:
 /* Call static constructors */
   bl __libc_init_array
 /* Call the application's entry point.*/
-  bl main
+  bl entry
 
 LoopForever:
     b LoopForever

+ 1 - 1
Source/Templates/gcc/startup_stm32wl54xx_cm4.s

@@ -97,7 +97,7 @@ LoopFillZerobss:
 /* Call static constructors */
   bl __libc_init_array
 /* Call the application's entry point.*/
-  bl main
+  bl entry
 
 LoopForever:
     b LoopForever

+ 1 - 1
Source/Templates/gcc/startup_stm32wl55xx_cm0plus.s

@@ -97,7 +97,7 @@ LoopFillZerobss:
 /* Call static constructors */
   bl __libc_init_array
 /* Call the application's entry point.*/
-  bl main
+  bl entry
 
 LoopForever:
     b LoopForever

+ 1 - 1
Source/Templates/gcc/startup_stm32wl55xx_cm4.s

@@ -97,7 +97,7 @@ LoopFillZerobss:
 /* Call static constructors */
   bl __libc_init_array
 /* Call the application's entry point.*/
-  bl main
+  bl entry
 
 LoopForever:
     b LoopForever

+ 1 - 1
Source/Templates/gcc/startup_stm32wl5mxx_cm0plus.s

@@ -97,7 +97,7 @@ LoopFillZerobss:
 /* Call static constructors */
   bl __libc_init_array
 /* Call the application's entry point.*/
-  bl main
+  bl entry
 
 LoopForever:
     b LoopForever

+ 1 - 1
Source/Templates/gcc/startup_stm32wl5mxx_cm4.s

@@ -97,7 +97,7 @@ LoopFillZerobss:
 /* Call static constructors */
   bl __libc_init_array
 /* Call the application's entry point.*/
-  bl main
+  bl entry
 
 LoopForever:
     b LoopForever

+ 1 - 1
Source/Templates/gcc/startup_stm32wle4xx.s

@@ -97,7 +97,7 @@ LoopFillZerobss:
 /* Call static constructors */
   bl __libc_init_array
 /* Call the application's entry point.*/
-  bl main
+  bl entry
 
 LoopForever:
     b LoopForever

+ 1 - 1
Source/Templates/gcc/startup_stm32wle5xx.s

@@ -97,7 +97,7 @@ LoopFillZerobss:
 /* Call static constructors */
   bl __libc_init_array
 /* Call the application's entry point.*/
-  bl main
+  bl entry
 
 LoopForever:
     b LoopForever

+ 1 - 1
Source/Templates/iar/linker/stm32wl54xx_flash_cm0plus.icf

@@ -17,7 +17,7 @@ define symbol __ICFEDIT_region_RAM2_end__     = 0x2000FFFF;
 
 /*-Sizes-*/
 define symbol __ICFEDIT_size_cstack__ = 0x400;
-define symbol __ICFEDIT_size_heap__ = 0x200;
+define symbol __ICFEDIT_size_heap__ = 0x000;
 /**** End of ICF editor section. ###ICF###*/
 
 

+ 1 - 1
Source/Templates/iar/linker/stm32wl54xx_flash_cm4.icf

@@ -17,7 +17,7 @@ define symbol __ICFEDIT_region_RAM2_end__     = 0x2000BFFF;
 
 /*-Sizes-*/
 define symbol __ICFEDIT_size_cstack__ = 0x400;
-define symbol __ICFEDIT_size_heap__ = 0x200;
+define symbol __ICFEDIT_size_heap__ = 0x000;
 /**** End of ICF editor section. ###ICF###*/
 
 

+ 1 - 1
Source/Templates/iar/linker/stm32wl54xx_sram_cm0plus.icf

@@ -14,7 +14,7 @@ define symbol __ICFEDIT_region_RAM_end__   = 0x20007FFF;
 
 /*-Sizes-*/
 define symbol __ICFEDIT_size_cstack__ = 0x400;
-define symbol __ICFEDIT_size_heap__ = 0x200;
+define symbol __ICFEDIT_size_heap__ = 0x000;
 /**** End of ICF editor section. ###ICF###*/
 
 

+ 1 - 1
Source/Templates/iar/linker/stm32wl54xx_sram_cm4.icf

@@ -13,7 +13,7 @@ define symbol __ICFEDIT_region_RAM_end__   = 0x20003FFF;
 
 /*-Sizes-*/
 define symbol __ICFEDIT_size_cstack__ = 0x400;
-define symbol __ICFEDIT_size_heap__ = 0x200;
+define symbol __ICFEDIT_size_heap__ = 0x000;
 /**** End of ICF editor section. ###ICF###*/
 
 

+ 1 - 1
Source/Templates/iar/linker/stm32wl55xx_flash_cm0plus.icf

@@ -17,7 +17,7 @@ define symbol __ICFEDIT_region_RAM2_end__     = 0x2000FFFF;
 
 /*-Sizes-*/
 define symbol __ICFEDIT_size_cstack__ = 0x400;
-define symbol __ICFEDIT_size_heap__ = 0x200;
+define symbol __ICFEDIT_size_heap__ = 0x000;
 /**** End of ICF editor section. ###ICF###*/
 
 

+ 1 - 1
Source/Templates/iar/linker/stm32wl55xx_flash_cm4.icf

@@ -17,7 +17,7 @@ define symbol __ICFEDIT_region_RAM2_end__     = 0x2000BFFF;
 
 /*-Sizes-*/
 define symbol __ICFEDIT_size_cstack__ = 0x400;
-define symbol __ICFEDIT_size_heap__ = 0x200;
+define symbol __ICFEDIT_size_heap__ = 0x000;
 /**** End of ICF editor section. ###ICF###*/
 
 

+ 1 - 1
Source/Templates/iar/linker/stm32wl55xx_sram_cm0plus.icf

@@ -14,7 +14,7 @@ define symbol __ICFEDIT_region_RAM_end__   = 0x20007FFF;
 
 /*-Sizes-*/
 define symbol __ICFEDIT_size_cstack__ = 0x400;
-define symbol __ICFEDIT_size_heap__ = 0x200;
+define symbol __ICFEDIT_size_heap__ = 0x000;
 /**** End of ICF editor section. ###ICF###*/
 
 

+ 1 - 1
Source/Templates/iar/linker/stm32wl55xx_sram_cm4.icf

@@ -14,7 +14,7 @@ define symbol __ICFEDIT_region_RAM_end__   = 0x20003FFF;
 
 /*-Sizes-*/
 define symbol __ICFEDIT_size_cstack__ = 0x400;
-define symbol __ICFEDIT_size_heap__ = 0x200;
+define symbol __ICFEDIT_size_heap__ = 0x000;
 /**** End of ICF editor section. ###ICF###*/
 
 

+ 1 - 1
Source/Templates/iar/linker/stm32wl5mxx_flash_cm0plus.icf

@@ -17,7 +17,7 @@ define symbol __ICFEDIT_region_RAM2_end__     = 0x2000FFFF;
 
 /*-Sizes-*/
 define symbol __ICFEDIT_size_cstack__ = 0x400;
-define symbol __ICFEDIT_size_heap__ = 0x200;
+define symbol __ICFEDIT_size_heap__ = 0x000;
 /**** End of ICF editor section. ###ICF###*/
 
 

+ 1 - 1
Source/Templates/iar/linker/stm32wl5mxx_flash_cm4.icf

@@ -17,7 +17,7 @@ define symbol __ICFEDIT_region_RAM2_end__     = 0x2000BFFF;
 
 /*-Sizes-*/
 define symbol __ICFEDIT_size_cstack__ = 0x400;
-define symbol __ICFEDIT_size_heap__ = 0x200;
+define symbol __ICFEDIT_size_heap__ = 0x000;
 /**** End of ICF editor section. ###ICF###*/
 
 

+ 1 - 1
Source/Templates/iar/linker/stm32wl5mxx_sram_cm0plus.icf

@@ -14,7 +14,7 @@ define symbol __ICFEDIT_region_RAM_end__   = 0x20007FFF;
 
 /*-Sizes-*/
 define symbol __ICFEDIT_size_cstack__ = 0x400;
-define symbol __ICFEDIT_size_heap__ = 0x200;
+define symbol __ICFEDIT_size_heap__ = 0x000;
 /**** End of ICF editor section. ###ICF###*/
 
 

+ 1 - 1
Source/Templates/iar/linker/stm32wl5mxx_sram_cm4.icf

@@ -14,7 +14,7 @@ define symbol __ICFEDIT_region_RAM_end__   = 0x20003FFF;
 
 /*-Sizes-*/
 define symbol __ICFEDIT_size_cstack__ = 0x400;
-define symbol __ICFEDIT_size_heap__ = 0x200;
+define symbol __ICFEDIT_size_heap__ = 0x000;
 /**** End of ICF editor section. ###ICF###*/
 
 

+ 1 - 1
Source/Templates/iar/linker/stm32wle4xx_flash.icf

@@ -17,7 +17,7 @@ define symbol __ICFEDIT_region_RAM2_end__     = 0x2000FFFF;
 
 /*-Sizes-*/
 define symbol __ICFEDIT_size_cstack__ = 0x400;
-define symbol __ICFEDIT_size_heap__ = 0x200;
+define symbol __ICFEDIT_size_heap__ = 0x000;
 /**** End of ICF editor section. ###ICF###*/
 
 

+ 1 - 1
Source/Templates/iar/linker/stm32wle4xx_sram.icf

@@ -14,7 +14,7 @@ define symbol __ICFEDIT_region_RAM_end__   = 0x2000FFFF;
 
 /*-Sizes-*/
 define symbol __ICFEDIT_size_cstack__ = 0x400;
-define symbol __ICFEDIT_size_heap__ = 0x200;
+define symbol __ICFEDIT_size_heap__ = 0x000;
 /**** End of ICF editor section. ###ICF###*/
 
 

+ 1 - 1
Source/Templates/iar/linker/stm32wle5xx_flash.icf

@@ -17,7 +17,7 @@ define symbol __ICFEDIT_region_RAM2_end__     = 0x2000FFFF;
 
 /*-Sizes-*/
 define symbol __ICFEDIT_size_cstack__ = 0x400;
-define symbol __ICFEDIT_size_heap__ = 0x200;
+define symbol __ICFEDIT_size_heap__ = 0x000;
 /**** End of ICF editor section. ###ICF###*/
 
 

+ 1 - 1
Source/Templates/iar/linker/stm32wle5xx_sram.icf

@@ -14,7 +14,7 @@ define symbol __ICFEDIT_region_RAM_end__   = 0x2000FFFF;
 
 /*-Sizes-*/
 define symbol __ICFEDIT_size_cstack__ = 0x400;
-define symbol __ICFEDIT_size_heap__ = 0x200;
+define symbol __ICFEDIT_size_heap__ = 0x000;
 /**** End of ICF editor section. ###ICF###*/
 
 

+ 131 - 0
stm32_update.py

@@ -0,0 +1,131 @@
+# Copyright (c) 2006-2022, RT-Thread Development Team
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+# Change Logs:
+# Date           Author       Notes
+# 2021-10-11     Meco Man     First version
+
+# This file is suggested to use under Linux environment.
+# > python stm32_update.py
+# update STM32 startup assembly language file:
+# 1.replace main to entry (GCC)
+# 2.reduce the heap size as 0x000 (Keil IAR)
+# 3.extend the GCC stack size as 0x400, which is the same as Keil and IAR startup files.
+
+import os
+import re
+
+# replace 'bl main' to 'bl entry'
+def stm32update_main2entry(path):
+    oldline = ''
+    newline = ''
+
+    for root, dirs, files in os.walk(path):
+        for file in files:
+            if os.path.splitext(file)[1] == '.s': # find .s files (Keil MDK)
+                file_path = os.path.join(root,file)
+                flag_need_replace = False
+                with open(file_path,'r+',) as f:
+                    while True:
+                        line = f.readline()
+                        if line == '':
+                            break
+                        elif ('bl' in line) and ('main' in line): # find 'bl main'
+                            oldline = line # bl main
+                            newline = line.replace('main', 'entry') # use 'entry' to replace 'main'
+                            flag_need_replace = True # mark that need to be replaced
+                            break
+
+                    if (flag_need_replace == True): # use 'entry' to replace 'main'
+                        f.seek(0)
+                        content = f.read()
+                        f.seek(0)
+                        f.truncate()
+                        newcontent = content.replace(oldline, newline)
+                        f.write(newcontent)
+
+#reduce the heap size as 0x000
+def stm32update_heap2zero(path):
+    oldline = ''
+    newline = ''
+    for root, dirs, files in os.walk(path):
+        for file in files:
+            file_path = os.path.join(root,file)
+            if os.path.splitext(file)[1] == '.s': # find .s files (Keil MDK)
+                with open(file_path,'r+',) as f:
+                    flag_need_replace = False
+                    while True:
+                        line = f.readline()
+                        if line == '':
+                            break
+
+                        re_result = re.match('\\s*Heap_Size\\s+EQU\\s+0[xX][0-9a-fA-F]+', line)
+                        if re_result != None:
+                            oldline = line
+                            newline = re.sub('0[xX][0-9a-fA-F]+','0x00000000', oldline)
+                            flag_need_replace = True
+                            break
+
+                    if flag_need_replace == True:
+                        f.seek(0)
+                        content = f.read()
+                        f.seek(0)
+                        f.truncate()
+                        newcontent = content.replace(oldline, newline)
+                        f.write(newcontent)
+
+            elif os.path.splitext(file)[1] == '.icf': # find .icf files (IAR)
+                with open(file_path,'r+',) as f:
+                    flag_need_replace = False
+                    while True:
+                        line = f.readline()
+                        if line == '':
+                            break
+
+                        re_result = re.match('\\s*define\\s+symbol\\s+__ICFEDIT_size_heap__\\s*=\\s*0[xX][0-9a-fA-F]+', line)
+                        if re_result != None:
+                            oldline = line
+                            newline = re.sub('0[xX][0-9a-fA-F]+','0x000', oldline)
+                            flag_need_replace = True
+                            break
+
+                    if flag_need_replace == True:
+                        f.seek(0)
+                        content = f.read()
+                        f.seek(0)
+                        f.truncate()
+                        newcontent = content.replace(oldline, newline)
+                        f.write(newcontent)
+
+            elif os.path.splitext(file)[1] == '.lds': # find .lds files (GCC)
+                with open(file_path,'r+',) as f:
+                    flag_need_replace = False
+                    while True:
+                        line = f.readline()
+                        if line == '':
+                            break
+
+                        re_result = re.match('\\s*_system_stack_size\\s*=\\s*0[xX][0-9a-fA-F]+', line)
+                        if re_result != None:
+                            oldline = line
+                            newline = re.sub('0[xX][0-9a-fA-F]+','0x400', oldline)
+                            flag_need_replace = True
+                            break
+
+                    if flag_need_replace == True:
+                        f.seek(0)
+                        content = f.read()
+                        f.seek(0)
+                        f.truncate()
+                        newcontent = content.replace(oldline, newline)
+                        f.write(newcontent)
+
+
+def stm32_update(path):
+    stm32update_main2entry(path)
+    stm32update_heap2zero(path)
+
+if __name__ == "__main__":
+    stm32_update(os.getcwd())
+    print("STM32 startup assembly language file update successfully!")