2022-05-22
md
Installing the AT Firmware on an ESP-01S

ESP-01 image How hard can it be to install the AT firmware onto an ESP-01? That tiny card which came with the AT firmware was among the first ESP boards used in the hobbyist world and it remains available to this day. AT version 1.2.0 was flashed on ESP-01S that I obtained a few weeks ago. Having replaced the AT firmware for a previous project, I wanted to reinstall AT, but using the newest version. I did get version 1.7.5 running. Unfortunately, I could not manage to install the latest version (version 2.2.0) of the Espressif AT firmware following the instructions from Espressif, but there is a third party compiled version which does work.

Table of contents

  1. Getting Version 1.7.5 of the AT Firmware
  2. Flashing the Firmware with esptool.py
  3. Updating to Version 1.7.5
  4. Version 2.2.0
  5. Necessary Warning?

Getting Version 1.7.5 of the AT Firmware toc

Following the second suggestion from Robert Oostenveld in Restoring the AT firmware on the ESP8266 (September 22, 2018), I went to the latest version of the ESP8266 NonOS repository which is now two years old. There is a warning stressing that the ESP8266_NONOS_SDK is now deprecated.

Starting from December 2019, We will not add any new features to the ESP8266 NonOS SDK. We will only fix critical bugs in the ESP8266 NonOS SDK. We will only maintain the master branch of ESP8266 NonOS SDK, which is a continuously bug-fix version based on v3.0. This means: All other released branches will not be updated. All the future versions will be released from only the master branch mentioned above. It is suggested that the ESP8266_RTOS_SDK, instead of ESP8266 NonOS SDK, be used for your projects.

Nevertheless the bin/at/ directory contains version 1.7.4 of the (Nano) AT firmware which supports an SSL library with fewer ciphers but which fits on 1 MB of flash memory which corresponds to the amount of flash on "newer" versions of the ESP-01 sometimes identified as the ESP-01S (see Differences between ESP-01 and ESP-01S). The "normal" version of the AT firmware requires at least 2 MB of flash, so it cannot be installed on the EPS-01. That version of AT is in the master branch of the repository which corresponds to version 3.0.4 of the SDK. As it happens there is a version 3.0.5 branch which contains version 1.7.5 of the AT firmware, which as of now is the latest version of AT within the NOOS SDK.

I only needed three binary files from the repository

but it might be useful to download all .bin files in the bin/ and bin/at/512+512/ directories to experiment further (something which I have not done). Here is a long bash command to obtain all those files at once as long as wget is installed.

wget https://github.com/espressif/ESP8266_NONOS_SDK/raw/release/v3.0.5/bin/blank.bin https://github.com/espressif/ESP8266_NONOS_SDK/raw/release/v3.0.5/bin/boot_v1.2.bin https://github.com/espressif/ESP8266_NONOS_SDK/raw/release/v3.0.5/bin/boot_v1.2.bin https://github.com/espressif/ESP8266_NONOS_SDK/raw/release/v3.0.5/bin/boot_v1.6.bin https://github.com/espressif/ESP8266_NONOS_SDK/raw/release/v3.0.5/bin/boot_v1.7.bin https://github.com/espressif/ESP8266_NONOS_SDK/raw/release/v3.0.5/bin/esp_init_data_default_v05.bin https://github.com/espressif/ESP8266_NONOS_SDK/raw/release/v3.0.5/bin/esp_init_data_default_v08.bin https://github.com/espressif/ESP8266_NONOS_SDK/raw/release/v3.0.5/bin/at/512%2B512/user1.1024.new.2.bin https://github.com/espressif/ESP8266_NONOS_SDK/raw/release/v3.0.5/bin/at/512%2B512/user2.1024.new.2.bin

Then I created a text file named upload.txt which contains the name of the binary files to flash to the ESP01 along with the address at which they are to be placed in the flash memory.

write_flash -e -fm dout --flash_freq 80m -fs 1 MB 0x00000 boot_v1.2.bin 0x01000 user1.1024.new.2.bin 0xfc000 esp_init_data_default_v05.bin

The last three lines are pulled from the Flash size 8Mbit: 512KB+512KB section in the AT documentation in the repository. The first line contains upload parameters for the esptool.py utility that will be used in the next section.

Flashing the Firmware with esptool.py toc

There must be more than five copies of the Python script esptool.py by Espressif that uploads firmware to ESP chips on my desktop computer. I chose to work with a recent copy (version 3.1) found in the PlatformIO tools. I created a subdirectory named AT of the esptool.py directory and copied all four files mentioned in the previous section into it. Connect the ESP-01S to the desktop computer with a USB-TTY dongle or a programmer as shown on the right. Look up which device is created. From long experience I know, it will most likely be /dev/ttyUSB0 but it could be /dev/ttyUSB1. On a Windows machine, the USB to serial converter will show up as a COM port. If needed, do the usual dance to put the ESP8286 in bootloader mode. Basically, GPIO0 has to be grounded when the ESP8266 is reset or powered up. With the programmer shown on the left, it's all done automatically; I believe that there may be some button presses needed with the device shown on the right, but I can't say for sure since I don't have one of those. Once the ESP is in flash mode, it's a simple matter to upload the firmware to it given that information.

michel@hp:~/.platformio/packages/tool-esptoolpy/AT$ ls upload.txt boot_v1.2.bin esp_init_data_default_v05.bin user1.1024.new.2.bin michel@hp:~/.platformio/packages/tool-esptoolpy/AT$ ls /dev/ttyUSB* /dev/ttyUSB0 michel@hp:~/.platformio/packages/tool-esptoolpy/AT$ ../esptool.py -p /dev/ttyUSB0 -b 115200 @upload.txt adjust according to the device port esptool.py /dev/ttyUSB0 -b 115200 write_flash -e -fm dout --flash_freq 80m -fs 1 MB 0x00000 boot_v1.2.bin 0x01000 user1.1024.new.2.bin 0xfc000 esp_init_data_default_v05.bin esptool.py v3.1 Serial port /dev/ttyUSB0 Connecting.... Detecting chip type... ESP8266 Chip is ESP8266EX Features: WiFi Crystal is 26MHz MAC: a0:20:a6:30:de:5c Uploading stub... Running stub... Stub running... Configuring flash size... Erasing flash (this may take a while)... Chip erase completed successfully in 2.8s Flash params set to 0x032f Compressed 1936 bytes to 1462... Wrote 1936 bytes (1462 compressed) at 0x00000000 in 0.2 seconds (effective 84.2 kbit/s)... Hash of data verified. Compressed 413924 bytes to 297091... Wrote 413924 bytes (297091 compressed) at 0x00001000 in 26.3 seconds (effective 126.0 kbit/s)... Hash of data verified. Compressed 128 bytes to 75... Wrote 128 bytes (75 compressed) at 0x000fc000 in 0.1 seconds (effective 16.8 kbit/s)... Hash of data verified. Leaving... Hard resetting via RTS pin...

It would be nice if that would be sufficient, but it is imperative to test that everything worked. First reset the ESP-01 or turn power to it off then back on. It should show up as the same device/COM port as before. The Serial Monitor of the Arduino IDE can be used to communicate with the AT firmware; set the baud to 115200 and Both NL & CR for line ending. Alternatively, a terminal program such as cu can verify that a new version of the AT firmware has been flashed. With cu, I had to manually enter a CtrlJ key combination after pressing the Enter key (or press the sequence CtrlM CtrlJ) at the end of each AT command because AT commands must be terminated with both the CR and LF ASCII control codes.

michel@hp:~$ cu -l /dev/ttyUSB0 -s 115200 Connected. AT OK AT+GMR AT version:1.7.5.0(Oct 20 2021 19:14:04) SDK version:3.0.5(b29dcd3) compile time:Oct 20 2021 20:13:45 Bin version(Wroom 02):1.7.5 OK

That's a confirmation that version 1.7.5 (October 20, 2021) of the AT firmware is now running on the ESP-01S.

Updating to Version 1.7.5 toc

As per Update steps, it would have been possible to update the version 1.7.4 of the AT firmware over-the-air. Of course, the ESP must be connected to the local Wi-Fi network before attempting this.

AT+CWMODE_CUR=1 OK AT+CWLAP +CWLAP:(3,"Welcome!!",-84,"18:90:88:56:3d:c6",1,33,0,4,4,7,0) +CWLAP:(3,"",-87,"d6:e2:cb:4d:71:fa",6,32767,0,4,4,7,0) +CWLAP:(5,"",-89,"d6:e2:cb:4d:71:fe",6,32767,0,4,4,7,0) +CWLAP:(3,"Playtek",-47,"f7:ae:42:42:43:44",11,32767,0,4,4,7,1) +CWLAP:(3,"",-84,"fa:5e:42:43:6b:13",11,32767,0,4,4,7,0) +CWLAP:(5,"",-86,"fa:5e:42:43:6b:17",11,32767,0,4,4,7,0) OK AT+CWJAP="Playtek","12345678" adjust name and password as needed WIFI CONNECTED WIFI GOT IP OK AT+CIFSR +CIFSR:STAIP,"192.168.1.143" +CIFSR:STAMAC,"a0:20:93:30:31:32" OK AT+GMR AT version:1.7.4.0(May 11 2020 19:13:04) SDK version:3.0.4(9532ceb) compile time:May 27 2020 10:12:17 Bin version(Wroom 02):1.7.4 OK AT+CIUPDATE +CIPUPDATE:1 +CIPUPDATE:2 +CIPUPDATE:3 +CIPUPDATE:4 be patient, it takes a couple of minutes OK WIFI DISCONNECT ets Jan 8 2013,rst cause:1, boot mode:(3,6) load 0x40100000, len 816, room 16 tail 0 chksum 0x8d load 0x3ffe8000, len 788, room 8 tail 12 chksum 0xcf ho 0 tail 12 room 4 load 0x3ffe8314, len 288, room 12 tail 4 chksum 0xcf csum 0xcf 2nd boot version : 1.2 SPI Speed : 80MHz SPI Mode : SPI Flash Size : 8Mbit jump to run user2 correct flash map �cl`{�o$ ... �crd;l ready WIFI CONNECTED WIFI GOT IP AT+GMR AT version:1.7.5.0(Oct 20 2021 19:14:04) SDK version:3.0.5(b29dcd3) compile time:Oct 20 2021 20:13:50 Bin version(Wroom 02):1.7.5 OK

I power cycled the ESP-01 just to make sure that everything worked.

It is not possible to update AT version 1.2.0 in this fashion. It does not appear that there is an upgrade path beyond 1.7.5. The AT+CIUPDATE command did nothing useful when the firmware is already at version 1.7.5. Later it may be possible to update if there's ever a newer version created in the ESP8266 NonOS environment.

Version 2.2.0 toc

In the Released Firmware page of the ESP-AT User Guide, there is an important note.

Note: Espressif has not released a separate version for the 1 MB ESP8285/8266 series of chips, but you can refer to How to Download the Latest Temporary Version of AT Firmware from GitHub and choose to download the 1 MB firmware on the CI (Continuous Integration) of GitHub (Please switch to release/v2.2.0.0_esp8266 branch and download esp8285-1MB-at under the Artifacts page).

Following those instructions, I found esp8285-1MB-at.zip (note: this link will not work as soon as another integration of the firmware is done), but I was unable to install that version.

michel@hp:~/.platformio/packages/tool-esptoolpy/AT$ ../esptool.py -p /dev/ttyUSB0 -b 115200 write_flash -e @download.config esptool.py /dev/ttyUSB0 -b 115200 write_flash -e --flash_mode dout --flash_freq 80m --flash_size 1 MB 0x8000 partition_table/partition-table.bin 0x9000 ota_data_initial.bin 0x0 bootloader/bootloader.bin 0x20000 esp-at.bin 0x18000 at_customize.bin 0x1A000 customized_partitions/client_cert.bin 0x1B000 customized_partitions/client_key.bin 0x1C000 customized_partitions/client_ca.bin 0x1D000 customized_partitions/mqtt_cert.bin 0x1E000 customized_partitions/mqtt_key.bin 0x1F000 customized_partitions/mqtt_ca.bin 0x19000 customized_partitions/factory_param.bin esptool.py v3.1 Serial port /dev/ttyUSB0 Connecting.... Detecting chip type... ESP8266 Chip is ESP8266EX Features: WiFi Crystal is 26MHz MAC: a0:20:93:30:31:32 Uploading stub... Running stub... Stub running... Configuring flash size... Erasing flash (this may take a while)... Chip erase completed successfully in 2.2s Compressed 3072 bytes to 103... Wrote 3072 bytes (103 compressed) at 0x00008000 in 0.1 seconds (effective 429.0 kbit/s)... Hash of data verified. Compressed 8192 bytes to 31... Wrote 8192 bytes (31 compressed) at 0x00009000 in 0.1 seconds (effective 659.1 kbit/s)... Hash of data verified. Flash params set to 0x022f Compressed 10224 bytes to 6861... Wrote 10224 bytes (6861 compressed) at 0x00000000 in 0.8 seconds (effective 107.9 kbit/s)... Hash of data verified. Compressed 843600 bytes to 529958... Wrote 843600 bytes (529958 compressed) at 0x00020000 in 46.9 seconds (effective 143.9 kbit/s)... Hash of data verified. Compressed 3072 bytes to 151... Wrote 3072 bytes (151 compressed) at 0x00018000 in 0.1 seconds (effective 357.4 kbit/s)... Hash of data verified. Compressed 2344 bytes to 1487... Wrote 2344 bytes (1487 compressed) at 0x0001a000 in 0.2 seconds (effective 103.5 kbit/s)... Hash of data verified. Compressed 3368 bytes to 2526... Wrote 3368 bytes (2526 compressed) at 0x0001b000 in 0.3 seconds (effective 87.8 kbit/s)... Hash of data verified. Compressed 2344 bytes to 1499... Wrote 2344 bytes (1499 compressed) at 0x0001c000 in 0.2 seconds (effective 87.6 kbit/s)... Hash of data verified. Compressed 1168 bytes to 895... Wrote 1168 bytes (895 compressed) at 0x0001d000 in 0.1 seconds (effective 71.9 kbit/s)... Hash of data verified. Compressed 1692 bytes to 1322... Wrote 1692 bytes (1322 compressed) at 0x0001e000 in 0.2 seconds (effective 80.4 kbit/s)... Hash of data verified. Compressed 1172 bytes to 914... Wrote 1172 bytes (914 compressed) at 0x0001f000 in 0.2 seconds (effective 59.0 kbit/s)... Hash of data verified. Compressed 4096 bytes to 81... Wrote 4096 bytes (81 compressed) at 0x00019000 in 0.1 seconds (effective 365.4 kbit/s)... Hash of data verified. Leaving... Hard resetting via RTS pin...

While the uploading appears to proceed correctly, something goes wrong and the blue communication LED remains on even after a power cycle. It was possible to connect to the ESP serial port, but only garbage was received at all plausible baud and AT commands were ignored. Quite recently Arnaud Baixas described the same situation in the Espressif ESP-AT Forum when using the esp8285-1MB-at.zip from a slightly older commit. Unfortunately, no one has offered a solution to our common problem.

However, the issue was raised in the Espressif ESP-AT GitHub repository and Juraj Andrássy (JAndrassy) provides a complete binary ESP8266-1MB-tx1rx3-AT_V2.2.zip as a solution. As before, I created a subdirectory in the directory containing esptool.py and unzipped the content of Juraj's compilation of the AT firmware into it. Since the archive contained the download parameters, it was even simpler to flash this version of the firmware.

michel@hp:~/.platformio/packages/tool-esptoolpy/ESP-AT$ ../esptool.py -p /dev/ttyUSB0 -b 115200 write_flash -e @download.config esptool.py /dev/ttyUSB0 -b 115200 write_flash -e --flash_mode dio --flash_freq 80m --flash_size 1 MB 0x8000 partition_table/partition-table.bin 0x9000 ota_data_initial.bin 0x0 bootloader/bootloader.bin 0x20000 esp-at.bin 0x18000 at_customize.bin 0x1A000 customized_partitions/client_cert.bin 0x1B000 customized_partitions/client_key.bin 0x1C000 customized_partitions/client_ca.bin 0x1D000 customized_partitions/mqtt_cert.bin 0x1E000 customized_partitions/mqtt_key.bin 0x1F000 customized_partitions/mqtt_ca.bin 0x19000 customized_partitions/factory_param.bin esptool.py v3.1 Serial port /dev/ttyUSB0 Connecting.... Detecting chip type... ESP8266 Chip is ESP8266EX Features: WiFi Crystal is 26MHz MAC: a0:20:93:30:31:32 Uploading stub... Running stub... Stub running... Configuring flash size... Erasing flash (this may take a while)... Chip erase completed successfully in 2.1s Compressed 3072 bytes to 103... Wrote 3072 bytes (103 compressed) at 0x00008000 in 0.1 seconds (effective 432.0 kbit/s)... Hash of data verified. Compressed 8192 bytes to 31... Wrote 8192 bytes (31 compressed) at 0x00009000 in 0.1 seconds (effective 651.9 kbit/s)... Hash of data verified. Compressed 10224 bytes to 6862... Wrote 10224 bytes (6862 compressed) at 0x00000000 in 0.8 seconds (effective 108.0 kbit/s)... Hash of data verified. Compressed 807184 bytes to 510586... Wrote 807184 bytes (510586 compressed) at 0x00020000 in 45.1 seconds (effective 143.1 kbit/s)... Hash of data verified. Compressed 3072 bytes to 151... Wrote 3072 bytes (151 compressed) at 0x00018000 in 0.1 seconds (effective 359.4 kbit/s)... Hash of data verified. Compressed 2344 bytes to 1487... Wrote 2344 bytes (1487 compressed) at 0x0001a000 in 0.2 seconds (effective 103.9 kbit/s)... Hash of data verified. Compressed 3368 bytes to 2526... Wrote 3368 bytes (2526 compressed) at 0x0001b000 in 0.3 seconds (effective 88.1 kbit/s)... Hash of data verified. Compressed 2344 bytes to 1499... Wrote 2344 bytes (1499 compressed) at 0x0001c000 in 0.2 seconds (effective 87.8 kbit/s)... Hash of data verified. Compressed 1168 bytes to 895... Wrote 1168 bytes (895 compressed) at 0x0001d000 in 0.1 seconds (effective 71.3 kbit/s)... Hash of data verified. Compressed 1692 bytes to 1322... Wrote 1692 bytes (1322 compressed) at 0x0001e000 in 0.2 seconds (effective 80.7 kbit/s)... Hash of data verified. Compressed 1172 bytes to 914... Wrote 1172 bytes (914 compressed) at 0x0001f000 in 0.2 seconds (effective 59.1 kbit/s)... Hash of data verified. Compressed 4096 bytes to 78... Wrote 4096 bytes (78 compressed) at 0x00019000 in 0.1 seconds (effective 366.6 kbit/s)... Hash of data verified. Leaving... Hard resetting via RTS pin..

A cursory verification shows that the firmware appears to work.

michel@hp:~/Téléchargements/Devices/ESP/ESP-01/AT$ cu -l /dev/ttyUSB0 -s 115200 Connected. {ll��|�d�| � d� b|���s�bd #��no�$gn���cp��ds$sdp�g�AT AT OK AT+GMR AT version:2.2.0.0(s-b097cdf - ESP8266 - Jun 17 2021 12:58:29) SDK version:v3.4-22-g967752e2 compile time(6800286):Jul 11 2021 11:09:32 Bin version:2.2.0(ESP8266_1MB) OK

The dates are confusing. This 2.2.0 version is dated July 2021 and was compiled with an older version of the SDK while the 1.7.5 version was compiled 3 months later.

Necessary Warning? toc

At a glance, it is difficult to ascertain which version should be used. Version 1.7.5 is compiled against the deprecated ESP8266_NOOS SDK, while the newer version is compiled against the ESP8266_RTOS SDK (see What is ESP-AT). From the casual user/hobbyist point of view, this is not necessarily very important. The AT firmware turns the ESP board into a self-contained serial to Wi-Fi converter. If the AT command set is nearly the same then it may not matter. Without doing my homework, I have no basis for a definitive judgment.

Without wanting to impugn anyone's reputation in any way, it must be pointed out that I could not find the source for the 2.2.0 binary provided by Juraj Andrássy. The author does say that he compiled from the Espressif source, but I would be more comfortable if this was a bit more transparent. When he wrote that he read the manual then I suppose he is referring to How to compile and develop your own AT project in the ESP-AT User Guide for the release-v2.2.0.0_esp8266. Nothing prevents anyone from attempting to do that, but I'm too lazy to do that at this point.

For those that worry about such things, here is the at_nano source for version 1.7.4 and the source for version 1.7.5 can be found here. I believe the source for the 2.2.0 version would be here.

Perhaps ESP_ATMod ESP8266 AT Firmware (Command Processor) With TLS 1.2 Capability by Jiri Bilek (JiriBilek) is worth examining. The project license is LGPL-3.0 and, consequently, the source is available. This library improves the TLS implementation by adding GCM-based ciphers at the expense of some functionality. There is no problem compiling this project with PlatformIO and installing it on an ESP-01S and, presumably, one could use the Arduino IDE to do the same.

Finally, to take full advantage of version 1.7.x of the AT firmware, you can read the manual: ESP8266 Non-OS AT Instruction Set Version 3.0.5 Espressif Systems 2021. The ESP-AT User Guide should apply to version 2.2.0 on ESP8266.