From 384b0ba8eea8863805efb9a00ed159a3df3023e2 Mon Sep 17 00:00:00 2001 From: Morgan Allen Date: Fri, 10 Aug 2018 10:10:27 -0700 Subject: [PATCH] move to esptool-wrapper for flashing esp devices --- package.json | 1 + test/lora32/main/main.c | 4 ++- test/test.js | 63 ++++++++++++++++++++--------------------- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/package.json b/package.json index 124e76e..6f76c03 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/test/lora32/main/main.c b/test/lora32/main/main.c index 7467b83..071cedd 100644 --- a/test/lora32/main/main.c +++ b/test/lora32/main/main.c @@ -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) { diff --git a/test/test.js b/test/test.js index 20ceecb..30c9ead 100644 --- a/test/test.js +++ b/test/test.js @@ -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) {