Can I accidentally destroy an ESP8266 ESP-12F module's bootloader?

1.5k views Asked by At

I'm new to these devices and even if they are very cheap, I don't unnecessarily want to brick them.

I've used esptool to flash the NodeMCU firmware onto my modules. When doing so, I need to specify the address where the file(s) get written, which usually is 0x00000. Does that mean that the firmware actually contains the bootloader? Or is it located in a separate region on the flash?

If the bootloader itself is contained in the firmware file, an interrupted flashing process would render the module useless, I suppose?

Thanks for clarification!

1

There are 1 answers

1
Maximilian Gerhardt On BEST ANSWER

You can't damage the module this way. I probably did a hundred flashes, some of which failed (e.g. due to a too high baud rate). The firmware itself does contain the bootloader at 0x000000, but that's a second-stage bootloader which can be exchanged arbitrarily. You shouldn't be able to overwrite the first-stage bootloader. Quoting from the man who created rBoot, an open-source alternative for the properitary Espressif booatloader at http://richard.burtons.org/:

The boot loader is written to the first sector of the SPI flash and is executed like any other program, the built in first stage boot loader does not know it is loading a second stage loader rather than any other program.

So what happens next? Well the second stage boot loader isn’t open source, it’s provided to us as a binary blob to use blindly.

In short: You cannot damage your module by writing nonsense to 0x00000. It will maybe execute some arbitrary code before it finds an invalid opcode, but that's not enough to make the CPU explode or the module to be damaged. Reflashing the firmware is enough to recover from a damaged second-stage bootloader.

So where is that first-stage bootloader exactly? From the comments at richard.burtons.org/2015/05/17/esp8266-boot-process, the creator answered this himself as:

Commentator: I have been figuring out if the first stage boot loader is in the processors ROM or in the Flash. I guess it is in the ROM. If this is in ROM then there is no risk of messing flash and leave the device useless. Could you please confirm it.

Richard: That’s correct. Stage one is in rom and you can’t do anything to break it.