GPIO REGISTER AND PIN LIST !!

costaud
Posts: 138
Joined: Fri Oct 24, 2014 7:40 pm

GPIO REGISTER AND PIN LIST !!

Postby costaud » Wed Nov 05, 2014 1:38 am

ESP8266 is really powerfull!!

NOTE:
1. Keep an eye on the strapping page, UOTXD,MTDO,GPIO0,GPIO2 might affect the boot-mode.
2. The input and output side both connect to the pad.When the output is disabled , it is set to be an input pin.
3. Each gpio has a same first-order sigma-delta pwm source, which can generate a hardware pwm signal.


Next , spi and uart register spec will be released soon.
Attachments
ESP8266_Pin_List_141105.xlsx
(64.6 KiB) Downloaded 2381 times
ESP8266_GPIO_Register_141105.xls
(31.5 KiB) Downloaded 2644 times

Fadi
Posts: 13
Joined: Mon Oct 27, 2014 9:48 am

Re: GPIO REGISTER AND PIN LIST !!

Postby Fadi » Fri Nov 07, 2014 11:47 pm

Thanks

User avatar
rudi
Posts: 197
Joined: Fri Oct 24, 2014 7:55 pm

Re: GPIO REGISTER AND PIN LIST !!

Postby rudi » Tue Nov 11, 2014 7:07 pm

hi costaud, thank you.
is there a adress list for read values example
- MAC Adress AP ( Flash tool read it 'barcode' )
- MAC Adress Station ( Flash Tool read it 'barcode' )
- CHIP ID ( will be fine like MAC Adress in Flash Tool )
- 'companion ID' ( .. )
will help to sort out in produktion
see forward to your post ;-)
best wishes
rudi ;-)

-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

User avatar
rudi
Posts: 197
Joined: Fri Oct 24, 2014 7:55 pm

Re: GPIO REGISTER AND PIN LIST !!

Postby rudi » Tue Nov 11, 2014 10:18 pm

like this

Base Adress MAC Adress:
0x3ff00050
0x3ff00054
0x3ff00058
0x3ff0005c

CHIP ID :
;-)
?


Code: Select all

            reg1 = self.read_reg(0x3ff00050)
            reg2 = self.read_reg(0x3ff00054)
            reg3 = self.read_reg(0x3ff00058)
            reg4 = self.read_reg(0x3ff0005c)




examples are in esptool.py too..
viewtopic.php?f=7&t=25

short code

Code: Select all


 """read mac addr"""
    def get_mac(self):
        retry_times = 3
        try:
            reg1 = self.read_reg(0x3ff00050)
            reg2 = self.read_reg(0x3ff00054)
            reg3 = self.read_reg(0x3ff00058)
            reg4 = self.read_reg(0x3ff0005c)
        except:
            print "read reg error"
            return False
       
        chip_flg = ( reg3>>15 )&0x1
        if chip_flg == 0:
            print 'warning : ESP8089 CHIP DETECTED, STOP'
            return False
        else:
            print 'chip_flg',chip_flg
            m0 = ((reg2>>16)&0xff)
            m1 = ((reg2>>8)&0xff)
            m2 = ((reg2 & 0xff ))
            m3 = ((reg1>>24)&0xff)   
            self.MAC2 = m0
            self.MAC3 = m1
            self.MAC4 = m2
            self.MAC5 = m3
           
            if m0 ==0:
                print "r1: %02x; r2:%02x ; r3: %02x"%(m1,m2,m3)
                mac= "1A-FE-34-%02x-%02x-%02x"%(m1,m2,m3)
                mac2 = "1AFE34%02x%02x%02x"%(m1,m2,m3)
                mac = mac.upper()
                mac2 = mac2.upper()
                mac_ap = ("1A-FE-34-%02x-%02x-%02x"%(m1,m2,m3)).upper()
                mac_sta = ("18-FE-34-%02x-%02x-%02x"%(m1,m2,m3)).upper()
            elif m0 == 1:
                print "r1: %02x; r2:%02x ; r3: %02x"%(m1,m2,m3)
                mac= "AC-D0-74-%02x-%02x-%02x"%(m1,m2,m3)
                mac2 = "ACD074%02x%02x%02x"%(m1,m2,m3)
                mac = mac.upper()
                mac2 = mac2.upper()
                mac_ap = ("AC-D0-74-%02x-%02x-%02x"%(m1,m2,m3)).upper()
                mac_sta = ("AC-D0-74-%02x-%02x-%02x"%(m1,m2,m3)).upper()   
            else:
                print "mac read error ..."
                return False
   



long code

Code: Select all


# coding=gbk
#!/usr/bin/env python
#
# ESP8266 ROM Bootloader Utility
# https://github.com/themadinventor/esptool
#
# Copyright (C) 2014 Fredrik Ahlberg
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
# Street, Fifth Floor, Boston, MA 02110-1301 USA.



import sys
reload(sys)
sys.setdefaultencoding('gbk')
code_type = sys.getfilesystemencoding()

import sys
import struct
import serial
import math
import time
import shutil
import os
#import argparse






class ESPROM:

    # These are the currently known commands supported by the ROM
    ESP_FLASH_BEGIN = 0x02
    ESP_FLASH_DATA  = 0x03
    ESP_FLASH_END   = 0x04
    ESP_MEM_BEGIN   = 0x05
    ESP_MEM_END     = 0x06
    ESP_MEM_DATA    = 0x07
    ESP_SYNC        = 0x08
    ESP_WRITE_REG   = 0x09
    ESP_READ_REG    = 0x0a

    # Maximum block sized for RAM and Flash writes, respectively.
    ESP_RAM_BLOCK   = 0x1800
    ESP_FLASH_BLOCK = 0x400

    # Default baudrate used by the ROM. Don't know if it is possible to change.
    ESP_ROM_BAUD    = 115200

    # First byte of the application image
    ESP_IMAGE_MAGIC = 0xe9

    # Initial state for the checksum routine
    ESP_CHECKSUM_MAGIC = 0xef
   
    ESP_MAC = ""
   
    #download state
    ESP_DL_OK = 0x0
    ESP_DL_IDLE = 0x1
    ESP_DL_CONNECT_ERROR = 0x2
    ESP_DL_SYNC = 0x3
    ESP_DL_SYNC_ERROR = 0x4
    ESP_DL_ERASE = 0x5
    ESP_DL_ERASE_ERROR = 0x6
    ESP_DL_DOWNLOADING = 0x7
    ESP_DL_DOWNLOAD_ERROR = 0x8
    ESP_DL_FAIL = 0x9
    ESP_DL_FINISH = 0xA
    ESP_DL_STOP = 0xB
   

    def __init__(self, frame, port = 6, baudrate = 115200):
        self._COM = port
        self.ESP_ROM_BAUD = baudrate
        self.isOpen =  False
        self.stopFlg = False
        self.state = self.ESP_DL_IDLE
        self.process_num = 0
        self.MAC2 = 0
        self.MAC3 = 0
        self.MAC4 = 0
        self.MAC5 = 0
        self.frame = frame
       
        print "_COM: ",self._COM
        print "ESP_ROM_BAUD : ",self.ESP_ROM_BAUD

       
    """reset some status used"""
    def reset(self):
        self.isOpen =  False
        self.stopFlg = False
        self.state = self.ESP_DL_IDLE
        self.process_num = 0       
       
    """close com port"""
    def disconnect(self):
        if self.isOpen:
            self._port.close()
            print "com closed"
            self.isOpen = False
           
        else:
            print "already closed"
           
    """open RS232 port"""
    def com_connect(self,com_port=6,baudrate=115200):
        if self.isOpen:
            print 'com open'
            self._port.close()
            print "com port closed"
        self._COM = com_port
        self.ESP_ROM_BAUD = baudrate
        try:
            self._port = serial.Serial(self._COM-1,self.ESP_ROM_BAUD)
            print "serial port opened"
            self.isOpen = True
            self.stopFlg=False
            self.state = self.ESP_DL_SYNC
            return True
        except:
            print "serial port open error"
            self.state = self.ESP_DL_CONNECT_ERROR
            return False
   
    """synchronize baudrate"""
    def device_sync(self):
        if self.isOpen==False:
            print "error : com not open"
        else:
            try:
                self.connect()
                print "chip sync ok!"
                self.state = self.ESP_DL_SYNC
                return True
            except:
                print "chip sync error."
                self.state = self.ESP_DL_SYNC_ERROR
                return False
               
    def flash_download(self,filename = '', address = 0,reboot=False):
        self.state = self.ESP_DL_DOWNLOADING
        image = file(filename, 'rb').read()
        print 'Erasing flash...'       
        try:
            self.flash_begin(len(image), address)
        except:
            print "erase flash error"
            self.state = self.ESP_DL_ERASE_ERROR
            return False
        seq = 0
        blocks = math.floor(len(image)/self.ESP_FLASH_BLOCK +1 )
        try:
            while len(image) > 0 and not self.stopFlg:
                print '\rWriting at 0x%08x... (%d %%)' % (address + seq*self.ESP_FLASH_BLOCK, 100*self.process_num/self.total_len),#100*seq/blocks),
                self.process_num +=1
                sys.stdout.flush()
                self.flash_block(image[0:self.ESP_FLASH_BLOCK], seq)
                image = image[self.ESP_FLASH_BLOCK:]
                seq += 1
            if self.stopFlg:
                print 'stop...'
            else:
                print '\nLeaving...'
            self.state = self.ESP_DL_FINISH
            return True
        except:
            print "error when download firmware"
            self.state = self.ESP_DL_DOWNLOAD_ERROR
            return False
       
    """a serial steps of downloading"""
    def flash_download_thread(self,com,baudrate,_dl_list):
        self.ESP_MAC = ""
        self._COM=com
        self.ESP_ROM_BAUD=baudrate
        self.stopFlg=False
        self.total_len = 0
        self.process_num = 0
        self.dl_list = []+_dl_list
       
        ret = True
        if self.isOpen==True:
            self.disconnect()
        ret = self.com_connect(self._COM,self.ESP_ROM_BAUD)
       
        if ret:
            ret = self.device_sync()
           
        if ret:
            ret = self.get_mac()
           
        if ret:
            try:
                if self.frame.panel_idBindPanel.get_bind_enable():
                    if self.MAC2==0:
                        ltmp = self.id_bind(0x18,0xfe,0x34,self.MAC3,self.MAC4,self.MAC5,self.frame.panel_idBindPanel.get_bind_addr())
                    elif self.MAC2==1:
                        ltmp = self.id_bind(0xAC,0xD0,0x74,self.MAC3,self.MAC4,self.MAC5,self.frame.panel_idBindPanel.get_bind_addr())
                    else:
                        print "SELF.MAC2 JUDGE ERROR ..."
                        ret = False 
                    self.dl_list.append(ltmp)
                    pass
            except:
                print "id bind generate error"
                ret = False
            pass
           
        if ret:
            image_list = []
            for idx in range(len(self.dl_list)):
                filename,offset = self.dl_list[idx]
                print 'filename: ',filename
                print 'offset : ',offset
                image = file(filename, 'rb').read()
                blocks = math.floor(len(image)/self.ESP_FLASH_BLOCK +1 )
                self.total_len += blocks
                #print "total len !!!=============",self.total_len
                image_list.append(image)
               
            for filename,offset in self.dl_list:
                ret = self.flash_download(filename,offset,False)
                if not ret or self.stopFlg:
                    break
       
        if self.isOpen:
            self.disconnect()
           
        if self.stopFlg:
            self.state = self.ESP_DL_STOP
   
    """write mac addr into a given addr of flash"""
    def id_bind(self,mac0,mac1,mac2,mac3,mac4,mac5,addr):
        rep_path = os.path.join( os.path.abspath('./'),'bin_tmp')
        if not os.path.isdir(rep_path):
            os.mkdir(rep_path)       
        f = file('./bin_tmp/id_bind.bin','wb')
        print "test addr : ",addr
        offset = addr%0x1000
       
        id_data = '\xff'*offset
        id_data +="%c%c%c%c%c%c"%(mac0,mac1,mac2,mac3,mac4,mac5)
        #if (0x10-offset-6)>0:
        id_data += '\xff'*(4-(offset+6)%4)
        print('id data : ',id_data)
        f.write(id_data)
        f.close()
        del(f)
        time.sleep(0.1)
        return [rep_path+'/id_bind.bin',addr-addr%0x1000]
       
    """stop downloading"""
    def stop_download(self):
        self.stopFlg=True
       
    """read mac addr"""
    def get_mac(self):
        retry_times = 3
        try:
            reg1 = self.read_reg(0x3ff00050)
            reg2 = self.read_reg(0x3ff00054)
            reg3 = self.read_reg(0x3ff00058)
            reg4 = self.read_reg(0x3ff0005c)
        except:
            print "read reg error"
            return False
       
        chip_flg = ( reg3>>15 )&0x1
        if chip_flg == 0:
            print 'warning : ESP8089 CHIP DETECTED, STOP'
            return False
        else:
            print 'chip_flg',chip_flg
            m0 = ((reg2>>16)&0xff)
            m1 = ((reg2>>8)&0xff)
            m2 = ((reg2 & 0xff ))
            m3 = ((reg1>>24)&0xff)   
            self.MAC2 = m0
            self.MAC3 = m1
            self.MAC4 = m2
            self.MAC5 = m3
           
            if m0 ==0:
                print "r1: %02x; r2:%02x ; r3: %02x"%(m1,m2,m3)
                mac= "1A-FE-34-%02x-%02x-%02x"%(m1,m2,m3)
                mac2 = "1AFE34%02x%02x%02x"%(m1,m2,m3)
                mac = mac.upper()
                mac2 = mac2.upper()
                mac_ap = ("1A-FE-34-%02x-%02x-%02x"%(m1,m2,m3)).upper()
                mac_sta = ("18-FE-34-%02x-%02x-%02x"%(m1,m2,m3)).upper()
            elif m0 == 1:
                print "r1: %02x; r2:%02x ; r3: %02x"%(m1,m2,m3)
                mac= "AC-D0-74-%02x-%02x-%02x"%(m1,m2,m3)
                mac2 = "ACD074%02x%02x%02x"%(m1,m2,m3)
                mac = mac.upper()
                mac2 = mac2.upper()
                mac_ap = ("AC-D0-74-%02x-%02x-%02x"%(m1,m2,m3)).upper()
                mac_sta = ("AC-D0-74-%02x-%02x-%02x"%(m1,m2,m3)).upper()   
            else:
                print "mac read error ..."
                return False
               
           
            #self.mp.textCtrl_BinPath3.SetValue("AP:"+mac_ap+'\n'+"STA:"+mac_sta)
            #self.mp.textCtrl_BinPath3.SetValue(mac_sta)
           
            f_mac = open("./MAC_ADDR/MAC_TABLE.CSV",'a')
            f_mac.write(mac_ap+','+mac_ap.replace("-","")+","+mac_sta+","+mac_sta.replace("-","")+'\n')
            f_mac.close()
               
               
               
            print 'MAC AP : %s'%mac_ap
            print 'MAC STA: %s'%mac_sta
            ######self.gen_bar(mac)
            self.ESP_MAC_AP = mac_ap
            self.ESP_MAC_STA = mac_sta
            #self.mp.MAC=mac
            return True           
       


    """ Read bytes from the serial port while performing SLIP unescaping """
    def read(self, length = 1):
        b = ''
        while len(b) < length:
            c = self._port.read(1)
            if c == '\xdb':
                c = self._port.read(1)
                if c == '\xdc':
                    b = b + '\xc0'
                elif c == '\xdd':
                    b = b + '\xdb'
                else:
                    raise Exception('Invalid SLIP escape')
            else:
                b = b + c
        return b

    """ Write bytes to the serial port while performing SLIP escaping """
    def write(self, packet):
        buf = '\xc0'
        for b in packet:
            if b == '\xc0':
                buf += '\xdb\xdc'
            elif b == '\xdb':
                buf += '\xdb\xdd'
            else:
                buf += b
        buf += '\xc0'
        self._port.write(buf)

    """ Calculate checksum of a blob, as it is defined by the ROM """
    @staticmethod
    def checksum(data, state = ESP_CHECKSUM_MAGIC):
        for b in data:
            state ^= ord(b)
        return state

    """ Send a request and read the response """
    def command(self, op = None, data = None, chk = 0):
        if op:
            # Construct and send request
            pkt = struct.pack('<BBHI', 0x00, op, len(data), chk) + data
            self.write(pkt)

        # Read header of response and parse
        if self._port.read(1) != '\xc0':
            raise Exception('Invalid head of packet')
        hdr = self.read(8)
        (resp, op_ret, len_ret, val) = struct.unpack('<BBHI', hdr)
        if resp != 0x01 or (op and op_ret != op):
            raise Exception('Invalid response')

        # The variable-length body
        body = self.read(len_ret)

        # Terminating byte
        if self._port.read(1) != chr(0xc0):
            raise Exception('Invalid end of packet')

        return val, body

    """ Perform a connection test """
    def sync(self):
        self.command(ESPROM.ESP_SYNC, '\x07\x07\x12\x20'+32*'\x55')
        for i in xrange(7):
            self.command()

    """ Try connecting repeatedly until successful, or giving up """
    def connect(self):
        print 'Connecting...'
        self._port.timeout = 0.2
        for i in xrange(50):
            if self.stopFlg:
                print 'stop...'
                break
            else:
                   
                try:
                    self._port.flushInput()
                    self._port.flushOutput()
                    self.sync()
                    self._port.timeout = 1
                   
                    return 0
                except:
                    time.sleep(0.05)
        raise Exception('Failed to connect')

    """ Read memory address in target """
    def read_reg(self, addr):
        res = self.command(ESPROM.ESP_READ_REG, struct.pack('<I', addr))
        if res[1] != "\0\0":
            raise Exception('Failed to read target memory')
        return res[0]

    """ Write to memory address in target """
    def write_reg(self, addr, value, mask, delay_us = 0):
        if self.command(ESPROM.ESP_WRITE_REG,
                struct.pack('<IIII', addr, value, mask, delay_us))[1] != "\0\0":
            raise Exception('Failed to write target memory')

    """ Start downloading an application image to RAM """
    def mem_begin(self, size, blocks, blocksize, offset):
        if self.command(ESPROM.ESP_MEM_BEGIN,
                struct.pack('<IIII', size, blocks, blocksize, offset))[1] != "\0\0":
            raise Exception('Failed to enter RAM download mode')

    """ Send a block of an image to RAM """
    def mem_block(self, data, seq):
        if self.command(ESPROM.ESP_MEM_DATA,
                struct.pack('<IIII', len(data), seq, 0, 0)+data, ESPROM.checksum(data))[1] != "\0\0":
            raise Exception('Failed to write to target RAM')

    """ Leave download mode and run the application """
    def mem_finish(self, entrypoint = 0):
        if self.command(ESPROM.ESP_MEM_END,
                struct.pack('<II', int(entrypoint == 0), entrypoint))[1] != "\0\0":
            raise Exception('Failed to leave RAM download mode')

    """ Start downloading to Flash (performs an erase) """
    def flash_begin(self, size, offset):
        old_tmo = self._port.timeout
        self._port.timeout = 10
        if self.command(ESPROM.ESP_FLASH_BEGIN,
                struct.pack('<IIII', size, 0x200, 0x400, offset))[1] != "\0\0":
            raise Exception('Failed to enter Flash download mode')
        self._port.timeout = old_tmo

    """ Write block to flash """
    def flash_block(self, data, seq):
        if self.command(ESPROM.ESP_FLASH_DATA,
                struct.pack('<IIII', len(data), seq, 0, 0)+data, ESPROM.checksum(data))[1] != "\0\0":
            raise Exception('Failed to write to target Flash')

    """ Leave flash mode and run/reboot """
    def flash_finish(self, reboot = False):
        if self.command(ESPROM.ESP_FLASH_END,
                struct.pack('<I', int(not reboot)))[1] != "\0\0":
            raise Exception('Failed to leave Flash mode')


class ESPFirmwareImage:
   
    def __init__(self, filename = None):
        self.segments = []
        self.entrypoint = 0

        if filename is not None:
            f = file(filename, 'rb')
            (magic, segments, _, _, self.entrypoint) = struct.unpack('<BBBBI', f.read(8))
           
            # some sanity check
            if magic != ESPROM.ESP_IMAGE_MAGIC or segments > 16:
                raise Exception('Invalid firmware image')
       
            for i in xrange(segments):
                (offset, size) = struct.unpack('<II', f.read(8))
                if offset > 0x40200000 or offset < 0x3ffe0000 or size > 65536:
                    raise Exception('Suspicious segment %x,%d' % (offset, size))
                self.segments.append((offset, size, f.read(size)))

            # Skip the padding. The checksum is stored in the last byte so that the
            # file is a multiple of 16 bytes.
            align = 15-(f.tell() % 16)
            f.seek(align, 1)

            self.checksum = ord(f.read(1))

    def add_segment(self, addr, data):
        self.segments.append((addr, len(data), data))

    def save(self, filename):
        f = file(filename, 'wb')
        f.write(struct.pack('<BBBBI', ESPROM.ESP_IMAGE_MAGIC, len(self.segments), 0, 0, self.entrypoint))

        checksum = ESPROM.ESP_CHECKSUM_MAGIC
        for (offset, size, data) in self.segments:
            f.write(struct.pack('<II', offset, size))
            f.write(data)
            checksum = ESPROM.checksum(data, checksum)

        align = 15-(f.tell() % 16)
        f.seek(align, 1)
        f.write(struct.pack('B', checksum))

def arg_auto_int(x):
    return int(x, 0)

if __name__ == '__main__':
    pass
    #parser = argparse.ArgumentParser(description = 'ESP8266 ROM Bootloader Utility', prog = 'esptool')

    #parser.add_argument(
            #'--port', '-p',
            #help = 'Serial port device',
            #default = '/dev/ttyUSB0')

    #subparsers = parser.add_subparsers(
            #dest = 'operation',
            #help = 'Run esptool {command} -h for additional help')

    #parser_load_ram = subparsers.add_parser(
            #'load_ram',
            #help = 'Download an image to RAM and execute')
    #parser_load_ram.add_argument('filename', help = 'Firmware image')

    #parser_dump_mem = subparsers.add_parser(
            #'dump_mem',
            #help = 'Dump arbitrary memory to disk')
    #parser_dump_mem.add_argument('address', help = 'Base address', type = arg_auto_int)
    #parser_dump_mem.add_argument('size', help = 'Size of region to dump', type = arg_auto_int)
    #parser_dump_mem.add_argument('filename', help = 'Name of binary dump')

    #parser_read_mem = subparsers.add_parser(
            #'read_mem',
            #help = 'Read arbitrary memory location')
    #parser_read_mem.add_argument('address', help = 'Address to read', type = arg_auto_int)

    #parser_write_mem = subparsers.add_parser(
            #'write_mem',
            #help = 'Read-modify-write to arbitrary memory location')
    #parser_write_mem.add_argument('address', help = 'Address to write', type = arg_auto_int)
    #parser_write_mem.add_argument('value', help = 'Value', type = arg_auto_int)
    #parser_write_mem.add_argument('mask', help = 'Mask of bits to write', type = arg_auto_int)

    #parser_write_flash = subparsers.add_parser(
            #'write_flash',
            #help = 'Write a binary blob to flash')
    #parser_write_flash.add_argument('address', help = 'Base address, 4KiB-aligned', type = arg_auto_int)
    #parser_write_flash.add_argument('filename', help = 'Binary file to write')

    #parser_image_info = subparsers.add_parser(
            #'image_info',
            #help = 'Dump headers from an application image')
    #parser_image_info.add_argument('filename', help = 'Image file to parse')

    #parser_make_image = subparsers.add_parser(
            #'make_image',
            #help = 'Create an application image from binary files')
    #parser_make_image.add_argument('output', help = 'Output image file')
    #parser_make_image.add_argument('--segfile', '-f', action = 'append', help = 'Segment input file')
    #parser_make_image.add_argument('--segaddr', '-a', action = 'append', help = 'Segment base address', type = arg_auto_int)
    #parser_make_image.add_argument('--entrypoint', '-e', help = 'Address of entry point', type = arg_auto_int, default = 0)

    #args = parser.parse_args()

    ## Create the ESPROM connection object, if needed
    #esp = None
    #if args.operation not in ('image_info','make_image'):
        #esp = ESPROM(args.port)
        #esp.connect()

    ## Do the actual work. Should probably be split into separate functions.
    #if args.operation == 'load_ram':
        #image = ESPFirmwareImage(args.filename)

        #print 'RAM boot...'
        #for (offset, size, data) in image.segments:
            #print 'Downloading %d bytes at %08x...' % (size, offset),
            #sys.stdout.flush()
            #esp.mem_begin(size, math.ceil(size / float(esp.ESP_RAM_BLOCK)), esp.ESP_RAM_BLOCK, offset)

            #seq = 0
            #while len(data) > 0:
                #esp.mem_block(data[0:esp.ESP_RAM_BLOCK], seq)
                #data = data[esp.ESP_RAM_BLOCK:]
                #seq += 1
            #print 'done!'

        #print 'All segments done, executing at %08x' % image.entrypoint
        #esp.mem_finish(image.entrypoint)

    #elif args.operation == 'read_mem':
        #print '0x%08x = 0x%08x' % (args.address, esp.read_reg(args.address))

    #elif args.operation == 'write_mem':
        #esp.write_reg(args.address, args.value, args.mask, 0)
        #print 'Wrote %08x, mask %08x to %08x' % (args.value, args.mask, args.address)

    #elif args.operation == 'dump_mem':
        #f = file(args.filename, 'wb')
        #for i in xrange(args.size/4):
            #d = esp.read_reg(args.address+(i*4))
            #f.write(struct.pack('<I', d))
            #if f.tell() % 1024 == 0:
                #print '\r%d bytes read... (%d %%)' % (f.tell(), f.tell()*100/args.size),
                #sys.stdout.flush()
        #print 'Done!'

    #elif args.operation == 'write_flash':
        #image = file(args.filename, 'rb').read()
        #print 'Erasing flash...'
        #esp.flash_begin(len(image), args.address)
        #seq = 0
        #blocks = math.ceil(len(image)/esp.ESP_FLASH_BLOCK)
        #while len(image) > 0:
            #print '\rWriting at 0x%08x... (%d %%)' % (args.address + seq*esp.ESP_FLASH_BLOCK, 100*seq/blocks),
            #sys.stdout.flush()
            #esp.flash_block(image[0:esp.ESP_FLASH_BLOCK], seq)
            #image = image[esp.ESP_FLASH_BLOCK:]
            #seq += 1
        #print '\nLeaving...'
        #esp.flash_finish(False)

    #elif args.operation == 'image_info':
        #image = ESPFirmwareImage(args.filename)
        #print ('Entry point: %08x' % image.entrypoint) if image.entrypoint != 0 else 'Entry point not set'
        #print '%d segments' % len(image.segments)
        #print
        #checksum = ESPROM.ESP_CHECKSUM_MAGIC
        #for (idx, (offset, size, data)) in enumerate(image.segments):
            #print 'Segment %d: %5d bytes at %08x' % (idx+1, size, offset)
            #checksum = ESPROM.checksum(data, checksum)
        #print
        #print 'Checksum: %02x (%s)' % (image.checksum, 'valid' if image.checksum == checksum else 'invalid!')

    #elif args.operation == 'make_image':
        #image = ESPFirmwareImage()
        #if len(args.segfile) == 0:
            #raise Exception('No segments specified')
        #if len(args.segfile) != len(args.segaddr):
            #raise Exception('Number of specified files does not match number of specified addresses')
        #for (seg, addr) in zip(args.segfile, args.segaddr):
            #data = file(seg, 'rb').read()
            #image.add_segment(addr, data)
        #image.entrypoint = args.entrypoint
        #image.save(args.output)



-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

yorknh
Posts: 3
Joined: Wed Feb 18, 2015 5:18 am

Re: GPIO REGISTER AND PIN LIST !!

Postby yorknh » Thu Apr 16, 2015 10:50 pm

It's a fairly small thing, but I think it would be more intuitive if the function labels in the spreadsheet started at 0 rather than 1. You wouldn't need the paragraph in 2.1 of ESP8266 GPIO Instruction that explains that if you are using function3 of the table the value you write to the register is 2.

Who is online

Users browsing this forum: No registered users and 13 guests