winIDEA SDK
Loading...
Searching...
No Matches
create_ws.py
1import isystem.connect as ic
2
3def set_emulator_type(cmgr: ic.ConnectionMgr, emulator_type: str):
4 """
5 Sets the emulator type used.
6 :param cmgr: winIDEA connection manager
7 :param emulator_type: Type of emulator used.
8 Options available are iC5000, iC5500, iC5700,
9 iC7mini, iC7pro, iC7max, IFX_DAS, PE_Micro, ST_Link and XCP
10 """
11 # Create hardware option controller instance
12 opt_hardware = ic.COptionController(cmgr, '/iOPEN/Hardware')
13
14 # Set the emulator used.
15 opt_hardware.set('Emulator', emulator_type)
16
17
18def set_USB_comm(cmgr: ic.ConnectionMgr, device: str = ''):
19 """
20 Sets the emulator to use USB connection.
21 :param cmgr: winIDEA connection manager
22 :param device: USB device name composed of emulator type and the
23 emulator serial number. Used when there are more than 1 emulator
24 connected to your PC, otherwise it can remain empty.
25 More information: https://www.isystem.com/downloads/winIDEA/help/winidea-configuration-communication-type.html
26 """
27 opt_communication = ic.COptionController(cmgr, '/iOPEN/Communication')
28 in_params = {}
29 in_params['Mode'] = 'USB'
30 in_params['USBDeviceName'] = device
31
32 # Set the communication options.
33 opt_communication.set_multi(in_params)
34
35
36def set_debug_protocol_to_DAP(cmgr: ic.ConnectionMgr, debug_clock_khz: int):
37 """
38 Sets the debug protocol to DAP and configures the debug clock.
39 :param cmgr: winIDEA connection manager
40 :param debug_clock_khz: Debug clock in kilohertz.
41 """
42 opt_debug = ic.COptionController(cmgr, '/iOPEN/Emulation.Debugging')
43 opt_debug.set('DebugChannel','DAP')
44
45 opt_dap = ic.COptionController(cmgr, '/iOPEN/Emulation.OCD_TRICORE')
46 in_params = {}
47 in_params['DAPClock'] = str(debug_clock_khz)
48 in_params['DebugMode'] = 'DAP'
49 in_params['DAPE'] = 'false'
50 opt_dap.set_multi(in_params)
51
52
53def main():
54 cmgr = ic.ConnectionMgr()
55 cmgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
56 WORKSPACE_PATH = 'C:\\Test\\example.xjrf'
57
58 ws_ctrl = ic.CWorkspaceController(cmgr)
59 cfg = ic.CCfg_debug_basic()
60 cfg.set_Device('TC399XE')
61 cfg.set_SymPath('debug/output.elf')
62 cfg.set_UseSymForPgm(True)
63 cfg.set_CreateSMP(True)
64 ws_ctrl.create(WORKSPACE_PATH, '', cfg)
65
66 cfg_ctrl = ic.CConfigurationController(cmgr)
67 opt_session = cfg_ctrl.ide_session()
68
69 SECOND_APPLICATION_NAME = 'app2'
70 SECOND_APPLICATION_FILE_PATH = 'app2/app2.elf'
71
72 opt_app_files = cfg_ctrl.ide_app_files('')
73 opt_app_files.add_file(SECOND_APPLICATION_FILE_PATH, 'Elf', 0)
74
75 opt_app = opt_session.add_app(SECOND_APPLICATION_NAME)
76 opt_app.symbol_files().add_file(SECOND_APPLICATION_FILE_PATH, 'Elf', 0)\
77
78 opt_SoC = opt_session.SoC('')
79 opt_SoC.program_files().add_file(SECOND_APPLICATION_FILE_PATH, 'Elf', 0)
80
81 opt_SoC.add_memory_space('MemorySpace2', 'SCR', SECOND_APPLICATION_NAME)
82
83 set_emulator_type(cmgr, 'iC7mini')
84 set_USB_comm(cmgr)
85 set_debug_protocol_to_DAP(cmgr, 10000)
86 dbg_ctrl = ic.CDebugFacade(cmgr)
87 dbg_ctrl.download()
88
89if __name__ == "__main__":
90 main()