A little help with SDU V9 anyone?

Topics concerning the Tesla front and rear drive unit drop-in board
Post Reply
User avatar
SuppaTenko
Posts: 13
Joined: Mon Nov 13, 2023 1:40 pm
Has thanked: 1 time
Been thanked: 4 times
Contact:

A little help with SDU V9 anyone?

Post by SuppaTenko »

I decided to try Tesla SDU board. I can't order directly, so I generated gerbers and ordered boards, then soldered them. Decided to make V8 or V9 with ESP32. The difference between V8 and V9 is not so big, so used V9 for the sake of freshness. Soldered all components, and now I'm ready to flash.
So, my actions now should look like this:
- flash ESP32 sketch
- flash ESP32 filesystem
- flash STM32 fw
- apply Tesla settings from git and test on real motor

My questions:
First of all, which version of ESP32 firmware should I use?
Is it this one? https://github.com/jsphuebner/esp32-web-interface/
I also found this thread:
viewtopic.php?t=3478&start=25
It has links to Pete9008's repo which is not working right now...
This repo also had some installation information which is unreachable now.
So, should I use sketch from johu's repo?
If so - it gives me some compilation errors related to SPI ffs lib. Also, 8266 is mentioned all around the sketch. Is this one actually good for WROOM-32?

Next... In this thread johu also speaks about CAN mapping errors and other problems with fresh fw...
viewtopic.php?t=2690&start=325
So, is fresh version no good? Fixed or not?...

Which EXACT version of ESP32 interface firmware from which EXACT repo I should use?
And also, which EXACT version of main STM32 FW is least problematic and compatible to ESP32 and V8/V9 board?

I'm very sorry, but I'm a bit confused here.
Cast in the name of God, ye not guilty.
User avatar
johu
Site Admin
Posts: 6980
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 461 times
Been thanked: 1778 times
Contact:

Re: A little help with SDU V9 anyone?

Post by johu »

Yes ESP32 repo on jsphuebner is good. On the uart-backend branch.
Install the latest stm32-sine that you find on git, i.e. compile yourself. It fixes various CAN issues compared to 5.35.R
And these parameters are fresher than those on git: https://openinverter.org/parameters/view.html?id=27
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
SuppaTenko
Posts: 13
Joined: Mon Nov 13, 2023 1:40 pm
Has thanked: 1 time
Been thanked: 4 times
Contact:

Re: A little help with SDU V9 anyone?

Post by SuppaTenko »

Ok, made ESP32 firmware roll.
Here's my step-by-step guide. I use win10 64bit LTSC.
I downloaded:
- sketch from jsphuebner's repo
https://github.com/jsphuebner/esp32-web-interface
- mkspiffs - win64 for esp32, v0.2.3
https://github.com/igrr/mkspiffs/releases/tag/0.2.3
- esptool - v4.10.0 for windows
https://github.com/espressif/esptool/re ... ag/v4.10.0
- gen_esp32part.exe
This one can be obtained from arduino-esp32 core repo here:
https://github.com/espressif/arduino-es ... ster/tools
Ore use local one from arduino hardware packages folder.
- Flash download tool from this guide - v3.9.9 R2
https://docs.espressif.com/projects/esp ... _tool.html

Next, configured arduino ide. I use fresh version 2.3.6 - updated esp32 core and libs etc.
Then opened downloaded sketch and compiled - got some errors related to SPIFFS. It's because sketch misses inclusion:
#include <SPIFFS.h>
Add it after #include <FS.h>
I also installed ESP32Time library.

Make sure that STM32 has no FW - it will mess up the process!
Next - go to Tools and select ESP32 core - with board ESP32 Dev Module.
Leave other settings as is - partition scheme is Default 4Mb with spiffs, 240MHz core clock etc...
Set up COM-port with connected adapter - I use cheap CH340E one. Port speed should be 115200.
image.png
Then go to sketch - Export compiled binary. Correct any errors if any spawn in process.
In sketch folder subfolder 'build' will be created. Find file esp32-web-interface.ino.merged.bin - it's compiled ketch with bootloader and partition table.
Now, open flash download tool (FDT in short), set prog-gnd jumper and connect your adapter to SDU board.
image.png
image.png (21.24 KiB) Viewed 282 times
Give power to SDU and make sure that you can read chip info from FDT.
image.png
If everything is wired good - you will get data. Now open SPIDownload tab, select esp32-web-interface.ino.merged.bin, set write offset to 0x0 and hit START. Wait till process is done.
image.png
Remove prog-gnd jumper and restart SDU power. Connect to adapter with arduino IDE/
If everything is good - you will se error E (167) SPIFFS: mount failed, -10025
It means that firmware works, but has no SPIFFS. I you connect to wifi and open 192.168.4.1 - you will get file not found error.
image.png
Now, we need to upload SPIFFS image. All files web interfaces uses are inside data folder provided with sketch.
Uploading with sh script didn't work for me, so does built-in firmware update page.
To upload spiffs i used mentioned small tools.
1) We need to know needed size and offset of spiffs image. To get them i used esptool.exe. Put prog-gnd jumper on and restart power to reboot ESP32.
2) open cmd and navigate to esptool.exe folder
3) read partition table data like this:
esptool.exe --port COM6 read_flash 0x8000 0xC00 partitions.bin
Use your com-port. 0x800 is default partition table offset and 0xc00 is default length.
In esptool folder partitions.bin file will be created.
image.png
4) Use gen_esp32part.exe to get partition data:
gen_esp32part.exe partitions.bin > partitions.csv
image.png
5) Open partitions.csv and find SPIFFS-related line.
It contains partition offset and size - in default case 0x290000 and 1408K.
image.png
image.png (74.6 KiB) Viewed 282 times
6) Generate SPIFFS image itself. 1408K is 1441792 bytes or 0x160000 in HEX.
Use mkspiffs to create image from provided data folder. In my case - like this:
mkspiffs -c C:\Users\Tenko\Desktop\esp32-web-interface\data -b 4096 -p 256 -s 0x160000 spiffs.bin
This will create needed image of this exact size.
image.png
7) Upload image to ESP32 - set prog-gnd jumper, reset power. Navigate to esptool folder and use this command to upload:
esptool.exe --port COM6 write_flash 0x290000 spiffs.bin
image.png
Now it should be done - if you remove prog jumper and reboot - you will have your web-interface on 192.168.4.1
Proceed with stm32 update...
image.png
Cast in the name of God, ye not guilty.
User avatar
johu
Site Admin
Posts: 6980
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 461 times
Been thanked: 1778 times
Contact:

Re: A little help with SDU V9 anyone?

Post by johu »

As we say around here: many ways lead to Rome :) Not the shortest path but it worked ;)
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
SuppaTenko
Posts: 13
Joined: Mon Nov 13, 2023 1:40 pm
Has thanked: 1 time
Been thanked: 4 times
Contact:

Re: A little help with SDU V9 anyone?

Post by SuppaTenko »

Pretty wonky, yes. But as i said, in my case other ways failed for some reason.
For example, when I flash FW directly from Arduino IDE - i get problems with partitioning and have mounting errors in debug.
It seems that even if I try to flash everything from it - it ends up uploading only compiled code partition, but not the table and boot. So, I ended up uploading full image with FDT.
Provided upload script seems to be sending something, but I end up with empty fs in the end.
This way I do everything manually and have more control - i can even change size of partitions if needed or add other files in image if I want to tinker with interface. And maybee it will help someone anyway =) As far as i can see, there are no detailed manuals for this, so guys who are not familiar with esp toolchain will have problems anyway.

I'll try to build freshest stm code from source this weekend and hopefully solder board to powertrain - just got my donor for all sockets couple of days ago.
Cast in the name of God, ye not guilty.
User avatar
SuppaTenko
Posts: 13
Joined: Mon Nov 13, 2023 1:40 pm
Has thanked: 1 time
Been thanked: 4 times
Contact:

Re: A little help with SDU V9 anyone?

Post by SuppaTenko »

Action time~!
image.png
image.png
Cast in the name of God, ye not guilty.
User avatar
SuppaTenko
Posts: 13
Joined: Mon Nov 13, 2023 1:40 pm
Has thanked: 1 time
Been thanked: 4 times
Contact:

Re: A little help with SDU V9 anyone?

Post by SuppaTenko »

Actually, I soldered regular board and wired ESP-M2 8285 module - and it worked better. This time upload script did the job properly, so I had no problems with filesystem. But 8285/8266 is very different from ESP32 in terms of filesystem approach and memory handling anyway. 1,5 years ago I also had no problems with it, so no surprise here. New interface seems to work much better compared to one I used that time with 'Leaf-o-Cycle' project and my homebrew pcb...
This one also needs some testing - I had a little bit of trouble finding single 3-input NAND in SC70 package and temporary replaced it with regular SO-8 74hc10. Also used LM2733X in place of MIC2288, but it should work no problem - a bit higher switch frequency, same feedback voltage, same pinout and generally same output characteristics. All of this can be ordered, but I wanted to test right here and right now, so for a moment I will let it be.
image.png
image.png
Cast in the name of God, ye not guilty.
Post Reply