7761923ec5
Squashed commit of the following: commit 32dd349ccff85cdcad81021b5185f8f7347786db Author: Huaqi Fang <578567190@qq.com> Date: Thu Jun 11 16:08:08 2020 +0800 bsp/nuclei: Add more documentation about how to use RT-Thread in RV-STAR Signed-off-by: Huaqi Fang <578567190@qq.com> commit c9474c20a558e9d7934a3d72cc9bb17a98c20871 Author: Huaqi Fang <578567190@qq.com> Date: Thu Jun 11 14:06:42 2020 +0800 bsp/nuclei: remove comments in rt_hw_*_drvinit Signed-off-by: Huaqi Fang <578567190@qq.com> commit 89b5caa2c3e55dc352b13f8e33229f03351b7049 Author: Huaqi Fang <578567190@qq.com> Date: Thu Jun 11 13:52:12 2020 +0800 bsp/nuclei: Add a entry README.md for nuclei bsp Signed-off-by: Huaqi Fang <578567190@qq.com> commit ae50d6e9bdc92ca4767c5ac7d0ded7252314a42e Author: Huaqi Fang <578567190@qq.com> Date: Thu Jun 11 11:52:52 2020 +0800 bsp/nuclei: update README.md cover more pinmux section Signed-off-by: Huaqi Fang <578567190@qq.com> commit 1a42d85dfe5bc7b009f057784249d54d0c82de0f Author: Huaqi Fang <578567190@qq.com> Date: Thu Jun 11 08:52:06 2020 +0800 bsp/nuclei: clean up unused code in drv_spi.c Signed-off-by: Huaqi Fang <578567190@qq.com> commit b40edcdf59c96ef261f65a0c023a24ac78cabb39 Author: Huaqi Fang <578567190@qq.com> Date: Wed Jun 10 14:09:15 2020 +0800 bsp/nuclei: Format the code comments for hw pinmux init Signed-off-by: Huaqi Fang <578567190@qq.com> commit c8ae9fdfdb989bbff85d911fee3124abd9d145db Author: Huaqi Fang <578567190@qq.com> Date: Mon Jun 8 17:12:43 2020 +0800 bsp/nuclei: Add more drivers support for gd32vf103 * More drivers are supported for rvstar board, see README.md * If user want to use these supported drivers, menuconfig is required * User also need to setup pinmux for its coresponding driver in board/board.c Signed-off-by: Huaqi Fang <578567190@qq.com> Signed-off-by: Huaqi Fang <578567190@qq.com>
91 lines
2.9 KiB
Python
91 lines
2.9 KiB
Python
import os
|
|
import sys
|
|
import rtconfig
|
|
|
|
if os.getenv('RTT_ROOT'):
|
|
RTT_ROOT = os.getenv('RTT_ROOT')
|
|
else:
|
|
RTT_ROOT = os.path.normpath(os.getcwd() + '/../../..')
|
|
|
|
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
|
|
from building import *
|
|
|
|
TARGET = 'rtthread.' + rtconfig.TARGET_EXT
|
|
|
|
AddOption('--run',
|
|
dest = 'run',
|
|
type='string',
|
|
nargs=1,
|
|
action = 'store',
|
|
default = "",
|
|
help = 'Upload or debug application using openocd')
|
|
|
|
DefaultEnvironment(tools=[])
|
|
env = Environment(tools = ['mingw'],
|
|
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
|
|
CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
|
|
CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS,
|
|
AR = rtconfig.AR, ARFLAGS = '-rc', LIBS = rtconfig.LIBS,
|
|
LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
|
|
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
|
|
env['ASCOM'] = env['ASPPCOM']
|
|
|
|
Export('RTT_ROOT')
|
|
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')
|
|
|
|
GDB = rtconfig.GDB
|
|
|
|
# prepare building environment
|
|
objs = PrepareBuilding(env, RTT_ROOT)
|
|
|
|
bsp_library_type = rtconfig.NUCLEI_SDK_SOC
|
|
rtconfig.BSP_LIBRARY_TYPE = bsp_library_type
|
|
|
|
if hasattr(rtconfig, 'NUCLEI_SDK_OPENOCD_CFG'):
|
|
openocd_cfg = rtconfig.NUCLEI_SDK_OPENOCD_CFG.replace('\\', '/')
|
|
else:
|
|
print("ERROR: Nuclei SDK package is not yet downloaded, please execute <pkgs --update> in command line first!")
|
|
exit(0)
|
|
|
|
# include hal drivers
|
|
hal_sconscript = os.path.join(libraries_path_prefix, bsp_library_type, 'HAL_Drivers', 'SConscript')
|
|
|
|
if os.path.isfile(hal_sconscript):
|
|
objs.extend(SConscript(hal_sconscript))
|
|
|
|
# make a building
|
|
DoBuilding(TARGET, objs)
|
|
|
|
# Run upload or debug if --run=upload or --upload=debug
|
|
run_target = GetOption('run')
|
|
SUPPORT_RUN_TARGETS = ["upload", "debug"]
|
|
if run_target in SUPPORT_RUN_TARGETS:
|
|
if os.path.isfile(TARGET):
|
|
if run_target == "upload":
|
|
upload_cmd = '{} {} -ex "set remotetimeout 240" \
|
|
-ex "target remote | openocd --pipe -f {}" \
|
|
--batch -ex "monitor halt" -ex "monitor flash protect 0 0 last off" -ex "load" \
|
|
-ex "monitor resume" -ex "monitor shutdown" -ex "quit"'.format(GDB, TARGET, openocd_cfg)
|
|
print("Upload application {} using openocd and gdb".format(TARGET))
|
|
print(upload_cmd)
|
|
os.system(upload_cmd)
|
|
elif run_target == "debug":
|
|
debug_cmd = '{} {} -ex "set remotetimeout 240" \
|
|
-ex "target remote | openocd --pipe -f {}"'.format(GDB, TARGET, openocd_cfg)
|
|
print("Debug application {} using openocd and gdb".format(TARGET))
|
|
print(debug_cmd)
|
|
os.system(debug_cmd)
|
|
else:
|
|
print(TARGET + ' not exist, please run scons first!!')
|
|
exit(0)
|