Skip to content

Commit 0ed4bec

Browse files
committed
use @commaai/qdl package
1 parent a32b8fd commit 0ed4bec

10 files changed

+136
-111
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

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

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

77
## Development
88

bun.lockb

-397 Bytes
Binary file not shown.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
"node": ">=20.11.0"
1515
},
1616
"dependencies": {
17+
"@commaai/qdl": "git+https://github.com/commaai/qdl.js.git",
1718
"@fontsource-variable/inter": "^5.0.18",
1819
"@fontsource-variable/jetbrains-mono": "^5.0.21",
19-
"android-fastboot": "github:commaai/fastboot.js#c3ec6fe3c96a48dab46e23d0c8c861af15b2144a",
2020
"comlink": "^4.4.1",
21+
"crc-32": "^1.2.2",
2122
"jssha": "^3.3.1",
2223
"react": "^18.3.1",
2324
"react-dom": "^18.3.1",
Binary file not shown.

src/app/Flash.jsx

+57-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { useCallback } from 'react'
1+
import { useCallback, useState } from 'react'
22

3-
import { Step, Error, useFastboot } from '../utils/fastboot'
3+
import { Step, Error, useQdl } from '../utils/flash'
44

55
import bolt from '../assets/bolt.svg'
66
import cable from '../assets/cable.svg'
@@ -57,8 +57,9 @@ const steps = {
5757
},
5858
[Step.DONE]: {
5959
status: 'Done',
60-
description: 'Your device has been updated successfully. You can now unplug the USB cable from your computer. To ' +
61-
'complete the system reset, follow the instructions on your device.',
60+
description: 'Your device has been updated successfully. You can now unplug the all cables from your device, '
61+
+'and wait for the light to stop blinking then plug the power cord in again. '
62+
+' To complete the system reset, follow the instructions on your device.',
6263
bgColor: 'bg-green-500',
6364
icon: done,
6465
},
@@ -67,7 +68,8 @@ const steps = {
6768
const errors = {
6869
[Error.UNKNOWN]: {
6970
status: 'Unknown error',
70-
description: 'An unknown error has occurred. Restart your browser and try again.',
71+
description: 'An unknown error has occurred. Unplug your device and wait for 20s. ' +
72+
'Restart your browser and try again.',
7173
bgColor: 'bg-red-500',
7274
icon: exclamation,
7375
},
@@ -79,12 +81,14 @@ const errors = {
7981
},
8082
[Error.LOST_CONNECTION]: {
8183
status: 'Lost connection',
82-
description: 'The connection to your device was lost. Check that your cables are connected properly and try again.',
84+
description: 'The connection to your device was lost. Check that your cables are connected properly and try again. ' +
85+
'Unplug your device and wait for around 20s.',
8386
icon: cable,
8487
},
8588
[Error.DOWNLOAD_FAILED]: {
8689
status: 'Download failed',
87-
description: 'The system image could not be downloaded. Check your internet connection and try again.',
90+
description:'The system image could not be downloaded. Unplug your device and wait for 20s. ' +
91+
'Check your internet connection and try again.',
8892
icon: cloudError,
8993
},
9094
[Error.CHECKSUM_MISMATCH]: {
@@ -111,6 +115,11 @@ const errors = {
111115
},
112116
}
113117

118+
const detachScript = [
119+
"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"
120+
];
121+
122+
const isLinux = navigator.userAgent.toLowerCase().includes('linux');
114123

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

188197
connected,
189198
serial,
190-
} = useFastboot()
199+
} = useQdl()
191200

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

232+
const [copied, setCopied] = useState(false);
233+
const handleCopy = () => {
234+
setCopied(true);
235+
setTimeout(() => {
236+
setCopied(false);
237+
}, 1000);
238+
};
239+
240+
223241
return (
224242
<div id="flash" className="relative flex flex-col gap-8 justify-center items-center h-full">
225243
<div
@@ -240,6 +258,37 @@ export default function Flash() {
240258
</div>
241259
<span className={`text-3xl dark:text-white font-mono font-light`}>{title}</span>
242260
<span className={`text-xl dark:text-white px-8 max-w-xl`}>{description}</span>
261+
{(title === "Lost connection" || title === "Ready") && isLinux && (
262+
<>
263+
<span className={`text-l dark:text-white px-2 max-w-xl`}>
264+
It seems that you&apos;re on Linux, make sure to run the script below in your terminal after plugging in your device.
265+
</span>
266+
<div className="relative mt-2 max-w-3xl">
267+
<div className="bg-gray-200 dark:bg-gray-800 rounded-md overflow-x-auto">
268+
<div className="relative">
269+
<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">
270+
{detachScript.map((line, index) => (
271+
<span key={index} className="block">
272+
{line}
273+
</span>
274+
))}
275+
</pre>
276+
<div className="absolute top-2 right-2">
277+
<button
278+
onClick={() => {
279+
navigator.clipboard.writeText(detachScript.join('\n'));
280+
handleCopy();
281+
}}
282+
className={`bg-${copied ? 'green' : 'blue'}-500 text-white px-1 py-1 rounded-md ml-2 text-sm`}
283+
>
284+
Copy
285+
</button>
286+
</div>
287+
</div>
288+
</div>
289+
</div>
290+
</>
291+
)}
243292
{error && (
244293
<button
245294
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"

src/app/index.jsx

+15-17
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export default function App() {
5959
<li>
6060
Fill in three fields. The first field is just a description and
6161
you can fill in anything. The next two fields are very important.
62-
Fill them in with <code>18D1</code> and <code>D00D</code> respectively.
62+
Fill them in with <code>05C6</code> and <code>9008</code> respectively.
6363
Press &quot;Install Driver&quot; and give it a few minutes to install.
6464
<img
6565
src={zadigForm}
@@ -76,54 +76,52 @@ export default function App() {
7676
<hr />
7777

7878
<section>
79-
<h2>Fastboot</h2>
80-
<p>Follow these steps to put your device into fastboot mode:</p>
79+
<h2>QDL Mode</h2>
80+
<p>Follow these steps to put your device into QDL mode:</p>
8181
<ol>
8282
<li>Power off the device and wait for the LEDs to switch off.</li>
83+
<li>Connect the device to your computer using the USB-C port <strong>(port 2)</strong>.</li>
8384
<li>Connect power to the OBD-C port <strong>(port 1)</strong>.</li>
84-
<li>Then, <a href="https://youtube.com/clip/Ugkx1pbkpkvFU9gGsUwvkrl7yxx-SfHOZejM?si=nsJ0WJHJwS-rnHXL">quickly</a> connect
85-
the device to your computer using the USB-C port <strong>(port 2)</strong>.</li>
86-
<li>After a few seconds, the device should indicate it&apos;s in fastboot mode and show its serial number.</li>
85+
<li>The device then should be visible as an option when choosing the device to flash</li>
8786
</ol>
8887
<img
8988
src={fastbootPorts}
9089
alt="image showing comma three and two ports. the upper port is labeled 1. the lower port is labeled 2."
9190
width={450}
9291
height={300}
9392
/>
94-
<p>
95-
If your device shows the comma spinner with a loading bar, then it&apos;s not in fastboot mode.
96-
Unplug all cables, wait for the device to switch off, and try again.
97-
</p>
9893
</section>
9994
<hr />
10095

10196
<section>
10297
<h2>Flashing</h2>
10398
<p>
104-
After your device is in fastboot mode, you can click the button to start flashing. A prompt may appear to
105-
select a device; choose the device labeled &quot;Android&quot;.
99+
After your device is in QDL mode, you can click the button to start flashing. A prompt may appear to
100+
select a device; choose the device starts with <code>QUSB_BULK</code>.
106101
</p>
107102
<p>
108-
The process can take 15+ minutes depending on your internet connection and system performance. Do not
103+
The process can take 30+ minutes depending on your internet connection and system performance. Do not
109104
unplug the device until all steps are complete.
110105
</p>
111106
</section>
112107
<hr />
113108

114109
<section>
115110
<h2>Troubleshooting</h2>
116-
<h3>Cannot enter fastboot or device says &quot;Press any key to continue&quot;</h3>
111+
<h3>Too slow</h3>
112+
<p>
113+
It is recommended that you use a USB 3.0 cable when flashing since it will speed up the flashing time by a lot.
114+
</p>
115+
<h3>Cannot enter QDL</h3>
117116
<p>
118117
Try using a different USB cable or USB port. Sometimes USB 2.0 ports work better than USB 3.0 (blue) ports.
119118
If you&apos;re using a USB hub, try connecting the device directly to your computer, or alternatively use a
120119
USB hub between your computer and the device.
121120
</p>
122121
<h3>My device&apos;s screen is blank</h3>
123122
<p>
124-
The device can still be in fastboot mode and reflashed normally if the screen isn&apos;t displaying
125-
anything. A blank screen is usually caused by installing older software that doesn&apos;t support newer
126-
displays. If a reflash doesn&apos;t fix the blank screen, then the device&apos;s display may be damaged.
123+
The device screen will be blank in QDL mode, but you can verify that it is in QDL if the device shows up
124+
when you press the Flash icon.
127125
</p>
128126
<h3>After flashing, device says unable to mount data partition</h3>
129127
<p>
2.64 KB
Loading

src/assets/zadig_form.png

2.74 KB
Loading

src/config.js

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ const config = {
33
release: 'https://raw.githubusercontent.com/commaai/openpilot/release3/system/hardware/tici/agnos.json',
44
master: 'https://raw.githubusercontent.com/commaai/openpilot/master/system/hardware/tici/agnos.json',
55
},
6+
loader: {
7+
url: 'https://raw.githubusercontent.com/commaai/flash/master/src/QDL/sdm845_fhprg.bin',
8+
},
69
}
710

811
export default config

0 commit comments

Comments
 (0)