Merge pull request #54 from liux-pro/main
support build-in USB-JTAG-Serial
This commit is contained in:
commit
ce8f8da11a
@ -11,7 +11,7 @@
|
|||||||
/>
|
/>
|
||||||
<link rel="icon" href="favicon.ico" />
|
<link rel="icon" href="favicon.ico" />
|
||||||
<script src="https://cdn.jsdelivr.net/npm/xterm@4.19.0/lib/xterm.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/xterm@4.19.0/lib/xterm.min.js"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/crypto-js@4.1.1/index.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/crypto-js@4.1.1/crypto-js.js"></script>
|
||||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
|
||||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
|
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
|
||||||
</head>
|
</head>
|
||||||
|
@ -84,6 +84,8 @@ export class ESPLoader {
|
|||||||
0x18: "16MB",
|
0x18: "16MB",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
USB_JTAG_SERIAL_PID = 0x1001;
|
||||||
|
|
||||||
chip: ROM;
|
chip: ROM;
|
||||||
IS_STUB: boolean;
|
IS_STUB: boolean;
|
||||||
FLASH_WRITE_SIZE: number;
|
FLASH_WRITE_SIZE: number;
|
||||||
@ -278,6 +280,25 @@ export class ESPLoader {
|
|||||||
async _connect_attempt(mode = "default_reset", esp32r0_delay = false) {
|
async _connect_attempt(mode = "default_reset", esp32r0_delay = false) {
|
||||||
this.log("_connect_attempt " + mode + " " + esp32r0_delay);
|
this.log("_connect_attempt " + mode + " " + esp32r0_delay);
|
||||||
if (mode !== "no_reset") {
|
if (mode !== "no_reset") {
|
||||||
|
if (this.transport.get_pid() === this.USB_JTAG_SERIAL_PID) {
|
||||||
|
// Custom reset sequence, which is required when the device
|
||||||
|
// is connecting via its USB-JTAG-Serial peripheral
|
||||||
|
await this.transport.setRTS(false);
|
||||||
|
await this.transport.setDTR(false);
|
||||||
|
await this._sleep(100);
|
||||||
|
|
||||||
|
await this.transport.setDTR(true);
|
||||||
|
await this.transport.setRTS(false);
|
||||||
|
await this._sleep(100);
|
||||||
|
|
||||||
|
await this.transport.setRTS(true);
|
||||||
|
await this.transport.setDTR(false);
|
||||||
|
await this.transport.setRTS(true);
|
||||||
|
|
||||||
|
await this._sleep(100);
|
||||||
|
await this.transport.setRTS(false);
|
||||||
|
await this.transport.setDTR(false);
|
||||||
|
} else {
|
||||||
await this.transport.setDTR(false);
|
await this.transport.setDTR(false);
|
||||||
await this.transport.setRTS(true);
|
await this.transport.setRTS(true);
|
||||||
await this._sleep(100);
|
await this._sleep(100);
|
||||||
@ -293,6 +314,7 @@ export class ESPLoader {
|
|||||||
await this._sleep(50);
|
await this._sleep(50);
|
||||||
await this.transport.setDTR(false);
|
await this.transport.setDTR(false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
let i = 0;
|
let i = 0;
|
||||||
let keepReading = true;
|
let keepReading = true;
|
||||||
while (keepReading) {
|
while (keepReading) {
|
||||||
@ -999,22 +1021,22 @@ export class ESPLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async hard_reset() {
|
async hard_reset() {
|
||||||
this.transport.setRTS(true); // EN->LOW
|
await this.transport.setRTS(true); // EN->LOW
|
||||||
await this._sleep(100);
|
await this._sleep(100);
|
||||||
this.transport.setRTS(false);
|
await this.transport.setRTS(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
async soft_reset() {
|
async soft_reset() {
|
||||||
if (!this.IS_STUB) {
|
if (!this.IS_STUB) {
|
||||||
// "run user code" is as close to a soft reset as we can do
|
// "run user code" is as close to a soft reset as we can do
|
||||||
this.flash_begin(0, 0);
|
await this.flash_begin(0, 0);
|
||||||
this.flash_finish(false);
|
await this.flash_finish(false);
|
||||||
} else if (this.chip.CHIP_NAME != "ESP8266") {
|
} else if (this.chip.CHIP_NAME != "ESP8266") {
|
||||||
throw new ESPError("Soft resetting is currently only supported on ESP8266");
|
throw new ESPError("Soft resetting is currently only supported on ESP8266");
|
||||||
} else {
|
} else {
|
||||||
// running user code from stub loader requires some hacks
|
// running user code from stub loader requires some hacks
|
||||||
// in the stub loader
|
// in the stub loader
|
||||||
this.command(this.ESP_RUN_USER_CODE, undefined, undefined, false);
|
await this.command(this.ESP_RUN_USER_CODE, undefined, undefined, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,10 @@ class Transport {
|
|||||||
: "";
|
: "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_pid() {
|
||||||
|
return this.device.getInfo().usbProductId;
|
||||||
|
}
|
||||||
|
|
||||||
slip_writer(data: Uint8Array) {
|
slip_writer(data: Uint8Array) {
|
||||||
let count_esc = 0;
|
let count_esc = 0;
|
||||||
let i = 0,
|
let i = 0,
|
||||||
@ -181,11 +185,18 @@ class Transport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_DTR_state = false;
|
||||||
async setRTS(state: boolean) {
|
async setRTS(state: boolean) {
|
||||||
await this.device.setSignals({ requestToSend: state });
|
await this.device.setSignals({ requestToSend: state });
|
||||||
|
// # Work-around for adapters on Windows using the usbser.sys driver:
|
||||||
|
// # generate a dummy change to DTR so that the set-control-line-state
|
||||||
|
// # request is sent with the updated RTS state and the same DTR state
|
||||||
|
// Referenced to esptool.py
|
||||||
|
await this.setDTR(this._DTR_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
async setDTR(state: boolean) {
|
async setDTR(state: boolean) {
|
||||||
|
this._DTR_state = state;
|
||||||
await this.device.setSignals({ dataTerminalReady: state });
|
await this.device.setSignals({ dataTerminalReady: state });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user