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

Topics concerning the Tesla front and rear drive unit drop-in board
User avatar
nubster
Posts: 78
Joined: Sat Oct 29, 2022 7:20 pm
Location: Los Angeles
Has thanked: 37 times
Been thanked: 6 times

How to program ESP32 Web Interface on V8 SDU board?

Post by nubster »

Hey all. Is there a guide for how I can go about programming the new ESP32-WROOM-32 wifi module with the web interface on a new/unprogrammed V8 board?

I'm attempting to follow the readme: https://github.com/jsphuebner/esp8266-web-interface, but it seems very specific to ESP8266 wifi modules. The V8 board uses an ESP32 module now, so are these two modules similar enough that I should be able to follow the same instructions, with only changing a few things?

I tried the Arduino & Platform.io methods and changing anything obvious (like the serial port ID), but I am getting various errors depending on which method used. I also don't see ESPRESSIF ESP32-WROOM available in the Arduino IDE board manager, and the platform.io configs have a lot of references to ESP8266xxx libraries, so I'm not sure if I am going down the right path here. I searched GitHub for an updated/different repo but didn't find anything.

I have some experience with Arduino, but this is my first time interacting with an ESP32 module, so please forgive my ignorance. I managed to program the STM32 successfully via the ST-Link Utility and got a red blinking LED. I just need to figure out this last bit.

Thanks!! :pray:
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 »

royhen99
Posts: 208
Joined: Sun Feb 20, 2022 4:23 am
Location: N. Wiltshire. UK
Has thanked: 15 times
Been thanked: 96 times

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

Post by royhen99 »

I have tried in both platform.io and Arduino IDE and both compile but I can not get the SPIFSS size set correctly in platform.io.
If this is wrong I just get "FileNotFound" when connecting to the web page.

In arduino IDE I used ESP32 DEV Module and set the partion scheme to Huge APP. This gives a 1MB SPIFSS which seems to be needed on both the ESP32 and EPS8266.

To work correctly the number of stop bits needs setting to 2, in line 73 and 139 of inverter.cpp.
interface->begin(DEFAULT_BAUD, SERIAL_8N2);

After compiling connect to the wifi module and use upload.sh to upload the files to the file system.

https://github.com/Bedz01/esp32-web-interface-port
upload.sh from https://github.com/Pete9008/esp32-web-i ... /tree/johu

edit: Although I can get Bedz01 version running web page etc, there are problems with the AP/STA connection logic, so not recommended.
User avatar
nubster
Posts: 78
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: Fri Mar 31, 2023 9:44 pm This may help https://openinverter.org/forum/vie ... 74#p52874
Ahh. Thank you guys, this makes way more sense. I'll give it a shot later today/tomorrow. Much appreciated!
User avatar
johu
Site Admin
Posts: 5759
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 157 times
Been thanked: 1005 times
Contact:

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

Post by johu »

I use the port from Petes repo also and he has integrated my changes. The Bedz port didn't work for me. When programming new boards I use platformio.
I have a cheap USB->TTL cable with a 5V pin. This can be used and via the SDU boards 3.3V regulator will power up the board.
On the 6-pin header "Prog" and "Gnd" must be bridged for programming mode, the other pins connected as labeled.
Then run

Code: Select all

pio run --target upload
power cycle by unplugging, then run

Code: Select all

pio run --target uploadfs
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
nubster
Posts: 78
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: Sat Apr 01, 2023 7:23 pm I use the port from Petes repo also and he has integrated my changes. The Bedz port didn't work for me. When programming new boards I use platformio.

I have a cheap USB->TTL cable with a 5V pin. This can be used and via the SDU boards 3.3V regulator will power up the board.
On the 6-pin header "Prog" and "Gnd" must be bridged for programming mode, the other pins connected as labeled.
Thanks for clarifying your process and how to get into programming mode!

I also have a cheap USB-TTL adapter with 5v pin, so perfect. I'll keep this thread updated and perhaps contribute to the documentation when I'm done since I'm new to all this and may be in a better position to clarify and beef up the docs for someone new like myself.
User avatar
nubster
Posts: 78
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 »

Ok, I had some time to try Pete's repo yesterday, but I keep getting the error: Failed to connect to ESP32: No serial data received when I try to run:

Code: Select all

 pio run --target upload
I'm using a 6-pin header + jumper to bridge PROG and GND per @johu's comment and confirmed the voltage is 0v when running.

After cloning Pete's repo and installing the PlatformIO Core CLI, on both my Mac and PC I ran:

Code: Select all

pio device list
and see:

Mac:

Code: Select all

/dev/cu.usbserial-0001
----------------------
Hardware ID: USB VID:PID=10C4:EA60 SER=0001 LOCATION=2-1.2.3
Description: CP2102 USB to UART Bridge Controller

/dev/cu.SLAB_USBtoUART
----------------------
Hardware ID: USB VID:PID=10C4:EA60 SER=0001 LOCATION=2-1.2.3
Description: CP2102 USB to UART Bridge Controller
PC:

Code: Select all

COM3
----
Hardware ID: USB VID:PID=10C4:EA60 SER=0001 LOCATION=1-2.2.3
Description: Silicon Labs CP210x USB to UART Bridge (COM3)
I created an platformio-local-override.ini in the project with:

Code: Select all

[env]
board_build.flash_mode = qout
upload_port = /dev/cu.usbserial-0001
upload_speed = 921600

monitor_port = /dev/cu.usbserial-0001
monitor_speed = 115200
I tried all three ports but I just get the same error no matter if I'm on Mac or PC.

Reading thru various ESP32 forums and videos I'm finding a lot of folks suggesting to add a capacitor to the EN pin of the ESP32 to fix this error, but it looks like the board already has one (C60). I also installed the drivers for the USB TTL adapter but didn't seem to help.

Attached is a pic of how I am connecting the serial adapter.
PXL_20230404_164441340.jpg
Any ideas about what I might be missing/doing wrong?
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 »

You may need to give the board a reset prior to running the command?

I have two setups dependant on what I'm programming. On a ESP32 eval board I hold the PROG button while pressing the reset button to get into programming mode (if doing it in PlatformIO you can see the bootloader start up in the terminal window). When programming my own board I have RTS driving the ESP reset line (automatically driven by pio) and the prog line linked to gnd on the programming header.

Edit - I tend to use the platformIO tab in Visual studio and the Upload and Upload Filesystem Image commands to program the board. I believe you can do the same in the Arduino IDE but haven't tried it.
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 »

Just had a look at the schematic - no reset button so ignore the above. With pin1 and pin2 of the programming header linked it should power up into programming mode. Also bear in mind that rx and tx are swapped on the schematic so tx on the header actually goes to tx on the dongle (no crossover needed).
User avatar
nubster
Posts: 78
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 »

Thanks for the quick reply, Pete!

I'm unsure what you mean about the "reset line." What reset line exactly? Are you saying that somehow you can programmatically send a signal to a pin to trigger a reset instead of manually disconnecting/reconnecting the power? I don't see a reset pin on the SDU board, so I'm a little confused... please let me know if I am misunderstanding. To clarify, I've been "resetting" by unplugging the entire USB adapter and then plugging it back in.

I didn't notice the PlatformIO tab had a bunch of functions until just now. FWIW - I tried the "monitor" function, and see:

Code: Select all

 *  Executing task: platformio device monitor --environment release 

pyenv shell 3.10.6
--- Terminal on /dev/cu.usbserial-0001 | 115200 8-N-1
--- Available filters and text transformations: colorize, debug, default, direct, esp32_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at https://bit.ly/pio-monitor-filters
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H
Does this tell you if it's getting into programming mode or not? What does it actually say when it successfully enters programming mode? Do you think it's unable to connect because the module is not actually entering programming mode?
User avatar
nubster
Posts: 78
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: Tue Apr 04, 2023 6:44 pm Just had a look at the schematic - no reset button so ignore the above. With pin1 and pin2 of the programming header linked it should power up into programming mode. Also bear in mind that rx and tx are swapped on the schematic so tx on the header actually goes to tx on the dongle (no crossover needed).
Ok. No prob. It seems the image I posted isn't loading. Give me a sec to fix... it shows how I have it all wired up.
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 »

Sorry, different chip vendors call things different things. The En line is essentially the same as the reset line, when pulled low it resets the processor when high it enables the processor. On my board I use RTS to drive the En line low and reset the processor to put it into boot mode. On the V8 board you can't do that and have to power cycle it.

How are you powering your V8 board? From the USB adaptor or from another supply? If the former then unplugging the USB will reset the ESP, for the latter it won't.

I'll see if I can set my board up now and get a capture of what you should see.
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 »

This is what I see in the monitor window when powering the ESP up in programming mode (the waiting for download being the important bit):
Monitor.png
And then this is the end of the Upload sequence:
Upload.png
User avatar
nubster
Posts: 78
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 »

I fixed the image in my post above so you can see how I wired it. I have RX->TX, TX->RX, etc. My USB adapter doesn't have an RTS pin. I am new to UART, but I understand this signal indicates when it's ready to send data... so I think I understand what you're saying.

I am powering the board via the USB adapter 5v pin, per @Johu's comment above. I wonder if I should power it up separately and add the jumper after it's already running or something to get it to reset into programming mode.

Really appreciate the assistance!! :pray:
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 »

I think you need to swap your Rx and Tx lines, Tx-Tx and Rx-Rx. The lines look like they are already swapped on the V8 pcb.
User avatar
nubster
Posts: 78
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 »

Yeah, I tried swapping the TX/RX lines, but I got the same exact error.

Here is what I see:
Screen Shot 2023-04-04 at 12.45.30 PM.png
I noticed your monitor output indicates it is waiting for download, and mine does not. It feels like my issue is that it's just not going into programming mode.
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 »

Agree, it doesn't appear to be going into programming mode.

Do you have a multimeter? Could you check the voltages on the 3V3 pin (2nd from top on the left), EN pin (3rd from top on left) and IO0 pin (bottom pin on right) with respect to ground (top left or top right pin) on the ESP32?

Edit - best check on the ESP32 pins if possible, not the PCB connections (just in case of poor solder joints).

Edit2 - One other thing worth trying. With the USB connected and the monitor open try disconnecting and reconnecting the positive supply from the serial dongle to the PCB to rest the ESP32. Doing it that way means that the USB serial connection stays active so you stand a better chance of seeing the waiting for download message.
User avatar
nubster
Posts: 78
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: Tue Apr 04, 2023 8:00 pm Could you check the voltages on the 3V3 pin (2nd from top on the left), EN pin (3rd from top on left) and IO0 pin (bottom pin on right) with respect to ground (top left or top right pin) on the ESP32?

Edit - best check on the ESP32 pins if possible, not the PCB connections (just in case of poor solder joints).

Edit2 - One other thing worth trying. With the USB connected and the monitor open try disconnecting and reconnecting the positive supply from the serial dongle to the PCB to rest the ESP32. Doing it that way means that the USB serial connection stays active so you stand a better chance of seeing the waiting for download message.
  • 3V3 PIN: 3.200v
  • EN PIN: 3.197v
  • IO0 PIN: 0.000v
I also tried unplugging just the 5V wire from the serial dongle to see if that did anything but it doesn't seem to help. I attached the monitor output I see when doing that.
Screen Shot 2023-04-04 at 1.14.37 PM.png
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 »

Two things there are a little off. First the voltage is a little low, it should be much nearer 3.3V. Second the dongle appears to reset when you connect the 5V. Both these suggest that the dongle may be struggling to power the logic board. The ESP tends to take quite a big gulp of current when it starts up and it is possible that the dongle can't provide it.

It might be worth leaving the 5v to the dongle disconnected (GND, Tx and Rx still connected) and instead power the logic board up from a 12V supply (on 12V_IN) if you are able?
User avatar
nubster
Posts: 78
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 »

Sure! With 12V power to PIN13 and the 5V wire removed from the dongle:
  • 3V3 PIN: 3.281
  • EN PIN: 3.280
  • IO0 PIN: 0.0
I still see the same monitor output and error when programming. No indication of waiting for download. I tried bridging the PROG jumper before and after powering the board, but I didn't see any serial monitor activity when I did so. I even tried two other boards (I got five from JLCPCB), and so far, three have the same behavior.

When you ground/un-ground the PROG pin with the serial monitor connected, do you see activity indicating that it reset? Also, what OS are you using?
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 »

The voltages are much better, shame it's still not programming! Which way have you got Rx and Tx connected now?

Grounding/ungrounding prog shouldn't do anything. The ESP only samples the state of that line (IO0) when it powers up (comes out of reset). If it's low it runs the built in bootloader, if it's high it runs the normal user program. Once it's sampled it it doesn't matter what the line does till the next reset/power up. It's only doing a reset that should cause something to happen on the monitor (or a power cycle in your case).

To get it into programming mode with a separate supply turn off the 12V supply, make sure the the prog jumper link is fitted and turn the 12V power back on. The USB and dongle can be left connected throughout the process.

Edit - Linux (Ubuntu/Mint)

Edit2 - Afraid I'm out of ideas (and it's getting late here) - good luck with figuring it out!
User avatar
nubster
Posts: 78
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 »

Some promising developments. I'm not sure what I did, but the monitor finally said, "waiting for download". I then tried to program it, but it failed with the same error as before. When I rechecked the monitor, it seemed to be back in normal mode again. This happened ~3 times in a row. Now I can't seem to get it back into programming mode at all again. :? Something is off. Perhaps a flaky connection or order of operations thing. I will chase it down.

You have reassured me that I'm not totally missing a step and am mostly doing everything right. Thanks again for all the help. Have a good night!
User avatar
nubster
Posts: 78
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 »

So I can't get it to go into programming mode via USB 5V at all. I tried unplugging the entire USB dongle and just the 5V pin to reset it, but it always boots back into normal mode for me. Maybe I'm doing something wrong.

However, if I power the board via 12V, disconnect the USB 5V pin, and then flip the Tx & Rx pins so that Tx->Tx and Rx->Rx, it boots into programming mode consistently now, and I see "waiting for download" in the serial monitor!

Unfortunately, I still get the same error when trying to upload! Progress, at least. I'll keep at it.
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 »

Have you used the dongle for anything else, do you know whether it works? If not it would be worth testing it. With it disconnected from the V8 board just connect Tx back to Rx and then use a terminal program (something like putty or realterm) to send characters to the comm port and check that they are received back correctly.

Btw - not sure whether there is a time limit between the ESP entering the bootload and the download starting. I've never noticed one but seem to remember seeing something that mentioned a 10sec limit?
User avatar
johu
Site Admin
Posts: 5759
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 157 times
Been thanked: 1005 times
Contact:

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

Post by johu »

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.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
Post Reply