Skip to content

Commit 74a6f1f

Browse files
committed
move unbind script to instructions
1 parent 57cc3de commit 74a6f1f

File tree

2 files changed

+42
-44
lines changed

2 files changed

+42
-44
lines changed

src/app/Flash.jsx

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

33
import { Step, Error, useQdl } from '../utils/flash'
4-
import { isLinux } from '../utils/platform'
54

65
import bolt from '../assets/bolt.svg'
76
import cable from '../assets/cable.svg'
@@ -116,8 +115,6 @@ const errors = {
116115
},
117116
}
118117

119-
const DETACH_SCRIPT = "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-
121118
function LinearProgress({ value, barColor }) {
122119
if (value === -1 || value > 100) value = 100
123120
return (
@@ -226,14 +223,6 @@ export default function Flash() {
226223
window.removeEventListener("beforeunload", beforeUnloadListener, { capture: true })
227224
}
228225

229-
const [copied, setCopied] = useState(false);
230-
const handleCopy = () => {
231-
setCopied(true);
232-
setTimeout(() => {
233-
setCopied(false);
234-
}, 1000);
235-
};
236-
237226
return (
238227
<div id="flash" className="relative flex flex-col gap-8 justify-center items-center h-full">
239228
<div
@@ -254,34 +243,6 @@ export default function Flash() {
254243
</div>
255244
<span className="text-3xl dark:text-white font-mono font-light">{title}</span>
256245
<span className="text-xl dark:text-white px-8 max-w-xl">{description}</span>
257-
{(title === "Ready" || title === "Lost connection") && isLinux && (
258-
<>
259-
<span className="text-l dark:text-white px-2 max-w-xl">
260-
On Linux systems, devices in QDL mode are automatically bound to the kernel&apos;s qcserial driver, and need to be unbound before we can access the device.
261-
Run the script below in your terminal after plugging in your device.
262-
</span>
263-
<div className="relative mt-2 max-w-3xl">
264-
<div className="bg-gray-200 dark:bg-gray-800 rounded-md overflow-x-auto">
265-
<div className="relative">
266-
<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">
267-
{DETACH_SCRIPT}
268-
</pre>
269-
<div className="absolute top-2 right-2">
270-
<button
271-
onClick={() => {
272-
void navigator.clipboard.writeText(DETACH_SCRIPT);
273-
handleCopy();
274-
}}
275-
className={`bg-${copied ? 'green' : 'blue'}-500 text-white px-1 py-1 rounded-md ml-2 text-sm`}
276-
>
277-
Copy
278-
</button>
279-
</div>
280-
</div>
281-
</div>
282-
</div>
283-
</>
284-
)}
285246
{error && (
286247
<button
287248
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

+41-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,44 @@
1-
import { Suspense, lazy } from 'react'
1+
import { Suspense, lazy, useState } from 'react'
22

33
import comma from '../assets/comma.svg'
44
import qdlPorts from '../assets/qdl-ports.svg'
55
import zadigCreateNewDevice from '../assets/zadig_create_new_device.png'
66
import zadigForm from '../assets/zadig_form.png'
77

8-
import { isWindows } from '../utils/platform'
8+
import { isLinux, isWindows } from '../utils/platform'
99

1010
const Flash = lazy(() => import('./Flash'))
1111

12-
const VENDOR_ID = "05C6";
13-
const PRODUCT_ID = "9008";
12+
const VENDOR_ID = '05C6'
13+
const PRODUCT_ID = '9008'
14+
const DETACH_SCRIPT = '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';
15+
16+
function CopyText({ children: text }) {
17+
const [copied, setCopied] = useState(false)
18+
const handleCopy = () => {
19+
setCopied(true)
20+
setTimeout(() => {
21+
setCopied(false)
22+
}, 1000)
23+
}
24+
25+
return <div className="relative w-full">
26+
<pre className="font-mono text-sm px-4 py-6">
27+
{text}
28+
</pre>
29+
<div className="absolute top-2 right-2">
30+
<button
31+
onClick={() => {
32+
void navigator.clipboard.writeText(text);
33+
handleCopy();
34+
}}
35+
className={`bg-${copied ? 'green' : 'blue'}-500 text-white px-1 py-1 rounded-md ml-2 text-sm`}
36+
>
37+
Copy
38+
</button>
39+
</div>
40+
</div>;
41+
}
1442

1543
export default function App() {
1644
const version = import.meta.env.VITE_PUBLIC_GIT_SHA || 'dev'
@@ -90,6 +118,15 @@ export default function App() {
90118
width={450}
91119
height={300}
92120
/>
121+
{isLinux && (<>
122+
<strong>Note for Linux users</strong>
123+
<p>
124+
On Linux systems, devices in QDL mode are automatically bound to the kernel&apos;s qcserial driver, and
125+
need to be unbound before we can access the device. Copy the script below into your terminal and run it
126+
after plugging in your device.
127+
</p>
128+
<CopyText>{DETACH_SCRIPT}</CopyText>
129+
</>)}
93130
<p>
94131
After your device is in QDL mode, you can click the button to start flashing. A prompt may appear to
95132
select a device; choose the device starts with <code>QUSB_BULK</code>.

0 commit comments

Comments
 (0)