Problem flashing an ESP8266 (NodeMCU or AT firmware)

I've got a bunch of ESP-01 (ESP8266) which are pre-flashed with some AT firmware from Ai-Thinker. When I boot them up, I see "Ai-Thinker Technology Co. Ltd. ready". I've got a hobby project where I program an ATMEGA16 to interface a wifi connection via AT commands over serial/UART to the ESP. This is quite cumbersome, and requires a lot of hardware (crystals etc).

The ESP units are capable of "hosting" and running a small program directly on the chip, so I want to learn how to do that :slight_smile: Looking at an Instructable, it seems so easy; just upload a lua file (init.lua) and it will run. However, I then understand that the ESP will need to be running the NodeMCU firmware (obviously) which expects this file + can interpret and run it.

So then I got esptool and made a custom build of NodeMCU (at https://nodemcu-build.com/) using the 7 default/suggested modules (file, GPIO, net, node, timer, UART, WiFi). Esptool seems to be able to successfully flash the binary (with GPIO0 pulled low/GND) but after reboot I see problems in the log:

ets Jan 8 2013,rst cause:2, boot mode:(3,7)

load 0x40100000, len 27444, room 16
tail 4
chksum 0xef
load 0x00000000, len 0, room 4
tail 0
chksum 0xef
ho 12 tail 0 room 4
load 0x00000000, len 0, room 12
tail 0
chksum 0xef
csum 0xef
csum err
ets_main.c

Note the "csum err" at the end. The flashing succeded at 100% and even verified the hash of data.

So, I try to erase the flash, and revert back to the AT firmware -- downloaded from Released Firmware — ESP-AT User Guide documentation but then I get this log from the bootloader (at 74480 baud):

ets Jan 8 2013,rst cause:2, boot mode:(3,7)

load 0x40210010, len 711800, room 16

and I don't see any "ready" (at 115200 baud).

Where do I go from here? Am I making life unnecessarily hard by using the (old?) ESP8266, rather than the new ESP32 modules? What I want is a (relatively) simple + small unit for IoT projects -- sometimes running directly off the ESP, other times used with a separate ATMEL chip.

Totally agree, super cumbersome to control an ESP-01 thru AT-commands, even without the hardware obstacle.

It can be quite a big program in fact most ESP-01 have 1MB of flash memory (if the pcb is blue that may suggest it to be only half of that)

Depending a bit on what hardware you already have this is quite a decent tutorial, describing what can be done. (keep in mind the builtin LED is 'actibe LOW' and connected to GPIO1 on most ESP-01's )

It always does, but for esp's there are many bad tutorials online. Anyway it is not complex to upload an Arduino C++ dialect sketch.

Not much purpose in that, but you probably didn't get the exact same version.

Not really.

So the ESP-01 will do the trick, though using an Atmel MCU in combination is probably less practical than using an esp8266 dev board like a nodeMCU or D1 mini. Or an ESP32 dev board if you are looking for more power. There are hardly AVR boards that complement an ESP efficiently.

Thanks for responding!

My setup is to program the ESP without using an Arduino... Hope I'm not totally off topic in this forum. Just pulling GPIO0 low, and connecting RX/TX to a USB-serial unit, and it should be straight forward. At least, in theory!

Reason I wanted to be able to revert back to AT firmware is my existing project using an atmega16 and AT commands. I should be able to switch between projects...

You may very well be able to upload an AT-firmware onto the ESP again, even if it is not exactly the same version that was on there. If it returns 'OK' after the AT, that means it works.

Should work easy enough, yes.Is the USB-serial unit providing 3.3v for the ESP ? You should put a voltage divider on the ESP's RX PIN.
Normally speaking, if you install the ESP core, and select 'generic ESP8266' it should work with the default settings (though you probably have 1MB flash) Start out with a simple blink using GPIO 1 as a led pin.
Anyway keep in mind that during normal operation not GPIO 0 or GPIO 2 or even GPIO 1 can be pulled "LOW" at boot.

The power supply at the end of the breadboard is powering the ESP, with 3.3V. The usb-serial unit supports both 5V and 3.3V TTL, so I've set it to 3.3V. So I don't believe I need to adjust any voltages... Unless everything should be "upped" to 5V? I have read posts about people actually failing to work with 3.3V, and having more success with 5V TTL.

During normal boot, I have GP2 and GP0 unconnected, while CHPD (EN) is pulled high.
As you might see, I've also tried adding 10nF caps across the 3.3V power rails.

When you say "ESP core", is that some software to replace esptool.py? I still don't quite get this; is it supposed to be possible to flash the ESP using this simple setup, and esptool.py? This is the guide I'm trying to follow: https://www.instructables.com/ESP8266-Web-Server-Without-Arduino/

Could it be that this is, in fact, not resulting in a compatible NodeMCU binary? For the simple "hello world" (blinkenlights) project I'm attempting, I expect I should have quite basic module requirements.

This is done in LUA, this is the Arduino forum. Here we support people using Arduinos and other boards that are supported using the Arduino IDE. ESP8266 is one of those boards. At times people come here to control an ESP with AT-commands through a sketch running on a different MCU (like the 16u2 (or 4 ?), which is cumbersome, but there are people willing to support that.
Within the (open-source) Arduino IDE you can install a core for ESP8266 (and many other boards btw) and you can compile a sketch (c++ dialect) for any board that is supported. That i am willing to support.

1 Like

Yes! And I am beginning to get an overview of this, so thanks for all your patience. As I said, my aim is to learn how to program the ESP -- the Node/Lua approach just appeared at first glance to be the simplest. Not so simple if you don't have Node installed...

My plan has been to eventually move on to using the ESP8266WiFi library, which, as I now understand, means using the Arduino libraries/IDE (not necessarily the Arduino hardware). I've got some new keywords and reading material, and I'll try this approach. Perhaps we'll meet in a different (more on-topic) thread :slight_smile:

As for this thread, I think I'll just have to conclude that while uploading a simple Lua file looks very simple and convenient, the prerequisites (i.e. getting the correct Node binary, and flashing it) is/can be quite difficult. Thanks again!

Yep pretty much that. ESP8266WiFi & ESP8266Webserver are easy enough to use. The link in Reply#2 is still the recommended one and you can look at the examples that come with the core.

Just a follow-up comment: Using the link you suggested, everything just worked. No fuss, just wire up the ESP as per the tutorial (GPIO0 grounded) and flash the C++ "sketch" from Arduino IDE. I'm genuinely impressed, after all the hassle I had with both the NodeMCU and the AT firmware. Thanks again!

There are so many bad tutorials out there for the ESP, that after i had it sorted myself i went through a whole lot of them and found this one that i almost fully agree with and explains everything correctly. I bookmarked it and refer to it when situations like this occur. (which is quite often really) Glad to be of help.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.