MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / create_need_files

Function create_need_files

tools/vscpyocd.py:5–71  ·  view source on GitHub ↗

Generate pyocd.yaml files

(targetId, packpath)

Source from the content-addressed store, hash-verified

3import json
4
5def create_need_files(targetId, packpath):
6 """
7 Generate pyocd.yaml files
8 """
9 yaml_file = open('pyocd.yaml', 'w')
10 if yaml_file:
11 yaml_file.write('\npack:\n')
12 yaml_file.write(' - ' + packpath + '\n')
13 yaml_file.close()
14
15 """
16 Generate .vscode/launch.json files
17 """
18 vsc_launch_file = open('.vscode/launch.json', 'w')
19 if vsc_launch_file:
20 config_obj = {}
21 config_obj['name'] = 'Cortex Debug'
22 config_obj['cwd'] = '${workspaceFolder}'
23 config_obj['executable'] = 'rt-thread.elf'
24 config_obj['request'] = 'launch'
25 config_obj['type'] = 'cortex-debug'
26 config_obj['runToEntryPoint'] = 'Reset_Handler'
27 config_obj['servertype'] = 'pyocd'
28 if os.getenv('RTT_EXEC_PATH'):
29 config_obj['armToolchainPath'] = os.getenv('RTT_EXEC_PATH').replace('\\', '/')
30 else:
31 print('env <RTT_EXEC_PATH> not set!')
32 config_obj['toolchainPrefix'] = 'arm-none-eabi'
33 config_obj['targetId'] = targetId
34
35 json_obj = {}
36 json_obj['version'] = '0.2.0'
37 json_obj['configurations'] = [config_obj]
38 vsc_launch_file.write(json.dumps(json_obj, ensure_ascii=False, indent=4))
39 vsc_launch_file.close()
40
41 """
42 Generate .vscode/tasks.json files
43 """
44 vsc_tasks_file = open('.vscode/tasks.json', 'w')
45 if vsc_tasks_file:
46 task_build_obj = {}
47 task_build_obj['type'] = 'shell'
48 task_build_obj['label'] = 'Build target files'
49 task_build_obj['command'] = 'scons'
50 task_build_obj['args'] = ['-j12']
51 task_build_obj['problemMatcher'] = ['$gcc']
52 task_build_obj['group'] = 'build'
53
54 task_download_obj = {}
55 task_download_obj['type'] = 'shell'
56 task_download_obj['label'] = 'Download code to flash memory'
57 task_download_obj['command'] = 'python'
58 task_download_obj['args'] = ['-m', 'pyocd', 'flash', '--erase', 'chip', '--target', \
59 targetId, 'rt-thread.elf']
60 task_download_obj['problemMatcher'] = ['$gcc']
61 task_download_obj['group'] = 'build'
62

Callers 1

Calls 2

openFunction · 0.50
writeMethod · 0.45

Tested by

no test coverage detected