User Tools

Site Tools


esp8266:firmware-programming

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
esp8266:firmware-programming [2019/02/02 21:55]
admin
esp8266:firmware-programming [2019/02/02 22:07] (current)
admin
Line 3: Line 3:
 -- //​Instructions tested on **April 2017**, may be outdated! - The following instructions require **technical skills** and assume that you are [[esp8266:​open-hardware-dev-board|using my LELESP dev board]] (or a similar one)// -- -- //​Instructions tested on **April 2017**, may be outdated! - The following instructions require **technical skills** and assume that you are [[esp8266:​open-hardware-dev-board|using my LELESP dev board]] (or a similar one)// --
  
 +==== Testing the connection ====
  
 I connected the module to my PC through the FTDI cable. At this point, I wanted to start talking to the ESP. For that, a terminal emulator like picocom or the standard screen command will do the job. First, your board might talk at any of several baud rates. The ones to try first are 9600 and 115200 (it depends on the version of the firmware running onboard). I connected the module to my PC through the FTDI cable. At this point, I wanted to start talking to the ESP. For that, a terminal emulator like picocom or the standard screen command will do the job. First, your board might talk at any of several baud rates. The ones to try first are 9600 and 115200 (it depends on the version of the firmware running onboard).
Line 15: Line 16:
  
   AT   AT
 +  ​
   OK   OK
 +  ​
   AT+GMR   AT+GMR
   AT version:​0.25.0.0(Jun ​ 5 2015 16:27:16)   AT version:​0.25.0.0(Jun ​ 5 2015 16:27:16)
Line 23: Line 24:
   Ai-Thinker Technology Co. Ltd.   Ai-Thinker Technology Co. Ltd.
   Jun 23 2015 23:23:50   Jun 23 2015 23:23:50
- +  ​ 
 +  
   AT+RST   AT+RST
 +  ​
   OK   OK
 +  ​
    ets Jan  8 2013,rst cause:2, boot mode:(3,7)    ets Jan  8 2013,rst cause:2, boot mode:(3,7)
 +  ​
   load 0x40100000, len 1396, room 16    load 0x40100000, len 1396, room 16 
   tail 4   tail 4
Line 41: Line 42:
   chksum 0xc0   chksum 0xc0
   csum 0xc0   csum 0xc0
 +  ​
   2nd boot version : 1.4(b1)   2nd boot version : 1.4(b1)
     SPI Speed      : 40MHz     SPI Speed      : 40MHz
Line 47: Line 48:
     SPI Flash Size & Map: 8Mbit(512KB+512KB)     SPI Flash Size & Map: 8Mbit(512KB+512KB)
   jump to run user1 @ 1000   jump to run user1 @ 1000
 +  ​
   ���(�SQS�(RQ�)HT�)SHHHC���r�ù�   ���(�SQS�(RQ�)HT�)SHHHC���r�ù�
   Ai-Thinker Technology Co. Ltd.   Ai-Thinker Technology Co. Ltd.
 +  ​
   invalid   invalid
- +  ​ 
 +  
   AT+CWMODE?   AT+CWMODE?
   +CWMODE:2   +CWMODE:2
 +  ​
   OK   OK
 +  ​
   AT+CWMODE=1   AT+CWMODE=1
 +  ​
   OK   OK
 +  ​
   AT+CWLAP   AT+CWLAP
   +CWLAP:​(4,"​FASTWEB-1-T4oittrFQO6h",​-85,"​f0:​84:​2f:​4d:​62:​08",​6)   +CWLAP:​(4,"​FASTWEB-1-T4oittrFQO6h",​-85,"​f0:​84:​2f:​4d:​62:​08",​6)
Line 70: Line 71:
   +CWLAP:​(4,"​WIND-WiFi-C7BE",​-79,"​64:​a6:​51:​00:​c7:​be",​11)   +CWLAP:​(4,"​WIND-WiFi-C7BE",​-79,"​64:​a6:​51:​00:​c7:​be",​11)
   +CWLAP:​(3,"​Vodafone-30083995",​-80,"​90:​35:​6e:​7b:​a0:​b8",​12)   +CWLAP:​(3,"​Vodafone-30083995",​-80,"​90:​35:​6e:​7b:​a0:​b8",​12)
 +  ​
   OK   OK
   AT+CIPSTAMAC?​   AT+CIPSTAMAC?​
   +CIPSTAMAC:"​18:​fe:​34:​da:​c4:​5b"​   +CIPSTAMAC:"​18:​fe:​34:​da:​c4:​5b"​
 +  ​
   OK   OK
  
Line 80: Line 81:
  
 So, ESP8266 boots up into the serial modem mode, and you can communicate with it using a set of AT commands (historically AT commands are based on the Hayes Command Set). Have a look at a list of the AT Commands supported by ESP8266 for more information on the commands shown above. So, ESP8266 boots up into the serial modem mode, and you can communicate with it using a set of AT commands (historically AT commands are based on the Hayes Command Set). Have a look at a list of the AT Commands supported by ESP8266 for more information on the commands shown above.
 +
 +==== Upgrading the firmware ====
 +
 +Esptool.py is a tool that can be used to install/​upgrade firmware onto ESP-XX modules. It is a Python-based,​ open source, platform independent,​ utility to communicate with the ROM bootloader in Espressif ESP8266 ∧ ESP32 chips that was started as an unofficial community project but now is also supported by Espressif.
 +
 +The latest stable esptool.py release can be installed from pypi via pip or pip3 with
 +
 +  pip install esptool
 +
 +and used as follows
 +
 +  esptool.py -p /​dev/​ttyUSB0 -b 115000 write_flash 0x000000 ai-thinker-v1.1.1.bin ​
 +  esptool.py v1.3
 +  Connecting.....
 +  Auto-detected Flash size: 8m
 +  Running Cesanta flasher stub...
 +  Flash params set to 0x0020
 +  Writing 1044080 @ 0x0... 55296 (5 %)
 +  ...
 +  ​
 +  Wrote 1044480 bytes at 0x0 in 90.6 seconds (92.3 kbit/s)...
 +  Leaving...
 +
 +Manually assembling a bootable firmware image can be a bit of a pain, but the tool is useful to install official, ready-made AiThinker images.
 +
 +Moreover, the most recent version of the Espressif firmware cannot run on the ESP-01. A working version of the firmware is ai-thinker-v1.1.1 ([[https://​github.com/​sleemanj/​ESP8266_Simple/​raw/​master/​firmware/​ai-thinker-v1.1.1-115200.bin|download here]] - md5sum: 26fce93d7fa31fba177da9a4ae171657)
 +
 +==== Setup ESP inside the Arduino IDE ====
 +
 +First, Arduino IDE needs to be configured to support the ESP module (Arduino version 1.6.4 or higher is required). To install this additional board, as I did for the ATtiny44, follow this step:
 +
 +  * Open the preferences of the Arduino IDE from File -> Preferences
 +  * Enter the URL http://​arduino.esp8266.com/​stable/​package_esp8266com_index.json into the "​Additional Board Manager URLs" field and click OK
 +  * Select the board from Tools -> Board -> Boards Manager. Scroll down (or search) and select the ESP8266 board menu; finally, install "​ESP8266 platform"​ (version 2.30 is the latest as of may 2017)
 +  * From Tools -> Board select "​Generic ESP8266 Module"​
 +
 +I left untouched all the board settings under Tools and I only checked the upload speed (115200).
 +
 +{{ :​esp8266:​esp8266_07.jpg?​nolink |}}
 +
 +==== ESP Hello World with Arduino IDE ====
 +
 +The first program I uploaded was the classic Blink sketch available from the Arduino examples. However, I changed the LED pin from 13 to 2 from 13, since ESP8266-01 has only two GPIO pins: GPIO0 and GPIO2.
 +
 +  void setup() {
 +    // initialize digital esp8266 gpio 2 as an output.
 +    pinMode(2, OUTPUT);
 +  }
 +
 +  // the loop function runs over and over again forever
 +  void loop() {
 +    digitalWrite(2,​ HIGH); ​  // turn the LED on (HIGH is the voltage level)
 +    delay(1000); ​             // wait for a second
 +    digitalWrite(2,​ LOW);    // turn the LED off by making the voltage LOW
 +    delay(1000); ​             // wait for a second
 +  }
 +
 +I compiled the code, clicked on (and released too early) the Upload button and...
 +
 +  Sketch uses 222,133 bytes (51%) of program storage space. Maximum is 434,160 bytes.
 +  Global variables use 31,508 bytes (38%) of dynamic memory, leaving 50,412 bytes for local variables. Maximum is 81,920 bytes.
 +  error: failed reading byte
 +  warning: espcomm_send_command:​ cant receive slip payload data
 +  error: failed reading byte
 +  warning: espcomm_send_command:​ cant receive slip payload data
 +  error: failed reading byte
 +  ...
 +  warning: espcomm_send_command:​ cant receive slip payload data
 +  warning: espcomm_sync failed
 +  error: espcomm_open failed
 +  error: espcomm_upload_mem failed
 +  error: espcomm_upload_mem failed
 +
 +So I kept the Program pressed button on my board, then i pushed Reset button and, finally, tried to upload the program again
 +
 +  Sketch uses 222,133 bytes (51%) of program storage space. Maximum is 434,160 bytes.
 +  Global variables use 31,508 bytes (38%) of dynamic memory, leaving 50,412 bytes for local variables. Maximum is 81,920 bytes.
 +  Uploading 233280 bytes from /​tmp/​arduino_build_830276/​WiFiTelnetToSerial.ino.bin to flash at 0x00000000
 +  ................................................................................ [ 35% ]
 +  ................................................................................ [ 70% ]
 +  .................................................................... ​            [ 100% ]
 +
 +The GPIO2 pin was switching periodically from 3.3V to 0V, blinking the attached LED on my dev board!
 +
 +
 +----
 +**WARNING**
 +You need to enable flash programming when turning on the module. So, if you want to program the ESP8266, follows these steps:
 +  * turn off the ESP;
 +  * bring GPIO0 to ground;
 +  * turn on the ESP;
 +  * upload the code.
 +If you are using my board you just have to
 +  * press (and keep pressed) the program button;
 +  * push the reset button;
 +  * upload the code;
 +
 +In both cases, you can release the push-button as soon as Arduino IDE starts uploading.
 +----
esp8266/firmware-programming.txt · Last modified: 2019/02/02 22:07 by admin