Skip to content

Commit

Permalink
Toyota pedal support (commaai#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
rbiasini authored Feb 7, 2019
1 parent de1ba06 commit c91f038
Show file tree
Hide file tree
Showing 11 changed files with 386 additions and 2 deletions.
8 changes: 6 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@ jobs:
command: |
docker run panda_build /bin/bash -c "cd /panda/board; make bin"
- run:
name: Build Pedal STM image
name: Build Honda Pedal STM image
command: |
docker run panda_build /bin/bash -c "cd /panda/board/pedal; make obj/comma.bin"
docker run panda_build /bin/bash -c "cd /panda/board/pedal_honda; make obj/comma.bin"
- run:
name: Build Toyota Pedal STM image
command: |
docker run panda_build /bin/bash -c "cd /panda/board/pedal_toyota; make obj/comma.bin"
- run:
name: Build NEO STM image
command: |
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions board/pedal_toyota/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
obj/*
58 changes: 58 additions & 0 deletions board/pedal_toyota/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# :set noet
PROJ_NAME = comma

CFLAGS = -O2 -Wall -std=gnu11 -DPEDAL
CFLAGS += -mlittle-endian -mthumb -mcpu=cortex-m3
CFLAGS += -msoft-float -DSTM32F2 -DSTM32F205xx
CFLAGS += -I ../inc -I ../ -I ../../ -nostdlib
CFLAGS += -T../stm32_flash.ld

STARTUP_FILE = startup_stm32f205xx

CC = arm-none-eabi-gcc
OBJCOPY = arm-none-eabi-objcopy
OBJDUMP = arm-none-eabi-objdump
DFU_UTIL = "dfu-util"

# pedal only uses the debug cert
CERT = ../../certs/debug
CFLAGS += "-DALLOW_DEBUG"

canflash: obj/$(PROJ_NAME).bin
../../tests/pedal/enter_canloader.py $<

usbflash: obj/$(PROJ_NAME).bin
../../tests/pedal/enter_canloader.py; sleep 0.5
PYTHONPATH=../../ python -c "from python import Panda; p = [x for x in [Panda(x) for x in Panda.list()] if x.bootstub]; assert(len(p)==1); p[0].flash('obj/$(PROJ_NAME).bin', reconnect=False)"

recover: obj/bootstub.bin obj/$(PROJ_NAME).bin
../../tests/pedal/enter_canloader.py --recover; sleep 0.5
$(DFU_UTIL) -d 0483:df11 -a 0 -s 0x08004000 -D obj/$(PROJ_NAME).bin
$(DFU_UTIL) -d 0483:df11 -a 0 -s 0x08000000:leave -D obj/bootstub.bin

obj/main.o: main.c ../*.h
mkdir -p obj
$(CC) $(CFLAGS) -o $@ -c $<

obj/bootstub.o: ../bootstub.c ../*.h
mkdir -p obj
$(CC) $(CFLAGS) -o $@ -c $<

obj/$(STARTUP_FILE).o: ../$(STARTUP_FILE).s
$(CC) $(CFLAGS) -o $@ -c $<

obj/%.o: ../../crypto/%.c
$(CC) $(CFLAGS) -o $@ -c $<

obj/$(PROJ_NAME).bin: obj/$(STARTUP_FILE).o obj/main.o
# hack
$(CC) -Wl,--section-start,.isr_vector=0x8004000 $(CFLAGS) -o obj/$(PROJ_NAME).elf $^
$(OBJCOPY) -v -O binary obj/$(PROJ_NAME).elf obj/code.bin
SETLEN=1 ../../crypto/sign.py obj/code.bin $@ $(CERT)

obj/bootstub.bin: obj/$(STARTUP_FILE).o obj/bootstub.o obj/sha.o obj/rsa.o
$(CC) $(CFLAGS) -o obj/bootstub.$(PROJ_NAME).elf $^
$(OBJCOPY) -v -O binary obj/bootstub.$(PROJ_NAME).elf $@

clean:
rm -f obj/*
30 changes: 30 additions & 0 deletions board/pedal_toyota/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
MOVE ALL FILES TO board/pedal TO FLASH


This is the firmware for the comma pedal. It borrows a lot from panda.

The comma pedal is a gas pedal interceptor for Honda/Acura. It allows you to "virtually" press the pedal.

This is the open source software. Note that it is not ready to use yet.

== Test Plan ==

* Startup
** Confirm STATE_FAULT_STARTUP
* Timeout
** Send value
** Confirm value is output
** Stop sending messages
** Confirm value is passthru after 100ms
** Confirm STATE_FAULT_TIMEOUT
* Random values
** Send random 6 byte messages
** Confirm random values cause passthru
** Confirm STATE_FAULT_BAD_CHECKSUM
* Same message lockout
** Send same message repeated
** Confirm timeout behavior
* Don't set enable
** Confirm no output
* Set enable and values
** Confirm output
Loading

0 comments on commit c91f038

Please sign in to comment.