Skip to content

Commit

Permalink
Simpler stack to fix commaai#42
Browse files Browse the repository at this point in the history
  • Loading branch information
fedyk committed Nov 21, 2024
1 parent 786081d commit 43d057f
Show file tree
Hide file tree
Showing 24 changed files with 529 additions and 681 deletions.
8 changes: 1 addition & 7 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,15 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1

- run: bun install
- run: bun run build

- uses: actions/upload-pages-artifact@v3
with:
path: ./dist
path: ./

deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:

- run: bun install
- run: bun lint
- run: bun vitest
- run: bun test
Binary file modified bun.lockb
Binary file not shown.
200 changes: 198 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,206 @@
content="Update your comma device to the latest software"
/>
<title>flash.comma.ai</title>
<link href="https://cdn.jsdelivr.net/npm/@fontsource-variable/[email protected]/index.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/@fontsource-variable/[email protected]/index.min.css" rel="stylesheet">
<script src="https://cdn.tailwindcss.com?plugins=typography"></script>
<script>
tailwind.config = {
theme: {
extend: {
backgroundImage: {
'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))',
'gradient-conic':
'conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))',
},
fontFamily: {
sans: ['Inter Variable', 'sans-serif'],
monospace: ['JetBrains Mono Variable', 'monospace'],
},
}
}
}
</script>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
<div class="flex flex-col lg:flex-row flex-wrap">
<main class="p-12 md:p-16 lg:p-20 xl:p-24 w-screen max-w-none lg:max-w-prose lg:w-auto h-auto lg:h-screen lg:overflow-y-auto prose dark:prose-invert prose-green bg-white dark:bg-gray-900">
<section>
<img src="src/assets/comma.svg" alt="comma" width="128" height="128" class="dark:invert" />
<h1>flash.comma.ai</h1>
<p>This tool allows you to flash AGNOS onto your comma device.</p>
<p>
AGNOS is the Ubuntu-based operating system for your
<a href="https://comma.ai/shop/comma-3x" target="_blank">comma 3/3X</a>.
</p>
</section>
<hr />

<section>
<h2>Requirements</h2>
<ul>
<li>
A web browser which supports WebUSB (such as Google Chrome, Microsoft Edge, Opera), running on Windows, macOS, Linux, or Android.
</li>
<li>
A USB-C cable to power your device outside the car.
</li>
<li>
Another USB-C cable to connect the device to your computer.
</li>
</ul>
<h3>USB Driver</h3>
<p>
You need additional driver software for Windows before you connect
your device.
</p>
<ol>
<li>
Download and install <a href="https://zadig.akeo.ie/">Zadig</a>.
</li>
<li>
Under <code>Device</code> in the menu bar, select <code>Create New Device</code>.
<img
src="src/assets/zadig_create_new_device.png"
alt="Zadig Create New Device"
width="575"
height="254"
/>
</li>
<li>
Fill in three fields. The first field is just a description and
you can fill in anything. The next two fields are very important.
Fill them in with <code>05C6</code> and <code>9008</code> respectively.
Press &quot;Install Driver&quot; and give it a few minutes to install.
<img
src="src/assets/zadig_form.png"
alt="Zadig Form"
width="575"
height="254"
/>
</li>
</ol>
<p>
No additional software is required for macOS or Linux.
</p>
</section>
<hr />

<section>
<h2>QDL Mode</h2>
<p>Follow these steps to put your device into QDL mode:</p>
<ol>
<li>Power off the device and wait for the LEDs to switch off.</li>
<li>Connect the device to your computer using the USB-C port <strong>(port 2)</strong>.</li>
<li>Connect power to the OBD-C port <strong>(port 1)</strong>.</li>
<li>The device then should be visible as an option when choosing the device to flash</li>
</ol>
<img
src="src/assets/fastboot-ports.svg"
alt="image showing comma three and two ports. the upper port is labeled 1. the lower port is labeled 2."
width="450"
height="300"
/>
</section>
<hr />

<section>
<h2>Flashing</h2>
<p>
After your device is in QDL mode, you can click the button to start flashing. A prompt may appear to
select a device; choose the device starts with <code>QUSB_BULK</code>.
</p>
<p>
The process can take 30+ minutes depending on your internet connection and system performance. Do not
unplug the device until all steps are complete.
</p>
</section>
<hr />

<section>
<h2>Troubleshooting</h2>
<h3>Too slow</h3>
<p>
It is recommended that you use a USB 3.0 cable when flashing since it will speed up the flashing time by a lot.
</p>
<h3>Cannot enter QDL</h3>
<p>
Try using a different USB cable or USB port. Sometimes USB 2.0 ports work better than USB 3.0 (blue) ports.
If you&apos;re using a USB hub, try connecting the device directly to your computer, or alternatively use a
USB hub between your computer and the device.
</p>
<h3>My device&apos;s screen is blank</h3>
<p>
The device screen will be blank in QDL mode, but you can verify that it is in QDL if the device shows up
when you press the Flash icon.
</p>
<h3>After flashing, device says unable to mount data partition</h3>
<p>
This is expected after the filesystem is erased. Press confirm to finish resetting your device.
</p>
<h3>General Tips</h3>
<ul>
<li>Try another computer or OS</li>
<li>Try different USB ports on your computer</li>
<li>Try different USB-C cables, including the OBD-C cable that came with the device</li>
</ul>
<h3>Other questions</h3>
<p>
If you need help, join our <a href="https://discord.comma.ai" target="_blank">Discord server</a> and go to
the <strong>#hw-three-3x</strong> channel.
</p>
</section>

<div class="hidden lg:block">
<hr />
flash.comma.ai version: <code>dev</code>
</div>
</main>

<div id="root" class="lg:flex-1 h-[700px] lg:h-screen bg-gray-100 dark:bg-gray-800">
<p class="text-black dark:text-white">Loading...</p>
</div>

<div class="w-screen max-w-none p-12 md:p-16 prose dark:prose-invert bg-white dark:bg-gray-900 lg:hidden">
flash.comma.ai version: <code>dev</code>
</div>
</div>

<script type="importmap">
{
"imports": {
"react": "https://cdn.jsdelivr.net/npm/[email protected]/+esm",
"react-dom": "https://cdn.jsdelivr.net/npm/[email protected]/+esm",
"comlink": "https://cdn.jsdelivr.net/npm/[email protected]/+esm",
"crc-32": "https://cdn.jsdelivr.net/npm/[email protected]/+esm",
"jssha": "https://cdn.jsdelivr.net/npm/[email protected]/+esm",
"xz-decompress": "https://cdn.jsdelivr.net/npm/[email protected]/+esm"
}
}
</script>
<link rel="modulepreload" href="https://cdn.jsdelivr.net/npm/[email protected]/+esm" />
<link rel="modulepreload" href="https://cdn.jsdelivr.net/npm/[email protected]/+esm" />
<link rel="modulepreload" href="https://cdn.jsdelivr.net/npm/[email protected]/+esm" />
<link rel="modulepreload" href="https://cdn.jsdelivr.net/npm/[email protected]/+esm" />
<link rel="modulepreload" href="/src/app/Flash.js" />
<link rel="modulepreload" href="/src/config.js" />
<link rel="modulepreload" href="/src/QDL/utils.js" />
<link rel="modulepreload" href="/src/QDL/qdl.js" />
<link rel="modulepreload" href="/src/QDL/gpt.js" />
<link rel="modulepreload" href="/src/QDL/usblib.js" />
<link rel="modulepreload" href="/src/QDL/sahara.js" />
<link rel="modulepreload" href="/src/QDL/firehose.js" />
<link rel="modulepreload" href="/src/QDL/saharaDefs.js" />
<link rel="modulepreload" href="/src/QDL/xmlParser.js" />
<link rel="modulepreload" href="/src/QDL/sparse.js" />
<link rel="modulepreload" href="/src/utils/flash.js" />
<link rel="modulepreload" href="/src/utils/blob.js" />
<link rel="modulepreload" href="/src/utils/image.js" />
<link rel="modulepreload" href="/src/utils/manifest.js" />
<link rel="modulepreload" href="/src/utils/progress.js" />
<link rel="modulepreload" href="/src/workers/image.worker.js" />

<script type="module" src="/src/main.js"></script>
<script
defer
data-domain="flash.comma.ai"
Expand Down
49 changes: 13 additions & 36 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,45 +1,22 @@
{
"name": "@commaai/flash",
"version": "0.1.0",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"start": "vite preview",
"lint": "eslint . --ext js,jsx --report-unused-disable-directives",
"test": "vitest"
"devDependencies": {
"eslint": "^8.57.0",
"eslint-plugin-react": "^7.34.2",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-refresh": "^0.4.7"
},
"engines": {
"node": ">=20.11.0"
},
"dependencies": {
"@fontsource-variable/inter": "^5.0.18",
"@fontsource-variable/jetbrains-mono": "^5.0.21",
"comlink": "^4.4.1",
"crc-32": "^1.2.2",
"jssha": "^3.3.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"xz-decompress": "^0.2.1"
"private": true,
"scripts": {
"dev": "python3 -m http.server 5173",
"build": "echo \"Error: no build specified\" && exit 0",
"start": "python3 -m http.server 5173",
"lint": "echo \"Error: no lint confugured\" && exit 0",
"test": "echo \"Error: no test confugured\" && exit 0"
},
"devDependencies": {
"@tailwindcss/typography": "^0.5.13",
"@testing-library/jest-dom": "^6.4.5",
"@testing-library/react": "^15.0.7",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react": "^4.3.0",
"autoprefixer": "10.4.14",
"eslint": "^8.57.0",
"eslint-plugin-react": "^7.34.2",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-refresh": "^0.4.7",
"jsdom": "^22.1.0",
"postcss": "^8.4.38",
"tailwindcss": "^3.4.3",
"vite": "^5.2.12",
"vite-svg-loader": "^5.1.0",
"vitest": "^1.6.0"
}
"type": "module"
}
6 changes: 0 additions & 6 deletions postcss.config.js

This file was deleted.

6 changes: 3 additions & 3 deletions src/QDL/firehose.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { xmlParser } from "./xmlParser"
import { concatUint8Array, containsBytes, compareStringToBytes, sleep, readBlobAsBuffer } from "./utils"
import * as Sparse from "./sparse"
import { xmlParser } from "./xmlParser.js"
import { concatUint8Array, containsBytes, compareStringToBytes, sleep, readBlobAsBuffer } from "./utils.js"
import * as Sparse from "./sparse.js"


class response {
Expand Down
5 changes: 3 additions & 2 deletions src/QDL/gpt.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { containsBytes, bytes2Number } from "./utils"
import { buf as crc32 } from "crc-32"
import { containsBytes, bytes2Number } from "./utils.js"
import CRC32 from "crc-32"

export const AB_FLAG_OFFSET = 6;
export const AB_PARTITION_ATTR_SLOT_ACTIVE = (0x1 << 2);
export const PART_ATT_PRIORITY_BIT = BigInt(48)
export const PART_ATT_ACTIVE_BIT = BigInt(50)
export const PART_ATT_ACTIVE_VAL = BigInt(0x1) << PART_ATT_ACTIVE_BIT

const crc32 = CRC32.buf
const efiType = {
0x00000000 : "EFI_UNUSED",
0xEBD0A0A2 : "EFI_BASIC_DATA",
Expand Down
10 changes: 5 additions & 5 deletions src/QDL/qdl.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as gpt from "./gpt"
import { usbClass } from "./usblib"
import { Sahara } from "./sahara"
import { Firehose } from "./firehose"
import { concatUint8Array, runWithTimeout, containsBytes } from "./utils"
import * as gpt from "./gpt.js"
import { usbClass } from "./usblib.js"
import { Sahara } from "./sahara.js"
import { Firehose } from "./firehose.js"
import { concatUint8Array, runWithTimeout, containsBytes } from "./utils.js"


export class qdlDevice {
Expand Down
6 changes: 3 additions & 3 deletions src/QDL/sahara.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CommandHandler, cmd_t, sahara_mode_t, status_t, exec_cmd_t } from "./saharaDefs"
import { concatUint8Array, packGenerator, readBlobAsBuffer } from "./utils";
import config from "@/config"
import { CommandHandler, cmd_t, sahara_mode_t, status_t, exec_cmd_t } from "./saharaDefs.js"
import { concatUint8Array, packGenerator, readBlobAsBuffer } from "./utils.js";
import config from "../config.js"


export class Sahara {
Expand Down
2 changes: 1 addition & 1 deletion src/QDL/saharaDefs.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { structHelper_io } from "./utils"
import { structHelper_io } from "./utils.js"


export const cmd_t = {
Expand Down
2 changes: 1 addition & 1 deletion src/QDL/sparse.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { readBlobAsBuffer } from "./utils";
import { readBlobAsBuffer } from "./utils.js";

const FILE_MAGIC = 0xed26ff3a;
export const FILE_HEADER_SIZE = 28;
Expand Down
2 changes: 1 addition & 1 deletion src/QDL/usblib.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { concatUint8Array, sleep } from "./utils";
import { concatUint8Array, sleep } from "./utils.js";

const vendorID = 0x05c6;
const productID = 0x9008;
Expand Down
10 changes: 0 additions & 10 deletions src/app/App.test.jsx

This file was deleted.

Loading

0 comments on commit 43d057f

Please sign in to comment.