meshtastic / firmware

Meshtastic device firmware
https://meshtastic.org
GNU General Public License v3.0
3.29k stars 795 forks source link

[Bug]: Unable to flash M5Stack Core2 #2482

Closed loganmarchione closed 1 year ago

loganmarchione commented 1 year ago

Category

Hardware Compatibility

Hardware

Other

Firmware Version

N/A

Description

I'm new to Meshtastic, so bear with me here.

I have a M5Stack Core2. I saw a variant here and also found this, so I figured I could flash it. I'm running Arch Linux and it shows up under /dev/ttyACM0.

> esptool.py --port /dev/ttyACM0 chip_id
esptool.py v4.5.1
Serial port /dev/ttyACM0
Connecting....
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting....
Detecting chip type... ESP32
Chip is ESP32-D0WDQ6-V3 (revision v3.0)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 30:c6:f7:25:ef:9c
Uploading stub...
Running stub...
Stub running...
Warning: ESP32 has no Chip ID. Reading MAC instead.
MAC: 30:c6:f7:25:ef:9c
Hard resetting via RTS pin...

I cloned this repo, built the firmware according to these instructions, but had to change the port from COM8 to /dev/ttyACM0. I then tried to flash as per the instructions. Below is the output.

 *  Executing task: platformio run --target upload --environment m5stack-core 

Processing m5stack-core (board: m5stack-core-esp32; platform: platformio/espressif32@^6.1.0; framework: arduino)
----------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/m5stack-core-esp32.html
PLATFORM: Espressif 32 (6.2.0) > M5Stack Core ESP32
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES: 
 - framework-arduinoespressif32 @ 3.20008.0 (2.0.8) 
 - tool-esptoolpy @ 1.40501.0 (4.5.1) 
 - tool-mkfatfs @ 2.0.1 
 - tool-mklittlefs @ 1.203.210628 (2.3) 
 - tool-mkspiffs @ 2.230.0 (2.30) 
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
[nanopb] Installing Protocol Buffers dependencies
Requirement already satisfied: protobuf>=3.19.1 in /home/logan/.platformio/penv/lib/python3.11/site-packages (4.23.0)
[nanopb] No generation needed.
Found 71 compatible libraries
Scanning dependencies...
Dependency Graph
|-- ESP8266 and ESP32 OLED driver for SSD1306 displays @ 4.3.0+sha.b38094e
|-- OneButton @ 2.0.3
|-- arduino-fsm @ 2.2.0+sha.7db3702
|-- TinyGPSPlus @ 1.0.3+sha.127ad67
|-- Thread @ 0.0.0+sha.72921ac
|-- Nanopb @ 0.4.7
|-- ErriezCRC32 @ 1.0.1
|-- QMC5883LCompass @ 1.1.1
|-- NonBlockingRTTTL @ 1.3.0
|-- SparkFun ATECCX08a Arduino Library @ 1.3.1+sha.5cf62b3
|-- PubSubClient @ 2.8.0
|-- NTPClient @ 3.2.1
|-- Syslog @ 2.0.0
|-- Adafruit BusIO @ 1.14.1
|-- Adafruit Unified Sensor @ 1.1.9
|-- Adafruit BMP280 Library @ 2.6.6
|-- Adafruit BME280 Library @ 2.2.2
|-- BSEC2 Software Library @ 1.3.2200
|-- BME68x Sensor library @ 1.1.40407
|-- Adafruit MCP9808 Library @ 2.0.0
|-- Adafruit INA260 Library @ 1.5.0
|-- Adafruit INA219 @ 1.2.1
|-- Adafruit SHTC3 Library @ 1.0.1
|-- Adafruit LPS2X @ 2.0.4
|-- Adafruit SHT31 Library @ 2.2.0
|-- Adafruit PM25 AQI Sensor @ 1.0.6
|-- Adafruit MPU6050 @ 2.2.4
|-- Adafruit LIS3DH @ 1.2.4
|-- esp32_https_server @ 1.0.0+sha.23665b3
|-- NimBLE-Arduino @ 1.4.1
|-- RadioLib @ 6.0.0
|-- XPowersLib @ 0.1.4+sha.84b7373
|-- ESP32 Codec2 @ 1.0.1+sha.633326c
|-- TFT_eSPI @ 2.5.30
|-- SD @ 2.0.0
|-- SPI @ 2.0.0
|-- WiFi @ 2.0.0
|-- Wire @ 2.0.0
|-- Preferences @ 2.0.0
|-- HTTPClient @ 2.0.0
|-- WiFiClientSecure @ 2.0.0
|-- WebServer @ 2.0.0
|-- ESPmDNS @ 2.0.0
|-- LittleFS @ 2.0.0
Building in release mode
Using meshtastic platformio-custom.py, firmware version 2.1.12.666a1f34
Retrieving maximum program size .pio/build/m5stack-core/firmware.elf
Checking size .pio/build/m5stack-core/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [===       ]  32.3% (used 105936 bytes from 327680 bytes)
Flash: [========  ]  84.1% (used 2040105 bytes from 2424832 bytes)
Configuring upload protocol...
AVAILABLE: cmsis-dap, esp-bridge, esp-prog, espota, esptool, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa
CURRENT: upload_protocol = esptool
Looking for upload port...
Using manually specified: /dev/ttyACM0
Uploading .pio/build/m5stack-core/firmware.bin
esptool.py v4.5.1
Serial port /dev/ttyACM0
Connecting......
Chip is ESP32-D0WDQ6-V3 (revision v3.0)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 30:c6:f7:25:ef:9c
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Flash will be erased from 0x00001000 to 0x00005fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x00203fff...
Compressed 18960 bytes to 13073...
Writing at 0x00001000... (100 %)
Wrote 18960 bytes (13073 compressed) at 0x00001000 in 0.4 seconds (effective 361.1 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 137...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (137 compressed) at 0x00008000 in 0.1 seconds (effective 449.9 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 47...
Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.1 seconds (effective 612.2 kbit/s)...
Hash of data verified.
Compressed 2046000 bytes to 1255303...
Writing at 0x00010000... (1 %)
Writing at 0x0001a14b... (2 %)
Writing at 0x00023f73... (3 %)
Writing at 0x0002a162... (5 %)
Writing at 0x0002e74c... (6 %)
Writing at 0x00032bde... (7 %)
Writing at 0x0003f7ac... (9 %)
Writing at 0x0004bbad... (10 %)
Writing at 0x000548d6... (11 %)
Writing at 0x0005c15a... (12 %)
Writing at 0x0006ed0b... (14 %)
Writing at 0x000841b7... (15 %)
Writing at 0x0008c276... (16 %)
Writing at 0x00091c92... (18 %)
Writing at 0x0009778f... (19 %)
Writing at 0x0009da34... (20 %)
Writing at 0x000a319e... (22 %)
Writing at 0x000a839b... (23 %)
Writing at 0x000ae890... (24 %)
Writing at 0x000b4438... (25 %)
Writing at 0x000ba2f6... (27 %)
Writing at 0x000bf669... (28 %)
Writing at 0x000c52df... (29 %)
Writing at 0x000cb02b... (31 %)
Writing at 0x000d054a... (32 %)
Writing at 0x000d62b9... (33 %)
Writing at 0x000db8a8... (35 %)
Writing at 0x000e129e... (36 %)
Writing at 0x000e6c0d... (37 %)
Writing at 0x000ec62e... (38 %)
Writing at 0x000f2076... (40 %)
Writing at 0x000f7dab... (41 %)
Writing at 0x000fda4f... (42 %)
Writing at 0x00103622... (44 %)
Writing at 0x00108de7... (45 %)
Writing at 0x0010e324... (46 %)
Writing at 0x0011385c... (48 %)
Writing at 0x00118ad1... (49 %)
Writing at 0x0011deed... (50 %)
Writing at 0x00123186... (51 %)
Writing at 0x001283fb... (53 %)
Writing at 0x0012d96a... (54 %)
Writing at 0x00132ad3... (55 %)
Writing at 0x00138966... (57 %)
Writing at 0x0013e6d2... (58 %)
Writing at 0x00144a17... (59 %)
Writing at 0x0014a1cd... (61 %)
Writing at 0x0014f4a0... (62 %)
Writing at 0x0015482d... (63 %)
Writing at 0x00159ae8... (64 %)
Writing at 0x0015fbe1... (66 %)
Writing at 0x00165274... (67 %)
Writing at 0x0016a897... (68 %)
Writing at 0x0016fd86... (70 %)
Writing at 0x00175031... (71 %)
Writing at 0x0017a52b... (72 %)
Writing at 0x0017f6fe... (74 %)
Writing at 0x00184dbb... (75 %)
Writing at 0x0018a4e5... (76 %)
Writing at 0x001901c2... (77 %)
Writing at 0x00195b39... (79 %)
Writing at 0x0019bac4... (80 %)
Writing at 0x001a26ba... (81 %)
Writing at 0x001ac07d... (83 %)
Writing at 0x001b4672... (84 %)
Writing at 0x001b9be6... (85 %)
Writing at 0x001bfa04... (87 %)
Writing at 0x001c5351... (88 %)
Writing at 0x001ce27f... (89 %)
Writing at 0x001d438c... (90 %)
Writing at 0x001dd34b... (92 %)
Writing at 0x001e48ae... (93 %)
Writing at 0x001e99f7... (94 %)
Writing at 0x001ef3a6... (96 %)
Writing at 0x001f52e0... (97 %)
Writing at 0x001fa6e9... (98 %)
Writing at 0x001ffef5... (100 %)
Wrote 2046000 bytes (1255303 compressed) at 0x00010000 in 19.9 seconds (effective 822.0 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
==================== [SUCCESS] Took 35.13 seconds ====================

Environment    Status    Duration
-------------  --------  ------------
m5stack-core   SUCCESS   00:00:35.127
==================== 1 succeeded in 00:00:35.127 ====================

However, the device doesn't reset. When I force power off the device, it doesn't turn back on (the display never comes back). It is showing up for esptool.

> esptool.py --port /dev/ttyACM0 chip_id
esptool.py v4.5.1
Serial port /dev/ttyACM0
Connecting.....
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting....
Detecting chip type... ESP32
Chip is ESP32-D0WDQ6-V3 (revision v3.0)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 30:c6:f7:25:ef:9c
Uploading stub...
Running stub...
Stub running...
Warning: ESP32 has no Chip ID. Reading MAC instead.
MAC: 30:c6:f7:25:ef:9c
Hard resetting via RTS pin...

I can see the built firmware files in the correct directory.

> ls -la .pio/build/m5stack-core
total 82644
drwxr-xr-x 50 logan users     4096 May 10 23:12 .
drwxr-xr-x  3 logan users       50 May 10 23:12 ..
-rw-r--r--  1 logan users    18960 May 10 23:12 bootloader.bin
-rw-r--r--  1 logan users  2046000 May 10 23:12 firmware.bin
-rwxr-xr-x  1 logan users 48197868 May 10 23:12 firmware.elf
-rw-r--r--  1 logan users  2111536 May 10 23:12 firmware.factory.bin
-rw-r--r--  1 logan users 24077460 May 10 23:12 firmware.map
drwxr-xr-x  3 logan users     4096 May 10 23:12 FrameworkArduino
drwxr-xr-x  3 logan users       31 May 10 23:12 lib033
drwxr-xr-x  3 logan users       55 May 10 23:12 lib216
drwxr-xr-x  3 logan users       49 May 10 23:12 lib248
drwxr-xr-x  3 logan users       41 May 10 23:12 lib25e
drwxr-xr-x  3 logan users       49 May 10 23:12 lib277
drwxr-xr-x  3 logan users       51 May 10 23:12 lib2a5
drwxr-xr-x  3 logan users       73 May 10 23:12 lib2c5
drwxr-xr-x  3 logan users       49 May 10 23:12 lib2d4
drwxr-xr-x  3 logan users       57 May 10 23:12 lib336
drwxr-xr-x  3 logan users       47 May 10 23:12 lib341
drwxr-xr-x  3 logan users       71 May 10 23:12 lib3c9
drwxr-xr-x  3 logan users       45 May 10 23:12 lib3cd
drwxr-xr-x  3 logan users       45 May 10 23:12 lib3eb
drwxr-xr-x  3 logan users       33 May 10 23:12 lib431
drwxr-xr-x  3 logan users       75 May 10 23:12 lib489
drwxr-xr-x  3 logan users       95 May 10 23:12 lib4ec
drwxr-xr-x  3 logan users      127 May 10 23:12 lib534
drwxr-xr-x  3 logan users       39 May 10 23:12 lib5ea
drwxr-xr-x  3 logan users       51 May 10 23:12 lib5fd
drwxr-xr-x  3 logan users       59 May 10 23:12 lib7a8
drwxr-xr-x  3 logan users       39 May 10 23:12 lib7b1
drwxr-xr-x  3 logan users       43 May 10 23:12 lib7b3
drwxr-xr-x  3 logan users       75 May 10 23:12 lib806
drwxr-xr-x  3 logan users       59 May 10 23:12 lib827
drwxr-xr-x  3 logan users       71 May 10 23:12 lib834
drwxr-xr-x  3 logan users       57 May 10 23:12 lib8f7
drwxr-xr-x  3 logan users       55 May 10 23:12 lib9b5
drwxr-xr-x  3 logan users       69 May 10 23:12 lib9b9
drwxr-xr-x  3 logan users       73 May 10 23:12 lib9ee
drwxr-xr-x  3 logan users       73 May 10 23:12 liba21
drwxr-xr-x  3 logan users       43 May 10 23:12 liba45
drwxr-xr-x  3 logan users       73 May 10 23:12 liba99
drwxr-xr-x  3 logan users       71 May 10 23:12 libae9
drwxr-xr-x  3 logan users       43 May 10 23:12 libb04
drwxr-xr-x  3 logan users       59 May 10 23:12 libb49
drwxr-xr-x  3 logan users       39 May 10 23:12 libbcb
drwxr-xr-x  3 logan users       55 May 10 23:12 libc3b
drwxr-xr-x  3 logan users       57 May 10 23:12 libc7c
drwxr-xr-x  3 logan users       63 May 10 23:12 libc7f
drwxr-xr-x  3 logan users       31 May 10 23:12 libd2d
drwxr-xr-x  3 logan users       39 May 10 23:12 libd8a
drwxr-xr-x  3 logan users       47 May 10 23:12 libde3
drwxr-xr-x  3 logan users       49 May 10 23:12 libe2d
drwxr-xr-x  3 logan users       35 May 10 23:12 libe8c
drwxr-xr-x  3 logan users       35 May 10 23:12 libeae
drwxr-xr-x  3 logan users       45 May 10 23:12 libef5
-rw-r--r--  1 logan users  3309658 May 10 23:12 libFrameworkArduino.a
-rw-r--r--  1 logan users     3072 May 10 23:12 partitions.bin
-rw-r--r--  1 logan users  4831441 May 10 23:12 .sconsign311.dblite
drwxr-xr-x 13 logan users     4096 May 10 23:12 src

I also tried flashing via a manual flash, but got the same result (no display and no buttons work). Not sure if the error at the end is critical since the flash already completed, right?

> ./bin/device-install.sh -p /dev/ttyACM0 -f .pio/build/m5stack-core/firmware.bin
Trying to flash .pio/build/m5stack-core/firmware.bin, but first erasing and writing system information
esptool.py v4.5.1
Serial port /dev/ttyACM0
Connecting......
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting....
Detecting chip type... ESP32
Chip is ESP32-D0WDQ6-V3 (revision v3.0)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 30:c6:f7:25:ef:9c
Uploading stub...
Running stub...
Stub running...
Erasing flash (this may take a while)...
Chip erase completed successfully in 58.7s
Hard resetting via RTS pin...
esptool.py v4.5.1
Serial port /dev/ttyACM0
Connecting....
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting....
Detecting chip type... ESP32
Chip is ESP32-D0WDQ6-V3 (revision v3.0)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 30:c6:f7:25:ef:9c
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Flash will be erased from 0x00000000 to 0x001f3fff...
Compressed 2046000 bytes to 1255303...
Wrote 2046000 bytes (1255303 compressed) at 0x00000000 in 110.6 seconds (effective 147.9 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
usage: esptool write_flash [-h] [--erase-all] [--flash_freq {keep,80m,60m,48m,40m,30m,26m,24m,20m,16m,15m,12m}] [--flash_mode {keep,qio,qout,dio,dout}]
                           [--flash_size {detect,keep,256KB,512KB,1MB,2MB,2MB-c1,4MB,4MB-c1,8MB,16MB,32MB,64MB,128MB}] [--spi-connection SPI_CONNECTION]
                           [--no-progress] [--verify] [--encrypt] [--encrypt-files <address> <filename> [<address> <filename> ...]]
                           [--ignore-flash-encryption-efuse-setting] [--force] [--compress | --no-compress]
                           <address> <filename> [<address> <filename> ...]
esptool write_flash: error: argument <address> <filename>: [Errno 2] No such file or directory: 'bleota.bin'

In the end, I had to erase it and was able to flash a demo project again. Am I missing something simple? Again, this my first time using Meshtastic.

> esptool.py --port /dev/ttyACM0 erase_flash 

Relevant log output

No response

mverch67 commented 1 year ago

The M5Stack Core2 has different pin definitions than the old version. So you cannot use the old firmware for the new device. You would need to adapt all the pin definitions in the variant.h file according to the Core2 definitions (e.g. MISO is 38): image

The M5Stack has a LCD display 240x320 (ILI9341), the Core2 has a LCD 320x240 (ILI9342), so for the latter you may also need adaptations.

loganmarchione commented 1 year ago

Ahh ok my bad. Thanks for the reply! I have a Lilygo device on the way, so I'll wait for that!

caveman99 commented 1 year ago

I wrote the initial m5stack firmware, and at that ime i thought the core2 had the same pinout than the predecessors. i have a m5stack basic and a 9dop version here, no core2. it should not be too difficult to port meshtastic to the core2, since most of the components are similar and the TFT driver is configured via defines.