Why Did These LEDs Light Up? ESP32-S3 – Which Pins Are Safe to Use? [video]
youtube.com
youtube.com
Lost tens of hours of my life trying to bring a new ESP32-based board up. Debugging code, cutting traces and soldering bridge wires, buying and using a logic analyzer.
Turns out:
Some of the pins on the ESP32
a) Are strapping pins (configure stuff like what voltage to talk to FLASH). Luckily there's a few fuses you can blow to hardcode some of the settings the strapping pins are reading, so they ignore logic level on boot,
b) Default back to JTAG pins. For example, you have to explicitly reset GPIO12 - gpio_reset_pin(GPIO12) to use it as an I/O pin again (this burnt a day of my life).
Lesson learnt, if something weird is happening with your micro, check for strapping and / or default pin behavior.- What are the default states of every pin on start up?
- What is the boot sequence? Is there a pin or setting to switch the boot between Flash, RAM, bootloader, etc?
- Is there any built-in bootloader? How is it triggered?
- What are the Flash config bytes/fuse settings?
https://github.com/espressif/vscode-esp-idf-extension/blob/m...
The Rube-Goldbergy-ness of it all still makes me upset, but hey it works, and surprisingly well. Including JTAG debugging and all, too.
Bootstrapping?
Is that a hardware people thing?
Boot strapping in circuits usually refers to passive parts that provide power needed locally for switching parts.
In what way?
I've only ever come across pull up and pull down.
Edit: Wikipedia seems to equate strapping with setting a jumper. I can't seem to find any other references except related to esp devices.
As useful as they are, imo they are a bit problematic, because of that mixed-use state. You have to be able to setup that pin for your hardware configuration, and then during operation use it for your needs.
Most of these also have an internal fuse you can burn to force the state permanently, which is where the "slightly different" comes in. The fuse sets the permanent internal pull state, so you dont have to deal with the setup phase, except, that you need to make sure anything you use that pin for in your application defaults to the state you want, as you can still externally modify that pin at power-on.
By default, on bootup, an ESP32 uses the value of pin IO12 to determine SPI Flash chip voltage. It has an internal pull-down so defaults to low (3.3V flash chip). If held high during bootup, then ESP32 treats Flash Chip voltage as 1.8V.
If you an input (say DIP switches) with pull-ups on IO12 and the dip switch is "off", i.e. disconnecting the ground circuit / pulled-up. Then, at boot, the ESP32 thinks it need to use 1.8V to talk with the flash chip, instantly crashing boot.
The use-case is to signal to the chip (since it's going to be booting off flash) what voltage to use (if you're using a 1.8V logic chip).
Luckily (on the ESP32 at least) there's a bunch of internal fuses you can blow to stop it from sampling certain strapping pins at boot, and hard coding certain settings (in a irreversible way).
$ espefuse.py --do-not-confirm --port /dev/ttyUSBx set_flash_voltage 3.3V
Blows this fuse so you can use IO12 normally again.In hardware, you "strap" pins to a particular value when the chip powers on. You can strap them high (tie them to the power source), strap them low (tie them to GND), or sometimes they do something fancier and tie them high or low via a particular resistor (for more fine-grained configurations like timing patterns, power selection, or I2C address selection in pin-constrained environments).
Usually you can reuse the pins for something else after power on. Often there are efuse bits you can blow after manufacture in order to override the strapping values and use the pins as normal IOs.
https://www.espressif.com/sites/default/files/documentation/...
I know that it is substantially supported on the ESP32, which is great, but I’m not sure if it’s able to give you the HW access that Forth has, you can extend and build your own drivers on the Forth system, which is my main use case. I like to do things as bare to the metal as possible and C and forth give me that, it’s the same reason I never used the arduino framework.