diff --git a/apk/ai.comma.plus.offroad.apk b/apk/ai.comma.plus.offroad.apk index ed46e1a741..522611475f 100644 --- a/apk/ai.comma.plus.offroad.apk +++ b/apk/ai.comma.plus.offroad.apk @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:441c03e9bcb881ecc7933872d31d9dc7734a8673f3898fc8d8c49c6a15875b72 -size 15382430 +oid sha256:d6f5543949481e6c9dc225d33efb122957a8a85b2c16e6454f8c4f1b01d5d463 +size 15385239 diff --git a/apk/external/.gitignore b/apk/external/.gitignore new file mode 100644 index 0000000000..3cdb953094 --- /dev/null +++ b/apk/external/.gitignore @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0795c5ce6068f7ab3fcf23dccbee8b9c76da86808eacf4814ea99be4057ee83f +size 12 diff --git a/apk/external/com.spotify.music.apkpatch b/apk/external/com.spotify.music.apkpatch new file mode 100644 index 0000000000..79853d461a --- /dev/null +++ b/apk/external/com.spotify.music.apkpatch @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ce98217d60516c28fd68135a87144be86c63bd8f5e87de64f945925b6cce46af +size 1947345 diff --git a/apk/external/com.waze.apkpatch b/apk/external/com.waze.apkpatch new file mode 100644 index 0000000000..764901c817 --- /dev/null +++ b/apk/external/com.waze.apkpatch @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:57f794afccdc34ed52fc38628dbd20c1b9cae170b8c148cb49ab1e9dd1fe84f0 +size 3870675 diff --git a/apk/external/out/.gitkeep b/apk/external/out/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/apk/external/patcher.py b/apk/external/patcher.py new file mode 100755 index 0000000000..5713c208f1 --- /dev/null +++ b/apk/external/patcher.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3e43d684937dfd3f907ac5bcc83a513a3030600bba042ef2396dce208847f551 +size 3521 diff --git a/apk/external/src/.gitkeep b/apk/external/src/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/apk/external/tools/ApkPatch.android.jar b/apk/external/tools/ApkPatch.android.jar new file mode 100644 index 0000000000..6da31e3c6b --- /dev/null +++ b/apk/external/tools/ApkPatch.android.jar @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8358afec7442e90c4eeffc4db4b4b00793df0f51c909976b4e95e3c8f8dacdcd +size 1310659 diff --git a/apk/external/tools/apkpatch_android b/apk/external/tools/apkpatch_android new file mode 100755 index 0000000000..6c06520b1e --- /dev/null +++ b/apk/external/tools/apkpatch_android @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ca197862754835da4f0bc30823845e3448334f8c5e2093a1947348d2fed753a2 +size 176 diff --git a/apk/external/tools/certificate.pem b/apk/external/tools/certificate.pem new file mode 100755 index 0000000000..79acebef04 --- /dev/null +++ b/apk/external/tools/certificate.pem @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b2e32152e7972032fd64ad351323f50008602c60feb19522b1aadd414bf1f7b4 +size 1001 diff --git a/apk/external/tools/key.pk8 b/apk/external/tools/key.pk8 new file mode 100755 index 0000000000..8136ff8c2c --- /dev/null +++ b/apk/external/tools/key.pk8 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a07ce769d17334f803a499c520d4a7d88478ceb1a9cf740faf296f8f54616e82 +size 633 diff --git a/apk/external/tools/signapk.android.jar b/apk/external/tools/signapk.android.jar new file mode 100644 index 0000000000..d27e59b169 --- /dev/null +++ b/apk/external/tools/signapk.android.jar @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5743dd91db33116bd7444d7407eb14b140ab2694f8525fc34c66d22256f50634 +size 542612 diff --git a/apk/external/tools/signapk_android b/apk/external/tools/signapk_android new file mode 100755 index 0000000000..e38ec00139 --- /dev/null +++ b/apk/external/tools/signapk_android @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:123549475cad6ae6ce2261f81caf8f094b3b3d31076e3c320fd08301eb45e657 +size 194 diff --git a/launch_openpilot.sh b/launch_openpilot.sh index 4b55f80f11..2e7b163c8c 100755 --- a/launch_openpilot.sh +++ b/launch_openpilot.sh @@ -8,12 +8,6 @@ function launch { exec "${BASH_SOURCE[0]}" fi - # check if NEOS update is required - while [ "$(cat /VERSION)" -lt 4 ] && [ ! -e /data/media/0/noupdate ]; do - curl -o /tmp/updater https://neos.comma.ai/updater && chmod +x /tmp/updater && /tmp/updater - sleep 10 - done - # no cpu rationing for now echo 0-3 > /dev/cpuset/background/cpus echo 0-3 > /dev/cpuset/system-background/cpus @@ -26,6 +20,12 @@ function launch { until ping -W 1 -c 1 8.8.8.8; do sleep 1; done kill $spin_pid + # check if NEOS update is required + while [ "$(cat /VERSION)" -lt 4 ] && [ ! -e /data/media/0/noupdate ]; do + curl -o /tmp/updater https://neos.comma.ai/updater && chmod +x /tmp/updater && /tmp/updater + sleep 10 + done + export PYTHONPATH="$PWD" # start manager diff --git a/selfdrive/debug/get_fingerprint.py b/selfdrive/debug/get_fingerprint.py new file mode 100755 index 0000000000..c642c38f15 --- /dev/null +++ b/selfdrive/debug/get_fingerprint.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python + +# simple script to get a vehicle fingerprint. +# keep this script running for few seconds: some messages are published every few seconds + +# Instructions: +# - connect to a Panda +# - run selfdrive/boardd/boardd +# - launching this script +# - since some messages are published at low frequency, keep this script running for few seconds, +# until all messages are received at least once + +import zmq +import selfdrive.messaging as messaging +from selfdrive.services import service_list + +context = zmq.Context() +logcan = messaging.sub_sock(context, service_list['can'].port) +msgs = {} +while True: + lc = messaging.recv_sock(logcan, True) + for c in lc.can: + if c.src == 0: + msgs[c.address] = len(c.dat) + + fingerprint = ', '.join("%d: %d" % v for v in sorted(msgs.items())) + + print "number of messages:", len(msgs) + print "fingerprint", fingerprint diff --git a/selfdrive/manager.py b/selfdrive/manager.py index c3ed883382..044589c9cf 100755 --- a/selfdrive/manager.py +++ b/selfdrive/manager.py @@ -1,4 +1,5 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 + import os import sys import time @@ -40,6 +41,7 @@ if __name__ == "__main__": os._exit(os.wait()[1]) +import glob import shutil import hashlib import importlib @@ -54,6 +56,7 @@ os.environ['BASEDIR'] = BASEDIR import usb1 import zmq from setproctitle import setproctitle +from smbus2 import SMBus from common.params import Params from common.realtime import sec_since_boot @@ -68,6 +71,8 @@ import selfdrive.crash as crash from selfdrive.loggerd.config import ROOT +EON = os.path.exists("/EON") + # comment out anything you don't want to run managed_processes = { "uploader": "selfdrive.loggerd.uploader", @@ -272,10 +277,6 @@ def system(cmd): output=e.output[-1024:], returncode=e.returncode) -EON = os.path.exists("/EON") -if EON: - from smbus2 import SMBus - def setup_eon_fan(): if not EON: return @@ -530,34 +531,50 @@ def install_apk(path): return ret == 0 def update_apks(): + # patch apks + if os.getenv("PREPAREONLY"): + # assume we have internet, download too + patched = subprocess.call([os.path.join(BASEDIR, "apk/external/patcher.py")]) + else: + patched = subprocess.call([os.path.join(BASEDIR, "apk/external/patcher.py"), "patch"]) + cloudlog.info("patcher: %r" % (patched,)) + # install apks installed = get_installed_apks() - for app in os.listdir(os.path.join(BASEDIR, "apk/")): - if ".apk" in app: - app = app.split(".apk")[0] - if app not in installed: - installed[app] = None + + install_apks = (glob.glob(os.path.join(BASEDIR, "apk/*.apk")) + + glob.glob(os.path.join(BASEDIR, "apk/external/out/*.apk"))) + for apk in install_apks: + app = os.path.basename(apk)[:-4] + if app not in installed: + installed[app] = None + cloudlog.info("installed apks %s" % (str(installed), )) for app in installed.iterkeys(): + apk_path = os.path.join(BASEDIR, "apk/"+app+".apk") - if os.path.isfile(apk_path): - h1 = hashlib.sha1(open(apk_path).read()).hexdigest() - h2 = None - if installed[app] is not None: - h2 = hashlib.sha1(open(installed[app]).read()).hexdigest() - cloudlog.info("comparing version of %s %s vs %s" % (app, h1, h2)) - - if h2 is None or h1 != h2: - cloudlog.info("installing %s" % app) - + if not os.path.exists(apk_path): + apk_path = os.path.join(BASEDIR, "apk/external/out/"+app+".apk") + if not os.path.exists(apk_path): + continue + + h1 = hashlib.sha1(open(apk_path).read()).hexdigest() + h2 = None + if installed[app] is not None: + h2 = hashlib.sha1(open(installed[app]).read()).hexdigest() + cloudlog.info("comparing version of %s %s vs %s" % (app, h1, h2)) + + if h2 is None or h1 != h2: + cloudlog.info("installing %s" % app) + + success = install_apk(apk_path) + if not success: + cloudlog.info("needing to uninstall %s" % app) + system("pm uninstall %s" % app) success = install_apk(apk_path) - if not success: - cloudlog.info("needing to uninstall %s" % app) - system("pm uninstall %s" % app) - success = install_apk(apk_path) - assert success + assert success def manager_update(): update_apks() @@ -577,7 +594,7 @@ def uninstall(): with open('/cache/recovery/command', 'w') as f: f.write('--wipe_data\n') # IPowerManager.reboot(confirm=false, reason="recovery", wait=true) - os.system("service call power 16 i32 0 s16 recovery i32 1") + os.system("service call power 16 i32 0 s16 recovery i32 1") def main(): if os.getenv("NOLOG") is not None: diff --git a/selfdrive/updated.py b/selfdrive/updated.py index b87b0a9162..516fa31ba9 100644 --- a/selfdrive/updated.py +++ b/selfdrive/updated.py @@ -6,6 +6,9 @@ import os import time import subprocess +from common.basedir import BASEDIR +from selfdrive.swaglog import cloudlog + def main(gctx=None): while True: # try network @@ -14,12 +17,16 @@ def main(gctx=None): time.sleep(60) continue - # try fetch r = subprocess.call(["nice", "-n", "19", "git", "fetch", "--depth=1"]) + cloudlog.info("git fetch: %r", r) if r: time.sleep(60) continue + # download apks + r = subprocess.call(["nice", "-n", "19", os.path.join(BASEDIR, "apk/external/patcher.py"), "download"]) + cloudlog.info("patcher download: %r", r) + time.sleep(60*60*3) if __name__ == "__main__":