Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ CMakeCache.txt
*.clst
*.snap
node_modules
build
build
*-lock.json
14 changes: 14 additions & 0 deletions d.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
On branch nxp
Your branch is ahead of 'nxp/master' by 2 commits.
(use "git push" to publish your local commits)

Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: webusb/package.json

Untracked files:
(use "git add <file>..." to include in what will be committed)
d.txt

no changes added to commit (use "git add" and/or "git commit -a")
2 changes: 2 additions & 0 deletions webusb/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
window.ZstdCodec = require('zstd-codec').ZstdCodec;
require("zstd-codec/lib/module.js").run((binding) => {console.log("running", binding); window.binding = binding} )
5 changes: 5 additions & 0 deletions webusb/notes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
errors you keep running into:

must init git submodule for zstd
must start the emsdk thing to use emcc in terminal
updating node version to do serve -s build
19 changes: 10 additions & 9 deletions webusb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,24 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"-": "^0.0.1",
"@testing-library/jest-dom": "^5.16.5",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's "-" means here?

"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"fs": "^0.0.1-security",
"g": "^2.0.1",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really need "fs" ?

"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "^5.0.1",
"web-vitals": "^2.1.4"
"web-vitals": "^2.1.4",
"zstd-codec": "^0.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"build": "react-scripts build; browserify index.js -o build/bundle.js -t babelify --presets es2015; ",
"test": "react-scripts test",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

supposed, need run browserify before react-script

"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
Expand All @@ -35,5 +33,8 @@
"last 1 safari version"
]
},
"proxy": "http://localhost:5000"
"devDependencies": {
"@babel/core": "^7.22.9",
"babelify": "^10.0.0"
}
}
6 changes: 6 additions & 0 deletions webusb/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<script src="bundle.js"></script>
</head>

<body>

<div id="container"></div>


<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
Expand Down
12 changes: 12 additions & 0 deletions webusb/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@
display: inline-block;
}

.u-align-center {
align-content: center;
}

.h3 {
font-weight: 700;
}

.h4 {
font-weight: 500;
}

.link-container{
display: inline-block;
width : 16rem;
Expand Down
38 changes: 5 additions & 33 deletions webusb/src/App.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import React, { useState } from 'react';
import React, { useState, useEffect } from 'react';
import Combined from "./components/Combined";
import Decompress from "./components/Decompress";
import usePopup from "./logic/usePopup";

import NewApp from "./components/NewApp";

import './App.css'

const App = () => {
Expand All @@ -11,38 +14,7 @@ const App = () => {

return (
<div className="App">
<div className="u-flex u-column">
<div className="u-row">
<span className="link-container">bootloader [optional]: </span>
<span className="file-name">{bootFile? bootFile.name:""}</span>
<label className="custom-file-upload">
<input className="input" type="file" onChange={(e)=>setBootFile(e.target.files[0])}/>
Choose File
</label>
</div>

<div className="u-row">
<span className="link-container">flash: </span>
<span className="file-name">{flashFile? flashFile.name:""}</span>
<label className="custom-file-upload">
<input className="input" type="file" onChange={(e)=>setFlashFile(e.target.files[0])}/>
Choose File
</label>
</div>

<div className="popup-button">
<button onClick = {showPopup}>USB_down</button>
</div>

<div className="popup-loc ">
<div className="popup-container" style={show?{}:{display:'none'}}>
<Combined bootFile={bootFile} flashFile={flashFile}/>
<button onClick={()=>closePopup()}>close</button>
</div>
</div>
<span>{error}</span>
</div>

<NewApp />
</div>
);
}
Expand Down
4 changes: 4 additions & 0 deletions webusb/src/components/Combined.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
border-radius: 50%;
}

.popup-container {
width: 40rem;
}

.Popup-list {
margin:0;
padding-left: 1rem;
Expand Down
20 changes: 6 additions & 14 deletions webusb/src/components/Combined.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {useEffect, useState} from 'react';
import ProgressBar from './ProgressBar';
import useHIDBoot from '../logic/useHIDBoot';
import useUSBFlash from '../logic/useUSBFlash'
Expand All @@ -7,28 +6,17 @@ import imgSrc from '../images/imx8qxp_mek_bootmode.png'
import "./Combined.css"

const Combined = ({bootFile, flashFile}) => {
// const [imgUrl, setImgUrl] = useState();

const [{ requestHIDDevice, HIDdevice, bootProgress, bootTotal }] = useHIDBoot(bootFile);
const [{ requestUSBDevice, USBDevice, flashProgress, flashTotal}] = useUSBFlash(flashFile);

// useEffect(() => {
// const dothis = async()=>{
// const response = await fetch("mode");
// const blob = await response.blob();
// setImgUrl(URL.createObjectURL(blob));
// }
// dothis();
// }, [])

return(
<div>
<ul className="Popup-list">
<li>
<span>1. Switch Boot Mode to "SERIAL"</span>
<div className="u-flex u-center">
<div className="image-container">
{imgSrc? <img className="boot-image" src={imgSrc}/>: ""}
{imgSrc? <img className="boot-image" src={imgSrc} alt="boot mode switches"/>: ""}
</div>
</div>
</li>
Expand All @@ -39,6 +27,7 @@ const Combined = ({bootFile, flashFile}) => {
</div>
<div>
<span>2. </span>

<button className="Popup-button" onClick={requestHIDDevice}> Pair HIDdevice </button>
<span>{bootProgress? `${bootProgress} bytes out of ${bootTotal} downloaded`: ""}</span>
<div className="Popup-empty">
Expand All @@ -54,8 +43,11 @@ const Combined = ({bootFile, flashFile}) => {
</div>
<div>
<span>3. </span>

<button onClick={requestUSBDevice}>Pair USBDevice </button>
<div className="Popup-empty"> {USBDevice? `connected: ${USBDevice.productName}`: ""} </div>
<div className="Popup-empty">
+ {USBDevice? `connected: ${USBDevice.productName}`: ""}
+ </div>
</div>
</div>
</li>
Expand Down
25 changes: 25 additions & 0 deletions webusb/src/components/Decompress.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { useEffect, useState } from "react"
import useDecompress2 from '../logic/useDecompress2'

const Decompress = () => {
const [flashFile, setFlashFile] = useState();
const [{
requestUSBDevice
}] = useDecompress2(flashFile);

useEffect(()=> {
console.log(ZstdCodec)
console.log(window.binding);
}, [])

return (
<div>
file to decompress:
<input type="file" onChange={(e) => setFlashFile(e.target.files[0])}/>

<button onClick={requestUSBDevice}>Pair USBDevice </button>
</div>
)
}

export default Decompress
77 changes: 77 additions & 0 deletions webusb/src/components/NewApp.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
.new-app {
font-family: Arial,sans-serif;
padding-left: 2rem;
}

.button {
background-color: white;
color: black;
padding: 5px 10px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 10px;
border: thin black solid;
text-transform: uppercase;
font-weight: 600;
cursor: pointer;
}

.button-secondary {
background-color: darkorange;
color: white;
padding: 5px 10px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 10px;
border: thin darkorange solid;
text-transform: uppercase;
font-weight: 600;
cursor: pointer;
}

.file-action-container{
width: 14rem;
}

.file-name-container {
align-items: center;
margin-right: 4rem;
}

.popup-container {
width: 40rem;
}

.file-input-container {
background-color: white;
color: black;
padding: 5px 10px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 10px;
border: thin black solid;
text-transform: uppercase;
font-weight: 400;
}
.file-input {
display: none;
}

.instruction-title {
margin-bottom: 1rem;
}

.instruction-elt {
margin-bottom: 0.5rem;
}

.instruction-container {
flex:1;
}

.popup {
margin-top: 2rem;
}
Loading