Skip to content

Commit 787880f

Browse files
author
Sarah Wang
committed
cleanup 2 at nxp/master
1 parent 6881886 commit 787880f

4 files changed

Lines changed: 33 additions & 20 deletions

File tree

webusb/src/components/Combined.js

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import {useEffect, useState} from 'react';
21
import ProgressBar from './ProgressBar';
32
import useHIDBoot from '../logic/useHIDBoot';
43
import useUSBFlash from '../logic/useUSBFlash'
@@ -7,28 +6,17 @@ import imgSrc from '../images/imx8qxp_mek_bootmode.png'
76
import "./Combined.css"
87

98
const Combined = ({bootFile, flashFile}) => {
10-
// const [imgUrl, setImgUrl] = useState();
11-
129
const [{ requestHIDDevice, HIDdevice, bootProgress, bootTotal }] = useHIDBoot(bootFile);
1310
const [{ requestUSBDevice, USBDevice, flashProgress, flashTotal}] = useUSBFlash(flashFile);
1411

15-
// useEffect(() => {
16-
// const dothis = async()=>{
17-
// const response = await fetch("mode");
18-
// const blob = await response.blob();
19-
// setImgUrl(URL.createObjectURL(blob));
20-
// }
21-
// dothis();
22-
// }, [])
23-
2412
return(
2513
<div>
2614
<ul className="Popup-list">
2715
<li>
2816
<span>1. Switch Boot Mode to "SERIAL"</span>
2917
<div className="u-flex u-center">
3018
<div className="image-container">
31-
{imgSrc? <img className="boot-image" src={imgSrc}/>: ""}
19+
{imgSrc? <img className="boot-image" src={imgSrc} alt="boot mode switches"/>: ""}
3220
</div>
3321
</div>
3422
</li>
@@ -55,7 +43,9 @@ const Combined = ({bootFile, flashFile}) => {
5543
<div>
5644
<span>3. </span>
5745
<button onClick={requestUSBDevice}>Pair USBDevice </button>
58-
<div className="Popup-empty"> {USBDevice? `connected: ${USBDevice.productName}`: ""} </div>
46+
<div className="Popup-empty">
47+
+ {USBDevice? `connected: ${USBDevice.productName}`: ""}
48+
+ </div>
5949
</div>
6050
</div>
6151
</li>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { useEffect, useState } from "react"
2+
import useDecompress from '../logic/useDecompress'
3+
import { DATA_SZ, BLK_SZ, PACKET_SZ } from "../helper/sparse";
4+
5+
const Decompress = () => {
6+
const [flashFile, setFlashFile] = useState();
7+
const [{
8+
requestUSBDevice
9+
}] = useDecompress(flashFile);
10+
11+
useEffect(()=> {
12+
console.log(ZstdCodec)
13+
console.log(window.binding);
14+
}, [])
15+
16+
return (
17+
<div>
18+
file to decompress:
19+
<input type="file" onChange={(e) => setFlashFile(e.target.files[0])}/>
20+
21+
<button onClick={requestUSBDevice}>Pair USBDevice </button>
22+
</div>
23+
)
24+
}
25+
26+
export default Decompress

webusb/src/helper/sparse.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,12 @@ export function build_chunk_header (chunk_type, raw_data_bytelength, i) {
7979
}
8080

8181
if (chunk_type === CHUNK_TYPE_DONT_CARE) {
82-
chunk_format.chunk_sz = CHUNK_SZ * i; // don't care
82+
chunk_format.chunk_sz = CHUNK_SZ * i;
8383
chunk_format.total_sz = CHUNK_SZ*BLK_SZ * i + CHUNK_HEADER_SZ; // bytes raw_data + header
8484
}
85-
else if (chunk_type === CHUNK_TYPE_RAW) { // raw_data
85+
else if (chunk_type === CHUNK_TYPE_RAW) {
8686
chunk_format.chunk_sz = Math.ceil(raw_data_bytelength/BLK_SZ);
8787
chunk_format.total_sz = raw_data_bytelength + CHUNK_HEADER_SZ;
88-
89-
console.log(chunk_format)
9088
}
9189

9290
return obj_to_arr(chunk_format, chunk_header, CHUNK_HEADER_SZ);

webusb/src/logic/useUSBFlash.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
import {useEffect, useState} from 'react';
3333
import {str_to_arr, ab_to_str} from '../helper/functions.js'
34-
import {CHUNK_SZ, BLK_SZ, CHUNK_TYPE_RAW, CHUNK_TYPE_DONT_CARE, build_sparse_header, build_chunk_header} from '../helper/sparse.js'
34+
import {CHUNK_SZ, BLK_SZ, PACKET_SZ, CHUNK_TYPE_RAW, CHUNK_TYPE_DONT_CARE, build_sparse_header, build_chunk_header} from '../helper/sparse.js'
3535

3636
const USBrequestParams = { filters: [{ vendorId: 8137, productId: 0x0152 }] };
3737

@@ -77,7 +77,6 @@ const useUSBFlash = (flashFile) => {
7777

7878
const doFlash = async () => {
7979
// downloads and splits image into chunks to be processed
80-
const PACKET_SZ = 0x10000;
8180
const DATA_SZ = CHUNK_SZ * BLK_SZ; // in bytes
8281
if (flashFile===null) {return;}
8382

0 commit comments

Comments
 (0)