From 4b6c732cd757b8770d90e21c0e45c1991363d0f3 Mon Sep 17 00:00:00 2001 From: tyustli <1225613647@qq.com> Date: Mon, 25 Mar 2019 10:28:12 +0800 Subject: [PATCH] last push forget modified the templates to support C++ this time add C++ for templates --- bsp/stm32/libraries/templates/stm32f0xx/SConstruct | 1 + .../stm32f0xx/board/linker_scripts/link.lds | 14 ++++++++++++++ .../libraries/templates/stm32f0xx/rtconfig.py | 12 +++++++++++- bsp/stm32/libraries/templates/stm32f10x/SConstruct | 1 + .../stm32f10x/board/linker_scripts/link.lds | 13 +++++++++++++ .../libraries/templates/stm32f10x/rtconfig.py | 12 +++++++++++- bsp/stm32/libraries/templates/stm32f4xx/SConstruct | 1 + .../stm32f4xx/board/linker_scripts/link.lds | 13 +++++++++++++ .../libraries/templates/stm32f4xx/rtconfig.py | 12 +++++++++++- bsp/stm32/libraries/templates/stm32f7xx/SConstruct | 1 + .../stm32f7xx/board/linker_scripts/link.lds | 13 +++++++++++++ .../libraries/templates/stm32f7xx/rtconfig.py | 12 ++++++++++-- bsp/stm32/libraries/templates/stm32l4xx/SConstruct | 1 + .../stm32l4xx/board/linker_scripts/link.lds | 13 +++++++++++++ .../libraries/templates/stm32l4xx/rtconfig.py | 12 +++++++++++- 15 files changed, 125 insertions(+), 6 deletions(-) diff --git a/bsp/stm32/libraries/templates/stm32f0xx/SConstruct b/bsp/stm32/libraries/templates/stm32f0xx/SConstruct index c120f925d..7979e3a23 100644 --- a/bsp/stm32/libraries/templates/stm32f0xx/SConstruct +++ b/bsp/stm32/libraries/templates/stm32f0xx/SConstruct @@ -21,6 +21,7 @@ env = Environment(tools = ['mingw'], AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS, CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS, AR = rtconfig.AR, ARFLAGS = '-rc', + CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS, LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS) env.PrependENVPath('PATH', rtconfig.EXEC_PATH) diff --git a/bsp/stm32/libraries/templates/stm32f0xx/board/linker_scripts/link.lds b/bsp/stm32/libraries/templates/stm32f0xx/board/linker_scripts/link.lds index be18c21a2..222ed45f3 100644 --- a/bsp/stm32/libraries/templates/stm32f0xx/board/linker_scripts/link.lds +++ b/bsp/stm32/libraries/templates/stm32f0xx/board/linker_scripts/link.lds @@ -46,6 +46,14 @@ SECTIONS __rt_init_end = .; . = ALIGN(4); + + PROVIDE(__ctors_start__ = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + PROVIDE(__ctors_end__ = .); + + . = ALIGN(4); + _etext = .; } > ROM = 0 @@ -72,6 +80,12 @@ SECTIONS *(.data.*) *(.gnu.linkonce.d*) + + PROVIDE(__dtors_start__ = .); + KEEP(*(SORT(.dtors.*))) + KEEP(*(.dtors)) + PROVIDE(__dtors_end__ = .); + . = ALIGN(4); /* This is used by the startup in order to initialize the .data secion */ _edata = . ; diff --git a/bsp/stm32/libraries/templates/stm32f0xx/rtconfig.py b/bsp/stm32/libraries/templates/stm32f0xx/rtconfig.py index c4d744f4f..3c8992f7d 100644 --- a/bsp/stm32/libraries/templates/stm32f0xx/rtconfig.py +++ b/bsp/stm32/libraries/templates/stm32f0xx/rtconfig.py @@ -44,7 +44,7 @@ if PLATFORM == 'gcc': OBJCPY = PREFIX + 'objcopy' DEVICE = ' -mcpu=cortex-m0 -mthumb -ffunction-sections -fdata-sections' - CFLAGS = DEVICE + ' -std=c99 -Dgcc' + CFLAGS = DEVICE + ' -Dgcc' AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp -Wa,-mimplicit-it=thumb ' LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rt-thread.map,-cref,-u,Reset_Handler -T board/linker_scripts/link.lds' @@ -57,11 +57,15 @@ if PLATFORM == 'gcc': else: CFLAGS += ' -O2' + CXXFLAGS = CFLAGS + CFLAGS += ' -std=c99' + POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n' elif PLATFORM == 'armcc': # toolchains CC = 'armcc' + CXX = 'armcc' AS = 'armasm' AR = 'armar' LINK = 'armlink' @@ -85,11 +89,15 @@ elif PLATFORM == 'armcc': else: CFLAGS += ' -O2' + CXXFLAGS = CFLAGS + CFLAGS += ' -std=c99' + POST_ACTION = 'fromelf --bin $TARGET --output rtthread.bin \nfromelf -z $TARGET' elif PLATFORM == 'iar': # toolchains CC = 'iccarm' + CXX = 'iccarm' AS = 'iasmarm' AR = 'iarchive' LINK = 'ilinkarm' @@ -130,5 +138,7 @@ elif PLATFORM == 'iar': LFLAGS = ' --config "board/linker_scripts/link.icf"' LFLAGS += ' --entry __iar_program_start' + CXXFLAGS = CFLAGS + EXEC_PATH = EXEC_PATH + '/arm/bin/' POST_ACTION = 'ielftool --bin $TARGET rtthread.bin' diff --git a/bsp/stm32/libraries/templates/stm32f10x/SConstruct b/bsp/stm32/libraries/templates/stm32f10x/SConstruct index 05326b2b7..27b5e7fcc 100644 --- a/bsp/stm32/libraries/templates/stm32f10x/SConstruct +++ b/bsp/stm32/libraries/templates/stm32f10x/SConstruct @@ -21,6 +21,7 @@ env = Environment(tools = ['mingw'], AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS, CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS, AR = rtconfig.AR, ARFLAGS = '-rc', + CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS, LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS) env.PrependENVPath('PATH', rtconfig.EXEC_PATH) diff --git a/bsp/stm32/libraries/templates/stm32f10x/board/linker_scripts/link.lds b/bsp/stm32/libraries/templates/stm32f10x/board/linker_scripts/link.lds index 74d06fdc5..d22c800ca 100644 --- a/bsp/stm32/libraries/templates/stm32f10x/board/linker_scripts/link.lds +++ b/bsp/stm32/libraries/templates/stm32f10x/board/linker_scripts/link.lds @@ -46,6 +46,14 @@ SECTIONS __rt_init_end = .; . = ALIGN(4); + + PROVIDE(__ctors_start__ = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + PROVIDE(__ctors_end__ = .); + + . = ALIGN(4); + _etext = .; } > ROM = 0 @@ -72,6 +80,11 @@ SECTIONS *(.data.*) *(.gnu.linkonce.d*) + PROVIDE(__dtors_start__ = .); + KEEP(*(SORT(.dtors.*))) + KEEP(*(.dtors)) + PROVIDE(__dtors_end__ = .); + . = ALIGN(4); /* This is used by the startup in order to initialize the .data secion */ _edata = . ; diff --git a/bsp/stm32/libraries/templates/stm32f10x/rtconfig.py b/bsp/stm32/libraries/templates/stm32f10x/rtconfig.py index 40826ac99..c6d16622d 100644 --- a/bsp/stm32/libraries/templates/stm32f10x/rtconfig.py +++ b/bsp/stm32/libraries/templates/stm32f10x/rtconfig.py @@ -44,7 +44,7 @@ if PLATFORM == 'gcc': OBJCPY = PREFIX + 'objcopy' DEVICE = ' -mcpu=cortex-m3 -mthumb -ffunction-sections -fdata-sections' - CFLAGS = DEVICE + ' -std=c99 -Dgcc' + CFLAGS = DEVICE + ' -Dgcc' AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp -Wa,-mimplicit-it=thumb ' LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rt-thread.map,-cref,-u,Reset_Handler -T board/linker_scripts/link.lds' @@ -57,11 +57,15 @@ if PLATFORM == 'gcc': else: CFLAGS += ' -O2' + CXXFLAGS = CFLAGS + CFLAGS += ' -std=c99' + POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n' elif PLATFORM == 'armcc': # toolchains CC = 'armcc' + CXX = 'armcc' AS = 'armasm' AR = 'armar' LINK = 'armlink' @@ -85,11 +89,15 @@ elif PLATFORM == 'armcc': else: CFLAGS += ' -O2' + CXXFLAGS = CFLAGS + CFLAGS += ' -std=c99' + POST_ACTION = 'fromelf --bin $TARGET --output rtthread.bin \nfromelf -z $TARGET' elif PLATFORM == 'iar': # toolchains CC = 'iccarm' + CXX = 'iccarm' AS = 'iasmarm' AR = 'iarchive' LINK = 'ilinkarm' @@ -130,5 +138,7 @@ elif PLATFORM == 'iar': LFLAGS = ' --config "board/linker_scripts/link.icf"' LFLAGS += ' --entry __iar_program_start' + CXXFLAGS = CFLAGS + EXEC_PATH = EXEC_PATH + '/arm/bin/' POST_ACTION = 'ielftool --bin $TARGET rtthread.bin' diff --git a/bsp/stm32/libraries/templates/stm32f4xx/SConstruct b/bsp/stm32/libraries/templates/stm32f4xx/SConstruct index 1101c708b..629f25c6e 100644 --- a/bsp/stm32/libraries/templates/stm32f4xx/SConstruct +++ b/bsp/stm32/libraries/templates/stm32f4xx/SConstruct @@ -21,6 +21,7 @@ env = Environment(tools = ['mingw'], AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS, CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS, AR = rtconfig.AR, ARFLAGS = '-rc', + CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS, LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS) env.PrependENVPath('PATH', rtconfig.EXEC_PATH) diff --git a/bsp/stm32/libraries/templates/stm32f4xx/board/linker_scripts/link.lds b/bsp/stm32/libraries/templates/stm32f4xx/board/linker_scripts/link.lds index c6fe92740..50169db32 100644 --- a/bsp/stm32/libraries/templates/stm32f4xx/board/linker_scripts/link.lds +++ b/bsp/stm32/libraries/templates/stm32f4xx/board/linker_scripts/link.lds @@ -47,6 +47,14 @@ SECTIONS __rt_init_end = .; . = ALIGN(4); + + PROVIDE(__ctors_start__ = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + PROVIDE(__ctors_end__ = .); + + . = ALIGN(4); + _etext = .; } > ROM = 0 @@ -73,6 +81,11 @@ SECTIONS *(.data.*) *(.gnu.linkonce.d*) + PROVIDE(__dtors_start__ = .); + KEEP(*(SORT(.dtors.*))) + KEEP(*(.dtors)) + PROVIDE(__dtors_end__ = .); + . = ALIGN(4); /* This is used by the startup in order to initialize the .data secion */ _edata = . ; diff --git a/bsp/stm32/libraries/templates/stm32f4xx/rtconfig.py b/bsp/stm32/libraries/templates/stm32f4xx/rtconfig.py index 3241586f6..4a9fe33ce 100644 --- a/bsp/stm32/libraries/templates/stm32f4xx/rtconfig.py +++ b/bsp/stm32/libraries/templates/stm32f4xx/rtconfig.py @@ -44,7 +44,7 @@ if PLATFORM == 'gcc': OBJCPY = PREFIX + 'objcopy' DEVICE = ' -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections' - CFLAGS = DEVICE + ' -std=c99 -Dgcc' + CFLAGS = DEVICE + ' -Dgcc' AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp -Wa,-mimplicit-it=thumb ' LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rt-thread.map,-cref,-u,Reset_Handler -T board/linker_scripts/link.lds' @@ -57,11 +57,15 @@ if PLATFORM == 'gcc': else: CFLAGS += ' -O2' + CXXFLAGS = CFLAGS + CFLAGS += ' -std=c99' + POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n' elif PLATFORM == 'armcc': # toolchains CC = 'armcc' + CXX = 'armcc' AS = 'armasm' AR = 'armar' LINK = 'armlink' @@ -85,11 +89,15 @@ elif PLATFORM == 'armcc': else: CFLAGS += ' -O2' + CXXFLAGS = CFLAGS + CFLAGS += ' -std=c99' + POST_ACTION = 'fromelf --bin $TARGET --output rtthread.bin \nfromelf -z $TARGET' elif PLATFORM == 'iar': # toolchains CC = 'iccarm' + CXX = 'iccarm' AS = 'iasmarm' AR = 'iarchive' LINK = 'ilinkarm' @@ -130,5 +138,7 @@ elif PLATFORM == 'iar': LFLAGS = ' --config "board/linker_scripts/link.icf"' LFLAGS += ' --entry __iar_program_start' + CXXFLAGS = CFLAGS + EXEC_PATH = EXEC_PATH + '/arm/bin/' POST_ACTION = 'ielftool --bin $TARGET rtthread.bin' diff --git a/bsp/stm32/libraries/templates/stm32f7xx/SConstruct b/bsp/stm32/libraries/templates/stm32f7xx/SConstruct index b6053d64c..012e6b41b 100644 --- a/bsp/stm32/libraries/templates/stm32f7xx/SConstruct +++ b/bsp/stm32/libraries/templates/stm32f7xx/SConstruct @@ -21,6 +21,7 @@ env = Environment(tools = ['mingw'], AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS, CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS, AR = rtconfig.AR, ARFLAGS = '-rc', + CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS, LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS) env.PrependENVPath('PATH', rtconfig.EXEC_PATH) diff --git a/bsp/stm32/libraries/templates/stm32f7xx/board/linker_scripts/link.lds b/bsp/stm32/libraries/templates/stm32f7xx/board/linker_scripts/link.lds index c6fe92740..50169db32 100644 --- a/bsp/stm32/libraries/templates/stm32f7xx/board/linker_scripts/link.lds +++ b/bsp/stm32/libraries/templates/stm32f7xx/board/linker_scripts/link.lds @@ -47,6 +47,14 @@ SECTIONS __rt_init_end = .; . = ALIGN(4); + + PROVIDE(__ctors_start__ = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + PROVIDE(__ctors_end__ = .); + + . = ALIGN(4); + _etext = .; } > ROM = 0 @@ -73,6 +81,11 @@ SECTIONS *(.data.*) *(.gnu.linkonce.d*) + PROVIDE(__dtors_start__ = .); + KEEP(*(SORT(.dtors.*))) + KEEP(*(.dtors)) + PROVIDE(__dtors_end__ = .); + . = ALIGN(4); /* This is used by the startup in order to initialize the .data secion */ _edata = . ; diff --git a/bsp/stm32/libraries/templates/stm32f7xx/rtconfig.py b/bsp/stm32/libraries/templates/stm32f7xx/rtconfig.py index 5b01587ff..51fdf4d64 100644 --- a/bsp/stm32/libraries/templates/stm32f7xx/rtconfig.py +++ b/bsp/stm32/libraries/templates/stm32f7xx/rtconfig.py @@ -44,7 +44,7 @@ if PLATFORM == 'gcc': OBJCPY = PREFIX + 'objcopy' DEVICE = ' -mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections' - CFLAGS = DEVICE + ' -std=c99 -Dgcc' + CFLAGS = DEVICE + ' -Dgcc' AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp -Wa,-mimplicit-it=thumb ' LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rt-thread.map,-cref,-u,Reset_Handler -T board/linker_scripts/link.lds' @@ -57,11 +57,15 @@ if PLATFORM == 'gcc': else: CFLAGS += ' -O2' + CXXFLAGS = CFLAGS + CFLAGS += ' -std=c99' + POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n' elif PLATFORM == 'armcc': # toolchains CC = 'armcc' + CXX = 'armcc' AS = 'armasm' AR = 'armar' LINK = 'armlink' @@ -85,12 +89,14 @@ elif PLATFORM == 'armcc': else: CFLAGS += ' -O2' - CXXFLAGS = CFLAGS + CXXFLAGS = CFLAGS + POST_ACTION = 'fromelf --bin $TARGET --output rtthread.bin \nfromelf -z $TARGET' elif PLATFORM == 'iar': # toolchains CC = 'iccarm' + CXX = 'iccarm' AS = 'iasmarm' AR = 'iarchive' LINK = 'ilinkarm' @@ -131,5 +137,7 @@ elif PLATFORM == 'iar': LFLAGS = ' --config "board/linker_scripts/link.icf"' LFLAGS += ' --entry __iar_program_start' + CXXFLAGS = CFLAGS + EXEC_PATH = EXEC_PATH + '/arm/bin/' POST_ACTION = 'ielftool --bin $TARGET rtthread.bin' diff --git a/bsp/stm32/libraries/templates/stm32l4xx/SConstruct b/bsp/stm32/libraries/templates/stm32l4xx/SConstruct index e1989a9d8..58a36adbf 100644 --- a/bsp/stm32/libraries/templates/stm32l4xx/SConstruct +++ b/bsp/stm32/libraries/templates/stm32l4xx/SConstruct @@ -21,6 +21,7 @@ env = Environment(tools = ['mingw'], AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS, CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS, AR = rtconfig.AR, ARFLAGS = '-rc', + CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS, LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS) env.PrependENVPath('PATH', rtconfig.EXEC_PATH) diff --git a/bsp/stm32/libraries/templates/stm32l4xx/board/linker_scripts/link.lds b/bsp/stm32/libraries/templates/stm32l4xx/board/linker_scripts/link.lds index 2d009e649..d58eaf110 100644 --- a/bsp/stm32/libraries/templates/stm32l4xx/board/linker_scripts/link.lds +++ b/bsp/stm32/libraries/templates/stm32l4xx/board/linker_scripts/link.lds @@ -46,6 +46,14 @@ SECTIONS __rt_init_end = .; . = ALIGN(4); + + PROVIDE(__ctors_start__ = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + PROVIDE(__ctors_end__ = .); + + . = ALIGN(4); + _etext = .; } > ROM = 0 @@ -72,6 +80,11 @@ SECTIONS *(.data.*) *(.gnu.linkonce.d*) + PROVIDE(__dtors_start__ = .); + KEEP(*(SORT(.dtors.*))) + KEEP(*(.dtors)) + PROVIDE(__dtors_end__ = .); + . = ALIGN(4); /* This is used by the startup in order to initialize the .data secion */ _edata = . ; diff --git a/bsp/stm32/libraries/templates/stm32l4xx/rtconfig.py b/bsp/stm32/libraries/templates/stm32l4xx/rtconfig.py index d632114e2..ae800430f 100644 --- a/bsp/stm32/libraries/templates/stm32l4xx/rtconfig.py +++ b/bsp/stm32/libraries/templates/stm32l4xx/rtconfig.py @@ -44,7 +44,7 @@ if PLATFORM == 'gcc': OBJCPY = PREFIX + 'objcopy' DEVICE = ' -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections' - CFLAGS = DEVICE + ' -std=c99 -Dgcc' + CFLAGS = DEVICE + ' -Dgcc' AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp -Wa,-mimplicit-it=thumb ' LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rt-thread.map,-cref,-u,Reset_Handler -T board/linker_scripts/link.lds' @@ -57,11 +57,15 @@ if PLATFORM == 'gcc': else: CFLAGS += ' -O2' + CXXFLAGS = CFLAGS + CFLAGS += ' -std=c99' + POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n' elif PLATFORM == 'armcc': # toolchains CC = 'armcc' + CXX = 'armcc' AS = 'armasm' AR = 'armar' LINK = 'armlink' @@ -85,11 +89,15 @@ elif PLATFORM == 'armcc': else: CFLAGS += ' -O2' + CXXFLAGS = CFLAGS + CFLAGS += ' -std=c99' + POST_ACTION = 'fromelf --bin $TARGET --output rtthread.bin \nfromelf -z $TARGET' elif PLATFORM == 'iar': # toolchains CC = 'iccarm' + CXX = 'iccarm' AS = 'iasmarm' AR = 'iarchive' LINK = 'ilinkarm' @@ -130,5 +138,7 @@ elif PLATFORM == 'iar': LFLAGS = ' --config "board/linker_scripts/link.icf"' LFLAGS += ' --entry __iar_program_start' + CXXFLAGS = CFLAGS + EXEC_PATH = EXEC_PATH + '/arm/bin/' POST_ACTION = 'ielftool --bin $TARGET rtthread.bin' -- GitLab