Skip to content

Commit

Permalink
make pedal flash CAN compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
BogGyver committed Jun 12, 2019
1 parent cee67b6 commit d5abe28
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
16 changes: 12 additions & 4 deletions panda/board/pedal_tesla/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,31 @@ CERT = ../../certs/debug
CFLAGS += "-DALLOW_DEBUG"

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

usbflash: obj/$(PROJ_NAME).bin
../../tests/pedal/enter_canloader.py; sleep 0.5
../../tests/pedal/enter_canloader_tesla.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
../../tests/pedal/enter_canloader_tesla.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

include ../../common/version.mk

obj/cert.h: ../../crypto/getcertheader.py
../../crypto/getcertheader.py ../../certs/debug.pub ../../certs/release.pub > $@

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

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

obj/$(STARTUP_FILE).o: ../$(STARTUP_FILE).s
Expand Down
5 changes: 3 additions & 2 deletions panda/board/pedal_tesla/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@

#define CAN CAN1

//#define PEDAL

//#define PEDAL_USB

#ifdef PEDAL_USB
#include "drivers/usb.h"
#endif

#define ENTER_BOOTLOADER_MAGIC 0xdeadbeef
uint32_t enter_bootloader_mode;

void __initialize_hardware_early() {
Expand Down Expand Up @@ -87,6 +86,8 @@ int can_cksum(uint8_t *dat, int len, int addr) {
// addresses to be used on CAN
#define CAN_GAS_INPUT 0x551
#define CAN_GAS_OUTPUT 0x552
#define CAN_GAS_SIZE 6
#define COUNTER_CYCLE 0xF

void CAN1_TX_IRQHandler() {
// clear interrupt
Expand Down
1 change: 1 addition & 0 deletions panda/tests/pedal/enter_canloader_tesla.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def bulkRead(self, endpoint, length, timeout=0):
exit(0)
else:
p.can_send(0x551, "\xce\xfa\xad\xde\x1e\x0b\xb0\x0a", 2)

if args.fn:
time.sleep(0.1)
print "flashing", args.fn
Expand Down

0 comments on commit d5abe28

Please sign in to comment.