|
1 | 1 | import { useCallback, useState } from 'react'
|
2 | 2 |
|
3 | 3 | import { Step, Error, useQdl } from '../utils/flash'
|
| 4 | +import { isLinux } from '../utils/platform' |
4 | 5 |
|
5 | 6 | import bolt from '../assets/bolt.svg'
|
6 | 7 | import cable from '../assets/cable.svg'
|
@@ -115,8 +116,7 @@ const errors = {
|
115 | 116 | },
|
116 | 117 | }
|
117 | 118 |
|
118 |
| -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"; |
119 |
| -const isLinux = navigator.userAgent.toLowerCase().includes('linux'); |
| 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 | 120 |
|
121 | 121 | function LinearProgress({ value, barColor }) {
|
122 | 122 | if (value === -1 || value > 100) value = 100
|
@@ -252,23 +252,24 @@ export default function Flash() {
|
252 | 252 | <div className="w-full max-w-3xl px-8 transition-opacity duration-300" style={{ opacity: progress === -1 ? 0 : 1 }}>
|
253 | 253 | <LinearProgress value={progress * 100} barColor={bgColor} />
|
254 | 254 | </div>
|
255 |
| - <span className={`text-3xl dark:text-white font-mono font-light`}>{title}</span> |
256 |
| - <span className={`text-xl dark:text-white px-8 max-w-xl`}>{description}</span> |
257 |
| - {(title === "Lost connection" || title === "Ready") && isLinux && ( |
| 255 | + <span className="text-3xl dark:text-white font-mono font-light">{title}</span> |
| 256 | + <span className="text-xl dark:text-white px-8 max-w-xl">{description}</span> |
| 257 | + {(title === "Ready" || title === "Lost connection") && isLinux && ( |
258 | 258 | <>
|
259 |
| - <span className={`text-l dark:text-white px-2 max-w-xl`}> |
260 |
| - It seems that you're on Linux, make sure to run the script below in your terminal after plugging in your device. |
| 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'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. |
261 | 262 | </span>
|
262 | 263 | <div className="relative mt-2 max-w-3xl">
|
263 | 264 | <div className="bg-gray-200 dark:bg-gray-800 rounded-md overflow-x-auto">
|
264 | 265 | <div className="relative">
|
265 | 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">
|
266 |
| - {detachScript} |
| 267 | + {DETACH_SCRIPT} |
267 | 268 | </pre>
|
268 | 269 | <div className="absolute top-2 right-2">
|
269 | 270 | <button
|
270 | 271 | onClick={() => {
|
271 |
| - navigator.clipboard.writeText(detachScript); |
| 272 | + void navigator.clipboard.writeText(DETACH_SCRIPT); |
272 | 273 | handleCopy();
|
273 | 274 | }}
|
274 | 275 | className={`bg-${copied ? 'green' : 'blue'}-500 text-white px-1 py-1 rounded-md ml-2 text-sm`}
|
|
0 commit comments