How to program ESP32 Web Interface on V8 SDU board?  [SOLVED]

Topics concerning the Tesla front and rear drive unit drop-in board
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: How to program ESP32 Web Interface on V8 SDU board?

Post by Pete9008 »

Yep, that would do it!

That's why I dont use UART0 to talk to the stm on my board - I'd forgotten that you do on yours.
User avatar
nubster
Posts: 77
Joined: Sat Oct 29, 2022 7:20 pm
Location: Los Angeles
Has thanked: 37 times
Been thanked: 6 times

Re: How to program ESP32 Web Interface on V8 SDU board?

Post by nubster »

Pete9008 wrote: Wed Apr 05, 2023 7:38 am Have you used the dongle for anything else, do you know whether it works?
No idea. This is the first time I've ever tried using it, so point taken. I bought it a few months back for another project but didn't end up needing it. I'll test it as you suggest and keep the 10s timeout in mind.
johu wrote: Wed Apr 05, 2023 8:25 am Oh, one thing I haven't mentioned: the STM32 mustn't be programmed, otherwise you get bus contention on the TX line! So either erase it or hold it in reset.
Hmm, OK. I was indeed always programming the STM32 first, so I'll try programming the ESP32 first on a new board next attempt. I also realized I'm intermittently getting a different error saying, "Invalid head of packet (0x12): Possible serial noise or corruption", so perhaps this explains why.

I'll have some time later today to try these suggestions and post my results.
User avatar
nubster
Posts: 77
Joined: Sat Oct 29, 2022 7:20 pm
Location: Los Angeles
Has thanked: 37 times
Been thanked: 6 times

Re: How to program ESP32 Web Interface on V8 SDU board?

Post by nubster »

Success!

Erasing the STM32 seemed to be the final key that allowed me to program the ESP32, and I can now access the web interface! Thank you, guys!!

Now I just need to figure out how to load and save the default parameters. When I upload the parameter file, message says it's loading them, but then they never populate under the Parameters section, and the Save to Flash button doesn't seem to work. Is the following thread relevant/should I try those builds?: viewtopic.php?t=3328&start=25#top?
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: How to program ESP32 Web Interface on V8 SDU board?

Post by Pete9008 »

nubster wrote: Thu Apr 06, 2023 6:05 am Success!

Erasing the STM32 seemed to be the final key that allowed me to program the ESP32, and I can now access the web interface! Thank you, guys!!
Glad it's working :)
nubster wrote: Thu Apr 06, 2023 6:05 am Now I just need to figure out how to load and save the default parameters. When I upload the parameter file, message says it's loading them, but then they never populate under the Parameters section, and the Save to Flash button doesn't seem to work. Is the following thread relevant/should I try those builds?: viewtopic.php?t=3328&start=25#top?
Probably not, all those files are FOC builds (for permanent magnet motors). Is st-link reporting the flash size correctly? If so then this isn't your problem.

You should see the default parameters straight from the start (no need to load them). If you don't it suggest that the STM isn't running. You have disconnected the ESP serial programming dongle after programming it haven't you? If it is still connected it will interfere with the STM comms in the same way that the STM interfered with the programming.
User avatar
nubster
Posts: 77
Joined: Sat Oct 29, 2022 7:20 pm
Location: Los Angeles
Has thanked: 37 times
Been thanked: 6 times

Re: How to program ESP32 Web Interface on V8 SDU board?

Post by nubster »

Yes, the ST-Link reports Flash size is 128KBytes (see attached pic), and I am indeed disconnecting the ST-Link and restarting the board before accessing the web interface. The red LED is flashing, which I thought indicated the STM32 is running properly, but maybe that isn't always the case. Yet when I connect to the web interface it is void of any parameters, I cannot seem to load any, nor start the inverter.

I'm flashing the v5.24.R release of the stm32_foc.hex asset found here: https://github.com/jsphuebner/stm32-sine/releases. I noticed the name of the asset doesn't seem correct since as you said, it's not FOC but Sine. Is this just a simple typo, or am I flashing the wrong firmware?
image.png
FWIW - I encountered a similar behavior a few times before while installing a V7 board. I was working on the wiring harness, and "all of a sudden" the interface stopped auto-updating. When I hit refresh all the parameters were gone and I could not load them or start the inverter. The inverter was basically non-responsive until restarting it, which fixed it and all the parameters were back. I chalked it up to me working on the harness since once I had everything wired up and running properly I haven't seen it again.
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: How to program ESP32 Web Interface on V8 SDU board?

Post by Pete9008 »

Doesn't look like the flash size is you problem so the other thread isn't relevant.

You probably need to go back to an earlier version (5.00??) to find a pre-built version of the sin code (the only recent changes have been to the foc version). Also worth checking catphish's current control code if you don't need regen (viewtopic.php?t=3086).

You are using the johu fork of the ESP code aren't you https://github.com/Pete9008/esp32-web-i ... /tree/johu? The master version won't work on your board as it uses a different comm port pinout.

One other check worth doing is to connect just the Rx line (and GND) from you serial dongle to the ESP programming header and then watch what is received in a terminal program. The ESP should send the 'json' command each time you update the web page (should see this if connected to the Rx line on the pin header) and the STM should respond with a long block of parameter data in human readable format (should see this if connected to the Tx header pin). The baud rate will either be 115200 or 921600 depending on whether the switch to fastbaud rate has worked.
User avatar
nubster
Posts: 77
Joined: Sat Oct 29, 2022 7:20 pm
Location: Los Angeles
Has thanked: 37 times
Been thanked: 6 times

Re: How to program ESP32 Web Interface on V8 SDU board?

Post by nubster »

Pete9008 wrote: Sat Apr 08, 2023 10:09 am You probably need to go back to an earlier version (5.00??) to find a pre-built version of the sin code (the only recent changes have been to the foc version)...

You are using the johu fork of the ESP code aren't you https://github.com/Pete9008/esp32-web-i ... /tree/johu? The master version won't work on your board as it uses a different comm port pinout.
Ok, I finally got it!

I was using the stm32_foc.hex asset because that was the only one I saw in the latest release (v5.24.R), but I see now if I explore older releases, there is a stm32_sine.hex asset available. After switching to the johu branch of the esp32-web-interface and downloading & flashing the stm32_sine.hex (v5.20.R-2), I am good to go.

So I was using the wrong STM firmware AND the wrong ESP branch. :?

This was quite the journey for me, and I learned a lot! Thank you and @johu for guiding me through everything. I took a lot of notes and am happy to contribute a how-to guide detailing the process of building a Tesla SDU board from scratch. If this is something you think the community would appreciate, please let me know where to submit a PR. Assuming https://github.com/jsphuebner/Tesla-Front-Drive-Unit would be the most appropriate, but let me know otherwise.
User avatar
johu
Site Admin
Posts: 5684
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 960 times
Contact:

Re: How to program ESP32 Web Interface on V8 SDU board?

Post by johu »

Yes, feel free to add it there.
might eventually make sense to shell it out as it's the same procedure on all esp32 based oi boards
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
nubster
Posts: 77
Joined: Sat Oct 29, 2022 7:20 pm
Location: Los Angeles
Has thanked: 37 times
Been thanked: 6 times

Re: How to program ESP32 Web Interface on V8 SDU board?

Post by nubster »

johu wrote: Sun Apr 09, 2023 7:45 pm Yes, feel free to add it there.
PR submitted!
Post Reply