So I figured, if they can do it, I can too. And I did, and now you can too. Here is how.
There are several aspects to this setup.
- Hardware
I essentially used the Arduino trick of connecting RESET to DTR with a capacitor. This causes the chip to reset when DTR goes low. I also connected DTR to GPIO0 with a diode. Thus, setting DTR low for abour 15ms resets the chip and causes it to go into bootloader mode. I also added 10k pullups to the RESET, GPIO0, GPIO2, CH_PD lines. I have included a schematic. - Esptool
I have used mamalala's makefiles and ESPTOOL.exe to generate the firmware files, even though I use a different esptool to upload. You can find this tool here: viewtopic.php?f=9&t=142. I installed esptool in E:\Espressif\esptool.
I suspect that the makefiles could be modified to use the Python esptool-py to create the firmware image, but I have not done so. - Flasher
I modified the esptool-py Python script to activate DTR in order to reset the chip into bootloader mode. Pulling DTR low causes the chip to reset, and about 15ms later it looks as if the chip samples GIO0 to determine if it should go into bootloader mode. With DTR and GPIO0 still low, it goes into bootloader mode and turns GPIO0 back into an output, so DTR is pulled back up again. Another change has been made to the flasher app, it uses a named pipe to comunicate with the serial terminal app, in order to get control of the com port. After the flashing is done, control of the com port is returned back to the terminal. This was my first dabbling in Python, so feel free to make changes. - Serial Terminal
I'm lazy, so I went hunting for simple app I could hack. I found it on http://termie.sourceforge.net/. It's a basic serial terminal, written in C#. The source code was clean and easy to modify. I added a new thread that creates and monitors the named pipe that the flasher will talk to. When it receives a request, the terminal just closes the com port until it receives another command to reopen the port. - Visual Studio
With the free Visual Studio 2013 community edition, there is really no reason to be using anything else. You can easily add makefile projects to Visual Studio. You still need to have makefiles , but now you no longer need to leave the IDE. You can just select 'build' and the code will compile, then flash, reboot without you having to do anything else.
The files:
How to setup:
- First, make sure you have a working makefile that allows you to build and flash.
- Then, substitute the modified esptool-py.py. Things should still work.
- Modify your hookup to add the diode, the capacitor, the pullups and the connection to DTR. This should allow you to flash without setting any jumpers.
- Install Visual Studio 2013 and compile the C# terminal.
- Use the terminal. It works like just about every other terminal, except this one will get out of the way when you want to flash.
- Add your project to Visual Studio. Select 'New/Project/Other languages/C++/Makefile project. About the only thing you need to worry about is the actual make command (typically: 'make all flash'). Now everytime you select 'build project', things should happen automatically.
All of this should of course be considered beta. I think the terminal needs a bit more work, especially to handle errors. Eventually it would be nice to get better integration into Visual Studio. I think it may be possible to use Visual Micro for that. They already do it for the Arduino and Chipkit (PIC32) variants of gcc, so it should be possible to add a similar toolset.
Have fun.
Pete