Skip to content

Commit

Permalink
use @commaai/qdl package
Browse files Browse the repository at this point in the history
  • Loading branch information
incognitojam committed Jan 17, 2025
1 parent 07437e6 commit 2815fde
Show file tree
Hide file tree
Showing 10 changed files with 136 additions and 111 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[flash.comma.ai](https://flash.comma.ai)

This tool allows you to flash AGNOS onto your comma device. Uses a fork of [fastboot.js](https://github.com/kdrag0n/fastboot.js).
This tool allows you to flash AGNOS onto your comma device.

## Development

Expand Down
Binary file modified bun.lockb
Binary file not shown.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
"node": ">=20.11.0"
},
"dependencies": {
"@commaai/qdl": "git+https://github.com/commaai/qdl.js.git",
"@fontsource-variable/inter": "^5.0.18",
"@fontsource-variable/jetbrains-mono": "^5.0.21",
"android-fastboot": "github:commaai/fastboot.js#c3ec6fe3c96a48dab46e23d0c8c861af15b2144a",
"comlink": "^4.4.1",
"crc-32": "^1.2.2",
"jssha": "^3.3.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
Expand Down
Binary file renamed src/QDL/programmer.bin → src/QDL/sdm845_fhprg.bin
Binary file not shown.
65 changes: 57 additions & 8 deletions src/app/Flash.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useCallback } from 'react'
import { useCallback, useState } from 'react'

import { Step, Error, useFastboot } from '../utils/fastboot'
import { Step, Error, useQdl } from '../utils/flash'

import bolt from '../assets/bolt.svg'
import cable from '../assets/cable.svg'
Expand Down Expand Up @@ -57,8 +57,9 @@ const steps = {
},
[Step.DONE]: {
status: 'Done',
description: 'Your device has been updated successfully. You can now unplug the USB cable from your computer. To ' +
'complete the system reset, follow the instructions on your device.',
description: 'Your device has been updated successfully. You can now unplug the all cables from your device, '
+'and wait for the light to stop blinking then plug the power cord in again. '
+' To complete the system reset, follow the instructions on your device.',
bgColor: 'bg-green-500',
icon: done,
},
Expand All @@ -67,7 +68,8 @@ const steps = {
const errors = {
[Error.UNKNOWN]: {
status: 'Unknown error',
description: 'An unknown error has occurred. Restart your browser and try again.',
description: 'An unknown error has occurred. Unplug your device and wait for 20s. ' +
'Restart your browser and try again.',
bgColor: 'bg-red-500',
icon: exclamation,
},
Expand All @@ -79,12 +81,14 @@ const errors = {
},
[Error.LOST_CONNECTION]: {
status: 'Lost connection',
description: 'The connection to your device was lost. Check that your cables are connected properly and try again.',
description: 'The connection to your device was lost. Check that your cables are connected properly and try again. ' +
'Unplug your device and wait for around 20s.',
icon: cable,
},
[Error.DOWNLOAD_FAILED]: {
status: 'Download failed',
description: 'The system image could not be downloaded. Check your internet connection and try again.',
description:'The system image could not be downloaded. Unplug your device and wait for 20s. ' +
'Check your internet connection and try again.',
icon: cloudError,
},
[Error.CHECKSUM_MISMATCH]: {
Expand All @@ -111,6 +115,11 @@ const errors = {
},
}

const detachScript = [
"for d in /sys/bus/usb/drivers/qcserial/*-*; do [ -e \"$d\" ] && echo -n \"$(basename $d)\" | sudo tee /sys/bus/usb/drivers/qcserial/unbind > /dev/null; done"
];

const isLinux = navigator.userAgent.toLowerCase().includes('linux');

function LinearProgress({ value, barColor }) {
if (value === -1 || value > 100) value = 100
Expand Down Expand Up @@ -187,7 +196,7 @@ export default function Flash() {

connected,
serial,
} = useFastboot()
} = useQdl()

const handleContinue = useCallback(() => {
onContinue?.()
Expand Down Expand Up @@ -220,6 +229,15 @@ export default function Flash() {
window.removeEventListener("beforeunload", beforeUnloadListener, { capture: true })
}

const [copied, setCopied] = useState(false);
const handleCopy = () => {
setCopied(true);
setTimeout(() => {
setCopied(false);
}, 1000);
};


return (
<div id="flash" className="relative flex flex-col gap-8 justify-center items-center h-full">
<div
Expand All @@ -240,6 +258,37 @@ export default function Flash() {
</div>
<span className={`text-3xl dark:text-white font-mono font-light`}>{title}</span>
<span className={`text-xl dark:text-white px-8 max-w-xl`}>{description}</span>
{(title === "Lost connection" || title === "Ready") && isLinux && (
<>
<span className={`text-l dark:text-white px-2 max-w-xl`}>
It seems that you&apos;re on Linux, make sure to run the script below in your terminal after plugging in your device.
</span>
<div className="relative mt-2 max-w-3xl">
<div className="bg-gray-200 dark:bg-gray-800 rounded-md overflow-x-auto">
<div className="relative">
<pre className="font-mono text-sm text-gray-800 dark:text-gray-200 bg-gray-300 dark:bg-gray-700 rounded-md p-6 flex-grow max-w-m text-wrap">
{detachScript.map((line, index) => (
<span key={index} className="block">
{line}
</span>
))}
</pre>
<div className="absolute top-2 right-2">
<button
onClick={() => {
navigator.clipboard.writeText(detachScript.join('\n'));
handleCopy();
}}
className={`bg-${copied ? 'green' : 'blue'}-500 text-white px-1 py-1 rounded-md ml-2 text-sm`}
>
Copy
</button>
</div>
</div>
</div>
</div>
</>
)}
{error && (
<button
className="px-4 py-2 rounded-md bg-gray-200 hover:bg-gray-300 dark:bg-gray-700 dark:hover:bg-gray-600 text-gray-800 dark:text-gray-200 transition-colors"
Expand Down
32 changes: 15 additions & 17 deletions src/app/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default function App() {
<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>18D1</code> and <code>D00D</code> respectively.
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={zadigForm}
Expand All @@ -76,54 +76,52 @@ export default function App() {
<hr />

<section>
<h2>Fastboot</h2>
<p>Follow these steps to put your device into fastboot mode:</p>
<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>Then, <a href="https://youtube.com/clip/Ugkx1pbkpkvFU9gGsUwvkrl7yxx-SfHOZejM?si=nsJ0WJHJwS-rnHXL">quickly</a> connect
the device to your computer using the USB-C port <strong>(port 2)</strong>.</li>
<li>After a few seconds, the device should indicate it&apos;s in fastboot mode and show its serial number.</li>
<li>The device then should be visible as an option when choosing the device to flash</li>
</ol>
<img
src={fastbootPorts}
alt="image showing comma three and two ports. the upper port is labeled 1. the lower port is labeled 2."
width={450}
height={300}
/>
<p>
If your device shows the comma spinner with a loading bar, then it&apos;s not in fastboot mode.
Unplug all cables, wait for the device to switch off, and try again.
</p>
</section>
<hr />

<section>
<h2>Flashing</h2>
<p>
After your device is in fastboot mode, you can click the button to start flashing. A prompt may appear to
select a device; choose the device labeled &quot;Android&quot;.
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 15+ minutes depending on your internet connection and system performance. Do not
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>Cannot enter fastboot or device says &quot;Press any key to continue&quot;</h3>
<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 can still be in fastboot mode and reflashed normally if the screen isn&apos;t displaying
anything. A blank screen is usually caused by installing older software that doesn&apos;t support newer
displays. If a reflash doesn&apos;t fix the blank screen, then the device&apos;s display may be damaged.
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>
Expand Down
Binary file modified src/assets/zadig_create_new_device.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/assets/zadig_form.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ const config = {
release: 'https://raw.githubusercontent.com/commaai/openpilot/release3/system/hardware/tici/agnos.json',
master: 'https://raw.githubusercontent.com/commaai/openpilot/master/system/hardware/tici/agnos.json',
},
loader: {
url: 'https://raw.githubusercontent.com/commaai/flash/master/src/QDL/sdm845_fhprg.bin',
},
}

export default config
Loading

0 comments on commit 2815fde

Please sign in to comment.