May 22, 2018

BASIC in the ESP32

Amazingly, the chip has a BASIC interpreter tucked away in the bootrom. I grabbed one of my WeMOS modules, soldered a wire from +3.3 to GPIO12 and connected up the USB cable. Then once I connect with picocom at 115200 baud, I see:
picocom -b 115200 /dev/ttyUSB2

ets Jun  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x33 (SPI_FAST_FLASH_BOOT)
flash read err, 1000
Falling back to built-in command interpreter.
OK
>ets Jun  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x33 (SPI_FAST_FLASH_BOOT)
flash read err, 1000
Falling back to built-in command interpreter.
OK
It does this in a loop until I hit return, then it stops at the ">" prompt waiting. You can get an informational greeting as follows:
>about
ESP32 ROM Basic (c) 2016 Espressif Shanghai
Derived from TinyBasic Plus by Mike Field and Scott Lawrence

Look at the bootrom

The only string that I have seen in the above that the "strings" command can find in the bootrom code is:
strings esp32.bin | grep built
Falling back to built-in command interpreter.
Very likely TinyBasic uses some kind of compression or scheme more compact than ascii to represent characters. The above string is at address 0x4006eeef, as follows:
4006eee0 2025 752c 2025 7520 6473 2025 700a 0046    %u, %u ds %p  F
4006eef0 616c 6c69 6e67 2062 6163 6b20 746f 2062   alling back to b
4006ef00 7569 6c74 2d69 6e20 636f 6d6d 616e 6420   uilt-in command
4006ef10 696e 7465 7270 7265 7465 722e 0a00 736c   interpreter.  sl
I don't find 0x4006eeef as a constant in the ROM, nor do I find 0x3ff9eeef, which might be an alias in the ROM1 space.