Python on the chip
MicroPython is Python 3 made small enough for a microcontroller: it fits in 256 KB of code and 16 KB of RAM. Its compiler and runtime run on the ESP32 itself, so the chip can read Python text and run it.
First, a laptop tool called esptool copies MicroPython onto the board's 4 MiB flash chip, starting at address 0x1000. That is the only firmware you flash. From then on, your Python is just text the interpreter reads.
Live at the prompt
Plug in USB and open a serial terminal at 115,200 baud. The chip answers with >>>, the REPL prompt. REPL means read, evaluate, print, loop: it reads a line you type, runs it, prints any result and waits again.
Type led = Pin(13, Pin.OUT) and press Enter. The text travels down the cable. On the chip the compiler turns it into bytecode, a compact list of steps, and the virtual machine runs them. Now led lives in the heap, in SRAM.
Type led.value(1). The chip runs it and sets pin 13 high, close to 3.3 volts, and the LED lights. Nothing was compiled on the laptop or flashed: you try an idea and see the answer straight away.
On its own
Typed lines are gone after a reset. To keep a program, save it as a file: mpremote cp main.py : copies main.py into a small filesystem on the flash chip, beside MicroPython. Files survive power off.
At every reset MicroPython runs boot.py if there is one, then main.py. The reset starts with empty memory, so lines 1 to 3 build led again: get Pin, import the time module, make pin 13 an output.
Line 4 starts a loop that never ends. led.on() sets the pin high, time.sleep(0.5) waits half a second, led.off() sets it low, and it waits again: one blink per second, with no laptop needed.
With the cable in, press Ctrl-C in the terminal. MicroPython raises KeyboardInterrupt inside the loop, main.py stops where it was, and the >>> prompt returns. Edit, copy, reset, and try again in seconds.
The price
Convenience costs time. The virtual machine does many machine steps per bytecode; MicroPython's own native mode runs roughly 2 times faster. Every new object takes heap, and the garbage collector that frees it can pause for several milliseconds.
What happens
;; step 1/10 · interpreter MicroPython a lean Python 3 for microcontrollers needs 256 KB of code space, 16 KB of RAM compiler Python text -> bytecode (on the chip) runtime a virtual machine runs the bytecode ESP32 up to 240 MHz, 520 KB SRAM, 448 KB ROM
The ESP32 chip itself has no flash for programs: the board's 4 MiB flash chip sits beside it (the figure draws it as its own chip). The download page asks you to erase the flash first and to pick the .bin for your board: the ESP32_GENERIC build is for boards with 4 MiB or more of flash. The same blink in Arduino C++ for an ESP32 board is digitalWrite(LED, HIGH); delay(500); and so on, compiled to machine code on the laptop and flashed after every change (see the lesson "From code to chip: compile, link and flash"). It runs faster and has no garbage collector; MicroPython trades that for the live REPL.