hn / ginlong-solis

Solis inverter ESP8266 data logger, S3 WiFi stick reverse engineering and ESPhome firmware
90 stars 16 forks source link

Can't upload to S3 #7

Closed hcouplet closed 1 year ago

hcouplet commented 1 year ago

I have an error when uploading the firmware. It start flashing, then after some time, I am getting an error : ValueError: Failed to write to 0x800B000

Here is the log :

➜  libretiny-esphome git:(platform/libretuya) ✗ python3.10 -m esphome upload solis2-stick.yaml --device
/dev/tty.SLAB_USBtoUART
INFO Reading configuration solis2-stick.yaml...
****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
Obsolete PIO Core v6.1.6 is used (previous was 6.1.7)
Please remove multiple PIO Cores from a system:
https://docs.platformio.org/en/latest/core/installation/troubleshooting.html
****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
Processing solis2-stick (board: generic-rtl8710bx-4mb-980k; framework: arduino; platform: libretiny)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Configuring upload protocol...
AVAILABLE: uart
CURRENT: upload_protocol = uart
Looking for upload port...
Using manually specified: /dev/tty.SLAB_USBtoUART
Uploading .pioenvs/solis2-stick/firmware.uf2
|-- Detected file type: UF2 - esphome 2023.5.0-dev
|-- Connecting to 'Realtek AmebaZ' on /dev/tty.SLAB_USBtoUART @ 1500000
|   |-- Success! Chip info: Realtek RTL87xxB
|-- Writing '.pioenvs/solis2-stick/firmware.uf2'
|   |-- esphome 2023.5.0-dev @ 2023-05-23 00:27:42 -> generic-rtl8710bx-4mb-980k
|-- ValueError: Failed to write to 0x800B000
|   |-- File "/usr/local/lib/python3.10/site-packages/ltchiptool/soc/ambz/flash.py", line 147, in flash_write_raw

My chip looks the same as yours : IMG_7466

hn commented 1 year ago

Please try to solely flash the app alone using the Python2 version of rtltool:

python2 ./rtltool2.py -p /dev/ttyUSB0 wf 0xb000 ./.esphome/build/solis-inv/.pioenvs/solis-inv/image_0x00B000.ota1.bin
hcouplet commented 1 year ago

Thanks for your response. It helped a lot. Now I can flash it and it's working.

Here are my findings.

  1. As the link to the russian site for rtltool.py was dead, so I used rtltool.py from https://hackaday.io/project/182205-py-ft10/log/206206-rtltool or https://github.com/cyber-murmel/rtltool. They are both the same and may be you could update the reference.
  2. for the rtltool.py, no need for the "RTL8762x MP Tool Kits(ZIP)". Just run trltool.py with pyton2.7 3
    I have issue with OTA. It says that the Auth is not correct. I had to flash in twice (not sure if the is correct) at 0xb000 and at 0x100000
/Users/hcouplet/.pyenv/versions/2.7.18/bin/python2 /Users/hcouplet/prg/projects/other/homeassistant/solis-stick/rtltool.py \
    -p /dev/tty.usbserial-0001 wf 0xb000 \
    /Users/hcouplet/prg/projects/other/homeassistant/solis-stick/libretiny-esphome/.esphome/build/solis2-stick/.pioenvs/solis2-stick/image_ota1.0x00B000.bin

/Users/hcouplet/.pyenv/versions/2.7.18/bin/python2 /Users/hcouplet/prg/projects/other/homeassistant/solis-stick/rtltool.py \
    -p /dev/tty.usbserial-0001 wf 0x100000 \
    /Users/hcouplet/prg/projects/other/homeassistant/solis-stick/libretiny-esphome/.esphome/build/solis2-stick/.pioenvs/solis2-stick/image_ota2.0x100000.bin

I ended up disabling OTA Password and OTA is working fine (I needed this before putting back the S3 card into the case to be able to update remotely the firmware). I updated ota_component.cpp to bypass the wrong ota password commenting line at 239 : image After that flashing is working fine but the response is not valid (bypass error message). it's some kind of digest auth with nonce and cnonce, may be the version in that tree has something wrong.

  1. I did all the initial flash on my mac but after installed LibreTiny ESPHOME on my HA. ESPHome was already there and I can use both of them :
    image

For this I used the add repository button on https://github.com/libretiny-eu/esphome-hass-addon So now I am using the libretiny version only for my solis S3. OTA (without password) is working fine.

hn commented 1 year ago
kuba2k2 commented 1 year ago

Hi, thanks for the ping.

  1. It seems that some people have issues with ltchiptool flashing (I don't, but others do...). Since there are many versions of rtltool scattered around the Internet (on github, forums, etc), both for Python 2 and 3... can you send the version which you've found to work the most reliably? It's possible that I broke the one used in ltchiptool somehow, or maybe it was broken since I got it in the first place.
  2. @hcouplet you're actually the second person reporting OTA issues lately (see https://github.com/kuba2k2/libretiny/issues/142). @hn do you have the latest version of LibreTiny (AND esphome) installed? Maybe there's something that changed in latest ESPHome versions that needs a fix on Realtek.
hn commented 1 year ago

@kuba2k2

I use this rtltool version for python2, created by @pvvx, It always worked so far.

If I remember correctly, I re-installed both LibreTiny and ESPhome when you released LT 1.0.2 (May 11). Unlike @hcouplet, I don't have any (OTA-)problems with these versions, so everything is fine (except the strange ModBus sync problem, but that's a different story).