Skip to content

Commit 45901d8

Browse files
committed
Add flashing algorithms for all boards supported by pyOCD.
1 parent 667dfe8 commit 45901d8

File tree

11 files changed

+19716
-246
lines changed

11 files changed

+19716
-246
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ this.hid = new DAPjs.HID(device);
6969
// open hid device
7070
await this.hid.open();
7171
dapDevice = new DAPjs.DAP(this.hid);
72-
this.target = new DAPjs.FlashTarget(dapDevice, DAPjs.FlashTargets.get(this.deviceCode));
72+
const flashAlgorithm = await DAPjs.FlashAlgorithm.load(deviceCode);
73+
this.target = new DAPjs.FlashTarget(dapDevice, flashAlgorithm);
7374

7475
// init and halt target
7576
await this.target.init();

examples/flash.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ function getTarget(device) {
112112
console.log("Device opened");
113113

114114
var dapDevice = new DAPjs.DAP(hid);
115-
target = new DAPjs.FlashTarget(dapDevice, DAPjs.FlashTargets.get(deviceCode));
115+
var flashAlgorithm = DAPjs.FlashAlgorithm.load(deviceCode);
116+
target = new DAPjs.FlashTarget(dapDevice, flashAlgorithm);
116117
return target.init();
117118
})
118119
.then(() => {

examples/web.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,9 @@
218218
log("Device opened.");
219219

220220
this.dapDevice = new DAPjs.DAP(this.hid);
221-
this.target = new DAPjs.FlashTarget(this.dapDevice, DAPjs.FlashTargets.get(this.deviceCode));
221+
const flashAlgorithm = await DAPjs.FlashAlgorithm.load(this.deviceCode).catch(error => log(error));
222+
if (!flashAlgorithm) return log("No flashing algorithm can be found for this board.");
223+
this.target = new DAPjs.FlashTarget(this.dapDevice, flashAlgorithm);
222224

223225
log("Initialising device.");
224226

0 commit comments

Comments
 (0)