diff --git a/README.md b/README.md index e2956ddd..4be1dabc 100644 --- a/README.md +++ b/README.md @@ -8,13 +8,24 @@ It supports 3x CAN, 2x LIN, and 1x GMLAN. It also charges a phone. On the comput It uses an [STM32F413](http://www.st.com/en/microcontrollers/stm32f413-423.html?querycriteria=productId=LN2004). -It is 2nd gen hardware, reusing code and parts from the [NEO](https://github.com/commaai/neo) interface board. - ![panda tests](https://github.com/commaai/panda/workflows/tests/badge.svg) ![panda drivers](https://github.com/commaai/panda/workflows/drivers/badge.svg) ## Usage +Setup your dependencies: + +```bash +# Ubuntu +sudo apt-get install dfu-util gcc-arm-none-eabi python3-pip +pip install -r requirements.txt + +# macOS +brew tap ArmMbed/homebrew-formulae +brew install python dfu-util arm-none-eabi-gcc +pip install -r requirements.txt +``` + ### Python To install the library: @@ -47,16 +58,12 @@ sudo udevadm control --reload-rules && sudo udevadm trigger The panda jungle uses different udev rules. See [the repo](https://github.com/commaai/panda_jungle#udev-rules) for instructions. -### JavaScript - -See [PandaJS](https://github.com/commaai/pandajs) - - ## Software interface support As a universal car interface, it should support every reasonable software interface. -- [User space](https://github.com/commaai/panda/tree/master/python) +- [Python library](https://github.com/commaai/panda/tree/master/python) +- [C++ library](https://github.com/commaai/openpilot/tree/master/selfdrive/boardd) - [socketcan in kernel](https://github.com/commaai/panda/tree/master/drivers/linux) (alpha) - [Windows J2534](https://github.com/commaai/panda/tree/master/drivers/windows) diff --git a/UPDATING.md b/UPDATING.md deleted file mode 100644 index ab60f88a..00000000 --- a/UPDATING.md +++ /dev/null @@ -1,9 +0,0 @@ -# Updating your panda - -Panda should update automatically via the [openpilot](http://openpilot.comma.ai/). - -On Linux or Mac OSX, you can manually update it using: -``` -sudo pip install --upgrade pandacan` -PYTHONPATH="" sudo python -c "import panda; panda.flash_release()"` -``` diff --git a/__init__.py b/__init__.py index 6b2d73a8..6f8af2bd 100644 --- a/__init__.py +++ b/__init__.py @@ -1,7 +1,7 @@ # flake8: noqa # pylint: skip-file -from .python import Panda, PandaDFU, flash_release, \ - BASEDIR, ensure_st_up_to_date, PandaSerial, pack_can_buffer, unpack_can_buffer, \ +from .python import Panda, PandaDFU, \ + BASEDIR, PandaSerial, pack_can_buffer, unpack_can_buffer, \ DEFAULT_FW_FN, DEFAULT_H7_FW_FN, MCU_TYPE_H7, MCU_TYPE_F4, DLC_TO_LEN, LEN_TO_DLC, \ ALTERNATIVE_EXPERIENCE diff --git a/board/README.md b/board/README.md index 4bd4b89a..4434d28a 100644 --- a/board/README.md +++ b/board/README.md @@ -1,20 +1,3 @@ -Dependencies --------- - -**Mac** - -``` -xcode-select --install -./get_sdk_mac.sh -``` - -**Debian / Ubuntu** - -``` -./get_sdk.sh -``` - - Programming ---- diff --git a/board/get_sdk.sh b/board/get_sdk.sh deleted file mode 100755 index c0d05651..00000000 --- a/board/get_sdk.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -sudo apt-get install dfu-util gcc-arm-none-eabi python3-pip -sudo pip install libusb1 pycryptodome requests diff --git a/board/get_sdk_mac.sh b/board/get_sdk_mac.sh deleted file mode 100755 index 9e4b7159..00000000 --- a/board/get_sdk_mac.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -# Need formula for gcc -sudo easy_install pip -/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" -brew tap ArmMbed/homebrew-formulae -brew install python dfu-util arm-none-eabi-gcc -pip install --user libusb1 pycryptodome requests diff --git a/board/main.c b/board/main.c index 62d646d5..94d0c7f7 100644 --- a/board/main.c +++ b/board/main.c @@ -169,7 +169,7 @@ void tick_handler(void) { #endif // set green LED to be controls allowed - current_board->set_led(LED_GREEN, controls_allowed | green_led_enabled); + current_board->set_led(LED_GREEN, controls_allowed); // turn off the blue LED, turned on by CAN // unless we are in power saving mode diff --git a/board/main_comms.h b/board/main_comms.h index 9dac7451..3eef0f33 100644 --- a/board/main_comms.h +++ b/board/main_comms.h @@ -529,10 +529,6 @@ int comms_control_handler(ControlPacket_t *req, uint8_t *resp) { case 0xf6: siren_enabled = (req->param1 != 0U); break; - // **** 0xf7: set green led enabled - case 0xf7: - green_led_enabled = (req->param1 != 0U); - break; // **** 0xf8: disable heartbeat checks case 0xf8: if (!is_car_safety_mode(current_safety_mode)) { diff --git a/board/main_declarations.h b/board/main_declarations.h index 208afadf..d4df77ba 100644 --- a/board/main_declarations.h +++ b/board/main_declarations.h @@ -14,7 +14,6 @@ void pwm_set(TIM_TypeDef *TIM, uint8_t channel, uint8_t percentage); uint8_t hw_type = 0; const board *current_board; uint32_t uptime_cnt = 0; -bool green_led_enabled = false; // heartbeat state uint32_t heartbeat_counter = 0; diff --git a/python/__init__.py b/python/__init__.py index 4f0915cc..07efeed4 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -14,8 +14,6 @@ from typing import Optional from itertools import accumulate from .dfu import PandaDFU, MCU_TYPE_F2, MCU_TYPE_F4, MCU_TYPE_H7 # pylint: disable=import-error -from .flash_release import flash_release # noqa pylint: disable=import-error -from .update import ensure_st_up_to_date # noqa pylint: disable=import-error from .serial import PandaSerial # noqa pylint: disable=import-error from .isotp import isotp_send, isotp_recv # pylint: disable=import-error from .config import DEFAULT_FW_FN, DEFAULT_H7_FW_FN, SECTOR_SIZES_FX, SECTOR_SIZES_H7 # noqa pylint: disable=import-error @@ -600,9 +598,6 @@ class Panda: # ******************* configuration ******************* - def set_usb_power(self, on): - self._handle.controlWrite(Panda.REQUEST_OUT, 0xe6, int(on), 0, b'') - def set_power_save(self, power_save_enabled=0): self._handle.controlWrite(Panda.REQUEST_OUT, 0xe7, int(power_save_enabled), 0, b'') @@ -847,7 +842,3 @@ class Panda: # ****************** Siren ***************** def set_siren(self, enabled): self._handle.controlWrite(Panda.REQUEST_OUT, 0xf6, int(enabled), 0, b'') - - # ****************** Debug ***************** - def set_green_led(self, enabled): - self._handle.controlWrite(Panda.REQUEST_OUT, 0xf7, int(enabled), 0, b'') diff --git a/python/flash_release.py b/python/flash_release.py deleted file mode 100755 index ae50e6dc..00000000 --- a/python/flash_release.py +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/env python3 - -import sys -import time -import requests -import json -import io - -def flash_release(path=None, st_serial=None): - from panda import Panda, PandaDFU - from zipfile import ZipFile - - def status(x): - print("\033[1;32;40m" + x + "\033[00m") - - if st_serial is not None: - # look for Panda - panda_list = Panda.list() - if len(panda_list) == 0: - raise Exception("panda not found, make sure it's connected and your user can access it") - elif len(panda_list) > 1: - raise Exception("Please only connect one panda") - st_serial = panda_list[0] - print("Using panda with serial %s" % st_serial) - - if path is None: - print("Fetching latest firmware from github.com/commaai/panda-artifacts") - r = requests.get("https://raw.githubusercontent.com/commaai/panda-artifacts/master/latest.json") - url = json.loads(r.text)['url'] - r = requests.get(url) - print("Fetching firmware from %s" % url) - path = io.BytesIO(r.content) - - zf = ZipFile(path) - zf.printdir() - - version = zf.read("version").decode().strip() - status("0. Preparing to flash " + str(version)) - - code_bootstub = zf.read("bootstub.panda.bin") - code_panda = zf.read("panda.bin") - - # enter DFU mode - status("1. Entering DFU mode") - panda = Panda(st_serial) - panda.reset(enter_bootstub=True) - panda.reset(enter_bootloader=True) - time.sleep(1) - - # program bootstub - status("2. Programming bootstub") - dfu = PandaDFU(PandaDFU.st_serial_to_dfu_serial(st_serial)) - dfu.program_bootstub(code_bootstub) - time.sleep(1) - - # flash main code - status("3. Flashing main code") - panda = Panda(st_serial) - panda.flash(code=code_panda) - panda.close() - - # check for connection - status("4. Verifying version") - panda = Panda(st_serial) - my_version = panda.get_version() - print("dongle id: %s" % panda.get_serial()[0]) - print(my_version, "should be", version) - assert(str(version) == str(my_version)) - - # done! - status("6. Success!") - -if __name__ == "__main__": - flash_release(*sys.argv[1:]) diff --git a/python/update.py b/python/update.py deleted file mode 100755 index f8e32804..00000000 --- a/python/update.py +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env python3 -import os -import time - -def ensure_st_up_to_date(): - from panda import Panda, PandaDFU, BASEDIR - - with open(os.path.join(BASEDIR, "VERSION")) as f: - repo_version = f.read() - - repo_version += "-EON" if os.path.isfile('/EON') else "-DEV" - - panda = None - panda_dfu = None - - while 1: - # break on normal mode Panda - panda_list = Panda.list() - if len(panda_list) > 0: - panda = Panda(panda_list[0]) - break - - # flash on DFU mode Panda - panda_dfu = PandaDFU.list() - if len(panda_dfu) > 0: - panda_dfu = PandaDFU(panda_dfu[0]) - panda_dfu.recover() - - print("waiting for board...") - time.sleep(1) - - if panda.bootstub or not panda.get_version().startswith(repo_version): - panda.flash() - - if panda.bootstub: - panda.recover() - - assert(not panda.bootstub) - version = str(panda.get_version()) - print("%s should be %s" % (version, repo_version)) - assert(version.startswith(repo_version)) - -if __name__ == "__main__": - ensure_st_up_to_date()