Skip to content

Install M5 Stack on Linux

Baitcookie edited this page Mar 11, 2021 · 7 revisions

Installation on Linux

To use serial devices you as the user may need to be in certain group. On a debian/ubuntu based system this is group dialout. Check the device file for the group and add the current user to it, e.g. with sudo usermod -a -G dialout $USER, then you may need to restart your desktop environment (logout/-in). As a quick workaround you can login via ssh locally ssh -X $USER@localhost then on that shell the group is set.

ls -la /dev/ttyUSB0
crw-rw---- 1 root dialout 188, 0 Feb 22 09:17 /dev/ttyUSB0

m5burner

M5 provide a zip download link for the beta version in the docs with binaries. On the official download page there are links to stable versions. Download (71 MB) and unpack to a local dir

# the beta is an older one than the one from download page (at time of writing v 2.0.0 vs. Current: 2.2.4, Lastest: 2.2.7)
#dlurl="https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/software/M5Burner-Beta-Linux.zip"
dlurl="https://static-cdn.m5stack.com/resource/software/M5Burner_Linux.zip"
tmpf=$(mktemp --tmpdir "m5burner-linux-dl-XXXX.zip")
mkdir -p "$HOME/local/m5burner/"
wget "$dlurl" -O "$tmpf"
unzip -d $HOME/local/m5burner/ "$tmpf"

There is an improved start script in the code repository (m5burner.sh) which works from any location and tries to find the binary, if necessary. Copy it to a location in your $PATH variable.

#!/bin/bash

m5dir="$HOME/local/m5burner/"
m5b="m5burner"
m5bin="$m5dir/bin/$m5b"
if [ ! -x "$m5bin" ] ; then
    echo "m5burner not found in default location ($m5dir), searching..."
    if [ -n "$(which m5burner)" ] ;then
        m5bin=$(which m5burner)
    else
        m=$(find "$HOME" -maxdepth 4 -type f -name "$m5b"| head -n 1)
        if [ -x "$m" ] ; then
            m5bin="$m"
        else
            echo "...not found, exiting"
            exit 1
        fi
    fi
fi

"$m5bin" --no-sandbox

UIFlow-Desktop

The official download page lists a download for UIFlow-Desktop-IDE, which resembles the flow.m5stack.com website for programming with blockly and python.

wget https://static-cdn.m5stack.com/resource/software/UIFlow-Desktop-IDE_Linux.zip -O /tmp/UIFlow-Desktop-IDE_Linux.zip
mkdir -p $HOME/local/m5uiflow/
unzip -d $HOME/local/m5uiflow/ /tmp/UIFlow-Desktop-IDE_Linux.zip

$HOME/local/m5uiflow/bin/uiflow-desktop-ide

Burn an image to the device

In m5burner select an image and flash onto the connected device, here called burn. Serial should be given at COM and is likely /dev/ttyUSB0, if this is your only USB to serial device, or try the highest number.

UIFlow_Matrix

UIFlow_Matrix-v1.7.2

This firmware version was iinitially a fail, please switch to an older one (or newer, if failing) or remove and re-download this firmware. Finally this version seems to work here, too.

 Start Burn 
 =================
$HOME/local/m5burner/packages/tools/esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 750000 --before default_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 0x1000 $HOME/local/m5burner/packages/fw/atom/UIFlow_Matrix-v1.7.2.bin
=================
esptool.py v2.5.0
Serial port /dev/ttyUSB0
Connecting...
.
.

Chip is ESP32-PICO-D4 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, Embedded Flash, VRef calibration in efuse
MAC: 24:a1:60:45:47:30
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 750000
Changed.
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed 63448 bytes to 15554...

Writing at 0x00001000... (100 %)

Wrote 63448 bytes (15554 compressed) at 0x00001000 in 0.3 seconds (effective 1895.1 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

=================
 Burn Successfully 
=================

Boot messages and APIKEY can be seen in the COM Monitor:

ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 188777542, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:5276
load:0x40078000,len:12872
load:0x40080400,len:3512
entry 0x4008063c

       _  __ _               
 _   _(_)/ _| | _____      __
| | | | | |_| |/ _ \ \ /\ / /
| |_| | |  _| | (_) \ V  V / 
 \__,_|_|_| |_|\___/ \_/\_/  

APIKEY: YOURAPIKEY

The device creates a Wifi which is named like M5-YOURAPIKEY and a webserver reachable after connecting to this via the IP/URL: 192.168.4.1

  • configure your wifi password (technically the password is sent unencrypted via a GET request like http://192.168.4.1/configure?ssid=YOURSSID&password=YOURWIFIPW)
    • If you get the warning ×_× WiFi connection failed Click here return configure page., then try again (password wrong?)
    • success indicated by ^_^ WiFi connection success Reset device now ..
      • reset and your device should can now connect to your network, indicated at startup by a red glow (Wifi connecting), followed by a blue one (Wifi connection success).

:::alert TODO: how to connect? ui thing cannot find it Error messages are: /dev/ttyUSB0 [ Disconnected ]Upload code failed, maybe your device is offline check it and retry :::

export APIKEY=YOURAPIKEY host ESP-$APIKEY ESP-YOURAPIKEY.fritz.box has address 192.168.21.149

Issues using or configuring

m5burner message after configuring wifi credentials

m5burner js error

m5burner write message, this stalls and config fails