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.
The MorphESP240 (right) and its Dev Shield (left)
On bottom of the board you have :
- The battery connector (left)
- The reset button (bottom left)
- The USB-C connector (bottom middle)
- The boot button (bottom right)
So let's see how to get started with it from an Linux environment ...
Useful files:
- Get the latest CircuitPython '.bin' file from Saola 1 w/WROOM.
- Get the latest CircuitPython Libray here: https://circuitpython.org/libraries
- Get the latest BeBoxoS repository:
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:
- Activate Boot mode: push reset button (left), push/release boot button (right), release reset button (left)
sudo python3 ./esptool.py --chip esp32s2 erase_flash
- You may get some errors messages at the end because you need to reset the MorphESP240 manually.
- Reset MorphESP240: left button.
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 ..
- You may get some errors messages at the end because you need to reset the MorphESP240 manually.
- Reset MorphESP240: left button.
Identify system information for your device:
You will need to identity how to have access to your MorphESP240 from Linux.
- Display information about the device from your logs (after you reset or plug it)
sudo dmesg
- You should get something like this :
[ 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
- Find information about serial port (tty) and the removable disk device to mount
- So in my case:
Serial port: /dev/ttyACM0
Disk: /dev/sdc1
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 :
- Get this one from BeBoxoS repository:
cp circuitpython_MORPH_ESP240/CIRCUITPY/lib/morph.py CIRCUITPY/lib/
- Get others from official 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/
- Edit your SSID and WiFi credentials on
circuitpython_MORPH_ESP240/CIRCUITPY/secrets.py
- Then copy the file on MorphESP240:
cp circuitpython_MORPH_ESP240/CIRCUITPY/secrets.py CIRCUITPY/
- Copy the main file:
cp circuitpython_MORPH_ESP240/CIRCUITPY/code.py CIRCUITPY/
- Sync
sudo sync
You should see CircuitPython running on your serial terminal.
... and output on the IPS screen :)
MorphESP240 running CircuitPython
Before unplugging or resetting, unmount the MorphESP240:
sudo umount /dev/sdc1