Skip to content

Commit

Permalink
Add DFU support for PWA (#3949)
Browse files Browse the repository at this point in the history
* Add webusbdfu support for PWA

* Cleanup

* Cleanup more

* protect flash memory

* Remove self

* Fix flashing for F4 and F7
  • Loading branch information
haslinghuis authored May 15, 2024
1 parent e32d7db commit b91698d
Show file tree
Hide file tree
Showing 6 changed files with 1,114 additions and 18 deletions.
8 changes: 1 addition & 7 deletions src/js/port_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,10 @@ import { get as getConfig } from "./ConfigStorage";
import serial from "./serial";
import MdnsDiscovery from "./mdns_discovery";
import { isWeb } from "./utils/isWeb";
import { usbDevices } from "./usb_devices";

const TIMEOUT_CHECK = 500 ; // With 250 it seems that it produces a memory leak and slowdown in some versions, reason unknown

export const usbDevices = { filters: [
{'vendorId': 1155, 'productId': 57105}, // STM Device in DFU Mode || Digital Radio in USB mode
{'vendorId': 10473, 'productId': 393}, // GD32 DFU Bootloader
{'vendorId': 0x2E3C, 'productId': 0xDF11}, // AT32F435 DFU Bootloader
{'vendorId': 12619, 'productId': 262}, // APM32 DFU Bootloader
] };

const PortHandler = new function () {
this.currentPorts = [];
this.initialPorts = false;
Expand Down
13 changes: 9 additions & 4 deletions src/js/protocols/stm32.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,18 @@ import { bit_check } from "../bit";
import { gui_log } from "../gui_log";
import MSPCodes from "../msp/MSPCodes";
import PortUsage from "../port_usage";
import PortHandler, { usbDevices } from "../port_handler";
import PortHandler from "../port_handler";
import { API_VERSION_1_42 } from "../data_storage";
import serial from "../serial";
import STM32DFU from "./stm32usbdfu";
import semver from "semver";
import $ from 'jquery';

import { usbDevices } from "../usb_devices";
import { serialShim } from "../serial_shim";
import { usbShim } from "../usb_shim";

let serial = serialShim();
let dfu = usbShim();

const STM32_protocol = function () {
this.baud = null;
this.options = {};
Expand Down Expand Up @@ -112,7 +117,7 @@ STM32_protocol.prototype.connect = function (port, baud, hex, options, callback)
// refresh device list
PortHandler.check_usb_devices(function(dfu_available) {
if (dfu_available) {
STM32DFU.connect(usbDevices, hex, options);
dfu.connect(usbDevices, hex, options);
} else {
serial.connect(self.port, {bitrate: self.baud, parityBit: 'even', stopBits: 'one'}, function (openInfo) {
if (openInfo) {
Expand Down
Loading

0 comments on commit b91698d

Please sign in to comment.