Skip to content

Commit

Permalink
added documentation regarding reset-on-connect issue
Browse files Browse the repository at this point in the history
  • Loading branch information
AndiDittrich committed Aug 27, 2016
1 parent 15d64a2 commit cd1230c
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
55 changes: 55 additions & 0 deletions docs/Reset_on_Connect.md
Original file line number Diff line number Diff line change
@@ -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
```
Binary file added docs/nodemcu-reset-circuit.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion lib/NodeMcuConnector.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}));
}
});
Expand Down

0 comments on commit cd1230c

Please sign in to comment.