atc1441 / ZBS_Flasher

Arduino C++ Library and interface to flash the ZBS243 / SEM9110 8051 Microcontroller
138 stars 25 forks source link

Label doesn't reboot using pass through mode with an ESP32 #18

Closed Albert-nl closed 1 year ago

Albert-nl commented 1 year ago

Hi,

when I tried to use pass trough mode with a 2.9" RBW e-label using an ESP32, the label didn't properly reboot. I got this message on the uart tx output:

$ python3 zbs_flasher.py /dev/ttyUSB0 read image pass Using port: /dev/ttyUSB0 ZBS Flasher version: 32 Reading flash now 65536 / 65536 100% 11 seconds Reading flash done, now saving the file Saving file done, it took 11 seconds ZBS Reset Pass Through mode: booted at 0x1aec Reset reason: 00 SFDP: header not found failed to init eeprom

It seemed to me the hardware SPI from the ESP somehow locked the SPI bus for the label. After adding a spi->end() in the reset function this was solved.

diff --git a/ESP32_Flasher/src/zbs_interface.cpp b/ESP32_Flasher/src/zbs_interface.cpp
index df8f650..5675b9a 100644
--- a/ESP32_Flasher/src/zbs_interface.cpp
+++ b/ESP32_Flasher/src/zbs_interface.cpp
@@ -88,6 +88,7 @@ void ZBS_interface::enable_debug()

 void ZBS_interface::reset()
 {
+    spi->end();
     pinMode(_SS_PIN, INPUT);
     pinMode(_CLK_PIN, INPUT);
     pinMode(_MOSI_PIN, INPUT);

With that fix the label rebooted properly, pass throuh mode worked and I could see the label associated to the master

Hope that helps, Albert

atc1441 commented 1 year ago

Thanks a lot, did add it to the code

Albert-nl commented 1 year ago

Great, working fine indeed.