+
+ Controller Type
-
-
- Door Interlock
-
-
-
-
+
+
-
-
- Controller Type
-
-
-
-
+
+
+
-
+
diff --git a/app/js/websocket.js b/app/js/websocket.js
index 8a5400c..6d00aa1 100644
--- a/app/js/websocket.js
+++ b/app/js/websocket.js
@@ -301,6 +301,18 @@ function initSocket() {
string = string.replace('[31mflash complete.[39m', "
FLASH FAILED! ");
string = string.replace('[32m', "
");
string = string.replace('[39m', "");
+ if (string.indexOf("Hash of data verified") != -1) {
+ string = "
" + string + ""
+ }
+ if (string.indexOf("could not open port") != -1) {
+ string = "
" + string + ""
+ }
+ if (string.indexOf("something went wrong") != -1) {
+ string = "
" + string + ""
+ }
+ if (string.indexOf("fatal error occurred") != -1) {
+ string = "
" + string + ""
+ }
printLog("
[ Firmware Upgrade ] " + string)
// $('#sendCommand').click();
diff --git a/app/wizards/flashingtool/grbl-flashing.js b/app/wizards/flashingtool/grbl-flashing.js
index 385d32a..81eb2f2 100644
--- a/app/wizards/flashingtool/grbl-flashing.js
+++ b/app/wizards/flashingtool/grbl-flashing.js
@@ -1,37 +1,152 @@
-function flashGrblfromTroubleshooting() {
- var data = {
- port: $("#portUSB").val(),
- file: $("#flashGrblHex").val(),
- board: $("#flashGrblController").val()
+$(document).ready(function() {
+
+ $("#flashController").on("change", function() {
+ if (this.value == "interface") {
+ $("#flash-tool-machine-row").hide();
+ $("#flash-tool-door-row").hide();
+ $("#flash-tool-interface-fw-row").show();
+ if ($("#interfaceFirmwareVer").val() == "custom") {
+ $("#flash-tool-custom-row").show();
+ } else {
+ $("#flash-tool-custom-row").hide();
+ }
+ $("#customFirmwareSet").html("Please select the Interface Firmware binary file you want to flash");
+ } else {
+ $("#flash-tool-machine-row").show();
+ $("#flash-tool-door-row").show();
+ $("#flash-tool-interface-fw-row").hide();
+ $("#flash-tool-custom-row").hide();
+ $("#customFirmwareSet").html("Please select the Grbl Firmware hex file you want to flash");
+ }
+ });
+
+ $("#grblAxesCount").on("change", function() {
+ if (this.value == "custom") {
+ $("#flash-tool-door-row").hide();
+ $("#flash-tool-custom-row").show();
+ $("#customFirmwareSet").html("Please select the Grbl Firmware hex file you want to flash");
+ } else {
+ $("#flash-tool-door-row").show();
+ $("#flash-tool-custom-row").hide();
+ }
+ });
+
+ $("#interfaceFirmwareVer").on("change", function() {
+ if (this.value == "custom") {
+ $("#flash-tool-custom-row").show();
+ $("#customFirmwareSet").html("Please select the Interface Firmware binary file you want to flash");
+ } else {
+ $("#flash-tool-custom-row").hide();
+ }
+ });
+
+
+
+ // var fileOpen = document.getElementById('firmwareBin');
+ // if (fileOpen) {
+ // fileOpen.addEventListener('change', readEspFirmwareFile, false);
+ // }
+
+ function readEspFirmwareFile() {
+ console.log("Sending")
+ var form = document.getElementById('customFirmwareForm');
+ var formData = new FormData(form);
+ var xhr = new XMLHttpRequest();
+ xhr.onload = function() {
+ if (xhr.status == 200) {
+ $("#customFirmwareSet").html(xhr.response)
+ }
+ };
+ // Add any event handlers here...
+ xhr.open('POST', '/uploadCustomFirmware', true);
+ xhr.send(formData);
}
- socket.emit('flashGrbl', data)
-}
+
+});
function populateGrblBuilderToolForm() {
- //$("#filetoflash").empty();
Metro.dialog.open("#grblFlashDialog");
}
-function flashGrblfromWizard() {
- var formdata = {
- axesCount: $("#grblAxesCount").val(),
- door: $("#grblDoorEnable").val(),
- flashGrblController: $("#flashGrblController").val(),
- port: $("#portUSB2").val()
- };
+function flashFirmwarefromWizard() {
+ if ($("#flashController").val() != "interface") {
+ var data = {
+ port: $("#portUSB2").val(),
+ file: "grbl-" + $("#grblAxesCount").val() + "-" + $("#grblDoorEnable").val() + ".hex",
+ board: $("#flashController").val()
+ }
- $("#filetoflash").html('run file: ' + JSON.stringify(formdata));
- $("#filetoflash").append("
grbl-" + formdata.axesCount + "-" + formdata.door + ".hex");
+ if ($("#grblAxesCount").val() == "custom") {
+ // Custom Firmware
+ if ($("#firmwareBin").val().length > 0) {
+ var form = document.getElementById('customFirmwareForm');
+ var formData = new FormData(form);
+ var xhr = new XMLHttpRequest();
+ xhr.onload = function() {
+ if (xhr.status == 200) {
+ $("#customFirmwareSet").html(xhr.response);
+ data.file = $("#firmwareBin").val();
+ socket.emit('flashGrbl', data);
+ }
+ };
+ // Add any event handlers here...
+ xhr.open('POST', '/uploadCustomFirmware', true);
+ xhr.send(formData);
+ } else {
+ $('#controlTab').click();
+ $('#consoletab').click();
+ printLog("
[ Firmware Upgrade ] You selected the option to use a custom firmware file, but failed to select a file to use for the operation. Please try again")
+ }
- var data = {
- port: $("#portUSB").val(),
- file: "grbl-" + formdata.axesCount + "-" + formdata.door + ".hex",
- board: $("#flashGrblController").val()
+
+ } else {
+ // Precompiled Firmwares
+ socket.emit('flashGrbl', data)
+
+ }
+
+ } else if ($("#flashController").val() == "interface") {
+ var data = {
+ port: $("#portUSB2").val(),
+ file: "firmware.bin", // version that ships with Interface
+ board: $("#flashController").val()
+ }
+
+ if ($("#interfaceFirmwareVer").val() == "custom") {
+ // custom image
+ if ($("#firmwareBin").val().length > 0) {
+ var form = document.getElementById('customFirmwareForm');
+ var formData = new FormData(form);
+ var xhr = new XMLHttpRequest();
+ xhr.onload = function() {
+ if (xhr.status == 200) {
+ $("#customFirmwareSet").html(xhr.response);
+ data.file = $("#firmwareBin").val();
+ socket.emit('flashInterface', data);
+ }
+ };
+ // Add any event handlers here...
+ xhr.open('POST', '/uploadCustomFirmware', true);
+ xhr.send(formData);
+ } else {
+ $('#controlTab').click();
+ $('#consoletab').click();
+ printLog("
[ Firmware Upgrade ] You selected the option to use a custom firmware file, but failed to select a file to use for the operation. Please try again")
+ }
+
+ } else {
+ // latest included firmware
+ socket.emit('flashInterface', data)
+ }
+
+
+ } else {
+ console.log("no controller selected")
}
- socket.emit('flashGrbl', data)
}
+
// grbl-3axes-nodoor.hex
// grbl-3axes-opendoor.hex
// grbl-3axes-closeddoor.hex
diff --git a/boot_app0.bin b/boot_app0.bin
new file mode 100644
index 0000000..13562ca
Binary files /dev/null and b/boot_app0.bin differ
diff --git a/bootloadcommand.txt b/bootloadcommand.txt
new file mode 100644
index 0000000..44b930f
--- /dev/null
+++ b/bootloadcommand.txt
@@ -0,0 +1,2 @@
+./avrdude -Cavrdude.conf -v -patmega328p -cusbtiny -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xDE:m -Ulfuse:w:0xFF:m
+./avrdude -Cavrdude.conf -v -patmega328p -cusbtiny -Uflash:w:optiboot_atmega328.hex:i -Ulock:w:0x0F:m
\ No newline at end of file
diff --git a/bootloader_qio_80m.bin b/bootloader_qio_80m.bin
new file mode 100644
index 0000000..944f494
Binary files /dev/null and b/bootloader_qio_80m.bin differ
diff --git a/firmware.bin b/firmware.bin
new file mode 100644
index 0000000..3865fb9
Binary files /dev/null and b/firmware.bin differ
diff --git a/firmware.partitions.bin b/firmware.partitions.bin
new file mode 100644
index 0000000..0e52b4c
Binary files /dev/null and b/firmware.partitions.bin differ
diff --git a/index.js b/index.js
index 16a16bc..715c2ec 100644
--- a/index.js
+++ b/index.js
@@ -46,6 +46,30 @@ var mkdirp = require('mkdirp');
app.use(express.static(path.join(__dirname, "app")));
+// Interface firmware flash
+app.post('/uploadCustomFirmware', (req, res) => {
+ // 'firmwareBin' is the name of our file input field in the HTML form
+ let upload = multer({
+ storage: storage
+ }).single('firmwareBin');
+
+ upload(req, res, function(err) {
+ // req.file contains information of uploaded file
+ // req.body contains information of text fields, if there were any
+
+ if (err instanceof multer.MulterError) {
+ return res.send(err);
+ } else if (err) {
+ return res.send(err);
+ }
+
+ // Display uploaded image for user validation
+ firmwareImagePath = req.file.path;
+ res.send(`Using ` + req.file.path);
+ });
+});
+// end Interface Firmware flash
+
//Note when renewing Convert zerossl cert first `openssl.exe rsa -in domain-key.key -out domain-key.key`
// fix error: App threw an error during load
@@ -690,6 +714,17 @@ io.on("connection", function(socket) {
}, 1000)
})
+ socket.on("flashInterface", function(data) {
+ if (status.comms.connectionStatus > 0) {
+ debug_log('WARN: Closing Port ' + port);
+ stopPort();
+ } else {
+ debug_log('ERROR: Machine connection not open!');
+ }
+ flashInterface(data)
+ })
+
+
socket.on("connectTo", function(data) { // If a user picks a port to connect to, open a Node SerialPort Instance to it
@@ -2462,4 +2497,104 @@ function startChrome() {
}
}
+// Interface Programming
+var firmwareImagePath = path.join(__dirname, './firmware.bin');
+var spawn = require('child_process').spawn;
+const multer = require('multer');
+const storage = multer.diskStorage({
+ destination: function(req, file, cb) {
+ cb(null, uploadsDir);
+ },
+ // By default, multer removes file extensions so let's add them back
+ filename: function(req, file, cb) {
+ cb(null, file.fieldname + '-' + new Date().toJSON().replace(new RegExp(':', 'g'), '.') + path.extname(file.originalname));
+ }
+});
+
+function flashInterface(data) {
+ status.comms.connectionStatus = 6;
+
+ var port = data.port;
+ var file = data.file;
+ var board = data.board
+
+
+ console.log("Flashing Interface on " + port + " with board " + board + " file: " + file)
+ // var data = {
+ // 'port': port,
+ // 'string': debugString
+ // }
+ // io.sockets.emit("progStatus", data);
+ //
+
+ //for (let i = 0; i < ports.length; i++) {
+
+ var data = {
+ 'port': port,
+ 'string': "[Starting...]"
+ }
+ io.sockets.emit("progStatus", data);
+
+ var esptool_opts = [
+ '--chip', 'esp32',
+ '--port', port,
+ '--baud', '921600',
+ '--before', 'default_reset',
+ '--after', 'hard_reset',
+ 'write_flash',
+ '-z',
+ '--flash_mode', 'dio',
+ '--flash_freq', '80m',
+ '--flash_size', 'detect',
+ '0xe000', path.join(__dirname, "./boot_app0.bin"),
+ '0x1000', path.join(__dirname, "./bootloader_qio_80m.bin"),
+ '0x10000', path.resolve(firmwareImagePath),
+ '0x8000', path.join(__dirname, "./firmware.partitions.bin")
+ ];
+
+ var child = spawn(path.join(__dirname, "./esptool.exe"), esptool_opts);
+
+
+ child.stdout.on('data', function(data) {
+ var debugString = data.toString();
+ console.log(debugString)
+ var data = {
+ 'port': port,
+ 'string': debugString
+ }
+ io.sockets.emit("progStatus", data);
+ status.comms.connectionStatus = 6;
+
+ });
+
+ child.stderr.on('data', function(data) {
+ var debugString = data.toString();
+ console.log(debugString)
+ var data = {
+ 'port': port,
+ 'string': debugString
+ }
+ io.sockets.emit("progStatus", data);
+ status.comms.connectionStatus = 6;
+
+ });
+
+ child.on('close', (code) => {
+ var data = {
+ 'port': port,
+ 'string': `[exit]`,
+ 'code': code
+ }
+ io.sockets.emit("progStatus", data);
+ status.comms.connectionStatus = 0;
+
+ });
+
+
+}
+
+
+// end Interface Programming
+
+
process.on('exit', () => debug_log('exit'))
\ No newline at end of file
diff --git a/package-lock.json b/package-lock.json
index b4b4f9f..75df171 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "OpenBuildsCONTROL",
- "version": "1.0.241",
+ "version": "1.0.258",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -340,6 +340,11 @@
}
}
},
+ "append-field": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/append-field/-/append-field-1.0.0.tgz",
+ "integrity": "sha1-HjRA6RXwsSA9I3SOeO3XubW0PlY="
+ },
"aproba": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz",
@@ -708,8 +713,7 @@
"buffer-from": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
- "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==",
- "dev": true
+ "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A=="
},
"builder-util": {
"version": "22.8.0",
@@ -742,6 +746,33 @@
"sax": "^1.2.4"
}
},
+ "busboy": {
+ "version": "0.2.14",
+ "resolved": "https://registry.npmjs.org/busboy/-/busboy-0.2.14.tgz",
+ "integrity": "sha1-bCpiLvz0fFe7vh4qnDetNseSVFM=",
+ "requires": {
+ "dicer": "0.2.5",
+ "readable-stream": "1.1.x"
+ },
+ "dependencies": {
+ "isarray": {
+ "version": "0.0.1",
+ "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
+ "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8="
+ },
+ "readable-stream": {
+ "version": "1.1.14",
+ "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
+ "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=",
+ "requires": {
+ "core-util-is": "~1.0.0",
+ "inherits": "~2.0.1",
+ "isarray": "0.0.1",
+ "string_decoder": "~0.10.x"
+ }
+ }
+ }
+ },
"bytes": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz",
@@ -939,7 +970,6 @@
"version": "1.6.2",
"resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz",
"integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==",
- "dev": true,
"requires": {
"buffer-from": "^1.0.0",
"inherits": "^2.0.3",
@@ -951,7 +981,6 @@
"version": "2.3.7",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz",
"integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==",
- "dev": true,
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.3",
@@ -966,7 +995,6 @@
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
- "dev": true,
"requires": {
"safe-buffer": "~5.1.0"
}
@@ -1153,6 +1181,33 @@
"resolved": "https://registry.npmjs.org/detect-rpi/-/detect-rpi-1.4.0.tgz",
"integrity": "sha512-EeAj8C7zCdjzNqJCYEVmKcBvu9DmxJncCOkwvAfa7J4I0ZLRywZ1jSeeqI2Kvx/2Gn2OOa1lSXSigZ4wy4M6Tg=="
},
+ "dicer": {
+ "version": "0.2.5",
+ "resolved": "https://registry.npmjs.org/dicer/-/dicer-0.2.5.tgz",
+ "integrity": "sha1-WZbAhrszIYyBLAkL3cCc0S+stw8=",
+ "requires": {
+ "readable-stream": "1.1.x",
+ "streamsearch": "0.1.2"
+ },
+ "dependencies": {
+ "isarray": {
+ "version": "0.0.1",
+ "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
+ "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8="
+ },
+ "readable-stream": {
+ "version": "1.1.14",
+ "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
+ "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=",
+ "requires": {
+ "core-util-is": "~1.0.0",
+ "inherits": "~2.0.1",
+ "isarray": "0.0.1",
+ "string_decoder": "~0.10.x"
+ }
+ }
+ }
+ },
"directory-tree": {
"version": "2.2.4",
"resolved": "https://registry.npmjs.org/directory-tree/-/directory-tree-2.2.4.tgz",
@@ -2320,6 +2375,31 @@
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
},
+ "multer": {
+ "version": "1.4.2",
+ "resolved": "https://registry.npmjs.org/multer/-/multer-1.4.2.tgz",
+ "integrity": "sha512-xY8pX7V+ybyUpbYMxtjM9KAiD9ixtg5/JkeKUTD6xilfDv0vzzOFcCp4Ljb1UU3tSOM3VTZtKo63OmzOrGi3Cg==",
+ "requires": {
+ "append-field": "^1.0.0",
+ "busboy": "^0.2.11",
+ "concat-stream": "^1.5.2",
+ "mkdirp": "^0.5.1",
+ "object-assign": "^4.1.1",
+ "on-finished": "^2.3.0",
+ "type-is": "^1.6.4",
+ "xtend": "^4.0.0"
+ },
+ "dependencies": {
+ "mkdirp": {
+ "version": "0.5.5",
+ "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz",
+ "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==",
+ "requires": {
+ "minimist": "^1.2.5"
+ }
+ }
+ }
+ },
"nan": {
"version": "2.14.1",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.14.1.tgz",
@@ -3221,6 +3301,11 @@
}
}
},
+ "streamsearch": {
+ "version": "0.1.2",
+ "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-0.1.2.tgz",
+ "integrity": "sha1-gIudDlb8Jz2Am6VzOOkpkZoanxo="
+ },
"string-width": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz",
@@ -3234,8 +3319,7 @@
"string_decoder": {
"version": "0.10.31",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
- "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=",
- "dev": true
+ "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ="
},
"strip-ansi": {
"version": "3.0.1",
@@ -3470,8 +3554,7 @@
"typedarray": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
- "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=",
- "dev": true
+ "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c="
},
"typedarray-to-buffer": {
"version": "3.1.5",
@@ -3726,8 +3809,7 @@
"xtend": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
- "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==",
- "dev": true
+ "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ=="
},
"y18n": {
"version": "4.0.0",
diff --git a/package.json b/package.json
index 1b6665c..b864197 100644
--- a/package.json
+++ b/package.json
@@ -19,14 +19,15 @@
"formidable": "^1.2.2",
"https": "^1.0.0",
"ip": "^1.1.5",
+ "jscs-loader": "^0.3.0",
"lodash": "^4.17.19",
"md5": "^2.3.0",
"mkdirp": "^1.0.4",
+ "multer": "^1.4.2",
"node-abi": "^2.18.0",
"rimraf": "^3.0.2",
"serialport": "^9.0.1",
- "socket.io": "^2.3.0",
- "jscs-loader": "^0.3.0"
+ "socket.io": "^2.3.0"
},
"main": "index.js",
"scripts": {