Tesla Model 3 Rear Drive Unit Closed Source CAN Hacking

Topics concerning the Tesla front and rear drive unit drop-in board
AMP3R
Posts: 125
Joined: Sun Oct 09, 2022 8:32 pm
Has thanked: 2 times
Been thanked: 53 times

Re: Tesla Model 3 Rear Drive Unit Hacking

Post by AMP3R »

davefiddes wrote: Fri Aug 30, 2024 10:05 am Do you have an intact HVIL loop with a 20mA current running through it? Without that the HV bus discharge circuit on the inverter will not deactivate.
I haven't connected HVIL. Can you tell me how to emulate it? What voltage is there? Is PWM used?
davefiddes
Posts: 293
Joined: Mon Jan 18, 2021 12:39 pm
Location: Edinburgh, Scotland, UK
Has thanked: 75 times
Been thanked: 95 times

Re: Tesla Model 3 Rear Drive Unit Hacking

Post by davefiddes »

It's quite simple to emulate on the bench. It is a simple 20mA current loop and you can use the same 12VDC supply you use for the main inverter (it is optically isolated from the main inverter electronics).

I use the following circuit with an LM317L regulator:
hvil.png
The HV DC connector is part of the loop. I see you have the official cable so you should be good. If anyone wants to jumper it out you need to do this:
IMG_20240830_113428_695.jpg
The HV discharge circuitry is completely automatic but the HVIL current is monitored by the main inverter MCU.
AMP3R
Posts: 125
Joined: Sun Oct 09, 2022 8:32 pm
Has thanked: 2 times
Been thanked: 53 times

Re: Tesla Model 3 Rear Drive Unit Hacking

Post by AMP3R »

davefiddes wrote: Fri Aug 30, 2024 10:57 am It's quite simple to emulate on the bench. It is a simple 20mA current loop and you can use the same 12VDC supply you use for the main inverter (it is optically isolated from the main inverter electronics).

I use the following circuit with an LM317L regulator:

hvil.png

The HV DC connector is part of the loop. I see you have the official cable so you should be good. If anyone wants to jumper it out you need to do this:
IMG_20240830_113428_695.jpg

The HV discharge circuitry is completely automatic but the HVIL current is monitored by the main inverter MCU.
Thank you. Do you think the transistor that turns on the resistor bank is still okay when I kept the HV for a few minutes?
davefiddes
Posts: 293
Joined: Mon Jan 18, 2021 12:39 pm
Location: Edinburgh, Scotland, UK
Has thanked: 75 times
Been thanked: 95 times

Re: Tesla Model 3 Rear Drive Unit Hacking

Post by davefiddes »

Not sure. I suspect it'll probably be OK. IIRC Damien burned his out but he was running for quite some time.

I found you can see the operation of the discharge circuitry quite clearly with a current clamp on the HVDC input. With an idle inverter the two sources of current draw on the HVDC is the backup gate drive PSU and the HV discharge resistors. Turning on and off the HVIL circuit varied it quite significantly. You need a current clamp that is accurate in the DC mA range. My cheap UNI-T UT210E Pro seems to do the job OK.
AMP3R
Posts: 125
Joined: Sun Oct 09, 2022 8:32 pm
Has thanked: 2 times
Been thanked: 53 times

Re: Tesla Model 3 Rear Drive Unit Hacking

Post by AMP3R »

davefiddes wrote: Fri Aug 30, 2024 11:31 am Not sure. I suspect it'll probably be OK. IIRC Damien burned his out but he was running for quite some time.

I found you can see the operation of the discharge circuitry quite clearly with a current clamp on the HVDC input. With an idle inverter the two sources of current draw on the HVDC is the backup gate drive PSU and the HV discharge resistors. Turning on and off the HVIL circuit varied it quite significantly. You need a current clamp that is accurate in the DC mA range. My cheap UNI-T UT210E Pro seems to do the job OK.
Active discharge alert has gone. Thanks!
Screenshot from 2024-08-30 23-09-41.png
AMP3R
Posts: 125
Joined: Sun Oct 09, 2022 8:32 pm
Has thanked: 2 times
Been thanked: 53 times

Re: Tesla Model 3 Rear Drive Unit Hacking

Post by AMP3R »

So the immobilizer is unlocked, the inverter shows signs of life with a 10 kHz beep for a split second during power on and shows that it is in the IDLE state, the HVIL circuit is on.

I switch to D, the inverter shows N and the IDLE state doesn't change. That is, in order for D to be ENABLE, you first need to achieve STANDBY in P.
Screenshot from 2024-09-25 16-24-32.png
Does the motor need cell voltages? I think the problem lies somewhere in the messages from the BMS. What do you think?
20240925_162118.jpg
20240925_162010.jpg
P.S.Mangelsdorf
Posts: 1083
Joined: Tue Sep 17, 2019 8:33 pm
Location: Raleigh, NC, USA
Has thanked: 236 times
Been thanked: 278 times

Re: Tesla Model 3 Rear Drive Unit Hacking

Post by P.S.Mangelsdorf »

AMP3R wrote: Wed Sep 25, 2024 1:54 pm The funny thing is that there is no info anywhere on google that anyone has even tried to run this motor as is, without messing with inverter, and in fact there is no one to even ask.
I met someone on Drag Week (a spectator) who said he had a build using one of the Canadian Model 3 controllers (I think it was Ingenext). It sounded like the drive units were unmodified.

From what I've seen it's only those of you here on OI trying to get these running without a commercial controller. It does look like those commercial controllers might reprogram something, but not clear what.
If at first you don't succeed, buy a bigger hammer.

1940 Chevrolet w/ Tesla LDU - "Shocking Chevy" - Completed Hot Rod Drag Week 2023 and 2024

https://www.youtube.com/@MangelsdorfSpeed
AMP3R
Posts: 125
Joined: Sun Oct 09, 2022 8:32 pm
Has thanked: 2 times
Been thanked: 53 times

Re: Tesla Model 3 Rear Drive Unit Hacking

Post by AMP3R »

After playing with the motor for a while, I realized why the inverter doesn't switch into STANDBY mode.

Active errors: DIR_a144_configMismatch, DIR_a062_systemLimpMode, DIR_a092_bmsMIA.
Screenshot from 2024-09-28 02-10-25.png
Screenshot from 2024-09-28 02-10-53.png
Screenshot from 2024-09-28 02-10-01.png
AMP3R
Posts: 125
Joined: Sun Oct 09, 2022 8:32 pm
Has thanked: 2 times
Been thanked: 53 times

Re: Tesla Model 3 Rear Drive Unit Hacking

Post by AMP3R »

I noticed that DIR_a144_configMismatch is triggered by two messages 0×392 (info about battery) and 0×7FF (car config)

We can say that this is a fundamental error and because of it the motor will not spin.
AMP3R
Posts: 125
Joined: Sun Oct 09, 2022 8:32 pm
Has thanked: 2 times
Been thanked: 53 times

Re: Tesla Model 3 Rear Drive Unit Hacking

Post by AMP3R »

I figured out the 0×392 BMS_packConfig message, which triggers the DIR_a144_configMismatch error.
Just corrected the maximum voltage to 387 and the error disappeared.
Screenshot from 2024-10-07 15-21-17.png
Screenshot from 2024-10-07 15-21-41.png
AMP3R
Posts: 125
Joined: Sun Oct 09, 2022 8:32 pm
Has thanked: 2 times
Been thanked: 53 times

Re: Tesla Model 3 Rear Drive Unit Hacking

Post by AMP3R »

The first frame from the multiplexed message 0×7FF about the car config is ready. It turned out that all bits can be empty except bit 56
mux1.png
The second frame can be completely empty.
mux2.png
The third needs information about GTW_perfomancePackage, GTW_chassisType and GTW_packEnergy. Everything else can be zero.
mux3.png
The fourth can be completely empty.
mux4.png
The fifth can be completely empty.
mux5.png
The sixth is also empty.
mux6.png
DIR_a144_configMismatch goodbye
AMP3R
Posts: 125
Joined: Sun Oct 09, 2022 8:32 pm
Has thanked: 2 times
Been thanked: 53 times

Re: Tesla Model 3 Rear Drive Unit Hacking

Post by AMP3R »

The main system errors have disappeared, but the inverter does not switch to STANDBY mode yet. Any ideas?
Screenshot from 2024-10-09 21-45-08.png
Screenshot from 2024-10-09 21-45-29.png
Screenshot from 2024-10-09 21-45-40.png
davefiddes
Posts: 293
Joined: Mon Jan 18, 2021 12:39 pm
Location: Edinburgh, Scotland, UK
Has thanked: 75 times
Been thanked: 95 times

Re: Tesla Model 3 Rear Drive Unit Hacking

Post by davefiddes »

You look like you have a lot of happy systems there to my uneducated eyes. Have you got a capture of a working Tesla of a similar vintage to compared against?
AMP3R
Posts: 125
Joined: Sun Oct 09, 2022 8:32 pm
Has thanked: 2 times
Been thanked: 53 times

Re: Tesla Model 3 Rear Drive Unit Hacking

Post by AMP3R »

davefiddes wrote: Wed Oct 09, 2024 8:59 pm You look like you have a lot of happy systems there to my uneducated eyes. Have you got a capture of a working Tesla of a similar vintage to compared against?
Please look.
AMP3R
Posts: 125
Joined: Sun Oct 09, 2022 8:32 pm
Has thanked: 2 times
Been thanked: 53 times

Re: Tesla Model 3 Rear Drive Unit Hacking

Post by AMP3R »

vehicle can park.csv
(889.77 KiB) Downloaded 574 times
davefiddes
Posts: 293
Joined: Mon Jan 18, 2021 12:39 pm
Location: Edinburgh, Scotland, UK
Has thanked: 75 times
Been thanked: 95 times

Re: Tesla Model 3 Rear Drive Unit Hacking

Post by davefiddes »

I'll have a peek though I'm not sure there's much I can make of it. I guess I was more asking as to whether you had access to enough in the way of captures. Just looked at the price of second hand Model 3s and they're really quite affordable...hoping that someone with one and a sense of adventure would be able to help you out with on-going CAN captures.
AMP3R
Posts: 125
Joined: Sun Oct 09, 2022 8:32 pm
Has thanked: 2 times
Been thanked: 53 times

Re: Tesla Model 3 Rear Drive Unit Hacking

Post by AMP3R »

Ok
AMP3R
Posts: 125
Joined: Sun Oct 09, 2022 8:32 pm
Has thanked: 2 times
Been thanked: 53 times

Re: Tesla Model 3 Rear Drive Unit Hacking

Post by AMP3R »

Can anyone tell what DI_limitVBatHigh, DIR_ssmState, DIR_usmState and DIR_fluxState are?
Screenshot from 2024-10-12 17-47-09.png
Screenshot from 2024-10-12 17-47-41.png
Screenshot from 2024-10-12 17-48-09.png
AMP3R
Posts: 125
Joined: Sun Oct 09, 2022 8:32 pm
Has thanked: 2 times
Been thanked: 53 times

Re: Tesla Model 3 Rear Drive Unit Hacking

Post by AMP3R »

My drive unit probably has last one active error DIR_a155_vcfrontMIA (The DI ECU is not receiving the expected CAN communication from the VCFRONT, and considers it irrational or MIA)

I assume that this is due to the message 0×3A1. Who knows, does it definitely come from VCFront?
Screenshot from 2024-12-19 01-06-32.png
AMP3R
Posts: 125
Joined: Sun Oct 09, 2022 8:32 pm
Has thanked: 2 times
Been thanked: 53 times

Re: Tesla Model 3 Rear Drive Unit Hacking

Post by AMP3R »

A few days ago I had an idea to take another close look what the inverter sends to the vehicle CAN and after poking around found something interesting. It turns out that there are many more ids with alerts and errors than I thought. By simple calculations edited the dbc file and when turned on the drive unit I was stunned.

Of course, nothing will work, because the DI_a174_notOkToStartDrive alert is active. The logic lacks 12 volts, which I supply from a regular ATX power supply. If this turns out to be the cause, it will be very funny. But it is too early to rejoice.
Screenshot from 2025-02-02 21-54-41.png
AMP3R
Posts: 125
Joined: Sun Oct 09, 2022 8:32 pm
Has thanked: 2 times
Been thanked: 53 times

Re: Tesla Model 3 Rear Drive Unit Hacking

Post by AMP3R »

It's interesting to look how the immobilizer works.
Screenshot from 2025-02-17 21-00-20.png
As soon as the inverter recieved the 0×221 (VCFRONT_LVPowerState) message, it shoots 0×276 to the CAN vehicle for a split of second. This is a challenge for the VCSEC.

Meanwhile, the VCSEC is already ready and when you put the key card, it responds with the 0×3D9. That's it - the immo is unlocked.

The 0×276 challenge message is always new every time the inverter is restarted. After looking on its structure, I dare to assume that it has 65536 possible combinations.

The 0×276 and 0×3D9 messages are tightly linked. To verify this, I generated static challenge for my VCSEC several times in a row and the response at 0×3D9 was the same. During the experiment, the inverter was turned off.

In short how it works:

1. The motor sends a challenge.
2. VCSEC responds with a value calculated using a one-way hash function based on the challenge and the secret.
3. The motor checks the response using its own calculation of the expected hash value. If the values ​​match, authentication is confirmed.

For fun, it's possible to record the entire range of challenge/response pairs (65536), make look up table and try to replay these answers to the drive unit.
AMP3R
Posts: 125
Joined: Sun Oct 09, 2022 8:32 pm
Has thanked: 2 times
Been thanked: 53 times

Re: Tesla Model 3 Rear Drive Unit Hacking

Post by AMP3R »

Keyless driving enabled. This means that you can run the motor without a key card, but with the VCSEC connected.
photo_2025-02-22_17-23-10.jpg
User avatar
jetpax
Posts: 50
Joined: Wed Jan 01, 2020 12:33 am
Has thanked: 20 times
Been thanked: 23 times
Contact:

Re: Tesla Model 3 Rear Drive Unit Hacking

Post by jetpax »

AMP3R wrote: Mon Feb 17, 2025 6:56 pm While my bench power supply is on its way from China, I wanted to look how the immobilizer works.

Screenshot from 2025-02-17 21-00-20.png

As soon as the inverter logic has power and VCFRONT transmits the 0×221 (VCFRONT_LVPowerState) message, it (inverter) shoots the 0×276 message to the CAN vehicle for literally a split second. This is a challenge for the VCSEC.

Meanwhile, the VCSEC is already ready and when you put the key card, it responds with the 0×3D9 message for about one second. That's it - the immobilizer is unlocked.

The 0×276 challenge message is new every time the inverter is restarted. After looking on its structure, I dare to assume that it has 65536 possible combinations.

The 0×276 and 0×3D9 messages are tightly linked. To verify this, I generated the same challenge for my VCSEC several times in a row and the response in 0×3D9 was the same. During the experiment, the inverter was turned off.

In short, for those who did not understand how it works:

1. The motor sends a challenge.
2. VCSEC responds with a value calculated using a one-way hash function based on the challenge and the secret.
3. The motor checks the response using its own calculation of the expected hash value. If the values ​​match, authentication is confirmed.

What secret is stored in VCSEC, a big big secret.

For fun, you can record the entire range of challenge/response pairs (65536) This will take about 18 and a half hours. But in fact, this method is of little use, since it will only work on a specific motor.
Great job!

So are you saying that if i record these 65536 challenge responses for a paired motor/VCSEC, then i could dump the motor firmware and flash it into another motor and the new motor should authenticate?
“Take the best that exists and make it better”
AMP3R
Posts: 125
Joined: Sun Oct 09, 2022 8:32 pm
Has thanked: 2 times
Been thanked: 53 times

Re: Tesla Model 3 Rear Drive Unit Hacking

Post by AMP3R »

:)
AMP3R
Posts: 125
Joined: Sun Oct 09, 2022 8:32 pm
Has thanked: 2 times
Been thanked: 53 times

Re: Tesla Model 3 Rear Drive Unit Hacking

Post by AMP3R »

:)
Post Reply