UtilitechAS / amsreader-firmware

ESP8266 and ESP32 compatible firmware to read, interpret and publish data to MQTT from smart electrical meters, both DLMS and DSMR is supported
Other
379 stars 72 forks source link

Can't flash XIAO ESP32C3 #786

Closed sonite closed 3 months ago

sonite commented 4 months ago

Describe your problem I can't get my XIAO ESP32C3 to work with the latest release. I have tried 3 methods:

ESP32C3 Flash download tool V3.9.5 With: esp32c3-2.3.5.bin @ 0x0

In terminal: 22:44:41.861 -> ESP-ROM:esp32c3-api1-20210207 22:44:41.861 -> Build:Feb 7 2021 22:44:41.861 -> rst:0x7 (TG0WDT_SYS_RST),boot:0x8 (SPI_FAST_FLASH_BOOT) 22:44:41.861 -> Saved PC:0x4005885e 22:44:41.861 -> SPIWP:0xee 22:44:41.861 -> mode:DIO, clock div:2 22:44:41.861 -> load:0x3c0f0020,len:0x48cf8 22:44:42.106 -> load:0x3fc8ba00,len:0x2c10 22:44:42.106 -> load:0x40380000,len:0x46e0 22:44:42.106 -> load:0x42000020,len:0xe938c

With the separate files: esp32c3-2.3.5\bootloader.bin @ 0x1000 esp32c3-2.3.5\partitions.bin @ 0x8000 esp32c3-2.3.5\boot_app0.bin @ 0xe000 esp32c3-2.3.5\frimware.bin @ 0x10000

In terminal: 22:47:40.619 -> invalid header: 0xffESP-ROM:esp32c3-api1-20210207 22:47:40.619 -> Build:Feb 7 2021 22:47:40.619 -> rst:0x7 (TG0WDT_SYS_RST),boot:0x8 (SPI_FAST_FLASH_BOOT) 22:47:40.619 -> Saved PC:0x4004c0dc 22:47:40.619 -> invalid header: 0xffffffff

Visual Studio + Platformio:

Use the [env:esp32c3] Build & upload ->

In terminal: ESP-ROM:esp32c3-api1-20210207 Build:Feb 7 2021 rst:0x3 (RTC_SW_SYS_RST),boot:0x8 (SPI_FAST_FLASH_BOOT) Saved PC:0x403cf752 SPIWP:0xee mode:DIO, clock div:1 load:0x3fcd5810,len:0xf4 load:0x403cc710,len:0x8a0 load:0x403ce710,len:0x2274 entry 0x403cc710

I have used it as a nat router so the hardware works.

sonite commented 4 months ago

New Setup in Platformio

[env:esp32c3]
platform = espressif32
framework = arduino
board = seeed_xiao_esp32c3
board_build.mcu = esp32c3
board_build.f_cpu = 160000000L
board_build.f_flash = 80000000L
board_build.flash_mode = qio
build_flags = ${common.build_flags}
lib_ldf_mode = off
lib_compat_mode = off
lib_deps = ${esp32.lib_deps}
lib_ignore = ${common.lib_ignore}
extra_scripts = ${common.extra_scripts}

It's unreliable but AMS2MQTT network is created and found. Can some times load the first config page 192.168.4.1. But as soon as I have saved Generic ESP and just picked a pin, SAVE. It stops working proper.

Terminal give me and then stops, It's like it just jump over the setting page of network:

09:10:54.086 -> (I) AMS bridge started

09:10:54.086 -> (I) Voltage: 0.00V

09:10:54.086 -> (D) ESP32 LittleFS

09:10:54.086 -> (D)  size: 1441792, used: 8192

09:10:54.118 -> (I) -----------------------------------------------

09:10:54.118 -> (I) --Network configuration--

09:10:54.118 -> (I) SSID:                 ''

09:10:54.118 -> (I) Psk:                  ''

09:10:54.118 -> (I) Hostname:             'ams-ec5d'

09:10:54.118 -> (I) IPv6:                 'No'

09:10:54.118 -> (I) mDNS:                 'Yes'

09:10:54.118 -> (I) 802.11b:              'Yes'

09:10:54.118 -> (I) 

09:10:54.118 -> (I) --MQTT configuration--

09:10:54.118 -> (I) Enabled:              No

09:10:54.118 -> (I) 

09:10:54.118 -> (I) --Web configuration--

09:10:54.118 -> (I) Security:             0

09:10:54.118 -> (I) 

09:10:54.118 -> (I) --Meter configuration--

09:10:54.153 -> (I) HAN RX:               2

09:10:54.153 -> (I) HAN RX pullup         Yes

09:10:54.153 -> (I) Baud:                 0

09:10:54.153 -> (I) Parity:               0

09:10:54.153 -> (I) Invert serial:        No

09:10:54.153 -> (I) Buffer size:          64

09:10:54.153 -> (I) Distribution system:  2

09:10:54.153 -> (I) Main fuse:            40

09:10:54.153 -> (I) Production Capacity:  0
gskjold commented 4 months ago

Try 2.3.4

sonite commented 4 months ago

Try 2.3.4

TY so much for replying. 2.3.4 is slightly better, but something breaks after the "AMS reader SNAPSHOT" or vendor settings.

When using the original setup in platfomio:

[env:esp32c3]
platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.07.00/platform-espressif32.zip
framework = arduino
board = esp32-c3-devkitm-1
board_build.mcu = esp32c3
build_flags = ${common.build_flags}
lib_ldf_mode = off
lib_compat_mode = off
lib_deps = ${esp32.lib_deps}
lib_ignore = ${common.lib_ignore}
extra_scripts = ${common.extra_scripts}

This won't allow the Terminal to run. But The AP starts. I can enter the IP in my browser and: bild

I tried this multiple times and chose the two different board types with UART0 and GPIO2, Save. The Network page is shown for about 10s (192.168.4.1/setup) and it dies.

When using slightly different settings in platformio I get some results from the Terminal. It just seems like the installation process stops when going to network setup. After that the device have saved the "zero" setting and just stops:

[env:esp32c3]
platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.10.01/platform-espressif32.zip
framework = arduino
board = seeed_xiao_esp32c3
board_build.mcu = esp32c3
board_build.f_cpu = 160000000L
board_build.f_flash = 80000000L
board_build.flash_mode = qio
build_flags = ${common.build_flags}
lib_ldf_mode = off
lib_compat_mode = off
lib_deps = ${esp32.lib_deps}
lib_ignore = ${common.lib_ignore}
extra_scripts = ${common.extra_scripts}
15:32:34.235 -> (I) AMS bridge started
15:32:34.235 -> (I) Voltage: 0.00V
15:32:34.235 -> (D) ESP32 LittleFS
15:32:34.235 -> (D)  size: 1441792, used: 8192
15:32:34.347 -> (I) No configuration, booting AP
15:32:34.347 -> (I) Entering setup mode
15:32:34.347 -> (I) (setupHanPort) Setting up HAN on pin -1/-1 with baud 0 and parity 0
15:32:34.514 -> (D) Hardware serial
15:32:34.514 -> 

The configuration stops. I restart the device and get this result:

5:36:55.745 -> (I) AMS bridge started
15:36:55.745 -> (I) Voltage: 0.00V
15:36:55.745 -> (D) ESP32 LittleFS
15:36:55.745 -> (D)  size: 1441792, used: 8192
15:36:55.745 -> (I) -----------------------------------------------
15:36:55.745 -> (I) --Network configuration--
15:36:55.745 -> (I) SSID:                 '  
15:36:55.745 -> (I) Psk:                  '
15:36:55.745 -> (I) IP:                   '   
15:36:55.745 -> (I) Gateway:              '                                 
15:36:55.745 -> (I) Subnet:               '                            
15:36:55.745 -> (I) DNS1:                 '                              ?ж ?„ ?Є ?J) B  ?0  ?'
15:36:55.745 -> (I) DNS2:                 '       ?ж ?„ ?Є ?J) B  ?0  ?'
15:36:55.745 -> (I) Hostname:             '                ?ж ?„ ?Є ?J) B  ?0  ?'
15:36:55.745 -> (I) IPv6:                 'Yes'
15:36:55.745 -> (I) mDNS:                 'Yes'
15:36:55.745 -> (I) 802.11b:              'Yes'
15:36:55.745 -> (I) 
15:36:55.745 -> (I) --MQTT configuration--
15:36:55.746 -> (I) Enabled:              Yes
15:36:55.746 -> (I) Host:                 '                      
15:36:55.746 -> (I) Port:                 65535
15:36:55.746 -> (I) Client ID:            '                          
15:36:55.777 -> (I) Publish topic:        '                       
15:36:55.777 -> (I) Subscribe topic:      '                        
15:36:55.777 -> (I) Username:             '              
15:36:55.777 -> (I) Password:             '            
15:36:55.777 -> (I) Payload format:       255
15:36:55.777 -> (I) SSL:                  Yes
15:36:55.777 -> (I) 
15:36:55.777 -> (I) --Web configuration--
15:36:55.777 -> (I) Security:             255
15:36:55.777 -> (I) Username:             '         
15:36:55.777 -> (I) Password:             '         
15:36:55.808 -> (I) 
15:36:55.808 -> (I) --Meter configuration--
15:36:55.808 -> (I) HAN RX:               20
15:36:55.808 -> (I) HAN RX pullup         Yes
15:36:55.808 -> (I) Baud:                 0
15:36:55.808 -> (I) Parity:               0
15:36:55.808 -> (I) Invert serial:        No
15:36:55.808 -> (I) Buffer size:          64
15:36:55.808 -> (I) Distribution system:  2
15:36:55.808 -> (I) Main fuse:            40
15:36:55.808 -> (I) Production Capacity:  0
15:36:55.808 -> (I) 
15:36:55.808 -> (I) --GPIO configuration--
15:36:55.808 -> (I) LED pin:              255
15:36:55.808 -> (I) LED inverted:         Yes
15:36:55.808 -> (I) LED red pin:          255
15:36:55.808 -> (I) LED green pin:        255
15:36:55.808 -> (I) LED blue pin:         255
15:36:55.808 -> (I) LED inverted:         Yes
15:36:55.808 -> (I) AP pin:               255
15:36:55.808 -> (I) Temperature pin:      255
15:36:55.808 -> (I) Temp analog pin:      255
15:36:55.808 -> (I) Vcc pin:              255
15:36:55.808 -> (I) LED disable pin:      255
15:36:55.808 -> (I) LED behaviour:        0
15:36:55.808 -> (I) Vcc multiplier:       1.000000
15:36:55.808 -> (I) GND resistor:         0
15:36:55.849 -> (I) Vcc resistor:         0
15:36:55.849 -> (I) 
15:36:55.849 -> (I) --Domoticz configuration--
15:36:55.849 -> (I) Enabled:              No
15:36:55.849 -> (I) 
15:36:55.849 -> (I) --NTP configuration--
15:36:55.849 -> (I) Enabled:              Yes
15:36:55.849 -> (I) Timezone:                             
15:36:55.849 -> (I) Server:                                        
15:36:55.849 -> (I) DHCP:                 Yes
15:36:55.849 -> (I) 
15:36:55.849 -> (I) 
15:36:55.849 -> (I) --UI configuration--
15:36:55.891 -> (I) Language:             en
15:36:55.891 -> (I) --UI configuration--
15:36:55.891 -> (I) Enabled:              Yes
15:36:55.891 -> (I) Hostname:                         
15:36:55.891 -> (I) Client ID:            ffffffff-ffff-ffff-ffff-ffffffffffff
15:36:55.891 -> (I) Interval:             255
15:36:55.891 -> (I) -----------------------------------------------
15:36:55.891 -> (I) Connecting to WiFi network:       
15:36:55.891 -> (I) Marking /translations-en.json for download
15:36:55.964 -> (I) (setupHanPort) Setting up HAN on pin 20/-1 with baud 0 and parity 0
15:36:56.043 -> (D) Hardware serial
15:36:56.043 -> 
sonite commented 4 months ago

2.2.28 works so far that I at last see the device in my home network and occupationally can configure it in its UI. Tomorrow I'll try 2.2.27 that works wit my ESP8266. E.g. this version is unstable for my XIAO ESP32C3.

ArnieO commented 4 months ago

It seems we have an issue with later builds for C3.

sonite commented 4 months ago

Tested 2.2.27 But it freezes after 15-39s. It seems to fetch the time and than just stop. I've removed the line ESP.deepSleep on row 352 in AmsToMqttBridge.cpp. I'm a bit unexperienced. Any suggestion what else I can do? bild

sonite commented 4 months ago

Observation by visuals. Every time HAN turns red. it stops. Another note. The XIAO ESP32C3 pin number 20-21 is not selectable: bild xiao_esp32c3_pinout_top

ArnieO commented 4 months ago

Thank you for the update - but as our readers do not use C3, we are not able to put high priority on solving. the "C3 issue".

Try older firmware versions (I am puzzled that 2.2.27 apparently do not work) and do an "Erase flash" before flashing - to be sure the device is clean.

sonite commented 4 months ago

Thank you for the update - but as our readers do not use C3, we are not able to put high priority on solving. the "C3 issue".

Try older firmware versions (I am puzzled that 2.2.27 apparently do not work) and do an "Erase flash" before flashing - to be sure the device is clean.

Thank you for replying and highlighting the importance of 'Erase Flash.' I've spent a couple of hours trying out the firmwares. While I can't definitively say if they work or not, here's what I've discovered:

bild

The reason I initially thought versions 2.3.4, 2.2.27, and 2.2.28 didn't work was probably because I attempted to change the board configuration to 'seeed_xiao_esp32c3,' a habit I carried over from version 2.3.5. However, they do work the original setting board = esp32-c3-devkitm-1 .

I utilized Flash Download Tool 3.9.5 to establish the USB connection upon reset and erased with QIO settings set as SPI mode. Following that, I used 'Erase Flash' in Visual Platformio just to ensure a clean slate before uploading all these firmwares.

ArnieO commented 4 months ago

Your observations are then the same as some others have seen: C3 builds for v2.2.x work, but not v2.3.x.

sonite commented 4 months ago

Three other observations (2.3.4 up n running):

But the other stuff works, MQTT sending to my Home assistant. ENTSO-E API ok.

gskjold commented 3 months ago

EDIT: First file was wrong, try this one: esp32c3.zip

avandorp commented 3 months ago

Your observations are then the same as some others have seen: C3 builds for v2.2.x work, but not v2.3.x.

2.3.4 works on my C3, OTA fails for 2.3.5 because of insufficient space, didn't try USB flashing yet because I would have to dismantle the installation.

gskjold commented 3 months ago

Have you tried the firmware from my previous comment?

sonite commented 3 months ago

Have you tried the firmware from my previous comment?

Hi, Thanks fo all the good work. Since I have 2.3.5 up n running after so much issues. I have to see if I can free another C3 for this project. Don't want to break something that works. Maybe at the end of the week. BR S

dbeinder commented 3 months ago

EDIT: First file was wrong, try this one: esp32c3.zip

@gskjold Your d0621e9 build works on C3 when flashed via USB/Serial, but web upgrade is still a problem, due to size limit:

ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x3 (RTC_SW_SYS_RST),boot:0xd (SPI_FAST_FLASH_BOOT)
Saved PC:0x40381d6a
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd5810,len:0xf4
load:0x403cc710,len:0x8a4
load:0x403ce710,len:0x2228
entry 0x403cc710
(I) AMS bridge started
(I) Voltage: 0.00V
WiFi.Mode(0) CUR=0
WiFi.Mode(1070184508) no change
(D) ESP32 LittleFS
(D)  size: 1441792
(I) Found firmware
(I)  flashing
(D)  firmware size: 1308848
(D)  available: 1306624
(I) -----------------------------------------------
gskjold commented 3 months ago

I've made a version where remote debugging have been stripped out: esp32c3.zip

It seems to be the only way to make this work for now...

dbeinder commented 2 months ago

For devs who want to keep hacking on their DIY devices with RemoteDebug before #805 is finished, here's a branch with modified partitions and working firmware upload: https://github.com/dbeinder/amsreader-firmware/tree/c3-big-app