Difference between revisions of "Pedal Interceptor"

From Tinkla: Tinkering with Tesla
(updated WPT-929 amazon link)
(36 intermediate revisions by 3 users not shown)
Line 1: Line 1:
The Comma Pedal is used to provide acceleration and regen braking capability on Tesla cars running Openpilot that do not have iBooster installed.
+
The Comma Pedal is used to provide advanced acceleration and regen braking capability on Tesla cars running Openpilot that do not have iBooster installed.
  
The Comma Pedal is an accelerator pedal interceptor. It is a device that is inserted between a car's electronic accelerator pedal and the DU (Drive Unit). It detects the voltage from the accelerator pedal which represents the pedal's position. It then writes that same voltage back out to the DU as if the accelerator pedal had produced it. When Openpilot is engaged, Openpilot sends the virtual acceleration position through the Comma Pedal instead.
+
Without electric brakes (iBooster) the car only uses regenerative braking. This is not enough for sudden slowdowns. YOU MUST BE READY TO MANUALLY BRAKE AT ANY MOMENT.
 +
[[File:Pedal.jpg|300px|border|right]]
  
Without electric brakes (iBooster) the car only uses regenerative braking. This is not enough for suddent slowdowns. YOU MUST BE READY TO MANUALLY BRAKE AT ANY MOMENT.
+
=== What it Does ===
 
+
The Comma Pedal is an accelerator pedal interceptor. It is a device that is inserted between a car's electronic accelerator pedal and the DU (Drive Unit). It detects the voltage from the accelerator pedal which represents the pedal's position. It then writes that same voltage back out to the DU as if the accelerator pedal had produced it.
The Comma Pedal is connected to the [[Tesla Giraffe|Giraffe]] on CAN3-EPAS usually using a Y adapter (that you have to make).
 
  
=== What it Does ===
 
 
The Comma Pedal has 4 main systems:
 
The Comma Pedal has 4 main systems:
 
# 2 Analog to Digital Convertors
 
# 2 Analog to Digital Convertors
Line 20: Line 19:
 
When Openpilot is NOT engaged, the Comma Pedal reads the voltage from the accelerator pedal and just passes it along to the DU.  
 
When Openpilot is NOT engaged, the Comma Pedal reads the voltage from the accelerator pedal and just passes it along to the DU.  
  
When Openpilot IS engaged with [[Longitudinal Control: ACC|longitudinal control]], the Comma Pedal gets accelerator commands from Openpilot and emulates a accelerator pedal to the DU.  
+
When Openpilot IS engaged with [[Longitudinal Control: ACC|longitudinal control]], it gets the virtual accelerator pedal position from Openpilot and passes it on to the DU.
  
The Comma Pedal is constantly sending the physical accelerator pedal's position to the CAN bus for Openpilot to read.
+
The Comma Pedal is also constantly sending the physical accelerator pedal's position to the CAN bus for Openpilot to read. This way you can increase speed temporarily without having to adjust max speed or disengage longitudinal control.
  
=== Obtaining a Comma Pedal (generic infor from Comma.ai wiki) ===
+
=== Obtaining a Comma Pedal ===
You cannot buy a pre-built comma pedal from Comma. Perhaps someone will begin selling them, but for now, you must either build it yourself (not recommended) Or have one fabricated through a service like Macrofab.  
+
You cannot buy a pre-built Comma Pedal from Comma. Fortunately there are other people in the community manufacturing and selling them:
 +
* sold by [https://discordapp.com/invite/Wyna3qy wocsor#0313] (no longer has a website link)
 +
* https://develolab.com/products/prod_FSN6fKevhpGWE2 (sold by [https://discordapp.com/invite/Wyna3qy Chase#7213])
 +
* https://www.ebay.com/str/level2tesla (sold by [https://discordapp.com/invite/Wyna3qy Flyboyn222pa#0407]
  
More information on HOW to do that will be added to this wiki in the future.
+
Since they're currently always sold out as soon as new ones get in stock, you could also [https://github.com/commaai/neo/tree/master/pedal build it yourself] (not recommended) or have one [https://medium.com/@joshuairl/comma-pedal-building-with-macrofab-6328bea791e8 fabricated through a service like Macrofab].
  
You can find an article written by a community member on how to build your own through MacroFab:
+
=== Wiring a Tesla Pedal ===
 +
[[File:Pedal board.jpg|300px|border|right]]
 +
In order to create your Tesla Pedal you need:
 +
* 1x Comma Pedal board (for sources see above section)
 +
* 1x [https://www.amazon.com/LeMotech-Plastic-Electrical-Junction-72x42x23mm/dp/B07F3Y8L95/ box to hold the board] if your Pedal doesn't already have a case (current ones ship with 3D printed cases). You will need to cut some [[:File:Pedal in box.png|small openings]] on the sides (and in front of the RJ45) if you use this one.
 +
* 1x set of "WPT-929" connectors (actually [https://www.molex.com/molex/products/datasheet.jsp?part=active/0314026110_CRIMP_HOUSINGS.xml Molex]) - [https://www.amazon.com/dp/B07GZY4ST4 fast shipping], [https://de.aliexpress.com/item/32778798102.html slow shipping]
 +
* ~3ft of wire for the connectors in case your Pedal and connectors don't come with them (~AWG24)
 +
* 1x SN-28B crimping tool (same one as used for EPAS cable - [https://www.amazon.com/Wovier-Compression-Ratcheting-0-1-1-0mm2-Wire-electrode/dp/B01CE4FAMW fast shipping], [https://www.aliexpress.com/item/32843027501.html slow shipping])
 +
* '''EITHER''' 1x ethernet cable ~2ft (not crossover) for current gen Pedal and [[Tesla Giraffe]] (rev B) which have RJ45 ports
 +
* '''OR''' 1x JST2 male and 1x female connector plus some twisted pair wire if RJ45 is not present. You can [https://www.digikey.com/product-detail/en/adafruit-industries-llc/1131/1528-1494-ND/5761282?WT.srch=1&gclid=EAIaIQobChMIjO_5yJyK4gIV1gOGCh1lOAh1EAQYAiABEgLflfD_BwE buy this] and cut it and you're done (not twisted but will work just fine)
  
[https://medium.com/@joshuairl/comma-pedal-building-with-macrofab-6328bea791e8 Comma Pedal: Building with MacroFab by Joshua F. Rountree]
 
  
The information needed to build one is located in Comma's [https://github.com/commaai/neo/tree/master/pedal EON GitHub repo.]
+
Use the diagram to connect the female WPT-929 pedal connector to the IN side of the pedal board and the male WSP-929 connector to the OUT side of the pedal connector.
 +
[[File:Tesla pedal wiring.png|330px|border|right]]
 +
[[File:Pedal connector.png|left|200px]][[File:Pedal pinout.png|400px]]
  
=== Wiring a Tesla Pedal ===
 
[[File:Tesla pedal wiring.png|thumb]]
 
[[File:Pedal pinout.png|thumb]]
 
[[File:Pedal connector.png|thumb]]
 
[[File:Pedal CAN connection.png|thumb]]
 
[[File:Pedal in box.png|thumb]]
 
In order to create your Tesla Pedal you need:
 
* 1x Comma Pedal board
 
* 1x [https://www.amazon.com/dp/B07GZY4ST4 set of WPT-929 connectors] w/ or w/o wires
 
* 1x JST2 male conenctor
 
* 1x JST2 female connector (or you can [https://www.digikey.com/product-detail/en/adafruit-industries-llc/1131/1528-1494-ND/5761282?WT.srch=1&gclid=EAIaIQobChMIjO_5yJyK4gIV1gOGCh1lOAh1EAQYAiABEgLflfD_BwE buy this] and cut it and you're done)
 
* box to hold the board (I used [https://www.amazon.com/LeMotech-Plastic-Electrical-Junction-72x42x23mm/dp/B07F3Y8L95/ref=sr_1_fkmrnull_1?keywords=LeMotech+5+Pieces+ABS+Plastic+Electrical+Project+Case+Power+Junction+Box%2C+Project+Box+Black+2.83%22+x+1.65%22+x+0.91%22%2872x42x23mm%29&qid=1558622636&s=hi&sr=1-1-fkmrnull this one] from Amazon). You will need to cut some small openings on the sides (and in front of the RJ45) if you use this one.
 
  
Note: the two JST2s are needed only if  you chose not to use an ethernet cable to conenct your Pedal to the [[Tesla Giraffe]] rev B.
 
  
Use the diagram to conenct the female WSP-929 pedal connector to the IN side of the pedal board and the male WSP-929 connector to the OUT side of the pedal connector.  
+
Connecting the CAN BUS from the Pedal to the [[Tesla Giraffe|Giraffe]] depends on your setup, as explained in the parts list above.
 +
[[File:Pedal CAN connection.png|thumb]]
 +
: Via RJ45: Plug in the ethernet cable into the RJ45 port of the Pedal and the other end into the RJ45 port of the Giraffe that is labelled with "comma". 
 +
: Via JST2: Solder positions 3 and 6 of the fake-ethernet port of the Pedal board to the two JST2 connectors (male and female) with enough length to reach EPAS cable/Giraffe. We need both because you will plug the female one in the [[Tesla Giraffe|Giraffe's]] EPAS connector and then the EPAS Harness into the male JST2. Red should be CAN+ and black should be CAN- (that's the convention also used in the image showing the CAN wire soldered to pins 3 and 6 of the fake ethernet port on the Pedal board).
  
To connect the CAN BUS from the Pedal to the [[Tesla Giraffe]] you can either use an Ethernet cable to connect the two RJ45 ports (if you have a [[Tesla Giraffe]] rev B) or you can use twised wire (preffered) to connect positions 3 and 6 of the fake-ethernet port of the pedal board to the two JST2 connectors (male and female). We need both because you will plug the female one in the [[Tesla Giraffe|Giraffe's]] EPAS connector and then the EPAS Harness into the male JSP2. Red should be CAN+ and black should be CAN- (that's the convention also used in the image showing the CAN wire soldered to pins 3 and 6 of the fake ethernet port on the pedal baord).
+
===  Installing the Tesla Pedal ===
 +
To install the Pedal, there are two steps:
 +
# connecting the board to the accelerator pedal
 +
# connecting the board to the [[Tesla Giraffe]]
  
=== Flashing the firmware for Tesla Pedal ===
+
[[File:Pedal connected.jpg|frameless|right]][[File:Pedal installed.jpg|frameless|right]]
 +
This [https://www.youtube.com/watch?v=UiQved6gt2U video] for a similar product shows you what you have to do in order to install the Pedal interceptor between the accelerator pedal and the car's existing connector. Take your time and watch the video first. The process is not complicated if you just follow it step by step.
  
You have to use a Tesla specific firmware on the pedal in order to work for Tesla.  
+
Once that is complete, connect your ethernet cable to the Pedal and the Giraffe's "comma" labelled RJ45 Port.
 +
Older Giraffes and Pedals without RJ45 ports connect over JST2: Disconnect the EPAS cable from the Tesla Giraffe and connect the female JST2 from your Pedal to the Giraffe. Then connect the EPAS cable to the male JST2 from your Pedal.
  
The firmware in my repo for the Tesla Pedal is located in /data/openpilot/panda/board/pedal_tesla. You can flash the pedal from your computer or from the EON (I did it from the EON). If you have a new board, it will automatically start in DFU mode. If not, you can enter the DFU mode either using a Panda Paw or by applying 5 volts to a special point on the board while conencting the board to USB (to power it up). That usually requires at least 2 people: one to keep the jumper for 5V in place and the other to connect the USB. [https://medium.com/@jfrux/flashing-the-comma-pedal-with-ubuntu-a83fb668f6e2 Instructions on how to enter DFU mode] were create by @jfrux.  
+
If your Pedal needs to be flashed, don't put your trim back on just yet. Instead connect the Giraffe and Panda to the car and and follow instructions below. This makes it easier to get to the Pedal in case necessary.<br>
 +
Once you're ready to cover everything up, make sure you don't forget to reconnect the footwell LED and that all your cables are positioned well, so that they don't rub against sharp edges and that there's no tension on them.
  
Once in DFU mode, go to the pedal_tesla directory and run
+
=== Flashing the firmware for Tesla Pedal ===
 +
You have to use a [https://github.com/BogGyver/panda/tree/tesla_pedal Tesla specific firmware] on the Pedal in order to work for Tesla.
 +
You can flash the Pedal directly from the EON, this is why '''we highly recommend installing the Pedal in your car before flashing (see section above)'''. If, for whatever reason, you need to flash your Pedal outside the car, use below instructions in conjunction with [https://medium.com/@jfrux/flashing-the-comma-pedal-with-ubuntu-a83fb668f6e2 this guide] by [https://medium.com/@jfrux @jfrux]
  
<code>make recover</code>
+
===== Step 1: Get the code =====
 +
SSH into your EON, then download our latest Pedal code (use <source lang="bash" inline>git pull</source> in /data/panda if you already cloned the repo).
 +
<source lang="bash">
 +
git clone --depth 1 https://github.com/BogGyver/panda.git -b tesla_pedal /data/panda
 +
</source>
  
Once the firmware flash complete, just reboot the pedal and you should be ready to go.
+
===== Step 2: Prepare your hardware =====
 +
Connect your EON to your car (Panda) if not already done. Then press the brake pedal to power up the Pedal.
  
With 0.5.10 and beyond, there is a new way to flash the pedal via CAN messages which will be used for furture (if needed) upgrades. For now, there are no changes to the firmware for Pedal.
+
Now kill all OP processes on the EON to free the CAN bus and change to the directory where all flashing related files are located.
 +
<source lang="bash">
 +
tmux kill-session -t comma
 +
cd /data/panda/board/pedal
 +
</source>
  
=== Installing the Tesla Pedal ===
+
===== Step 3.1: Flashing via CAN =====
 +
Flashing via CAN<sup>1</sup> is the recommended (easy) way but '''only possible with Pedals ordered after 7th Sept. 2019'''. Older Pedals and those built yourself need to follow Step 3.2 instead. They will then also gain the ability to be flashed via CAN for future updates.
  
To install the pedal, there are two steps:
+
Run and wait for this command to finish:
# connecting the board to the accelerator pedal
+
<source lang="bash">
# conencting the board to the [[Tesla Giraffe]]
+
make canflash
 +
</source>
 +
In case flashing is stuck at <source inline>checking for flasher</source>, press CTRL+C to abort and re run above command. If CAN flashing doesn't work for whatever reason you can always try Step 3.2 as a fallback.
  
This [https://www.youtube.com/watch?v=UiQved6gt2U video] for a similar product shows you what you have to do in order to install the pedal interceptror between the accelerator pedal and the car existing connector. Take your time and watch the video first. The process is not complicated if you just follow it step by step.
+
<sup>1</sup> <small>Original resource: [https://medium.com/@jfrux/comma-pedal-updating-the-firmware-over-can-fa438a3cf910 Comma Pedal: Updating the Firmware over CAN] by [https://medium.com/@jfrux @jfrux]</small>
  
Once that is complete, disconnect the EPAS cable from the Tesla Giraffe and connect the female JSP2 from your pedal to the Giraffe. Then connect the EPAS cable to the male JSP2 from your pedal.
+
===== Step 3.2: Flashing via USB =====
 +
'''Flashing via USB involves more steps and is only necessary if flashing via CAN is not possible yet (see explanation in Step 3.1).'''
  
=== Using the Tesla Pedal ===
+
If you built your Pedal yourself or it was shipped without any firmware, it will boot in DFU mode. To know which mode you're in look at the LED on the Pedal board: no light = DFU mode, slow blink = normal flash mode, fast blink = normal operations.
  
Without electric brakes (iBooster) the car only uses regenerative braking. This is not enough for suddent slowdowns. YOU MUST BE READY TO MANUALLY BRAKE AT ANY MOMENT.
+
If your Pedal LED is blinking, you can put your Pedal into DFU mode via CAN:
 +
: <source lang="bash">
 +
./enter_canloader.py --recover
 +
</source>
 +
: It's possible that the LED won't turn off on the first try, but usually does so after entering the command a second time*. In case you get an AssertionError, reboot EON and start over from step 2.
  
Out of the box, OP will use the Tesla CC (with stalk spamming) to control CC. This in our OP implementation is called Adaptive Cruise Control or ACC. CC on Tesla only works above 18 MPH (29 km/h).
+
While in DFU mode, connect your EON via USB to the Pedal (unplug from Panda or use a second USB cable) ensuring that the car does not go in Car Off mode (don't lift your butt off the driver's seat) since Pedal would lose power and therefore also DFU mode.<br />
 +
Now run this command to flash the bootloader and operational code:
 +
<source lang="bash">
 +
make recover
 +
</source>
 +
Sometimes you have to issue the command multiple times until it completes successfully. With the updated bootloader you'll be able to flash future updates via CAN.
  
If you turn off the Tesla CC by pressing on the CC stalk, OP will switch to Tesla Pedal (PDL) mode. This will also provide you with adaptive cruise control by sending the right commands to your Tesla Pedal. Tesla pedal works down to 1 MPH, but be careful, regen brakes stop working at 5 MPH (8 km/h).
+
Once done, unplug USB from the Pedal and back into the Panda.
  
Once you get used to it and you don't care about ACC anymore, you can modify the [[OpenPilot Configuration File|config file]] to always use pedal
+
<nowiki>*</nowiki> <small>If you can't or don't want to put the Pedal into DFU mode via CAN, you can also do so by [https://medium.com/@jfrux/flashing-the-comma-pedal-with-ubuntu-a83fb668f6e2#fcdf applying 5 Volt to a special point on the board] while connecting it to USB (to power it up). Car must obviously be off or disconnected for this. That usually requires 2 people: one to keep the jumper for 5V in place and the other to connect the USB.</small>
  
<code>force_pedal_over_cc = True</code>
+
===== Step 4: Cleanup =====
 +
If all went good you can reboot EON to restore the OP processes that were closed in step 2.<br>
 +
Once the pedal is back in operational mode (rapid LED blinking), PRND letters should be white. If it's not, first try to reboot pedal: Open the driver door while not sitting in the driver seat to make the car go in "Car Off" mode, then step on the brake to turn it back on.<br>
 +
If you still experience red PRND letters after a successful flash and pedal being in operational mode, it means a bad connection between the car and the accelerator, so check your pedal Molex connectors.
  
=== Guides for Building / Troubleshooting Your Comma Pedal ===
+
=== Using the Tesla Pedal ===
 +
Without electric brakes (iBooster) the car only uses regenerative braking. This is not enough for suddent slowdowns. YOU MUST BE READY TO MANUALLY BRAKE AT ANY MOMENT.
  
'''[https://medium.com/@jfrux/comma-pedal-updating-the-firmware-over-can-fa438a3cf910 Comma Pedal: Updating the Firmware over CAN]''' by [https://medium.com/@jfrux @jfrux] Use this guide to update your Comma Pedal for compatibility with Openpilot v0.5.10+
+
Out of the box, OP will use the Tesla CC (with stalk spamming) to control CC. This in our OP implementation is called Adaptive Cruise Control or ACC. CC on Tesla only works above 18 MPH (29 km/h).
  
'''[https://medium.com/@jfrux/comma-pedal-building-with-macrofab-6328bea791e8 Comma Pedal: Building with MacroFab]''' by [https://medium.com/@jfrux @jfrux]
+
If you turn off the Tesla CC by pressing on the CC stalk, OP will switch to Tesla Pedal mode (PCC). This will provide you with smooth adaptive cruise control by sending the right commands to your Tesla Pedal. Tesla Pedal works down to 1 MPH, but be careful, regen brakes stop working at 5 MPH (8 km/h).
  
'''[https://medium.com/@jfrux/flashing-the-comma-pedal-with-ubuntu-a83fb668f6e2 Comma Pedal: Flashing the Firmware]''' by [https://medium.com/@jfrux @jfrux]
+
Once you get used to it and you don't care about ACC anymore, you can set <source lang="Python" inline>force_pedal_over_cc = True</source> in the [[OpenPilot Configuration File|config file]] to always use Pedal.

Revision as of 17:45, 25 January 2020

The Comma Pedal is used to provide advanced acceleration and regen braking capability on Tesla cars running Openpilot that do not have iBooster installed.

Without electric brakes (iBooster) the car only uses regenerative braking. This is not enough for sudden slowdowns. YOU MUST BE READY TO MANUALLY BRAKE AT ANY MOMENT.
Pedal.jpg

What it Does

The Comma Pedal is an accelerator pedal interceptor. It is a device that is inserted between a car's electronic accelerator pedal and the DU (Drive Unit). It detects the voltage from the accelerator pedal which represents the pedal's position. It then writes that same voltage back out to the DU as if the accelerator pedal had produced it.

The Comma Pedal has 4 main systems:

  1. 2 Analog to Digital Convertors
    • This is used to read the voltage from the car's accelerator pedal into the Comma Pedal's processor. The accelerator pedal produces an output Voltage between 0 and 5 Volts.
  2. 2 Digital to Analog Convertors
    • This is used to send voltage back to the car's DU as if the accelerator pedal had produced it.
  3. 1 CAN Bus
    • The CAN Bus is the car's communication network. The Comma Pedal communicates with Openpilot using the CAN Bus. It connects to the Tesla Giraffe on CAN3.
  4. 1 USB
    • This is used to program and monitor the Comma Pedal, itself.

When Openpilot is NOT engaged, the Comma Pedal reads the voltage from the accelerator pedal and just passes it along to the DU.

When Openpilot IS engaged with longitudinal control, it gets the virtual accelerator pedal position from Openpilot and passes it on to the DU.

The Comma Pedal is also constantly sending the physical accelerator pedal's position to the CAN bus for Openpilot to read. This way you can increase speed temporarily without having to adjust max speed or disengage longitudinal control.

Obtaining a Comma Pedal

You cannot buy a pre-built Comma Pedal from Comma. Fortunately there are other people in the community manufacturing and selling them:

Since they're currently always sold out as soon as new ones get in stock, you could also build it yourself (not recommended) or have one fabricated through a service like Macrofab.

Wiring a Tesla Pedal

Pedal board.jpg

In order to create your Tesla Pedal you need:

  • 1x Comma Pedal board (for sources see above section)
  • 1x box to hold the board if your Pedal doesn't already have a case (current ones ship with 3D printed cases). You will need to cut some small openings on the sides (and in front of the RJ45) if you use this one.
  • 1x set of "WPT-929" connectors (actually Molex) - fast shipping, slow shipping
  • ~3ft of wire for the connectors in case your Pedal and connectors don't come with them (~AWG24)
  • 1x SN-28B crimping tool (same one as used for EPAS cable - fast shipping, slow shipping)
  • EITHER 1x ethernet cable ~2ft (not crossover) for current gen Pedal and Tesla Giraffe (rev B) which have RJ45 ports
  • OR 1x JST2 male and 1x female connector plus some twisted pair wire if RJ45 is not present. You can buy this and cut it and you're done (not twisted but will work just fine)


Use the diagram to connect the female WPT-929 pedal connector to the IN side of the pedal board and the male WSP-929 connector to the OUT side of the pedal connector.

Tesla pedal wiring.png
Pedal connector.png

Pedal pinout.png


Connecting the CAN BUS from the Pedal to the Giraffe depends on your setup, as explained in the parts list above.

Pedal CAN connection.png
Via RJ45: Plug in the ethernet cable into the RJ45 port of the Pedal and the other end into the RJ45 port of the Giraffe that is labelled with "comma".
Via JST2: Solder positions 3 and 6 of the fake-ethernet port of the Pedal board to the two JST2 connectors (male and female) with enough length to reach EPAS cable/Giraffe. We need both because you will plug the female one in the Giraffe's EPAS connector and then the EPAS Harness into the male JST2. Red should be CAN+ and black should be CAN- (that's the convention also used in the image showing the CAN wire soldered to pins 3 and 6 of the fake ethernet port on the Pedal board).

Installing the Tesla Pedal

To install the Pedal, there are two steps:

  1. connecting the board to the accelerator pedal
  2. connecting the board to the Tesla Giraffe
Pedal connected.jpg
Pedal installed.jpg

This video for a similar product shows you what you have to do in order to install the Pedal interceptor between the accelerator pedal and the car's existing connector. Take your time and watch the video first. The process is not complicated if you just follow it step by step.

Once that is complete, connect your ethernet cable to the Pedal and the Giraffe's "comma" labelled RJ45 Port. Older Giraffes and Pedals without RJ45 ports connect over JST2: Disconnect the EPAS cable from the Tesla Giraffe and connect the female JST2 from your Pedal to the Giraffe. Then connect the EPAS cable to the male JST2 from your Pedal.

If your Pedal needs to be flashed, don't put your trim back on just yet. Instead connect the Giraffe and Panda to the car and and follow instructions below. This makes it easier to get to the Pedal in case necessary.
Once you're ready to cover everything up, make sure you don't forget to reconnect the footwell LED and that all your cables are positioned well, so that they don't rub against sharp edges and that there's no tension on them.

Flashing the firmware for Tesla Pedal

You have to use a Tesla specific firmware on the Pedal in order to work for Tesla. 

You can flash the Pedal directly from the EON, this is why we highly recommend installing the Pedal in your car before flashing (see section above). If, for whatever reason, you need to flash your Pedal outside the car, use below instructions in conjunction with this guide by @jfrux

Step 1: Get the code

SSH into your EON, then download our latest Pedal code (use git pull in /data/panda if you already cloned the repo).

git clone --depth 1 https://github.com/BogGyver/panda.git -b tesla_pedal /data/panda
Step 2: Prepare your hardware

Connect your EON to your car (Panda) if not already done. Then press the brake pedal to power up the Pedal.

Now kill all OP processes on the EON to free the CAN bus and change to the directory where all flashing related files are located.

tmux kill-session -t comma
cd /data/panda/board/pedal
Step 3.1: Flashing via CAN

Flashing via CAN1 is the recommended (easy) way but only possible with Pedals ordered after 7th Sept. 2019. Older Pedals and those built yourself need to follow Step 3.2 instead. They will then also gain the ability to be flashed via CAN for future updates.

Run and wait for this command to finish:

make canflash

In case flashing is stuck at checking for flasher, press CTRL+C to abort and re run above command. If CAN flashing doesn't work for whatever reason you can always try Step 3.2 as a fallback.

1 Original resource: Comma Pedal: Updating the Firmware over CAN by @jfrux

Step 3.2: Flashing via USB

Flashing via USB involves more steps and is only necessary if flashing via CAN is not possible yet (see explanation in Step 3.1).

If you built your Pedal yourself or it was shipped without any firmware, it will boot in DFU mode. To know which mode you're in look at the LED on the Pedal board: no light = DFU mode, slow blink = normal flash mode, fast blink = normal operations.

If your Pedal LED is blinking, you can put your Pedal into DFU mode via CAN:

./enter_canloader.py --recover
It's possible that the LED won't turn off on the first try, but usually does so after entering the command a second time*. In case you get an AssertionError, reboot EON and start over from step 2.

While in DFU mode, connect your EON via USB to the Pedal (unplug from Panda or use a second USB cable) ensuring that the car does not go in Car Off mode (don't lift your butt off the driver's seat) since Pedal would lose power and therefore also DFU mode.
Now run this command to flash the bootloader and operational code:

make recover

Sometimes you have to issue the command multiple times until it completes successfully. With the updated bootloader you'll be able to flash future updates via CAN.

Once done, unplug USB from the Pedal and back into the Panda.

* If you can't or don't want to put the Pedal into DFU mode via CAN, you can also do so by applying 5 Volt to a special point on the board while connecting it to USB (to power it up). Car must obviously be off or disconnected for this. That usually requires 2 people: one to keep the jumper for 5V in place and the other to connect the USB.

Step 4: Cleanup

If all went good you can reboot EON to restore the OP processes that were closed in step 2.
Once the pedal is back in operational mode (rapid LED blinking), PRND letters should be white. If it's not, first try to reboot pedal: Open the driver door while not sitting in the driver seat to make the car go in "Car Off" mode, then step on the brake to turn it back on.
If you still experience red PRND letters after a successful flash and pedal being in operational mode, it means a bad connection between the car and the accelerator, so check your pedal Molex connectors.

Using the Tesla Pedal

Without electric brakes (iBooster) the car only uses regenerative braking. This is not enough for suddent slowdowns. YOU MUST BE READY TO MANUALLY BRAKE AT ANY MOMENT.

Out of the box, OP will use the Tesla CC (with stalk spamming) to control CC. This in our OP implementation is called Adaptive Cruise Control or ACC. CC on Tesla only works above 18 MPH (29 km/h).

If you turn off the Tesla CC by pressing on the CC stalk, OP will switch to Tesla Pedal mode (PCC). This will provide you with smooth adaptive cruise control by sending the right commands to your Tesla Pedal. Tesla Pedal works down to 1 MPH, but be careful, regen brakes stop working at 5 MPH (8 km/h).

Once you get used to it and you don't care about ACC anymore, you can set force_pedal_over_cc = True in the config file to always use Pedal.