diff --git a/CHANGES.md b/CHANGES.md index 72d96b8..57c5ada 100755 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,7 +1,8 @@ -### 2.0.0-BETA1 ### +### 2.0.0 ### * Added: `reset` command to Hard-Reset the NodeMCU module using DTR/RTS reset circuit (like NodeMCU DEV Kit) * Added: RAW output format to `fsinfo` command - feature requested [on GitHub](https://github.com/AndiDittrich/NodeMCU-Tool/issues/13) #13 * Added: `--connection-delay` option to fix broken reset circuits which cause a immediate hard-reset on opening the serial connection (dts/rts lines) #14 +* Added: Documentation regarding to [Reset-on-Connect Issues / Broken Reset Circuits](docs/Reset_on_Connect.md) * Changed: Default baudrate to **115200** - newer firmware versions using automatic baudrate detection which allows to use higher connection speeds by default * Changed: footprints of NodeMCU-Tool.js functions - port/baudrate are set globally by setOptions instead by each function * Changed: [logging-facility](https://github.com/AndiDittrich/Node.Logging-Facility) is used for global log output management diff --git a/README.md b/README.md index 544f035..3ba655d 100755 --- a/README.md +++ b/README.md @@ -38,7 +38,9 @@ Related Documents * [Common Use-Cases and Examples](docs/Examples.md) * [Programmatic Usage](docs/ProgrammaticUsage.md) +* [Fixing Reset-on-Connect Issue](docs/Reset_on_Connect.md) * [Contribution Guidelines](CONTRIBUTE.md) +* [NodeMCU DEVKIT Schematics](https://github.com/nodemcu/nodemcu-devkit-v1.0/blob/master/NODEMCU_DEVKIT_V1.0.PDF) * [Changelog](CHANGES.md) * [License](LICENSE.md) diff --git a/docs/Reset_on_Connect.md b/docs/Reset_on_Connect.md new file mode 100755 index 0000000..96e2233 --- /dev/null +++ b/docs/Reset_on_Connect.md @@ -0,0 +1,55 @@ +Fixing Reset-on-Connect Issue / Broken Reset Circuits +===================================================== + +Regarding to Issue #14 + +Build-In Reset Circuit +---------------------- + +The original [NodeMCU DEVKIT](https://github.com/nodemcu/nodemcu-devkit-v1.0) includes a build-in circuit to pull down the reset (RST) and/or flash (GPIO0) pins via the serial connection using the DTR/RTS lines. +This allows the user to execute a hard-reset or flash command via software. + +**Reset Circuit** (from [NodeMCU DEVKIT Schematics](https://github.com/nodemcu/nodemcu-devkit-v1.0/blob/master/NODEMCU_DEVKIT_V1.0.PDF)) +![Reset Circuit of NodeMCU DEVKIT](nodemcu-reset-circuit.jpg) + + +The Issue +--------------------- +It's a very useful feature, but on some modules these circuits cause a **reset on connect** which make the module inaccessible with NodeMCU-Tool: +on opening the serial connection software side, the module will be reset immediately and it reboots. Directly after reboot, the **auto-baudrate** detection of NodeMCU is capturing the serial input to determinate the used baudrate. +And this is the issue: NodeMCU-Tool sends a few hearbeat messages to the module to check its state, but these messages are list because of the auto-baudrate detection. Therefore the module is threatened as unavailable and a error message is raised. + +This behaviour can be caused by a hardware issue: wrong transistors, wrong series-resistors **or** a usb driver failure, which invokes the DTR/RTS lines asynchronous + +**Timeline** + +1. **NodeMCU-Tool** is establishing the serial connection +2. DTR/RTS lines are invoked +3. NodeMCU will do a hard-reset or go into flash mode +4. **NodeMCU-Tool** sends heartbeat sequence +5. NodeMCU Auto-Baudrate Detection is capturing the input or the module is not ready yet the receive incoming data +6. **NodeMCU-Tool** will not receive the hearbeat response - the module is threatened as unavailable + + +How to fix it +--------------------- + +NodeMCU-Tool v2.0.0 includes a special delay flag `--connection-delay N` which waits **N** milliseconds after establishing the connection and sends additional dummy sequences to trigger the auto-baudrate detection. + +**Timeline** +1. **NodeMCU-Tool** establishes the serial connection +2. **NodeMCU-Tool** is waiting **N** milliseconds until the hard-reset/reboot is done +3. **NodeMCU** becomes ready and starts the auto-baudrate detection +4. **NodeMCU-Tool** sends dummy sequence 1 to trigger the auto-baudrate detection +5. **NodeMCU-Tool** is waiting **N** milliseconds for baudrate detection +6. **NodeMCU-Tool** sends dummy sequence 2 to trigger the auto-baudrate detection +7. **NodeMCU-Tool** is waiting **N** milliseconds for baudrate detection +8. **NodeMCU** set its baudrate based on the previous dummy sequences +9. **NodeMCU-Tool** starts the regular heartbeat detection + +The connection delay is applied 3 times, between each step. A value between **300...500ms** has been approved as best option. + +**Example 1** +```bash +$ ./nodemcu-tool upload helloworld.lua --connection-delay 300 --baud 115200 +``` diff --git a/docs/nodemcu-reset-circuit.jpg b/docs/nodemcu-reset-circuit.jpg new file mode 100755 index 0000000..807562e Binary files /dev/null and b/docs/nodemcu-reset-circuit.jpg differ diff --git a/lib/NodeMcuConnector.js b/lib/NodeMcuConnector.js index 26cfc8a..30e3099 100755 --- a/lib/NodeMcuConnector.js +++ b/lib/NodeMcuConnector.js @@ -524,7 +524,7 @@ NodeMcuConnector.prototype.deviceInfo = function(showAll, cb){ // NodeMCU v1.1 - CP2102 Adapter | 0x10c4 Cygnal Integrated Products, Inc }else{ cb(null, ports.filter(function(item){ - return (item.vendorId == '0x1a86' || item.vendorId == '0x10c4' ); + return (item.vendorId == '0x1a86' || item.vendorId == '0x10c4'); })); } });