Update(boards): 更新micropython microbit和mithoncc板卡
This commit is contained in:
18
common/modules/web-modules/esptool.min.js
vendored
18
common/modules/web-modules/esptool.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -77,6 +77,12 @@ const CortexSpecialReg = {
|
||||
// Many more.
|
||||
};
|
||||
|
||||
const CoreRegister = {
|
||||
SP: 13,
|
||||
LR: 14,
|
||||
PC: 15,
|
||||
};
|
||||
|
||||
// Returns a representation of an Access Port Register.
|
||||
// Drawn from https://github.com/mmoskal/dapjs/blob/a32f11f54e9e76a9c61896ddd425c1cb1a29c143/src/util.ts#L63
|
||||
const apReg = (r, mode) => {
|
||||
@@ -159,6 +165,40 @@ class DAPWrapper {
|
||||
);
|
||||
}
|
||||
|
||||
async connectAsync() {
|
||||
await this.daplink.connect();
|
||||
await this.daplink.setSerialBaudrate(115200);
|
||||
await this.cortexM.connect();
|
||||
this.logging.event({
|
||||
type: "WebUSB-info",
|
||||
message: "connected",
|
||||
});
|
||||
|
||||
const serialInfo = this.boardSerialInfo();
|
||||
this.log(`Detected board ID ${serialInfo.id}`);
|
||||
|
||||
if (
|
||||
!this.loggedBoardSerialInfo ||
|
||||
!this.loggedBoardSerialInfo.eq(this.boardSerialInfo())
|
||||
) {
|
||||
this.loggedBoardSerialInfo = this.boardSerialInfo();
|
||||
this.logging.event({
|
||||
type: "WebUSB-info",
|
||||
message: "board-id/" + this.boardSerialInfo().id,
|
||||
});
|
||||
this.logging.event({
|
||||
type: "WebUSB-info",
|
||||
message:
|
||||
"board-family-hic/" +
|
||||
this.boardSerialInfo().familyId +
|
||||
this.boardSerialInfo().hic,
|
||||
});
|
||||
}
|
||||
|
||||
this._pageSize = await this.cortexM.readMem32(FICR.CODEPAGESIZE);
|
||||
this._numPages = await this.cortexM.readMem32(FICR.CODESIZE);
|
||||
}
|
||||
|
||||
// Drawn from https://github.com/microsoft/pxt-microbit/blob/dec5b8ce72d5c2b4b0b20aafefce7474a6f0c7b2/editor/extension.tsx#L119
|
||||
async reconnectAsync() {
|
||||
if (this.initialConnectionComplete) {
|
||||
|
||||
@@ -55,6 +55,21 @@ const CoreRegister = {
|
||||
PC: 15,
|
||||
};
|
||||
|
||||
/**
|
||||
* Utility to time out an action after a delay.
|
||||
*
|
||||
* The action cannot be cancelled; it may still proceed after the timeout.
|
||||
*/
|
||||
async function withTimeout(actionPromise, timeout) {
|
||||
const timeoutPromise = new Promise((_, reject) => {
|
||||
setTimeout(() => {
|
||||
reject(new Error());
|
||||
}, timeout);
|
||||
});
|
||||
// timeoutPromise never resolves so result must be from action
|
||||
return Promise.race([actionPromise, timeoutPromise]);
|
||||
}
|
||||
|
||||
class Page {
|
||||
constructor(targetAddr, data) {
|
||||
this.targetAddr = targetAddr;
|
||||
@@ -312,10 +327,10 @@ class PartialFlashing {
|
||||
const data = fs.getIntelHexForBoardId(boardId.normalize().id.toString(16));
|
||||
await this.dapwrapper.transport.open();
|
||||
await this.dapwrapper.daplink.flash(data.buffer);
|
||||
console.log({
|
||||
type: "WebUSB-info",
|
||||
message: "full-flash-successful",
|
||||
})
|
||||
// console.log({
|
||||
// type: "WebUSB-info",
|
||||
// message: "full-flash-successful",
|
||||
// });
|
||||
} finally {
|
||||
this.dapwrapper.daplink.removeListener(
|
||||
DAPjs.DAPLink.EVENT_PROGRESS,
|
||||
@@ -353,10 +368,10 @@ class PartialFlashing {
|
||||
if (e instanceof Error) {
|
||||
this.log("Resetting micro:bit timed out");
|
||||
this.log("Partial flashing failed. Attempting full flash");
|
||||
console.log({
|
||||
type: "WebUSB-info",
|
||||
message: "flash-failed/attempting-full-flash",
|
||||
});
|
||||
// console.log({
|
||||
// type: "WebUSB-info",
|
||||
// message: "flash-failed/attempting-full-flash",
|
||||
// });
|
||||
await this.fullFlashAsync(boardId, fs, updateProgress);
|
||||
return false;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user