'Run esptool with the specified arguments. --chip, --port and --baud
are filled in automatically from the command line. (can override default baud rate with baud param.)
Additional args passed in args parameter as a string.
Returns output from esptool.py as a string if there is any. Raises an exception if esptool.py fails.'

def run_esptool(self, args, baud=None):

    if (baud is None):
        baud = default_baudrate
    cmd = ([sys.executable, ESPTOOL_PY, '--chip', chip, '--port', serialport, '--baud', str(baud)] + args.split('    '))
    print ('Running    %s...' % '    '.join(cmd))
    try:
        output = subprocess.check_output([str(s) for s in cmd], cwd=TEST_DIR, stderr=subprocess.STDOUT)
        print output
        return output.decode('utf-8')
    except subprocess.CalledProcessError as e:
        print e.output
        raise e
