How to use the tockloader.board_interface.BoardInterface function in tockloader

To help you get started, we’ve selected a few tockloader examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tock / tockloader / tockloader / openocd.py View on Github external
OpenOCD directly.
'''

import logging
import platform
import shlex
import subprocess
import tempfile

from .board_interface import BoardInterface
from .exceptions import TockLoaderException

# global static variable for collecting temp files for Windows
collect_temp_files = []

class OpenOCD(BoardInterface):

	def __init__ (self, args):
		# Must call the generic init first.
		super().__init__(args)

		# Use command line arguments to set the necessary settings.
		self.openocd_board = getattr(self.args, 'openocd_board')
		self.openocd_options = getattr(self.args, 'openocd_options')
		self.openocd_commands = getattr(self.args, 'openocd_commands')
		self.openocd_cmd = getattr(self.args, 'openocd_cmd')
		self.openocd_prefix = ''
		self.openocd_address_translator = None

		# If the user specified a board, use that configuration to fill in any
		# missing settings.
		if self.board and self.board in self.KNOWN_BOARDS:
github tock / tockloader / tockloader / jlinkexe.py View on Github external
Different MCUs require different command line arguments so that the JLinkExe
tool knows which JTAG interface it is talking to. Since we don't want to burden
the user with specifying the board each time, we default to using a generic
cortex-m0 target, and use that to read the bootloader attributes to get the
correct version. Once we know more about the board we are talking to we use the
correct command line argument for future communication.
'''

import subprocess
import tempfile
import time

from .board_interface import BoardInterface
from .exceptions import TockLoaderException

class JLinkExe(BoardInterface):
	def _run_jtag_commands (self, commands, binary, write=True):
		'''
		- `commands`: List of JLinkExe commands. Use {binary} for where the name
		  of the binary file should be substituted.
		- `binary`: A bytes() object that will be used to write to the board.
		- `write`: Set to true if the command writes binaries to the board. Set
		  to false if the command will read bits from the board.
		'''
		delete = True
		if self.args.debug:
			delete = False

		if binary or not write:
			temp_bin = tempfile.NamedTemporaryFile(mode='w+b', suffix='.bin', delete=delete)
			if write:
				temp_bin.write(binary)
github tock / tockloader / tockloader / bootloader_serial.py View on Github external
import threading

# Although Windows is not supported actively, this allow features that "just
# work" to work on Windows.
if platform.system() != 'Windows':
	import fcntl

import serial
import serial.tools.list_ports
import serial.tools.miniterm

from . import helpers
from .board_interface import BoardInterface
from .exceptions import TockLoaderException

class BootloaderSerial(BoardInterface):
	'''
	Implementation of `BoardInterface` for the Tock Bootloader over serial.
	'''

	# "This was chosen as it is infrequent in .bin files" - immesys
	ESCAPE_CHAR = 0xFC

	# Commands from this tool to the bootloader.
	# The "X" commands are for external flash.
	COMMAND_PING               = 0x01
	COMMAND_INFO               = 0x03
	COMMAND_ID                 = 0x04
	COMMAND_RESET              = 0x05
	COMMAND_ERASE_PAGE         = 0x06
	COMMAND_WRITE_PAGE         = 0x07
	COMMAND_XEBLOCK            = 0x08
github tock / tockloader / tockloader / tockloader.py View on Github external
def print_known_boards (self):
		'''
		Simple function to print to console the boards that are hardcoded
		into Tockloader to make them easier to use.
		'''
		BoardInterface(self.args).print_known_boards()