move to esptool-wrapper for flashing esp devices

This commit is contained in:
Morgan Allen 2018-08-10 10:10:27 -07:00
parent 7028879878
commit 384b0ba8ee
3 changed files with 34 additions and 34 deletions

View File

@ -22,6 +22,7 @@
},
"dependencies": {
"async": "^2.6.1",
"esptool-wrapper": "^1.0.4",
"serialport": "^6.2.2",
"tape": "^4.9.1",
"testbed-query-fixtures": "^1.0.0"

View File

@ -121,9 +121,11 @@ void set_mode(void *args) {
}
void send(void *args) {
ESP_LOGI(TAG, "sending: %s\n", (char*)args);
ESP_LOGI(TAG, "sending: %s", (char*)args);
lora32_send(&lora, (uint8_t *)args, 12);
ESP_LOGI(TAG, "done");
};
void set_spreadfactor(void *args) {

View File

@ -1,4 +1,5 @@
var async = require("async");
var esptool = require("esptool-wrapper");
var homedir = require("homedir")();
var spawn = require("child_process").spawn;
var SerialPort = require("serialport");
@ -6,8 +7,6 @@ var path = require("path");
var test = require("tape");
var testbed = require("testbed-query-fixtures");
const exec = path.join(process.env.IDF_PATH, "components", "esptool_py", "esptool", "esptool.py");
const buildPath = path.join(__dirname, "lora32", "build");
try {
@ -31,41 +30,39 @@ if(devices.length < 2) {
const TB_DEV1 = devices[0].DEVNAME;
const TB_DEV2 = devices[1].DEVNAME;
var args = [
"--chip",
"esp32",
"--baud",
"460800",
"--before",
"default_reset",
"--after",
"hard_reset",
"write_flash",
"-z",
"--flash_mode",
"dio",
"--flash_freq",
"40m",
"--flash_size",
"detect",
"0x1000",
path.join(buildPath, "bootloader/bootloader.bin"),
"0x10000",
path.join(buildPath, "lora32.bin"),
"0x8000",
path.join(buildPath, "partitions_singleapp.bin")
];
var testBins = {
0x1000: path.join(buildPath, "bootloader/bootloader.bin"),
0x8000: path.join(buildPath, "partitions_singleapp.bin"),
0x10000: path.join(buildPath, "lora32.bin")
};
function flash(port, cb) {
var argsReset = [
"--before",
"default_reset",
"--after",
"hard_reset"
];
var argsWriteFlash = [
"-z",
"--flash_mode",
"dio",
"--flash_freq",
"40m",
"--flash_size",
"detect"
];
console.log("Flashing devices at %s", port);
var cp = spawn(exec, ["--port", port].concat(args));
cp.on("exit", function(code) {
console.log("%s\nexited: %d", port, code);
cb(code === 0 ? null : new Error("exited non-zero: " + code));
});
esptool({
port: port,
baud: 460800,
files: testBins,
args: argsReset,
cmdArgs: argsWriteFlash
}, cb);
}
function toggleReset(sp) {