Nearphuture.Org

CircuitPython on MorphESP240 with Linux [2021-08-15]


Intro:

The MorphESP240 by Morpheans (a young French company) is a nice little Dev board with an ESP32-S2 and a small color IPS screen with CircuitPython support.

MorphESP240 and its Proto Board

The MorphESP240 (right) and its Dev Shield (left)

On bottom of the board you have :

So let's see how to get started with it from an Linux environment ...

Useful files:

git clone https://github.com/beboxos/circuitpython_MORPH_ESP240.git

Get and install esptool:

git clone https://github.com/espressif/esptool.git
cd esptool
pip install --user -e .

If you need to call the tools from everywhere, add $HOME/.local/bin into your PATH Variable.

Erase MorphESP240:

sudo python3 ./esptool.py --chip esp32s2 erase_flash

Flash MorphESP240:

sudo python3 ./esptool.py --chip esp32s2 --port /dev/ttyACM0 --baud 921600 write_flash -z 0x0000 ~/Downloads/adafruit-circuitpython-espressif_saola_1_wroom-en_US-6.3.0.bin
cd ..

Identify system information for your device:

You will need to identity how to have access to your MorphESP240 from Linux.

sudo dmesg
[ 3469.089255] usb 2-1.3: new full-speed USB device number 4 using ehci-pci
[ 3469.190214] usb 2-1.3: New USB device found, idVendor=239a, idProduct=80a8, bcdDevice= 1.00
[ 3469.190232] usb 2-1.3: New USB device strings: Mfr=2, Product=3, SerialNumber=1
[ 3469.190239] usb 2-1.3: Product: Saola 1 w/WROOM
[ 3469.190243] usb 2-1.3: Manufacturer: Espressif
[ 3469.190247] usb 2-1.3: SerialNumber: 7CDFA10112A2
[ 3469.192339] usb-storage 2-1.3:1.2: USB Mass Storage device detected
[ 3469.192813] scsi host7: usb-storage 2-1.3:1.2
[ 3469.196359] input: Espressif Saola 1 w/WROOM Keyboard as /devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1.3/2-1.3:1.3/0003:239A:80A8.0006/input/input18
[ 3469.253137] input: Espressif Saola 1 w/WROOM Mouse as /devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1.3/2-1.3:1.3/0003:239A:80A8.0006/input/input19
[ 3469.253466] input: Espressif Saola 1 w/WROOM as /devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1.3/2-1.3:1.3/0003:239A:80A8.0006/input/input20
[ 3469.253764] hid-generic 0003:239A:80A8.0006: input,hidraw3: USB HID v1.11 Keyboard [Espressif Saola 1 w/WROOM] on usb-0000:00:1d.7-1.3/input3
[ 3469.295754] cdc_acm 2-1.3:1.0: ttyACM0: USB ACM device
[ 3469.295784] usbcore: registered new interface driver cdc_acm
[ 3469.295785] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
[ 3470.217804] scsi host7: scsi scan: INQUIRY result too short (5), using 36
[ 3470.217833] scsi 7:0:0:0: Direct-Access     Espressi Saola 1 w/WROOM  1.0  PQ: 0 ANSI: 2
[ 3470.218778] sd 7:0:0:0: Attached scsi generic sg3 type 0
[ 3470.219857] sd 7:0:0:0: [sdc] 1921 512-byte logical blocks: (984 kB/961 KiB)
[ 3470.220713] sd 7:0:0:0: [sdc] Write Protect is off
[ 3470.220727] sd 7:0:0:0: [sdc] Mode Sense: 03 00 00 00
[ 3470.221587] sd 7:0:0:0: [sdc] No Caching mode page found
[ 3470.221600] sd 7:0:0:0: [sdc] Assuming drive cache: write through
[ 3470.280886]  sdc: sdc1
[ 3470.313535] sd 7:0:0:0: [sdc] Attached SCSI removable disk

Get access to Serial terminal:

sudo screen /dev/ttyACM0

You will have access from here to REPL and your CircuitPython output.

mount the MorphESP240 volume:

mkdir CIRCUITPY
sudo mount /dev/sdc1 CIRCUITPY -o umask=000

Now copy the lib you need on CIRCUITPY/lib :

cp circuitpython_MORPH_ESP240/CIRCUITPY/lib/morph.py CIRCUITPY/lib/
cp -r  adafruit-circuitpython-bundle-6.x-mpy-20210806/lib/adafruit_display_shapes CIRCUITPY/lib/
cp -r  adafruit-circuitpython-bundle-6.x-mpy-20210806/lib/adafruit_display_text CIRCUITPY/lib/
cp -r  adafruit-circuitpython-bundle-6.x-mpy-20210806/lib/adafruit_display_hid CIRCUITPY/lib/
cp -r  adafruit-circuitpython-bundle-6.x-mpy-20210806/lib/adafruit_hid CIRCUITPY/lib/
cp -r  adafruit-circuitpython-bundle-6.x-mpy-20210806/lib/adafruit_rgb_display CIRCUITPY/lib/
cp -r  adafruit-circuitpython-bundle-6.x-mpy-20210806/lib/adafruit_requests.mpy CIRCUITPY/lib/
cp -r  adafruit-circuitpython-bundle-6.x-mpy-20210806/lib/adafruit_st7789.mpy CIRCUITPY/lib/
cp -r  adafruit-circuitpython-bundle-6.x-mpy-20210806/lib/neopixel.mpy CIRCUITPY/lib/
cp -r  adafruit-circuitpython-bundle-6.x-mpy-20210806/lib/adafruit_imageload CIRCUITPY/lib/

Put some code on CIRCUITPY (first try with example from BeBoXoS):

cp -r circuitpython_MORPH_ESP240/CIRCUITPY/images CIRCUITPY/
cp circuitpython_MORPH_ESP240/CIRCUITPY/secrets.py CIRCUITPY/
cp circuitpython_MORPH_ESP240/CIRCUITPY/code.py CIRCUITPY/
sudo sync

You should see CircuitPython running on your serial terminal.

... and output on the IPS screen :)

MorphESP240 running CircuitPython

MorphESP240 running CircuitPython

Before unplugging or resetting, unmount the MorphESP240:

sudo umount /dev/sdc1