May 22, 2018

BASIC in the ESP32

Amazingly, the chip has a BASIC interpreter tucked away in the bootrom.

Some output from the interpreter:

>about
ESP32 ROM Basic (c) 2016 Espressif Shanghai
Derived from TinyBasic Plus by Mike Field and Scott Lawrence
>help
A very Basic ROM console. Available commands/functions:
LIST
NEW
RUN
NEXT
LET
IF
GOTO
GOSUB
RETURN
REM
FOR
INPUT
PRINT
PHEX
POKE
STOP
BYE
MEM
?
'
DELAY
END
RSEED
HELP
ABOUT
IOSET
IODIR
PEEK
ABS
RND
IOGET
USR
Simple things like this work:
>run
OK
>10 print "hello"
>run
hello
OK
If you unplug and replug the device, your program vanishes. The Hackaday article gives the following program that enables GPIO 4 as output, turns it on and then off again, and then prints out the value of the GPIOs inputs in hex.
5 POKE &H3FF44020, 16
10 POKE &H3FF44004, 16
20 DELAY 200
20 POKE &H3FF44004, 0
30 DELAY 200
40 PHEX PEEK(&H3FF4403C)
50 GOTO 10