Development Cycle for the Wemos D1 Mini from Windows

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
bitninja
Posts: 165
Joined: Thu Sep 15, 2016 4:09 pm
Location: Spring, Texas

Development Cycle for the Wemos D1 Mini from Windows

Post by bitninja » Mon Oct 31, 2016 11:25 pm

I have been developing my MicroPython application for a few weeks now and wonder how everyone is doing their edit-load-test development. What tools and procedures they are using to develop with MicroPython.

I am working with Wemos D1 Mini Boards from a Windows PC and mostly use the ampy utility from Adafruit. I use it so much in fact, I wrote a little gui to list and edit files directly from the board.
ampy_app.png
ampy_app.png (25.98 KiB) Viewed 10777 times
It utilizies the Scintilla editor control so that the syntax highlighting is nice... but it is far from being a true editor... no search and replace, etc...

How does everybody else do their development?

stijn
Posts: 735
Joined: Thu Apr 24, 2014 9:13 am

Re: Development Cycle for the Wemos D1 Mini from Windows

Post by stijn » Tue Nov 01, 2016 9:06 am

I don't develop for hardware boards but if so I'd likely use SublimeText: it has all the python goodies including 'go to definition'/pep8/flake/... support and can easily be extended so commands can be added (and bound to keyboard shortcuts) to load code onto the board. You typcially spent most of your time in the editor anyway so it seems logical to select a good one even though it might take some time to setup or you might need a seperate program to deal with the boadr (then again, you'd be using that only a fraction of the time)

yeyeto2788
Posts: 28
Joined: Wed Mar 30, 2016 4:09 pm

Re: Development Cycle for the Wemos D1 Mini from Windows

Post by yeyeto2788 » Wed Nov 02, 2016 12:54 pm

Hello Bitninja,

My process is actually harder, I upload the bin files with NodeMCU Flasher https://github.com/nodemcu/nodemcu-flasher after uploading a empty bin to all memory addresses (crazy I know).

Then I use the WebREPL to upload the code but to run my code changes I have to import it and then run any function I have inside my code. (even more crazy).

Do you mind sending what you are using?

Thanks!

bitninja
Posts: 165
Joined: Thu Sep 15, 2016 4:09 pm
Location: Spring, Texas

Re: Development Cycle for the Wemos D1 Mini from Windows

Post by bitninja » Wed Nov 02, 2016 3:36 pm

Sure!

Here is the EXE. Make sure you have ampy installed and running.

https://dl.dropboxusercontent.com/u/112 ... nager2.zip

For the record... the source code can be found here.

https://github.com/joewez/AmpyFileManager

Notes:

- Sometimes ampy will fail on it's own and the app will seem not to work. Just try again.
- The program saves the backups under the same directory as the EXE
- Use at your own risk!
Last edited by bitninja on Tue Nov 29, 2016 12:20 am, edited 1 time in total.

User avatar
ernitron
Posts: 89
Joined: Fri Jun 03, 2016 5:53 pm
Location: The Netherlands

Re: Development Cycle for the Wemos D1 Mini from Windows

Post by ernitron » Wed Nov 02, 2016 6:37 pm

Hi bitninja and thanks for sharing. I will give it a try.

However, for me a combination of makefile and esptool and ampy are the fastest devop cycle. Actually mine looks a lot like:
  • 1. make flash
    2. edit with editor or ide. I stick to vi/vim and sometimes use geany
    3. make install
relying on a sample makefile that would be something like:

Code: Select all

# Serial port settings
# Windows
#PORT=/dev/cu.SLAB_USBtoUART
# MAC
#PORT=/dev/ttyACM0
# Linux Debian/Ubuntu
PORT=/dev/ttyUSB0

SPEED=115200

# Path to setup firmware and programs. configure your paths here
MPYCROSS=/opt/ESP8266/micropython/mpy-cross/mpy-cross
ESPTOOL=/opt/ESP8266/esp-open-sdk/esptool/esptool.py
# Install with sudo pip2 install adafruit-ampy
AMPY=ampy -p $(PORT)
FIRMWARE=/opt/ESP8266/micropython/esp8266/build/firmware-combined.bin

DATE=$(shell date +"%Y-%b-%d %H:%M:%S")
VERSION=1.0.1

######################################################################
# End of standard config
######################################################################
FILES := \
	main.py \
	version.py
	yoursourcefile.py
	
MPYFILES := \
	version.mpy  \
	yoursourcefile.mpy \

%.mpy: %.py
	$(MPYCROSS) $<

instructions:
	@echo "How to install:"
	@echo "1) make erase 2) make flash 3) make install"

check: $(MPYFILES)
	python3 -m py_compile *.py
	rm -rf __pycache__
	rm -f *.pyc

erase:
	$(ESPTOOL) --port $(PORT) erase_flash 

flash:
	@echo "Be sure about MEMORY SIZE"
	$(ESPTOOL) --port $(PORT) --baud 115200 write_flash --verify --flash_size=32m --flash_mode=qio 0x00000 $(FIRMWARE)
	@echo 'Power device again'

# Upload all
install: check $(MPYFILES) main.py
	sed -i -e "s/^version=.*/version="${VERSION} ${DATE}"/" version.py
	for f in $^ ; \
	do \
	    echo installing $$f ;\
	    $(AMPY) put $$f ;\
	done;

reset:
	$(AMPY) reset

I cannot imagine a faster cycle and I thank the community to have pointed me to ampy (before I was using my own ugly tool do upload code via serial port)

bitninja
Posts: 165
Joined: Thu Sep 15, 2016 4:09 pm
Location: Spring, Texas

Re: Development Cycle for the Wemos D1 Mini from Windows

Post by bitninja » Wed Nov 02, 2016 7:45 pm

I actually have a split working environment... I run Linux at home mostly and that's where I build my images, but then switch to Windows to use my little GUI to edit and load the application scripts. There I alternate between editing scripts with the GUI and testing them with PuTTY over the serial REPL.

I appreciate the information for using make in Linux. I will have to look into what I can do on that front so I don't have to switch.

Then again... I'm stuck on Windows at work, so that's why I put up the original post.

User avatar
ernitron
Posts: 89
Joined: Fri Jun 03, 2016 5:53 pm
Location: The Netherlands

Re: Development Cycle for the Wemos D1 Mini from Windows

Post by ernitron » Wed Nov 02, 2016 9:33 pm

Window with maybe cygwin or even with the ubuntu shell will do the same I guess. Not to mention with Mac. Many platforms, same way to develop.. that's my motto. Enjoy!

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Development Cycle for the Wemos D1 Mini from Windows

Post by Roberthh » Sat Nov 05, 2016 8:02 am

If you look at a toosl which is available for both Linux and Windows,you could try pycom's pymakr. It detects and supports an Wemos D1 at the serial interface. I do not like pymakr's multicolored-on-black style, and it is still in a kind of alpha release (even if they call it beta), but it works somehow. You can run code from the edit window, but it is not stored on the target device.
For the Wemos I started to use my esp8266 based ftp server, which allows to edit the file in-place on the D1, if you like and use an graphical ftp client. Still you have to use a terminal emulator. I use picocom on linux and putty or teraterm on Windows.

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: Development Cycle for the Wemos D1 Mini from Windows

Post by pfalcon » Mon Nov 07, 2016 10:12 pm

bitninja wrote:Sure!

Here is the EXE. Make sure you have ampy installed and running.

https://dl.dropboxusercontent.com/u/112 ... anager.zip

For the record... the source code can be found here.

https://github.com/joewez/AmpyFileManager
I'm so saddened. Among all mini-IDEs posted here on the forum (5+), I liked the screenshot of this one the most. And turned out, it's Windows-only. :-( .

Btw, the fastest way to run a simple, standalone script on any compliant MicroPython device is by using standard "pyboard.py" utility from the MicroPython distribution.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

bitninja
Posts: 165
Joined: Thu Sep 15, 2016 4:09 pm
Location: Spring, Texas

Re: Development Cycle for the Wemos D1 Mini from Windows

Post by bitninja » Tue Nov 08, 2016 2:08 am

OK, OK
I've run into this before. :)

There is hope though. If you can still stand the odor of C# I might be able to port this over to Mono with a bit more effort. It's not a complex app and I've done it before so I will give it a try. The result should work on Linux, Mac and Windows.

The only question is embedding the Scintilla control into the GTK+ framework. I'm sure it can be done... I just don't know how at the moment.

Post Reply