未验证 提交 830387f0 编写于 作者: B Bernard Xiong 提交者: GitHub

Merge pull request #2069 from SummerGGift/add_stm32_new_framework

[bsp][stm32] optimize scons --dist function
...@@ -32,17 +32,27 @@ if rtconfig.PLATFORM == 'iar': ...@@ -32,17 +32,27 @@ if rtconfig.PLATFORM == 'iar':
Export('RTT_ROOT') Export('RTT_ROOT')
Export('rtconfig') Export('rtconfig')
SDK_ROOT = os.path.abspath('./')
if os.path.exists(SDK_ROOT + '/libraries'):
libraries_path_prefix = SDK_ROOT + '/libraries'
else:
libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries'
SDK_LIB = libraries_path_prefix
Export('SDK_LIB')
# prepare building environment # prepare building environment
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
SDK_ROOT = os.path.abspath('./') stm32_library = 'STM32F1xx_HAL'
bsp_vdir = 'build' rtconfig.BSP_LIBRARY_TYPE = stm32_library
# include drivers
objs.extend(SConscript(os.path.dirname(SDK_ROOT) + '/libraries/STM32F1xx_HAL/SConscript'))
# include libraries # include libraries
objs.extend(SConscript(os.path.dirname(SDK_ROOT) + '/libraries/HAL_Drivers/SConscript')) objs.extend(SConscript(os.path.join(libraries_path_prefix, stm32_library, 'SConscript')))
# include drivers
objs.extend(SConscript(os.path.join(libraries_path_prefix, 'HAL_Drivers', 'SConscript')))
# make a building # make a building
DoBuilding(TARGET, objs) DoBuilding(TARGET, objs)
import os
import rtconfig import rtconfig
from building import * from building import *
Import('SDK_LIB')
cwd = GetCurrentDir() cwd = GetCurrentDir()
# add the general drivers. # add general drivers
src = Glob('board.c') src = Split('''
src += Glob('CubeMX_Config/Src/stm32f1xx_hal_msp.c') board.c
CubeMX_Config/Src/stm32f1xx_hal_msp.c
''')
path = [cwd] path = [cwd]
path += [cwd + '/CubeMX_Config/Inc'] path += [cwd + '/CubeMX_Config/Inc']
startup_path_prefix = SDK_LIB
if rtconfig.CROSS_TOOL == 'gcc': if rtconfig.CROSS_TOOL == 'gcc':
src += [cwd + '/../../libraries/STM32F1xx_HAL/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103xb.s'] src += [startup_path_prefix + '/STM32F1xx_HAL/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103xb.s']
elif rtconfig.CROSS_TOOL == 'keil': elif rtconfig.CROSS_TOOL == 'keil':
src += [cwd + '/../../libraries/STM32F1xx_HAL/CMSIS/Device/ST/STM32F1xx/Source/Templates/arm/startup_stm32f103xb.s'] src += [startup_path_prefix + '/STM32F1xx_HAL/CMSIS/Device/ST/STM32F1xx/Source/Templates/arm/startup_stm32f103xb.s']
elif rtconfig.CROSS_TOOL == 'iar': elif rtconfig.CROSS_TOOL == 'iar':
src += [cwd + '/../../libraries/STM32F1xx_HAL/CMSIS/Device/ST/STM32F1xx/Source/Templates/iar/startup_stm32f103xb.s'] src += [startup_path_prefix + '/STM32F1xx_HAL/CMSIS/Device/ST/STM32F1xx/Source/Templates/iar/startup_stm32f103xb.s']
CPPDEFINES = ['STM32F103xB'] CPPDEFINES = ['STM32F103xB']
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES) group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES)
Return('group')
Return('group')
\ No newline at end of file
...@@ -5,6 +5,9 @@ ARCH='arm' ...@@ -5,6 +5,9 @@ ARCH='arm'
CPU='cortex-m3' CPU='cortex-m3'
CROSS_TOOL='gcc' CROSS_TOOL='gcc'
# bsp lib config
BSP_LIBRARY_TYPE = None
if os.getenv('RTT_CC'): if os.getenv('RTT_CC'):
CROSS_TOOL = os.getenv('RTT_CC') CROSS_TOOL = os.getenv('RTT_CC')
if os.getenv('RTT_ROOT'): if os.getenv('RTT_ROOT'):
......
...@@ -32,16 +32,27 @@ if rtconfig.PLATFORM == 'iar': ...@@ -32,16 +32,27 @@ if rtconfig.PLATFORM == 'iar':
Export('RTT_ROOT') Export('RTT_ROOT')
Export('rtconfig') Export('rtconfig')
SDK_ROOT = os.path.abspath('./')
if os.path.exists(SDK_ROOT + '/libraries'):
libraries_path_prefix = SDK_ROOT + '/libraries'
else:
libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries'
SDK_LIB = libraries_path_prefix
Export('SDK_LIB')
# prepare building environment # prepare building environment
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
SDK_ROOT = os.path.abspath('./') stm32_library = 'STM32F4xx_HAL'
rtconfig.BSP_LIBRARY_TYPE = stm32_library
# include drivers
objs.extend(SConscript(os.path.dirname(SDK_ROOT) + '/libraries/STM32F4xx_HAL/SConscript'))
# include libraries # include libraries
objs.extend(SConscript(os.path.dirname(SDK_ROOT) + '/libraries/HAL_Drivers/SConscript')) objs.extend(SConscript(os.path.join(libraries_path_prefix, stm32_library, 'SConscript')))
# include drivers
objs.extend(SConscript(os.path.join(libraries_path_prefix, 'HAL_Drivers', 'SConscript')))
# make a building # make a building
DoBuilding(TARGET, objs) DoBuilding(TARGET, objs)
import os
import rtconfig import rtconfig
from building import * from building import *
Import('SDK_LIB')
cwd = GetCurrentDir() cwd = GetCurrentDir()
# add the general drivers. # add general drivers
src = Glob('board.c') src = Split('''
src += Glob('CubeMX_Config/Src/stm32f4xx_hal_msp.c') board.c
CubeMX_Config/Src/stm32f4xx_hal_msp.c
''')
path = [cwd] path = [cwd]
path += [cwd + '/CubeMX_Config/Inc'] path += [cwd + '/CubeMX_Config/Inc']
startup_path_prefix = SDK_LIB
if rtconfig.CROSS_TOOL == 'gcc': if rtconfig.CROSS_TOOL == 'gcc':
src += [cwd + '/../../libraries/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc/startup_stm32f407xx.s'] src += [startup_path_prefix + '/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc/startup_stm32f407xx.s']
elif rtconfig.CROSS_TOOL == 'keil': elif rtconfig.CROSS_TOOL == 'keil':
src += [cwd + '/../../libraries/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/arm/startup_stm32f407xx.s'] src += [startup_path_prefix + '/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/arm/startup_stm32f407xx.s']
elif rtconfig.CROSS_TOOL == 'iar': elif rtconfig.CROSS_TOOL == 'iar':
src += [cwd + '/../../libraries/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f407xx.s'] src += [startup_path_prefix + '/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f407xx.s']
CPPDEFINES = ['STM32F407xx'] CPPDEFINES = ['STM32F407xx']
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES) group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES)
......
...@@ -5,6 +5,9 @@ ARCH='arm' ...@@ -5,6 +5,9 @@ ARCH='arm'
CPU='cortex-m4' CPU='cortex-m4'
CROSS_TOOL='gcc' CROSS_TOOL='gcc'
# bsp lib config
BSP_LIBRARY_TYPE = None
if os.getenv('RTT_CC'): if os.getenv('RTT_CC'):
CROSS_TOOL = os.getenv('RTT_CC') CROSS_TOOL = os.getenv('RTT_CC')
if os.getenv('RTT_ROOT'): if os.getenv('RTT_ROOT'):
......
...@@ -32,16 +32,27 @@ if rtconfig.PLATFORM == 'iar': ...@@ -32,16 +32,27 @@ if rtconfig.PLATFORM == 'iar':
Export('RTT_ROOT') Export('RTT_ROOT')
Export('rtconfig') Export('rtconfig')
SDK_ROOT = os.path.abspath('./')
if os.path.exists(SDK_ROOT + '/libraries'):
libraries_path_prefix = SDK_ROOT + '/libraries'
else:
libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries'
SDK_LIB = libraries_path_prefix
Export('SDK_LIB')
# prepare building environment # prepare building environment
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
SDK_ROOT = os.path.abspath('./') stm32_library = 'STM32L4xx_HAL'
rtconfig.BSP_LIBRARY_TYPE = stm32_library
# include drivers
objs.extend(SConscript(os.path.dirname(SDK_ROOT) + '/libraries/STM32L4xx_HAL/SConscript'))
# include libraries # include libraries
objs.extend(SConscript(os.path.dirname(SDK_ROOT) + '/libraries/HAL_Drivers/SConscript')) objs.extend(SConscript(os.path.join(libraries_path_prefix, stm32_library, 'SConscript')))
# include drivers
objs.extend(SConscript(os.path.join(libraries_path_prefix, 'HAL_Drivers', 'SConscript')))
# make a building # make a building
DoBuilding(TARGET, objs) DoBuilding(TARGET, objs)
import os
import rtconfig import rtconfig
from building import * from building import *
Import('SDK_LIB')
cwd = GetCurrentDir() cwd = GetCurrentDir()
# add the general drivers. # add general drivers
src = Glob('board.c') src = Split('''
src += Glob('CubeMX_Config/Src/stm32l4xx_hal_msp.c') board.c
CubeMX_Config/Src/stm32l4xx_hal_msp.c
''')
path = [cwd] path = [cwd]
path += [cwd + '/CubeMX_Config/Inc'] path += [cwd + '/CubeMX_Config/Inc']
startup_path_prefix = SDK_LIB
if rtconfig.CROSS_TOOL == 'gcc': if rtconfig.CROSS_TOOL == 'gcc':
src += [cwd + '/../../libraries/STM32L4xx_HAL/CMSIS/Device/ST/STM32L4xx/Source/Templates/gcc/startup_stm32l475xx.s'] src += [startup_path_prefix + '/STM32L4xx_HAL/CMSIS/Device/ST/STM32L4xx/Source/Templates/gcc/startup_stm32l475xx.s']
elif rtconfig.CROSS_TOOL == 'keil': elif rtconfig.CROSS_TOOL == 'keil':
src += [cwd + '/../../libraries/STM32L4xx_HAL/CMSIS/Device/ST/STM32L4xx/Source/Templates/arm/startup_stm32l475xx.s'] src += [startup_path_prefix + '/STM32L4xx_HAL/CMSIS/Device/ST/STM32L4xx/Source/Templates/arm/startup_stm32l475xx.s']
elif rtconfig.CROSS_TOOL == 'iar': elif rtconfig.CROSS_TOOL == 'iar':
src += [cwd + '/../../libraries/STM32L4xx_HAL/CMSIS/Device/ST/STM32L4xx/Source/Templates/iar/startup_stm32l475xx.s'] src += [startup_path_prefix + '/STM32L4xx_HAL/CMSIS/Device/ST/STM32L4xx/Source/Templates/iar/startup_stm32l475xx.s']
CPPDEFINES = ['STM32L475xx'] CPPDEFINES = ['STM32L475xx']
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES) group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES)
......
...@@ -5,6 +5,9 @@ ARCH='arm' ...@@ -5,6 +5,9 @@ ARCH='arm'
CPU='cortex-m4' CPU='cortex-m4'
CROSS_TOOL='gcc' CROSS_TOOL='gcc'
# bsp lib config
BSP_LIBRARY_TYPE = None
if os.getenv('RTT_CC'): if os.getenv('RTT_CC'):
CROSS_TOOL = os.getenv('RTT_CC') CROSS_TOOL = os.getenv('RTT_CC')
if os.getenv('RTT_ROOT'): if os.getenv('RTT_ROOT'):
......
...@@ -32,17 +32,27 @@ if rtconfig.PLATFORM == 'iar': ...@@ -32,17 +32,27 @@ if rtconfig.PLATFORM == 'iar':
Export('RTT_ROOT') Export('RTT_ROOT')
Export('rtconfig') Export('rtconfig')
SDK_ROOT = os.path.abspath('./')
if os.path.exists(SDK_ROOT + '/libraries'):
libraries_path_prefix = SDK_ROOT + '/libraries'
else:
libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries'
SDK_LIB = libraries_path_prefix
Export('SDK_LIB')
# prepare building environment # prepare building environment
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
SDK_ROOT = os.path.abspath('./') stm32_library = 'STM32F1xx_HAL'
bsp_vdir = 'build' rtconfig.BSP_LIBRARY_TYPE = stm32_library
# include drivers
objs.extend(SConscript(os.path.dirname(SDK_ROOT) + '/libraries/STM32F1xx_HAL/SConscript'))
# include libraries # include libraries
objs.extend(SConscript(os.path.dirname(SDK_ROOT) + '/libraries/HAL_Drivers/SConscript')) objs.extend(SConscript(os.path.join(libraries_path_prefix, stm32_library, 'SConscript')))
# include drivers
objs.extend(SConscript(os.path.join(libraries_path_prefix, 'HAL_Drivers', 'SConscript')))
# make a building # make a building
DoBuilding(TARGET, objs) DoBuilding(TARGET, objs)
import os
import rtconfig import rtconfig
from building import * from building import *
Import('SDK_LIB')
cwd = GetCurrentDir() cwd = GetCurrentDir()
src = Glob('board.c') # add general drivers
src += Glob('CubeMX_Config/Src/stm32f1xx_hal_msp.c') src = Split('''
board.c
CubeMX_Config/Src/stm32f1xx_hal_msp.c
''')
if GetDepend(['BSP_USING_SPI_FLASH']): if GetDepend(['BSP_USING_SPI_FLASH']):
src += Glob('ports/spi_flash_init.c') src += Glob('ports/spi_flash_init.c')
path = [cwd] path = [cwd]
path += [cwd + '/CubeMX_Config/Inc'] path += [cwd + '/CubeMX_Config/Inc']
path += [cwd + '/ports'] path += [cwd + '/ports']
startup_path_prefix = SDK_LIB
if rtconfig.CROSS_TOOL == 'gcc': if rtconfig.CROSS_TOOL == 'gcc':
src += [cwd + '/../../libraries/STM32F1xx_HAL/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103xb.s'] src += [startup_path_prefix + '/STM32F1xx_HAL/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103xb.s']
elif rtconfig.CROSS_TOOL == 'keil': elif rtconfig.CROSS_TOOL == 'keil':
src += [cwd + '/../../libraries/STM32F1xx_HAL/CMSIS/Device/ST/STM32F1xx/Source/Templates/arm/startup_stm32f103xb.s'] src += [startup_path_prefix + '/STM32F1xx_HAL/CMSIS/Device/ST/STM32F1xx/Source/Templates/arm/startup_stm32f103xb.s']
elif rtconfig.CROSS_TOOL == 'iar': elif rtconfig.CROSS_TOOL == 'iar':
src += [cwd + '/../../libraries/STM32F1xx_HAL/CMSIS/Device/ST/STM32F1xx/Source/Templates/iar/startup_stm32f103xb.s'] src += [startup_path_prefix + '/STM32F1xx_HAL/CMSIS/Device/ST/STM32F1xx/Source/Templates/iar/startup_stm32f103xb.s']
CPPDEFINES = ['STM32F103xB'] CPPDEFINES = ['STM32F103xB']
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES) group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES)
......
...@@ -5,6 +5,9 @@ ARCH='arm' ...@@ -5,6 +5,9 @@ ARCH='arm'
CPU='cortex-m3' CPU='cortex-m3'
CROSS_TOOL='gcc' CROSS_TOOL='gcc'
# bsp lib config
BSP_LIBRARY_TYPE = None
if os.getenv('RTT_CC'): if os.getenv('RTT_CC'):
CROSS_TOOL = os.getenv('RTT_CC') CROSS_TOOL = os.getenv('RTT_CC')
if os.getenv('RTT_ROOT'): if os.getenv('RTT_ROOT'):
......
...@@ -32,17 +32,27 @@ if rtconfig.PLATFORM == 'iar': ...@@ -32,17 +32,27 @@ if rtconfig.PLATFORM == 'iar':
Export('RTT_ROOT') Export('RTT_ROOT')
Export('rtconfig') Export('rtconfig')
SDK_ROOT = os.path.abspath('./')
if os.path.exists(SDK_ROOT + '/libraries'):
libraries_path_prefix = SDK_ROOT + '/libraries'
else:
libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries'
SDK_LIB = libraries_path_prefix
Export('SDK_LIB')
# prepare building environment # prepare building environment
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
SDK_ROOT = os.path.abspath('./') stm32_library = 'STM32F1xx_HAL'
bsp_vdir = 'build' rtconfig.BSP_LIBRARY_TYPE = stm32_library
# include drivers
objs.extend(SConscript(os.path.dirname(SDK_ROOT) + '/libraries/STM32F1xx_HAL/SConscript'))
# include libraries # include libraries
objs.extend(SConscript(os.path.dirname(SDK_ROOT) + '/libraries/HAL_Drivers/SConscript')) objs.extend(SConscript(os.path.join(libraries_path_prefix, stm32_library, 'SConscript')))
# include drivers
objs.extend(SConscript(os.path.join(libraries_path_prefix, 'HAL_Drivers', 'SConscript')))
# make a building # make a building
DoBuilding(TARGET, objs) DoBuilding(TARGET, objs)
import os
import rtconfig import rtconfig
from building import * from building import *
Import('SDK_LIB')
cwd = GetCurrentDir() cwd = GetCurrentDir()
src = Glob('board.c') # add general drivers
src += Glob('CubeMX_Config/Src/stm32f1xx_hal_msp.c') src = Split('''
board.c
CubeMX_Config/Src/stm32f1xx_hal_msp.c
''')
if GetDepend(['BSP_USING_ETH']): if GetDepend(['BSP_USING_ETH']):
src += Glob('ports/w5500_device.c') src += Glob('ports/w5500_device.c')
...@@ -16,12 +22,14 @@ path = [cwd] ...@@ -16,12 +22,14 @@ path = [cwd]
path += [cwd + '/CubeMX_Config/Inc'] path += [cwd + '/CubeMX_Config/Inc']
path += [cwd + '/ports'] path += [cwd + '/ports']
startup_path_prefix = SDK_LIB
if rtconfig.CROSS_TOOL == 'gcc': if rtconfig.CROSS_TOOL == 'gcc':
src += [cwd + '/../../libraries/STM32F1xx_HAL/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103xe.s'] src += [startup_path_prefix + '/STM32F1xx_HAL/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103xe.s']
elif rtconfig.CROSS_TOOL == 'keil': elif rtconfig.CROSS_TOOL == 'keil':
src += [cwd + '/../../libraries/STM32F1xx_HAL/CMSIS/Device/ST/STM32F1xx/Source/Templates/arm/startup_stm32f103xe.s'] src += [startup_path_prefix + '/STM32F1xx_HAL/CMSIS/Device/ST/STM32F1xx/Source/Templates/arm/startup_stm32f103xe.s']
elif rtconfig.CROSS_TOOL == 'iar': elif rtconfig.CROSS_TOOL == 'iar':
src += [cwd + '/../../libraries/STM32F1xx_HAL/CMSIS/Device/ST/STM32F1xx/Source/Templates/iar/startup_stm32f103xe.s'] src += [startup_path_prefix + '/STM32F1xx_HAL/CMSIS/Device/ST/STM32F1xx/Source/Templates/iar/startup_stm32f103xe.s']
CPPDEFINES = ['STM32F103xE'] CPPDEFINES = ['STM32F103xE']
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES) group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES)
......
...@@ -5,6 +5,9 @@ ARCH='arm' ...@@ -5,6 +5,9 @@ ARCH='arm'
CPU='cortex-m3' CPU='cortex-m3'
CROSS_TOOL='gcc' CROSS_TOOL='gcc'
# bsp lib config
BSP_LIBRARY_TYPE = None
if os.getenv('RTT_CC'): if os.getenv('RTT_CC'):
CROSS_TOOL = os.getenv('RTT_CC') CROSS_TOOL = os.getenv('RTT_CC')
if os.getenv('RTT_ROOT'): if os.getenv('RTT_ROOT'):
......
...@@ -32,16 +32,27 @@ if rtconfig.PLATFORM == 'iar': ...@@ -32,16 +32,27 @@ if rtconfig.PLATFORM == 'iar':
Export('RTT_ROOT') Export('RTT_ROOT')
Export('rtconfig') Export('rtconfig')
SDK_ROOT = os.path.abspath('./')
if os.path.exists(SDK_ROOT + '/libraries'):
libraries_path_prefix = SDK_ROOT + '/libraries'
else:
libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries'
SDK_LIB = libraries_path_prefix
Export('SDK_LIB')
# prepare building environment # prepare building environment
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
SDK_ROOT = os.path.abspath('./') stm32_library = 'STM32F4xx_HAL'
rtconfig.BSP_LIBRARY_TYPE = stm32_library
# include drivers
objs.extend(SConscript(os.path.dirname(SDK_ROOT) + '/libraries/STM32F4xx_HAL/SConscript'))
# include libraries # include libraries
objs.extend(SConscript(os.path.dirname(SDK_ROOT) + '/libraries/HAL_Drivers/SConscript')) objs.extend(SConscript(os.path.join(libraries_path_prefix, stm32_library, 'SConscript')))
# include drivers
objs.extend(SConscript(os.path.join(libraries_path_prefix, 'HAL_Drivers', 'SConscript')))
# make a building # make a building
DoBuilding(TARGET, objs) DoBuilding(TARGET, objs)
import os
import rtconfig import rtconfig
from building import * from building import *
Import('SDK_LIB')
cwd = GetCurrentDir() cwd = GetCurrentDir()
# add the general drivers. # add general drivers
src = Glob('board.c') src = Split('''
src += Glob('CubeMX_Config/Src/stm32f4xx_hal_msp.c') board.c
CubeMX_Config/Src/stm32f4xx_hal_msp.c
''')
if GetDepend(['BSP_USING_ETH']): if GetDepend(['BSP_USING_ETH']):
src += Glob('ports/phy_reset.c') src += Glob('ports/phy_reset.c')
...@@ -17,12 +22,14 @@ path = [cwd] ...@@ -17,12 +22,14 @@ path = [cwd]
path += [cwd + '/CubeMX_Config/Inc'] path += [cwd + '/CubeMX_Config/Inc']
path += [cwd + '/ports'] path += [cwd + '/ports']
startup_path_prefix = SDK_LIB
if rtconfig.CROSS_TOOL == 'gcc': if rtconfig.CROSS_TOOL == 'gcc':
src += [cwd + '/../../libraries/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc/startup_stm32f407xx.s'] src += [startup_path_prefix + '/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc/startup_stm32f407xx.s']
elif rtconfig.CROSS_TOOL == 'keil': elif rtconfig.CROSS_TOOL == 'keil':
src += [cwd + '/../../libraries/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/arm/startup_stm32f407xx.s'] src += [startup_path_prefix + '/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/arm/startup_stm32f407xx.s']
elif rtconfig.CROSS_TOOL == 'iar': elif rtconfig.CROSS_TOOL == 'iar':
src += [cwd + '/../../libraries/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f407xx.s'] src += [startup_path_prefix + '/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f407xx.s']
CPPDEFINES = ['STM32F407xx'] CPPDEFINES = ['STM32F407xx']
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES) group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES)
......
...@@ -5,6 +5,9 @@ ARCH='arm' ...@@ -5,6 +5,9 @@ ARCH='arm'
CPU='cortex-m4' CPU='cortex-m4'
CROSS_TOOL='gcc' CROSS_TOOL='gcc'
# bsp lib config
BSP_LIBRARY_TYPE = None
if os.getenv('RTT_CC'): if os.getenv('RTT_CC'):
CROSS_TOOL = os.getenv('RTT_CC') CROSS_TOOL = os.getenv('RTT_CC')
if os.getenv('RTT_ROOT'): if os.getenv('RTT_ROOT'):
......
...@@ -32,16 +32,27 @@ if rtconfig.PLATFORM == 'iar': ...@@ -32,16 +32,27 @@ if rtconfig.PLATFORM == 'iar':
Export('RTT_ROOT') Export('RTT_ROOT')
Export('rtconfig') Export('rtconfig')
SDK_ROOT = os.path.abspath('./')
if os.path.exists(SDK_ROOT + '/libraries'):
libraries_path_prefix = SDK_ROOT + '/libraries'
else:
libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries'
SDK_LIB = libraries_path_prefix
Export('SDK_LIB')
# prepare building environment # prepare building environment
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
SDK_ROOT = os.path.abspath('./') stm32_library = 'STM32F4xx_HAL'
rtconfig.BSP_LIBRARY_TYPE = stm32_library
# include drivers
objs.extend(SConscript(os.path.dirname(SDK_ROOT) + '/libraries/STM32F4xx_HAL/SConscript'))
# include libraries # include libraries
objs.extend(SConscript(os.path.dirname(SDK_ROOT) + '/libraries/HAL_Drivers/SConscript')) objs.extend(SConscript(os.path.join(libraries_path_prefix, stm32_library, 'SConscript')))
# include drivers
objs.extend(SConscript(os.path.join(libraries_path_prefix, 'HAL_Drivers', 'SConscript')))
# make a building # make a building
DoBuilding(TARGET, objs) DoBuilding(TARGET, objs)
import os
import rtconfig import rtconfig
from building import * from building import *
Import('SDK_LIB')
cwd = GetCurrentDir() cwd = GetCurrentDir()
# add the general drivers. # add general drivers
src = Glob('board.c') src = Split('''
src += Glob('CubeMX_Config/Src/stm32f4xx_hal_msp.c') board.c
CubeMX_Config/Src/stm32f4xx_hal_msp.c
''')
if GetDepend(['BSP_USING_ETH']): if GetDepend(['BSP_USING_ETH']):
src += Glob('ports/phy_reset.c') src += Glob('ports/phy_reset.c')
...@@ -16,17 +21,15 @@ if GetDepend(['BSP_USING_SPI_FLASH']): ...@@ -16,17 +21,15 @@ if GetDepend(['BSP_USING_SPI_FLASH']):
path = [cwd] path = [cwd]
path += [cwd + '/CubeMX_Config/Inc'] path += [cwd + '/CubeMX_Config/Inc']
path += [cwd + '/ports'] path += [cwd + '/ports']
startup_path_prefix = SDK_LIB
if GetDepend(['BSP_USING_SDRAM']):
path += [cwd + '/ports']
if rtconfig.CROSS_TOOL == 'gcc': if rtconfig.CROSS_TOOL == 'gcc':
src += [cwd + '/../../libraries/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc/startup_stm32f429xx.s'] src += [startup_path_prefix + '/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc/startup_stm32f429xx.s']
elif rtconfig.CROSS_TOOL == 'keil': elif rtconfig.CROSS_TOOL == 'keil':
src += [cwd + '/../../libraries/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/arm/startup_stm32f429xx.s'] src += [startup_path_prefix + '/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/arm/startup_stm32f429xx.s']
elif rtconfig.CROSS_TOOL == 'iar': elif rtconfig.CROSS_TOOL == 'iar':
src += [cwd + '/../../libraries/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f429xx.s'] src += [startup_path_prefix + '/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f429xx.s']
CPPDEFINES = ['STM32F429xx'] CPPDEFINES = ['STM32F429xx']
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES) group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES)
......
...@@ -5,6 +5,9 @@ ARCH='arm' ...@@ -5,6 +5,9 @@ ARCH='arm'
CPU='cortex-m4' CPU='cortex-m4'
CROSS_TOOL='gcc' CROSS_TOOL='gcc'
# bsp lib config
BSP_LIBRARY_TYPE = None
if os.getenv('RTT_CC'): if os.getenv('RTT_CC'):
CROSS_TOOL = os.getenv('RTT_CC') CROSS_TOOL = os.getenv('RTT_CC')
if os.getenv('RTT_ROOT'): if os.getenv('RTT_ROOT'):
......
...@@ -32,16 +32,27 @@ if rtconfig.PLATFORM == 'iar': ...@@ -32,16 +32,27 @@ if rtconfig.PLATFORM == 'iar':
Export('RTT_ROOT') Export('RTT_ROOT')
Export('rtconfig') Export('rtconfig')
SDK_ROOT = os.path.abspath('./')
if os.path.exists(SDK_ROOT + '/libraries'):
libraries_path_prefix = SDK_ROOT + '/libraries'
else:
libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries'
SDK_LIB = libraries_path_prefix
Export('SDK_LIB')
# prepare building environment # prepare building environment
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
SDK_ROOT = os.path.abspath('./') stm32_library = 'STM32F4xx_HAL'
rtconfig.BSP_LIBRARY_TYPE = stm32_library
# include drivers
objs.extend(SConscript(os.path.dirname(SDK_ROOT) + '/libraries/STM32F4xx_HAL/SConscript'))
# include libraries # include libraries
objs.extend(SConscript(os.path.dirname(SDK_ROOT) + '/libraries/HAL_Drivers/SConscript')) objs.extend(SConscript(os.path.join(libraries_path_prefix, stm32_library, 'SConscript')))
# include drivers
objs.extend(SConscript(os.path.join(libraries_path_prefix, 'HAL_Drivers', 'SConscript')))
# make a building # make a building
DoBuilding(TARGET, objs) DoBuilding(TARGET, objs)
import os
import rtconfig import rtconfig
from building import * from building import *
Import('SDK_LIB')
cwd = GetCurrentDir() cwd = GetCurrentDir()
# add the general drivers. # add general drivers
src = Glob('board.c') src = Split('''
src += Glob('CubeMX_Config/Src/stm32f4xx_hal_msp.c') board.c
CubeMX_Config/Src/stm32f4xx_hal_msp.c
''')
if GetDepend(['BSP_USING_ETH']): if GetDepend(['BSP_USING_ETH']):
src += Glob('ports/phy_reset.c') src += Glob('ports/phy_reset.c')
...@@ -13,19 +18,18 @@ if GetDepend(['BSP_USING_ETH']): ...@@ -13,19 +18,18 @@ if GetDepend(['BSP_USING_ETH']):
if GetDepend(['BSP_USING_SPI_FLASH']): if GetDepend(['BSP_USING_SPI_FLASH']):
src += Glob('ports/spi_flash_init.c') src += Glob('ports/spi_flash_init.c')
path = [cwd] path = [cwd]
path += [cwd + '/CubeMX_Config/Inc'] path += [cwd + '/CubeMX_Config/Inc']
path += [cwd + '/ports'] path += [cwd + '/ports']
if GetDepend(['BSP_USING_SDRAM']): startup_path_prefix = SDK_LIB
path += [cwd + '/ports']
if rtconfig.CROSS_TOOL == 'gcc': if rtconfig.CROSS_TOOL == 'gcc':
src += [cwd + '/../../libraries/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc/startup_stm32f429xx.s'] src += [startup_path_prefix + '/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc/startup_stm32f429xx.s']
elif rtconfig.CROSS_TOOL == 'keil': elif rtconfig.CROSS_TOOL == 'keil':
src += [cwd + '/../../libraries/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/arm/startup_stm32f429xx.s'] src += [startup_path_prefix + '/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/arm/startup_stm32f429xx.s']
elif rtconfig.CROSS_TOOL == 'iar': elif rtconfig.CROSS_TOOL == 'iar':
src += [cwd + '/../../libraries/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f429xx.s'] src += [startup_path_prefix + '/STM32F4xx_HAL/CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f429xx.s']
CPPDEFINES = ['STM32F429xx'] CPPDEFINES = ['STM32F429xx']
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES) group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES)
......
...@@ -5,6 +5,9 @@ ARCH='arm' ...@@ -5,6 +5,9 @@ ARCH='arm'
CPU='cortex-m4' CPU='cortex-m4'
CROSS_TOOL='gcc' CROSS_TOOL='gcc'
# bsp lib config
BSP_LIBRARY_TYPE = None
if os.getenv('RTT_CC'): if os.getenv('RTT_CC'):
CROSS_TOOL = os.getenv('RTT_CC') CROSS_TOOL = os.getenv('RTT_CC')
if os.getenv('RTT_ROOT'): if os.getenv('RTT_ROOT'):
......
...@@ -810,6 +810,9 @@ def EndBuilding(target, program = None): ...@@ -810,6 +810,9 @@ def EndBuilding(target, program = None):
Env['target'] = program Env['target'] = program
Env['project'] = Projects Env['project'] = Projects
if hasattr(rtconfig, 'BSP_LIBRARY_TYPE'):
Env['bsp_lib_type'] = rtconfig.BSP_LIBRARY_TYPE
Env.AddPostAction(target, rtconfig.POST_ACTION) Env.AddPostAction(target, rtconfig.POST_ACTION)
# Add addition clean files # Add addition clean files
Clean(target, 'cconfig.h') Clean(target, 'cconfig.h')
......
...@@ -122,6 +122,24 @@ def bsp_update_kconfig(dist_dir): ...@@ -122,6 +122,24 @@ def bsp_update_kconfig(dist_dir):
line = line[0:position] + 'default: "rt-thread"\n' line = line[0:position] + 'default: "rt-thread"\n'
found = 0 found = 0
f.write(line) f.write(line)
def bsp_update_kconfig_library(dist_dir):
# change RTT_ROOT in Kconfig
if not os.path.isfile(os.path.join(dist_dir, 'Kconfig')):
return
with open(os.path.join(dist_dir, 'Kconfig'), 'r') as f:
data = f.readlines()
with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f:
found = 0
for line in data:
if line.find('RTT_ROOT') != -1:
found = 1
if line.find('../libraries') != -1 and found:
position = line.find('../libraries')
line = line[0:position] + 'libraries/Kconfig"\n'
found = 0
f.write(line)
def bs_update_ide_project(bsp_root, rtt_root): def bs_update_ide_project(bsp_root, rtt_root):
import subprocess import subprocess
...@@ -169,6 +187,15 @@ def MkDist_Strip(program, BSP_ROOT, RTT_ROOT, Env): ...@@ -169,6 +187,15 @@ def MkDist_Strip(program, BSP_ROOT, RTT_ROOT, Env):
print('=> %s' % os.path.basename(BSP_ROOT)) print('=> %s' % os.path.basename(BSP_ROOT))
bsp_copy_files(BSP_ROOT, dist_dir) bsp_copy_files(BSP_ROOT, dist_dir)
# copy stm32 bsp libiary files
if os.path.basename(os.path.dirname(BSP_ROOT)) == 'stm32':
print("=> copy stm32 bsp library")
library_path = os.path.join(os.path.dirname(BSP_ROOT), 'libraries')
library_dir = os.path.join(dist_dir, 'libraries')
bsp_copy_files(os.path.join(library_path, 'HAL_Drivers'), os.path.join(library_dir, 'HAL_Drivers'))
bsp_copy_files(os.path.join(library_path, Env['bsp_lib_type']), os.path.join(library_dir, Env['bsp_lib_type']))
shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig'))
# get all source files from program # get all source files from program
for item in program: for item in program:
walk_children(item) walk_children(item)
...@@ -260,6 +287,7 @@ def MkDist_Strip(program, BSP_ROOT, RTT_ROOT, Env): ...@@ -260,6 +287,7 @@ def MkDist_Strip(program, BSP_ROOT, RTT_ROOT, Env):
bsp_update_sconstruct(dist_dir) bsp_update_sconstruct(dist_dir)
# change RTT_ROOT in Kconfig # change RTT_ROOT in Kconfig
bsp_update_kconfig(dist_dir) bsp_update_kconfig(dist_dir)
bsp_update_kconfig_library(dist_dir)
# update all project files # update all project files
bs_update_ide_project(dist_dir, target_path) bs_update_ide_project(dist_dir, target_path)
...@@ -280,6 +308,15 @@ def MkDist(program, BSP_ROOT, RTT_ROOT, Env): ...@@ -280,6 +308,15 @@ def MkDist(program, BSP_ROOT, RTT_ROOT, Env):
print('=> %s' % os.path.basename(BSP_ROOT)) print('=> %s' % os.path.basename(BSP_ROOT))
bsp_copy_files(BSP_ROOT, dist_dir) bsp_copy_files(BSP_ROOT, dist_dir)
# copy stm32 bsp libiary files
if os.path.basename(os.path.dirname(BSP_ROOT)) == 'stm32':
print("=> copy stm32 bsp library")
library_path = os.path.join(os.path.dirname(BSP_ROOT), 'libraries')
library_dir = os.path.join(dist_dir, 'libraries')
bsp_copy_files(os.path.join(library_path, 'HAL_Drivers'), os.path.join(library_dir, 'HAL_Drivers'))
bsp_copy_files(os.path.join(library_path, Env['bsp_lib_type']), os.path.join(library_dir, Env['bsp_lib_type']))
shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig'))
# copy tools directory # copy tools directory
print('=> components') print('=> components')
do_copy_folder(os.path.join(RTT_ROOT, 'components'), os.path.join(target_path, 'components')) do_copy_folder(os.path.join(RTT_ROOT, 'components'), os.path.join(target_path, 'components'))
...@@ -316,6 +353,7 @@ def MkDist(program, BSP_ROOT, RTT_ROOT, Env): ...@@ -316,6 +353,7 @@ def MkDist(program, BSP_ROOT, RTT_ROOT, Env):
bsp_update_sconstruct(dist_dir) bsp_update_sconstruct(dist_dir)
# change RTT_ROOT in Kconfig # change RTT_ROOT in Kconfig
bsp_update_kconfig(dist_dir) bsp_update_kconfig(dist_dir)
bsp_update_kconfig_library(dist_dir)
# update all project files # update all project files
bs_update_ide_project(dist_dir, target_path) bs_update_ide_project(dist_dir, target_path)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册