emmebrusa / TSDZ2-Smart-EBike-1

TSDZ2 Open Source Firmware adapted to VLCD5-VLCD6-XH18 displays
GNU General Public License v3.0
137 stars 34 forks source link

Flashing Issue, SWIM connection? #112

Open UteAkaKute opened 1 month ago

UteAkaKute commented 1 month ago

Hey everyone!

I'm trying to flash using a 36V TSDZ2 with XH18 display. The program seems to compile just fine but I am not able to get it to flash.

Screenshot 2024-08-11 143102

I have checked the SWIM connections which seem to be just fine. I doubt this is actually a hardware issue since I have been able to back up the stock firmware using STVP by reading the program memory, data memory, and option byte. STVP sometimes also gives this error, but I am able to read it after one more try.

image

I have been power cycling while pulling the RST pin low on my ST-LINK V2 using the GND pin. I have updated the firmware on my STLINK v2 using STM32CubeProgrammer I have checked the main.hex (which seemed fine and not corrupted) and I have checked data_empty.hex, which was not in .../bin. ? I have checked the STlink connections numerous times.

Does anyone know what I can do to solve this flashing issue?

dzid26 commented 1 month ago

Nothing to do with the TSDZ2 firmware.

Things to try:

UteAkaKute commented 1 month ago

@dzid26 Wow thanks for the quick reply!

S104480000B3 S104480100B2 S10448032888 S104480500AE S104480700AC S104480900AA S104480b00A8 S104480d00A6 S104487e0035 S9030000FC

Also: I get the same STVP error message first two tikes trying to flash like I did when reading memory in STVP.

Quick note, I measured the voltage across GND and SWIM which is 5V, which indicates I should be able to flash (if i understood correctly)

dzid26 commented 1 month ago

Turning off the ebike battery and unpowering the USB does not make a difference, I have also tried this numerous times when power cycling

Looking at my old note https://github.com/vdudouyt/stm8flash/issues/123#issuecomment-2053753930 I have one thing to add. - When you power down the controller, wait 5minutes for the capacitors to discharge.

Other than that, it could be simply broken contact.

UteAkaKute commented 1 month ago

I have tried this waiting for capacitor discharge a number of times now, also to no avail. I remember now I might have programmed optionbyte using STM8S105x6 instead of STM8S105x4 which I was supposed to do I think. Now for some reason I can't read or program at all using STVP. The bike itself does still work. I'm ordering a new and better quality STLink somewhere to see if the connection issue might be due to a bad stlink. I read this here: https://www.pedelecs.co.uk/forum/threads/tsdz2-connection-error-with-st-linkv2.41873/

Wouldnt a broken contact be weird considering I was able to read and program?

dzid26 commented 1 month ago

When you wait for capacitors to be discharged, you can try powering up with nrst tied to ground as I mentioned in my note and then trying to flash option byte or unlock the chip with stm8flash.

Bad contacts could work sometimes.