Beispiel #1
0
def flash(port, firmware_file, erase_flash):
    # Initialize parameters
    args = Args()
    args.port = port
    args.baud = 460800

    # Initialize device
    initial_baud = min(ESP_ROM_BAUD, args.baud)
    esp = esptool.ESPROM(args.port, initial_baud)

    if erase_flash:
        # Connect to the device
        esp.connect()

        # Erase flash
        esptool.erase_flash(esp, None)
        # Wait for flash erase
        for i in xrange(10):
            print ".",
            sleep(1)
        print "\nDone erasing flash."

    # Reconnect
    esp.connect()

    # Prepare arguments for writing flash
    address = 0
    args.flash_size = "8m"
    args.addr_filename = [(address, open(firmware_file, "rb"))]

    # Write flash
    esptool.write_flash(esp, args)
    print "Done writing new firmware."
Beispiel #2
0
def flash(port, firmware_file, erase_flash):
    # Initialize parameters
    args = Args()
    args.port = port
    args.baud = 460800

    # Initialize device
    initial_baud = min(ESP_ROM_BAUD, args.baud)
    esp = esptool.ESPROM(args.port, initial_baud)

    if erase_flash:
        # Connect to the device
        esp.connect()

        # Erase flash
        esptool.erase_flash(esp, args)

    if not firmware_file:
        return

    # Reconnect
    esp.connect()

    # Prepare arguments for writing flash
    address = 0
    args.flash_size = "detect"
    args.addr_filename = [(address, open(firmware_file, "rb"))]

    # Write flash
    esptool.write_flash(esp, args)
    print("Done writing new firmware.")
 def __init__(self, parent,position,label,num,efuse_mode):#, pos):#id, pos, size, style, name):
     self.frame = parent
     self.num = num
     print 'test label:',label
     print 'self.num:',self.num
     self._init_ctrls(parent,position,label)#,pos)
     self.running =  False
     self.ESP_FDL = et.ESPROM(parent,6,115200,efuse_mode)
     self.ESP_FDL_STATE = -1
     #self.frame = parent
     
     self.Bind(wx.EVT_TIMER, self.update_pic,self.timer)
     self.Bind(wx.EVT_TIMER, self.set_gauge,self.timer2)
     self.load_path_conf()
Beispiel #4
0
def get_device_id(port='/dev/ttyUSB0'):
    while True:
        try:
            esp = esptool.ESPROM(port, esptool.ESPROM.ESP_ROM_BAUD)
            esp.connect()
            return str(format(esp.chip_id(), 'x'))
        except:
            port_list = list(port)
            if port_list[-1] == '0':
                port_list[-1] = '1'
            else:
                port_list[-1] = '0'
            port = ''.join(port_list)
            print 'port,', port
            res = raw_input('connect device fail, retry? y/n: ')
            if res == 'n':
                break
            elif res == 'q':
                exit()
Beispiel #5
0
 def connect(self):
     device = esptool.ESPROM(self.port, self.baud)
     device.connect()
     return device
Beispiel #6
0
if __name__ == "__main__":
    handler = UdevHandler()
    while True:
        cprint("Waiting for device", "green")
        device = handler.wait_for_device()

        cprint("New device added: {0}".format(device), "green")
        for field in [
                "DEVNAME",
                "ID_MODEL_ENC",
                "ID_USB_DRIVER",
        ]:
            print(field, device.properties.get(field))

        initial_baud = min(esptool.ESPROM.ESP_ROM_BAUD, BAUD)
        esp = esptool.ESPROM(device.properties['DEVNAME'], initial_baud)
        esp.connect()

        mac = esp.read_mac()
        mac = ':'.join(map(lambda x: '{0:02x}'.format(x), mac))

        chip_id = esp.chip_id()
        chip_id = "0x{0:08x}".format(chip_id)

        flash_id = esp.flash_id()

        flash_manuf = flash_id & 0xff
        flash_device = (flash_id & 0xff00) | (flash_id >> 16 & 0xff)

        link_hash = hashlib.sha256()
        link_hash.update(str(flash_id))
Beispiel #7
0
        device = handler.wait_for_device()

        devprops = device
        if hasattr(device, 'properties'):
            devprops = device.properties

        cprint("New device added: {0}".format(device), "green")
        for field in [
                "DEVNAME",
                "ID_MODEL_ENC",
                "ID_USB_DRIVER",
        ]:
            print(field, devprops.get(field))

        initial_baud = min(esptool.ESPROM.ESP_ROM_BAUD, BAUD)
        esp = esptool.ESPROM(devprops['DEVNAME'], initial_baud)
        esp.connect()

        mac = esp.read_mac()
        mac = ':'.join(map(lambda x: '{0:02x}'.format(x), mac))

        chip_id = esp.chip_id()
        chip_id = "0x{0:08x}".format(chip_id)

        flash_id = esp.flash_id()

        flash_manuf = flash_id & 0xff
        flash_device = (flash_id & 0xff00) | (flash_id >> 16 & 0xff)

        link_hash = hashlib.sha256()
        link_hash.update(str(flash_id))