def __init__(self): self.serial_redirection = SerialRedirection(self.TTY, self.BAUDRATE) self.openocd = OpenOCD.from_node(self) self.edbg = Edbg() self._current_fw = None self._in_debug = False
class NodeEdbgBase(OpenNodeBase): # pylint:disable=no-member """ Open node EDBG implementation """ ELF_TARGET = ('ELFCLASS32', 'EM_ARM') TTY = '/dev/iotlab/ttyON_CMSIS_DAP' BAUDRATE = 115200 AUTOTEST_AVAILABLE = [ 'echo', 'get_time', # mandatory 'get_uid', 'leds_on', 'leds_off', 'leds_blink' ] ALIM = '5V' def __init__(self): self.serial_redirection = SerialRedirection(self.TTY, self.BAUDRATE) self.openocd = OpenOCD.from_node(self) self.edbg = Edbg() self._current_fw = None self._in_debug = False @property def programmer(self): """Returns the openocd instance of the open node.""" return self.edbg @logger_call("Node EDBG: Setup of EDBG node") def setup(self, firmware_path): """ Flash open node, create serial redirection """ self._in_debug = False ret_val = 0 common.wait_no_tty(self.TTY) ret_val += common.wait_tty(self.TTY, LOGGER) ret_val += self.flash(firmware_path) ret_val += self.serial_redirection.start() return ret_val @logger_call("Node EDBG: teardown of EDBG node") def teardown(self): """ Stop serial redirection and flash idle firmware """ self._in_debug = False ret_val = 0 # ON may have been stopped at the end of the experiment. # And then restarted again in cn teardown. # This leads to problem where the TTY disappears and reappears during # the first 2 seconds. So let some time if it wants to disappear first. common.wait_no_tty(self.TTY) ret_val += common.wait_tty(self.TTY, LOGGER) # cleanup debugger before flashing ret_val += self.debug_stop() ret_val += self.serial_redirection.stop() ret_val += self.flash(None) return ret_val @logger_call("Node EDBG: flash of edbg node") def flash(self, firmware_path=None, binary=False, offset=0): """ Flash the given firmware on EDBG node :param firmware_path: Path to the firmware to be flashed on `node`. If None, flash 'idle' firmware. """ firmware_path = firmware_path or self.FW_IDLE LOGGER.info('Flash firmware on %s: %s', self.TYPE.upper(), firmware_path) self._current_fw = firmware_path if self._in_debug: return self.openocd.flash(firmware_path, binary, offset) return self.edbg.flash(firmware_path, binary, offset) @logger_call("Node EDBG: reset of EDBG node") def reset(self): """ Reset the EDBG node using jtag """ LOGGER.info('Reset %s node', self.TYPE.upper()) return self.openocd.reset() def debug_start(self): """ Start EDBG node debugger """ LOGGER.info('%s Node debugger start', self.TYPE.upper()) self._in_debug = True if self._current_fw is not None: # Reflash current firmware using openocd to avoid misbehavior of # previously flashed firmware (with edbg) self.flash(firmware_path=self._current_fw) return self.openocd.debug_start() def debug_stop(self): """ Stop EDBG node debugger """ LOGGER.info('%s Node debugger stop', self.TYPE.upper()) self._in_debug = False return self.openocd.debug_stop() @staticmethod def status(): """ Check EDBG node status """ # Status is called when open node is not powered # So can't check for FTDI return 0
def __init__(self): self.serial_redirection = SerialRedirection(self.TTY, self.BAUDRATE) self.openocd = OpenOCD.from_node(self) self.edbg = Edbg()
class NodeArduinoZero(object): """ Open node Arduino Zero implementation """ TYPE = 'arduino_zero' ELF_TARGET = ('ELFCLASS32', 'EM_ARM') TTY = '/dev/iotlab/ttyON_ARDUINO_ZERO' BAUDRATE = 115200 OPENOCD_CFG_FILE = static_path('iot-lab-arduino-zero.cfg') FW_IDLE = static_path('arduino_zero_idle.elf') FW_AUTOTEST = static_path('arduino_zero_autotest.elf') AUTOTEST_AVAILABLE = [ 'echo', 'get_time', # mandatory 'leds_on', 'leds_off' ] ALIM = '5V' def __init__(self): self.serial_redirection = SerialRedirection(self.TTY, self.BAUDRATE) self.openocd = OpenOCD.from_node(self) self.edbg = Edbg() self._current_fw = None self._in_debug = False @logger_call("Node Arduino Zero : Setup of arduino zero node") def setup(self, firmware_path): """ Flash open node, create serial redirection """ self._in_debug = False ret_val = 0 common.wait_no_tty(self.TTY) ret_val += common.wait_tty(self.TTY, LOGGER) ret_val += self.flash(firmware_path) ret_val += self.serial_redirection.start() return ret_val @logger_call("Node Arduino Zero : teardown of arduino zero node") def teardown(self): """ Stop serial redirection and flash idle firmware """ self._in_debug = False ret_val = 0 # ON may have been stopped at the end of the experiment. # And then restarted again in cn teardown. # This leads to problem where the TTY disappears and reappears during # the first 2 seconds. So let some time if it wants to disappear first. common.wait_no_tty(self.TTY) ret_val += common.wait_tty(self.TTY, LOGGER) # cleanup debugger before flashing ret_val += self.debug_stop() ret_val += self.serial_redirection.stop() ret_val += self.flash(None) return ret_val @logger_call("Node Arduino Zero : flash of arduino zero node") def flash(self, firmware_path=None): """ Flash the given firmware on Arduino Zero node :param firmware_path: Path to the firmware to be flashed on `node`. If None, flash 'idle' firmware. """ firmware_path = firmware_path or self.FW_IDLE LOGGER.info('Flash firmware on Arduino Zero: %s', firmware_path) self._current_fw = firmware_path if self._in_debug: return self.openocd.flash(firmware_path) return self.edbg.flash(firmware_path) @logger_call("Node Arduino Zero : reset of arduino zero node") def reset(self): """ Reset the Arduino Zero node using jtag """ LOGGER.info('Reset Arduino Zero node') return self.openocd.reset() def debug_start(self): """ Start Arduino Zero node debugger """ LOGGER.info('Arduino Zero Node debugger start') self._in_debug = True if self._current_fw is not None: # Reflash current firmware using openocd to avoid misbehavior of # previously flashed firmware (with edbg) self.flash(firmware_path=self._current_fw) return self.openocd.debug_start() def debug_stop(self): """ Stop Arduino Zero node debugger """ LOGGER.info('Arduino Zero Node debugger stop') self._in_debug = False return self.openocd.debug_stop() @staticmethod def status(): """ Check Arduino Zero node status """ # Status is called when open node is not powered # So can't check for FTDI return 0
class NodeSamr21(object): """ Open node SAMR21 implemention """ TYPE = 'samr21' ELF_TARGET = ('ELFCLASS32', 'EM_ARM') TTY = '/dev/iotlab/ttyON_SAMR21' BAUDRATE = 115200 OPENOCD_CFG_FILE = static_path('iot-lab-samr21.cfg') FW_IDLE = static_path('samr21_idle.elf') FW_AUTOTEST = static_path('samr21_autotest.elf') AUTOTEST_AVAILABLE = [ 'echo', 'get_time', # mandatory 'leds_on', 'leds_off' ] ALIM = '5V' def __init__(self): self.serial_redirection = SerialRedirection(self.TTY, self.BAUDRATE) self.openocd = OpenOCD.from_node(self) self.edbg = Edbg() @logger_call("Node SAMR21 : Setup of samr21 node") def setup(self, firmware_path): """ Flash open node, create serial redirection """ ret_val = 0 common.wait_no_tty(self.TTY) ret_val += common.wait_tty(self.TTY, LOGGER) ret_val += self.flash(firmware_path) ret_val += self.serial_redirection.start() return ret_val @logger_call("Node SAMR21 : teardown of samr21 node") def teardown(self): """ Stop serial redirection and flash idle firmware """ ret_val = 0 # ON may have been stopped at the end of the experiment. # And then restarted again in cn teardown. # This leads to problem where the TTY disappears and reappears during # the first 2 seconds. So let some time if it wants to disappear first. common.wait_no_tty(self.TTY) ret_val += common.wait_tty(self.TTY, LOGGER) # cleanup debugger before flashing ret_val += self.debug_stop() ret_val += self.serial_redirection.stop() ret_val += self.flash(None) return ret_val @logger_call("Node SAMR21 : flash of sam21 node") def flash(self, firmware_path=None): """ Flash the given firmware on SAMR21 node :param firmware_path: Path to the firmware to be flashed on `node`. If None, flash 'idle' firmware. """ firmware_path = firmware_path or self.FW_IDLE LOGGER.info('Flash firmware on SAMR21: %s', firmware_path) return self.edbg.flash(firmware_path) @logger_call("Node SAMR21 : reset of samr21 node") def reset(self): """ Reset the SAMR21 node using jtag """ LOGGER.info('Reset SAMR21 node') return self.openocd.reset() def debug_start(self): """ Start SAMR21 node debugger """ LOGGER.info('SAMR21 Node debugger start') return self.openocd.debug_start() def debug_stop(self): """ Stop SAMR21 node debugger """ LOGGER.info('SAMR21 Node debugger stop') return self.openocd.debug_stop() @staticmethod def status(): """ Check SAMR21 node status """ # Status is called when open node is not powered # So can't check for FTDI return 0