import isystem.connect as ic
def set_emulator_type(cmgr: ic.ConnectionMgr, emulator_type: str):
"""
Sets the emulator type used.
:param cmgr: winIDEA connection manager
:param emulator_type: Type of emulator used.
Options available are iC5000, iC5500, iC5700,
iC7mini, iC7pro, iC7max, IFX_DAS, PE_Micro, ST_Link and XCP
"""
opt_hardware = ic.COptionController(cmgr, '/iOPEN/Hardware')
opt_hardware.set('Emulator', emulator_type)
def set_USB_comm(cmgr: ic.ConnectionMgr, device: str = ''):
"""
Sets the emulator to use USB connection.
:param cmgr: winIDEA connection manager
:param device: USB device name composed of emulator type and the
emulator serial number. Used when there are more than 1 emulator
connected to your PC, otherwise it can remain empty.
More information: https://www.isystem.com/downloads/winIDEA/help/winidea-configuration-communication-type.html
"""
opt_communication = ic.COptionController(cmgr, '/iOPEN/Communication')
in_params = {}
in_params['Mode'] = 'USB'
in_params['USBDeviceName'] = device
opt_communication.set_multi(in_params)
def set_debug_protocol_to_DAP(cmgr: ic.ConnectionMgr, debug_clock_khz: int):
"""
Sets the debug protocol to DAP and configures the debug clock.
:param cmgr: winIDEA connection manager
:param debug_clock_khz: Debug clock in kilohertz.
"""
opt_debug = ic.COptionController(cmgr, '/iOPEN/Emulation.Debugging')
opt_debug.set('DebugChannel','DAP')
opt_dap = ic.COptionController(cmgr, '/iOPEN/Emulation.OCD_TRICORE')
in_params = {}
in_params['DAPClock'] = str(debug_clock_khz)
in_params['DebugMode'] = 'DAP'
in_params['DAPE'] = 'false'
opt_dap.set_multi(in_params)
def main():
cmgr = ic.ConnectionMgr()
cmgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
WORKSPACE_PATH = 'C:\\Test\\example.xjrf'
ws_ctrl = ic.CWorkspaceController(cmgr)
cfg = ic.CCfg_debug_basic()
cfg.set_Device('TC399XE')
cfg.set_SymPath('debug/output.elf')
cfg.set_UseSymForPgm(True)
cfg.set_CreateSMP(True)
ws_ctrl.create(WORKSPACE_PATH, '', cfg)
cfg_ctrl = ic.CConfigurationController(cmgr)
opt_session = cfg_ctrl.ide_session()
SECOND_APPLICATION_NAME = 'app2'
SECOND_APPLICATION_FILE_PATH = 'app2/app2.elf'
opt_app_files = cfg_ctrl.ide_app_files('')
opt_app_files.add_file(SECOND_APPLICATION_FILE_PATH, 'Elf', 0)
opt_app = opt_session.add_app(SECOND_APPLICATION_NAME)
opt_app.symbol_files().add_file(SECOND_APPLICATION_FILE_PATH, 'Elf', 0)\
opt_SoC = opt_session.SoC('')
opt_SoC.program_files().add_file(SECOND_APPLICATION_FILE_PATH, 'Elf', 0)
opt_SoC.add_memory_space('MemorySpace2', 'SCR', SECOND_APPLICATION_NAME)
set_emulator_type(cmgr, 'iC7mini')
set_USB_comm(cmgr)
set_debug_protocol_to_DAP(cmgr, 10000)
dbg_ctrl = ic.CDebugFacade(cmgr)
dbg_ctrl.download()
if __name__ == "__main__":
main()