1

I understand how compiler compile our code to make binary code. Then we can use avr gcc to upload bin code to atmega chips via programer (USB ISP) or via USB serial (required bootloader). I'm using ESP32 for a while and notice they work in difference way. As far as I know

  1. It not required Arduino bootloader.
  2. It not reset when re-open serial monitor.
  3. It use external memory chip.
  4. It have boot and reset button
  5. The USB Serial connect to ESP32 and we can upload bin code with it. (maybe the only way)
  6. In IDE it run python scrip (esptool.py) I wonder how the process going and how each element work for its part for completely understand the process.
5
  • 1
    avr gcc is the compiler ... it does not do the code upload
    – jsotola
    Oct 4, 2021 at 3:31
  • Arduino IDE is one possible way of getting code onto the ESP32. There’s lots of info available about using Arduino IDE with ESP32 (e.g., randomnerdtutorials.com/…). There are also other IDEs that will work see randomnerdtutorials.com/getting-started-with-esp32 for a list.
    – RowanP
    Oct 4, 2021 at 3:36
  • @RowanP That one confuse me. so with one bootloader esp32 can work with all environment??? or the system not required bootloader at all???
    – M lab
    Oct 4, 2021 at 5:56
  • 1
    @Mlab Explaining that’s beyond my expertise. I know that it uses a boot loader, and that it’s compatible with several environments. I’ll pass the baton to someone with deeper expertise.
    – RowanP
    Oct 4, 2021 at 6:43
  • 3
    Its more like the programming environments/IDEs are made compatible with the bootloaders (not other way round). For the Arduino IDE you need to install the ESP32 core, which includes the upload tool for its bootloader, making the Arduino IDE compatible with the bootloader of the ESP32. There are many other IDEs, which can be made compatible. I think only the native ESP IDE from Espressif is specifically made for ESPs
    – chrisl
    Oct 4, 2021 at 10:15

1 Answer 1

2

The ESP32 has a bootloader that uses serial embedded in its internal ROM. Whether that bootloader runs or not depends on the state of certain IO pins when the ESP32 starts up.

Those states are controlled by a small circuit that is triggered by the serial control lines (DTR and RTS).

On the Arduino there isn't that requirement, and the bootloader always runs when the chip resets, so a much simpler circuit is used to trigger a reset using just the DTR signal.

So for an Arduino whenever the serial port is opened the DTR signal resets the board. But for the ESP32 the RTS signal also has to be asserted along with the DTR signal in the right sequence to both set the correct IO pins and to reset the chip.

Whether the target device has internal flash or an external flash chip makes no difference. It is the bootloader's job to get the data into that flash. The AVR chips have a way of interfacing with the internal flash (ISP) to program it without a bootloader, but the ESP32, as it has external flash, doesn't need that (you can interface directly with the flash chip if you so wish).

The software on the PC that communicates with the bootloader has to speak the "language" the bootloader expects. Each family of chips has its own bootloader (some don't even have a bootloader, but that's another story) which speaks its own language. On the AVR chips that's usually a variant of the STK500 protocol, and the program avrdude is what communicates with it to send the program to flash. On the ESP32 (and the ESP8266 too) it's esptool.py that does the job. On chipKIT boards it's pic32prog. On Digipark it's micronucleus. There's as many upload programs as there are families of boards. Some programs, like avrdude and pic32prog are more flexible and can also talk to hardware programmers (USBASP, PICkit2 etc), but in general the upload program is written specifically for a particular bootloader.

3
  • So all ESP32 have build-in bootloader right? means I don't need to re-install it ever? I never see someone done that before
    – M lab
    Oct 5, 2021 at 15:10
  • 1
    @Mlab That is correct. It is getting more common to have a bootloader in ROM instead of (or as well as) having a hardware programming interface. The Arduino Due also has its bootloader in ROM, as do many other high-end ARM chips. It's common to have the bootloader operate in multiple modes, including booting off SD card (like the Pi does) depending on settings on certain IO pins.
    – Majenko
    Oct 5, 2021 at 15:14
  • That really anewer my question. I just self learner. By missing that information make my life a hard time figured out how things work. Thank to you.
    – M lab
    Oct 5, 2021 at 15:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.