Skip to content

Commit 40d41fc

Browse files
Add programming functionality to firmware tool
1 parent 4835232 commit 40d41fc

File tree

7 files changed

+78
-8
lines changed

7 files changed

+78
-8
lines changed

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
- name: Setup Pages
3535
uses: actions/configure-pages@v5
3636
- name: Grab Firmware Binary
37-
run: mkdir -p ./docs/_binaries && curl --clobber -L https://github.com/little-red-rover/lrr-firmware/releases/latest/download/lrr-firmware.bin -o ./docs/_binaries/lrr-firmware.bin
37+
run: mkdir -p ./docs/_binaries && curl -L https://github.com/little-red-rover/lrr-firmware/releases/latest/download/lrr-firmware.bin -o ./docs/_binaries/lrr-firmware.bin
3838
- name: Upload artifact
3939
uses: actions/upload-pages-artifact@v3
4040
with:

.gitignore

Whitespace-only changes.

docs/_sidebar.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
- [Coming soon...](contributing.md)
1313
* Troubleshooting
1414
- [Coming soon...](troubleshooting.md)
15-
- [Firmware Debugger](firmware_debug.md)
15+
- [Firmware Tool](firmware_tool.md)

docs/assembly.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ In the cable bag:
2727
| ---- | ---- | ---- |
2828
| 4-pin JST GH 1.25mm straight across cable | 1 | ![]() |
2929
| 6-pin JST PH 2.0mm reversed cables | 2 | ![]() |
30-
| M2.5 hex wrench | 1 | ![]() |
3130

3231
In the small parts bag:
3332

@@ -37,14 +36,21 @@ In the small parts bag:
3736
| Motor spacing shims | 2 | ![]() |
3837
| Wheel spacers | 2 | ![]() |
3938
| M3-8 machine screw | 3 | ![]() |
40-
39+
| M2.5 hex wrench | 1 | ![]() |
4140

4241
## Motor Subassembly
4342

4443
## Body Assembly
4544

4645
## First Power On
4746

47+
## Care for Your Rover
48+
49+
> [!WARNING]
50+
> **Never charge Little Red Rover unattended.**
51+
>
52+
> If something goes wrong during the charging process, lithium batteries, like the one contained in the rover, are a serious fire hazard. If the battery becomes hot, smokes, swells, or gives off an odor during charging, immediately stop charging and dipose of the battery safely.
53+
4854
## Next Steps
4955

5056
Now that you have an assembled robot, head over to the [software setup](/software_installation) page to get the robot moving around!

docs/firmware_tool.html

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,35 @@
3030
}
3131
</style>
3232

33+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/crypto-js.js"></script>
3334
<script type="module">
3435
import {Terminal} from 'https://cdn.jsdelivr.net/npm/[email protected]/+esm'
3536
import {FitAddon} from 'https://cdn.jsdelivr.net/npm/@xterm/[email protected]/+esm'
3637
import {ESPLoader, Transport} from "https://unpkg.com/esptool-js/bundle.js";
38+
3739
var term = new Terminal();
3840
const fitAddon = new FitAddon();
3941
term.loadAddon(fitAddon);
4042
term.open(document.getElementById('terminal'));
41-
// fitAddon.fit();
43+
fitAddon.fit();
4244

4345
let transport;
46+
let esploader;
4447
let device = null;
48+
let chip = null;
49+
50+
const espLoaderTerminal = {
51+
clean() {
52+
term.clear();
53+
},
54+
writeLine(data) {
55+
term.writeln(data);
56+
},
57+
write(data) {
58+
term.write(data);
59+
},
60+
};
61+
4562
let isConsoleClosed = false;
4663

4764
consoleStartButton.onclick = async () => {
@@ -71,10 +88,51 @@
7188
await transport.setDTR(true);
7289
}
7390
};
91+
92+
function loadBinaryResource(url) {
93+
const req = new XMLHttpRequest();
94+
req.open("GET", url, false);
95+
96+
// XHR binary charset opt by Marcus Granado 2006 [http://mgran.blogspot.com]
97+
req.overrideMimeType("text/plain; charset=x-user-defined");
98+
req.send(null);
99+
return req.status === 200 ? req.responseText : "";
100+
}
101+
102+
programButton.onclick = async () => {
103+
if (device === null) {
104+
device = await navigator.serial.requestPort({});
105+
transport = new Transport(device, true);
106+
}
107+
108+
try {
109+
let flashOptions = {
110+
transport,
111+
baudrate: 921600,
112+
terminal: espLoaderTerminal,
113+
};
114+
esploader = new ESPLoader(flashOptions);
115+
116+
chip = await esploader.main();
117+
118+
flashOptions = {
119+
fileArray: [{data: loadBinaryResource("./_binaries/lrr-firmware.bin"), address: 0x0}],
120+
flashSize: "keep",
121+
eraseAll: false,
122+
compress: true,
123+
calculateMD5Hash: (image) => CryptoJS.MD5(CryptoJS.enc.Latin1.parse(image)),
124+
};
125+
await esploader.writeFlash(flashOptions);
126+
} catch (e) {
127+
console.error(e);
128+
term.writeln(`Error: ${e.message}`);
129+
}
130+
};
74131
</script>
75132
</head>
76133

77134
<body>
135+
<input type="button" id="programButton" value="Program" />
78136
<input type="button" id="consoleStartButton" value="Connect" />
79137
<input type="button" id="resetButton" value="Reset" />
80138
<div id="terminal"></div>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# Firmware Flasher / Debugger
1+
# Firmware Tool
22

33
[firmware tool](/firmware_tool.html ':include :type=iframe width=100% height=400px')

docs/software_installation.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,22 @@ Start a new terminal (Terminal -> New Terminal) and run the following command to
7575

7676
<!-- tabs:start -->
7777

78+
#### **Hardware Beta Testers**
79+
80+
```bash
81+
git clone --recurse-submodules https://github.com/little-red-rover/lrr-fa24-beta.git
82+
```
83+
7884
#### **ROS2: Humble (Recommended)**
7985

8086
```bash
81-
git clone https://github.com/little-red-rover/lrr-template-project
87+
git clone --recurse-submodules https://github.com/little-red-rover/lrr-template-project
8288
```
8389

8490
#### **ROS1: Noetic**
8591

8692
```bash
87-
git clone https://github.com/little-red-rover/lrr-template-project && checkout noetic
93+
git clone --recurse-submodules https://github.com/little-red-rover/lrr-template-project && checkout noetic
8894
```
8995

9096

0 commit comments

Comments
 (0)