Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Create an interactive terminal session with the board.
This is a special-case use of Tockloader where this is really a helper
function for running some sort of underlying terminal-like operation.
Therefore, how we set this up is a little different from other
tockloader commands. In particular, we do _not_ want `tockloader.open()`
to have been called at this point.
'''
# By default, we use the serial connection and serial terminal. However,
# tockloader supports other terminals, and we choose the correct one
# here. There is no need to save the channel, since
# `channel.run_terminal()` never returns.
if self.args.rtt:
channel = JLinkExe(self.args)
else:
channel = BootloaderSerial(self.args)
channel.open_link_to_board(listen=True)
channel.run_terminal()
For the bootloader, this means opening a serial port. For JTAG, not much
needs to be done.
'''
# Verify both openocd and jlink are not set.
if getattr(self.args, 'jlink', False) and getattr(self.args, 'openocd', False):
raise TockLoaderException('Cannot use both --jlink and --openocd options')
# Get an object that allows talking to the board.
if hasattr(self.args, 'jlink') and self.args.jlink:
self.channel = JLinkExe(self.args)
elif hasattr(self.args, 'openocd') and self.args.openocd:
self.channel = OpenOCD(self.args)
else:
self.channel = BootloaderSerial(self.args)
# And make sure the channel is open (e.g. open a serial port).
self.channel.open_link_to_board()