2

I want to program a board with an esp32 on it using esp-prog and esptool. When I do that I get the following error:

...
Crystal is 40MHz
MAC: c8:2b:96:b8:e7:e0
Uploading stub...
Running stub...
Traceback (most recent call last):
File "/home/martin/workspace/esp/esp-idf/components/esptool_py/esptool/esptool.py", line 3470, in <module> _main()
...

But if I use esptool with the option --no-stub, I can program the board without an error. So what is this stub? For what is it for and what does it mean to use --no-stub?

1 Answers1

3

In software development, a stub is a piece of code or a program which is used in place of another. They often simulate the behavior of the original feature and sometimes they are used as a temporaro substitute for undeveloped code.

In the case of esptool, it uses a stub loader, which basically replaces the original bootloader used in the ESP to load your program via serial port to the ROM of your ESP32 device.

Basically this stub bootloader has the same behavior as the original bootloader, but it uses some UART routines which are more heavily optimised to load the ROM code.

Using --no-stub you will be using the original ESP32 bootloader, which is known to be slower at flashing the program and at some other operations. There are some commands which can only be used in the esptool bootloader, but if you are not using any optional commands to boot your code, it is safe to use --no-stub

Shunya
  • 2,344
  • 4
  • 16
  • 28
  • Thank you very much for the answer! What could be the reason that `--no-stub` works, but without this option, it fails? Who produces this stub? If I use a ESP32-DevKitC board and upload the same project to that board, it works without using `--no-stub`. Why? – Martin Günther Jan 17 '21 at 12:25
  • This stub is provided by esptool, might be worth to look in their [repository](https://github.com/espressif/esptool) to see if you are using the latest version. By my understanding this could be happening due to a timing issue in the stub code provided by esptool. – Shunya Jan 17 '21 at 12:29