• Using batch (.BAT) files to help with Flashing ESP8266

    Having installed ESPtool.py and downloaded the latest version of Espruino into a folder:
    In my case, I created a folder
    "C:\Users\jj\Documents\espruinoEsp8266Fl­ash"
    and then copied the two batch files into the subfolder
    "C:\Users\jj\Documents\espruinoEsp8266Fl­ash\espruino_1v95_esp8266"

    Identify the ESP8266 Chip

    Plug the ESP8266 into a USB port ( using supporting hardware)
    Ground GPIO pin 0
    Reset the chip and run ESPinfo.bat

    ESPinfo.bat

    :: Read ESP8288 or ESP32 chip info
    set /p pport=Enter a Com port 
    echo %pport%
    pause
    esptool.py --port %pport% --baud 115200 --no-stub chip_id
    esptool.py --port %pport% --baud 115200 --no-stub read_mac
    esptool.py --port %pport% --baud 115200 --no-stub flash_id
    pause
    

    and the output

    
    C:\Users\jj\Documents\espruinoEsp8266Fla­sh\espruino_1v95_esp8266>set /p pport=Enter a Com port
    Enter a Com port com3
    
    C:\Users\jj\Documents\espruinoEsp8266Fla­sh\espruino_1v95_esp8266>echo com3
    com3
    
    C:\Users\jj\Documents\espruinoEsp8266Fla­sh\espruino_1v95_esp8266>pause
    Press any key to continue . . .
    
    C:\Users\jj\Documents\espruinoEsp8266Fla­sh\espruino_1v95_esp8266>esptool.py --port com3 --baud 115200 --no-stub chip_id
    esptool.py v2.2.1
    Connecting....
    Detecting chip type... ESP8266
    Chip is ESP8266EX
    Enabling default SPI flash mode...
    Chip ID: 0x00cb2c23
    Hard resetting...
    
    C:\Users\jj\Documents\espruinoEsp8266Fla­sh\espruino_1v95_esp8266>esptool.py --port com3 --baud 115200 --no-stub read_mac
    esptool.py v2.2.1
    Connecting...
    Detecting chip type... ESP8266
    Chip is ESP8266EX
    Enabling default SPI flash mode...
    MAC: 18:fe:34:cb:2c:23
    Hard resetting...
    
    C:\Users\jj\Documents\espruinoEsp8266Fla­sh\espruino_1v95_esp8266>esptool.py --port com3 --baud 115200 --no-stub flash_id
    esptool.py v2.2.1
    Connecting...
    Detecting chip type... ESP8266
    Chip is ESP8266EX
    Enabling default SPI flash mode...
    Manufacturer: e0
    Device: 4014
    Detected flash size: 1MB
    Hard resetting...
    
    C:\Users\jj\Documents\espruinoEsp8266Fla­sh\espruino_1v95_esp8266>pause
    Press any key to continue . . .
    

    Note the Flash size for the chip I used is 1Mbyte. So I will use a batch file set up to program the ESP8266 with that size flash chip.
    Reset the ESP8266 and then run "C:\Users\jj\Documents\espruinoEsp8266Fl­ash\espruino_1v95_esp8266\FlashESP8266_1­M.bat"

    :: Flash ESP8288 1M chip with Espruino
    set /p pport=Enter a Com port 
    echo %pport%
    pause
    esptool.py --port %pport% --baud 57600 write_flash --flash_freq 40m --flash_mode qio --flash_size 1MB 0x0000 "boot_v1.6.bin" 0x1000 espruino_esp8266_user1.bin 0xFC000 esp_init_data_default.bin 0xFE000 blank.bin
    pause
    

    The output:

    
    C:\Users\jj\Documents\espruinoEsp8266Fla­sh\espruino_1v95_esp8266>set /p pport=Enter a Com port
    Enter a Com port com3
    
    C:\Users\jj\Documents\espruinoEsp8266Fla­sh\espruino_1v95_esp8266>echo com3
    com3
    
    C:\Users\jj\Documents\espruinoEsp8266Fla­sh\espruino_1v95_esp8266>pause
    Press any key to continue . . .
    
    C:\Users\jj\Documents\espruinoEsp8266Fla­sh\espruino_1v95_esp8266>esptool.py --port com3 --baud 57600 write_flash --flash_freq 40m --flash_mode qio --flash_size 1MB 0x0000 "boot_v1.6.bin" 0x1000 espruino_esp8266_user1.bin 0xFC000 esp_init_data_default.bin 0xFE000 blank.bin
    esptool.py v2.2.1
    Connecting....
    Detecting chip type... ESP8266
    Chip is ESP8266EX
    Uploading stub...
    Running stub...
    Stub running...
    Configuring flash size...
    Flash params set to 0x0020
    Compressed 3856 bytes to 2762...
    Wrote 3856 bytes (2762 compressed) at 0x00000000 in 0.5 seconds (effective 62.2 kbit/s)...
    Hash of data verified.
    Compressed 456756 bytes to 320993...
    Wrote 456756 bytes (320993 compressed) at 0x00001000 in 56.6 seconds (effective 64.5 kbit/s)...
    Hash of data verified.
    Compressed 128 bytes to 75...
    Wrote 128 bytes (75 compressed) at 0x000fc000 in 0.0 seconds (effective 32.3 kbit/s)...
    Hash of data verified.
    Compressed 4096 bytes to 26...
    Wrote 4096 bytes (26 compressed) at 0x000fe000 in 0.0 seconds (effective 2249.4 kbit/s)...
    Hash of data verified.
    
    Leaving...
    Hard resetting...
    
    C:\Users\jj\Documents\espruinoEsp8266Fla­sh\espruino_1v95_esp8266>pause
    Press any key to continue . . .
    

    Disconnect GPIO pin 0 from the ground and reset a couple of times.
    Start WebIde and connect to the ESP8266

    >reset()
    =undefined
     _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v95 Copyright 2017 G.Williams
    Espruino is Open Source. Our work is supported
    only by sales of official boards and donations:
    http://espruino.com/Donate
    Flash map 1MB:512/512, manuf 0xe0 chip 0x4014
    > 
    

    Need to create batch files for the other ESP8266 and ESP32 chips


    2 Attachments

About