Update ESP8266 esp-01 AT command Firmware?
AT 1.7
AT firmware 1.7.x is build on Espressif NonOS SDK 3.
The Espressif AT binary is built for 2MB-c1 flash partitioning. Flash Download Tool corrects it for 4 MB flash, but for esptool you should use the --flash_size 2MB-c1 option and the corresponding addresses.
esptool.py write_flash --flash_size 2MB-c1 0x0 boot_v1.7.bin 0x01000 at/1024+1024/user1.2048.new.5.bin 0x1fb000 blank.bin 0x1fc000 esp_init_data_default_v08.bin 0xfe000 blank.bin 0x1fe000 blank.bin

The AT 1.7.4 version has bin file for flashing to 1 MB flash.
esptool.py write_flash --flash_size 1MB 0x0 boot_v1.7.bin 0x01000 at/512+512/user1.1024.new.2.bin 0xfb000 blank.bin 0xfc000 esp_init_data_default_v08.bin 0xfe000 blank.bin 0x7e000 blank.bin

For some esp8266 modules you will have to add --flash_mode dout before --flash_size.
Resources:

the Espressif binaries - versions 1.7.x
AT 1.7 reference - it contains firmware flashing instructions too

AT 2.1
AT firmware 2.1.x is build on Espressif RTOS SDK for esp8266 and esp32.
The flashing command of AT2 with esptool is esptool.py write_flash @download.config. I recommend to change in download.config file flash_mode to qio if your ESP module supports it and flash frequency to 40MHz if your module doesn't support 80MHz.
Resources:

the Espressif AT2 binaries

Flashing tools

Flash Download Tool It is Windows only, but can detect settings of your ESP and apply them to the flashed settings binary
esptool.py installation instructions