Pandad: turn on panda power (#2073)

* pandad turn on panda power

* Add gpio.py

* needs bytes

Co-authored-by: Comma Device <device@comma.ai>
pull/2079/head
Willem Melching 5 years ago committed by GitHub
parent 39c7dc2072
commit 6bb2630eba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 22
      common/gpio.py
  2. 4
      common/hardware.py
  3. 2
      release/files_common
  4. 23
      selfdrive/pandad.py
  5. 4
      selfdrive/thermald/thermald.py

@ -0,0 +1,22 @@
GPIO_HUB_RST_N = 30
GPIO_UBLOX_RST_N = 32
GPIO_UBLOX_SAFEBOOT_N = 33
GPIO_UBLOX_PWR_EN = 34
GPIO_STM_RST_N = 124
GPIO_STM_BOOT0 = 134
def gpio_init(pin, output):
try:
with open(f"/sys/class/gpio/gpio{pin}/direction", 'wb') as f:
f.write(b"out" if output else b"in")
except Exception as e:
print(f"Failed to set gpio {pin} direction: {e}")
def gpio_set(pin, high):
try:
with open(f"/sys/class/gpio/gpio{pin}/value", 'wb') as f:
f.write(b"1" if high else b"0")
except Exception as e:
print(f"Failed to set gpio {pin} value: {e}")

@ -0,0 +1,4 @@
import os
EON = os.path.isfile('/EON')
TICI = os.path.isfile('/TICI')

@ -18,6 +18,8 @@ apk/ai.comma*.apk
common/.gitignore common/.gitignore
common/__init__.py common/__init__.py
common/android.py common/android.py
common/hardware.py
common/gpio.py
common/realtime.py common/realtime.py
common/clock.pyx common/clock.pyx
common/timeout.py common/timeout.py

@ -3,8 +3,27 @@
import os import os
import time import time
from common.hardware import TICI
from common.gpio import GPIO_HUB_RST_N, GPIO_STM_BOOT0, GPIO_STM_RST_N, gpio_init, gpio_set
from panda import BASEDIR, Panda, PandaDFU, build_st
from selfdrive.swaglog import cloudlog from selfdrive.swaglog import cloudlog
from panda import Panda, PandaDFU, BASEDIR, build_st
def set_panda_power(power=True):
if not TICI:
return
gpio_init(GPIO_STM_RST_N, True)
gpio_init(GPIO_STM_BOOT0, True)
gpio_init(GPIO_HUB_RST_N, True)
gpio_set(GPIO_STM_RST_N, False)
gpio_set(GPIO_HUB_RST_N, True)
gpio_set(GPIO_STM_BOOT0, False)
time.sleep(0.1)
gpio_set(GPIO_STM_RST_N, power)
def get_firmware_fn(): def get_firmware_fn():
@ -88,10 +107,12 @@ def update_panda():
def main(): def main():
set_panda_power()
update_panda() update_panda()
os.chdir("boardd") os.chdir("boardd")
os.execvp("./boardd", ["./boardd"]) os.execvp("./boardd", ["./boardd"])
if __name__ == "__main__": if __name__ == "__main__":
main() main()

@ -11,6 +11,7 @@ import cereal.messaging as messaging
from cereal import log from cereal import log
from common.android import get_network_strength, get_network_type from common.android import get_network_strength, get_network_type
from common.filter_simple import FirstOrderFilter from common.filter_simple import FirstOrderFilter
from common.hardware import EON, TICI
from common.numpy_fast import clip, interp from common.numpy_fast import clip, interp
from common.params import Params, put_nonblocking from common.params import Params, put_nonblocking
from common.realtime import DT_TRML, sec_since_boot from common.realtime import DT_TRML, sec_since_boot
@ -39,9 +40,6 @@ DAYS_NO_CONNECTIVITY_MAX = 7 # do not allow to engage after a week without inte
DAYS_NO_CONNECTIVITY_PROMPT = 4 # send an offroad prompt after 4 days with no internet DAYS_NO_CONNECTIVITY_PROMPT = 4 # send an offroad prompt after 4 days with no internet
DISCONNECT_TIMEOUT = 5. # wait 5 seconds before going offroad after disconnect so you get an alert DISCONNECT_TIMEOUT = 5. # wait 5 seconds before going offroad after disconnect so you get an alert
EON = os.path.isfile('/EON')
TICI = os.path.isfile('/TICI')
LEON = False LEON = False
last_eon_fan_val = None last_eon_fan_val = None

Loading…
Cancel
Save