Repository: commaai/eon-neos Branch: master Commit: 8f12ec711688 Files: 5 Total size: 5.6 KB Directory structure: gitextract_xc9gh4jz/ ├── .gitignore ├── README.md ├── download.py ├── flash.ps1 └── flash.sh ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ .*.swp files META-INF system.simg ota-signed-* recovery* platform-tools-latest-windows.zip platform-tools-latest-linux.zip platform-tools-latest-darwin.zip platform-tools/ ================================================ FILE: README.md ================================================ NEOS ====== NEOS is the operating system for your [comma two](https://comma.ai/shop/products/comma-two-devkit) and [EON Gold Dashcam Development Kit](https://comma.ai/shop/products/eon-gold-dashcam-devkit). Updates ------ When openpilot requires a NEOS update, you won't have to do anything. NEOS updates download in the background auotmatically, just like normal openpilot updates. This repo is for restoring or recovering your device. Restoring on macOS & Linux ------ 1. Connect your comma two (via a USB-C to USB-A cable) or EON Gold (via a USB-mini-B to USB-A cable) to your computer 2. Open a terminal 3. Clone this repo `git clone https://github.com/commaai/eon-neos.git`, then `cd eon-neos` 4. Run `./download.py` 5. Put your device into fastboot mode by turning off your device, then holding volume down + power. 6. Run `./flash.sh` DO NOT DISCONNECT THE DEVICE! Restoring on Windows ------ 1. Install the Google USB driver for ADB (Android Debug Bridge)... https://developer.android.com/studio/run/win-usb 2. Connect your comma two (via a USB-C to USB-A cable) or EON Gold (via a USB-mini-B to USB-A cable) to your computer 3. Download and extract this repository 4. Download & install Python 3 5. Run download.py to download NEOS and flashing tools 6. Put your device into fastboot mode by turning off your device, then holding volume down + power. 7. Run flash.ps1 (right click, run with powershell). DO NOT DISCONNECT THE DEVICE! ================================================ FILE: download.py ================================================ #!/usr/bin/env python import os import sys import json import hashlib import argparse import zipfile try: # Python 3 from urllib.request import urlopen, urlretrieve except ImportError: # Python 2 from urllib import urlopen, urlretrieve MASTER_MANIFEST = "https://raw.githubusercontent.com/commaai/openpilot/commatwo_master/selfdrive/hardware/eon/neos.json" RELEASE_MANIFEST = "https://raw.githubusercontent.com/commaai/openpilot/release2/selfdrive/hardware/eon/neos.json" def download_progress(count, blockSize, totalSize): if count % 1000 == 0: sys.stdout.write('.') sys.stdout.flush() def sha256_checksum(filename, block_size=65536): sha256 = hashlib.sha256() with open(filename, 'rb') as f: for block in iter(lambda: f.read(block_size), b''): sha256.update(block) return sha256.hexdigest() def download(url, fhash, finalname): if os.path.isfile(finalname) and sha256_checksum(finalname).lower() == fhash.lower(): print("already downloaded %s" % url) return print("downloading %s with hash %s" % (url, fhash)) fn = url.split("/")[-1] urlretrieve(url, fn, download_progress) assert sha256_checksum(fn).lower() == fhash.lower() print("hash check pass") os.rename(fn, finalname) if __name__ == "__main__": parser = argparse.ArgumentParser(description='Download NEOS') parser.add_argument('--master', action='store_true', help='Download NEOS version used on the master branch') args = parser.parse_args() manifest = MASTER_MANIFEST if args.master else RELEASE_MANIFEST r = urlopen(manifest) up = json.loads(r.read().decode()) download(up['recovery_url'], up['recovery_hash'], "recovery.img") download(up['ota_url'], up['ota_hash'], "ota-signed-latest.zip") with zipfile.ZipFile("ota-signed-latest.zip", 'r') as z: z.extractall() ================================================ FILE: flash.ps1 ================================================ $fastboot = "platform-tools/fastboot.exe" if (Test-Path -path $fastboot) { Write-Host 'Platform tools found'; } else { Write-Host 'Downloading platform tools'; $client = new-object System.Net.WebClient $client.DownloadFile("https://dl.google.com/android/repository/platform-tools_r28.0.2-windows.zip", "platform-tools.zip") Write-Host 'Extracting platform tools'; Expand-Archive -Path "platform-tools.zip" -DestinationPath "." -Force Remove-Item "platform-tools.zip" } if (Test-Path -path "files/system.img") { $zip_file = Get-Item "ota-signed-latest.zip" $system_img = Get-Item "files/system.img" if ($zip_file.CreationTime -gt $system_img.CreationTime){ Write-Host 'Newer version found. Extracting...'; Expand-Archive -Path "ota-signed-latest.zip" -DestinationPath "." -Force } } else { Write-Host 'Extracting NEOS...'; Expand-Archive -Path "ota-signed-latest.zip" -DestinationPath "." -Force } Invoke-Expression "$($fastboot) flash recovery recovery.img" Invoke-Expression "$($fastboot) flash boot files/boot.img" Invoke-Expression "$($fastboot) flash system files/system.img" Invoke-Expression "$($fastboot) erase userdata" Invoke-Expression "$($fastboot) format cache" Invoke-Expression "$($fastboot) reboot" Write-Host -NoNewLine 'Press any key to continue...'; $null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown'); ================================================ FILE: flash.sh ================================================ #!/bin/bash -e FASTBOOT=platform-tools/fastboot VERSION="r28.0.2" PLATFORM="$(uname -s | tr '[:upper:]' '[:lower:]')" if [ ! -f $FASTBOOT ]; then rm -rf platform-tools rm -f platform-tools-latest-$PLATFORM.zip curl -L https://dl.google.com/android/repository/platform-tools_$VERSION-$PLATFORM.zip --output platform-tools.zip unzip platform-tools.zip rm -f platform-tools.zip fi echo "Please enter your computer password if prompted" sudo $FASTBOOT oem 4F500301 || true sudo $FASTBOOT flash recovery recovery.img # from OTA [ -f files/logo.bin ] && $FASTBOOT flash LOGO files/logo.bin sudo $FASTBOOT flash boot files/boot.img sudo $FASTBOOT flash system files/system.img # clear userdata sudo $FASTBOOT erase userdata sudo $FASTBOOT format cache sudo $FASTBOOT reboot