@@ -1475,7 +1475,7 @@ function web_editor(config) {
1475
1475
1476
1476
function doFlash ( ) {
1477
1477
var startTime = new Date ( ) . getTime ( ) ;
1478
-
1478
+
1479
1479
// Hide serial and disconnect if open
1480
1480
if ( $ ( "#repl" ) . css ( 'display' ) != 'none' ) {
1481
1481
$ ( "#repl" ) . hide ( ) ;
@@ -1495,7 +1495,12 @@ function web_editor(config) {
1495
1495
}
1496
1496
}
1497
1497
1498
- var p = Promise . resolve ( ) ;
1498
+ // Get the hex to flash in bytes format, exit if there is an error
1499
+ try {
1500
+ var output = generateFullHex ( 'bytes' ) ;
1501
+ } catch ( e ) {
1502
+ return alert ( config . translate . alerts . error + e . message ) ;
1503
+ }
1499
1504
1500
1505
$ ( "#webusb-flashing-progress" ) . val ( 0 ) . hide ( ) ;
1501
1506
$ ( "#webusb-flashing-complete" ) . hide ( ) ;
@@ -1504,6 +1509,7 @@ function web_editor(config) {
1504
1509
$ ( "#flashing-info" ) . removeClass ( 'hidden' ) ;
1505
1510
$ ( "#flashing-overlay-container" ) . css ( "display" , "flex" ) ;
1506
1511
1512
+ var p = Promise . resolve ( ) ;
1507
1513
if ( usePartialFlashing ) {
1508
1514
REPL = null ;
1509
1515
$ ( "#repl" ) . empty ( ) ;
@@ -1513,15 +1519,13 @@ function web_editor(config) {
1513
1519
return PartialFlashing . connectDapAsync ( ) ;
1514
1520
} )
1515
1521
. then ( function ( ) {
1516
- var output = generateFullHex ( "bytes" ) ;
1517
1522
var updateProgress = function ( progress ) {
1518
1523
$ ( "#webusb-flashing-progress" ) . val ( progress ) . css ( "display" , "inline-block" ) ;
1519
1524
}
1520
1525
$ ( "#webusb-flashing-loader" ) . hide ( ) ;
1521
1526
$ ( "#webusb-flashing-progress" ) . val ( 0 ) . css ( "display" , "inline-block" ) ;
1522
1527
return PartialFlashing . flashAsync ( window . dapwrapper , output , updateProgress ) ;
1523
- } )
1524
-
1528
+ } ) ;
1525
1529
}
1526
1530
else {
1527
1531
// Push binary to board
@@ -1533,12 +1537,10 @@ function web_editor(config) {
1533
1537
$ ( "#webusb-flashing-progress" ) . val ( progress ) . css ( "display" , "inline-block" ) ;
1534
1538
} ) ;
1535
1539
1536
- var output = generateFullHex ( "string" ) ;
1537
-
1538
1540
// Encode firmware for flashing
1539
1541
var enc = new TextEncoder ( ) ;
1540
1542
var image = enc . encode ( output ) . buffer ;
1541
-
1543
+
1542
1544
$ ( "#webusb-flashing-loader" ) . hide ( ) ;
1543
1545
$ ( "#webusb-flashing-progress" ) . val ( 0 ) . css ( "display" , "inline-block" ) ;
1544
1546
return window . daplink . flash ( image ) ;
@@ -1566,7 +1568,6 @@ function web_editor(config) {
1566
1568
. finally ( function ( ) {
1567
1569
// Remove event listener
1568
1570
window . removeEventListener ( "unhandledrejection" , webusbErrorHandler ) ;
1569
-
1570
1571
} ) ;
1571
1572
}
1572
1573
0 commit comments