JetBrains / intellij-micropython

Plugin for MicroPython devices in PyCharm and IntelliJ
https://plugins.jetbrains.com/plugin/9777-micropython
Apache License 2.0
506 stars 106 forks source link

Support ESP8266 devices #2

Closed vlasovskikh closed 6 years ago

vlasovskikh commented 7 years ago

There are many devices based on the ESP8266 chip:

and others.

It would be nice to have them supported by the MicroPython Support plugin for PyCharm / IntelliJ.

See the discussion about supporting ESP8266 in PyCharm at PY-20308.

This issue is about the initial support for the ESP8266 devices.

The initial roadmap:

vlasovskikh commented 7 years ago

I've got Wemos D1 mini. I'll start working on the experimental support for it.

The current framework lacks the ability to permanently save the device selected in the configuration dialog. It's also not possible to add per-device UI elements to the configuration dialog. I've added these items to the roadmap in the issue text.

I found it hard to setup my device since the official website lacked the link to the up-to-date driver for the serial port of Wemos D1 mini. I've stated a wiki page about the device.

costastf commented 7 years ago

Ηι @vlasovskikh . Keep in mind that for all the boards out there, there are also a ton of clones that might behave slightly differently. I have a few wemos d1 mini and while some flash just fine with: esptool.py --port /dev/ttyUSB0 --baud 460800 write_flash --flash_size=detect 0 MICROPYTHON_FIRMWARE_FOR_ESP8266.bin some of them just stay with their led on with the preceding command and require esptool.py --port /dev/ttyUSB0 write_flash -fm dio -fs 32m 0 MICROPYTHON_FIRMWARE_FOR_ESP8266.bin to properly flash.

lensvol commented 7 years ago

@costastf I think the situation you are mentioning here is a well-known issue with WeMOS d1 mini Pro, related to increased flash size (16Mb) - https://github.com/micropython/micropython/issues/2335

It is a separate WeMOS board and should not be considered a clone. Otherwise, you are right on point. Perhaps there are should be an option to manually edit arguments to esptool? Assuming there will be esptool support at all.

vlasovskikh commented 7 years ago

@costastf Right, there could be various configuration parameters. I would like to start with almost no user-visible options in the plugin besides the precise model of the device. In theory, the model should be enough to be able to provide the necessary parameters or auto-detect the missing parameters like the device port. If the precise device model turns out to be not enough, I will reconsider this approach.

costastf commented 7 years ago

Hi, @lensvol in my case all boards have the same amount of memory and they are not the "pro" board. The same thing happens with some esp01 that I have, where the "on" led is inverted and on some of them it stays on and on some of them only comes on when writing. There is a big market in China with clones and they are very very difficult to identify and sometimes they do respond differently. For extra details you can have a look at http://hackaday.com/2017/05/15/attack-on-the-clones-a-review-of-two-common-esp8266-mini-d1-boards/

lensvol commented 7 years ago

Hi @costastf, I look into that further, thanks. It just reminded me of a similar issue with Pro version, that looked exactly like that and was fixed using command specified above (it was with stable 1.9.1, I believe).

vlasovskikh commented 7 years ago

@costastf @lensvol USB VID:PID numbers for the USB controllers of MicroPython boards could be enough for distinguishing the connected boards among all the USB devices. I've implemented WEMOS D1 mini REPL using this technique. The current version of the script is able to detect both BBC Micro:bit and WEMOS D1 mini based on their VID:PID. See #3 and our WEMOS D1 mini wiki page.

eduvik commented 7 years ago

@vlasovskikh the USB IDs are probably not unique to micropython boards as they're just USB-serial chips. Additionally, there's the use case of a 'bare' ESP board without onboard USB at all (e.g. ESP01, ESP12 etc) that need an external serial adapter. Having said that, simply the presence of a serial adapter on the machine will be a pretty big clue there's a device connected for most (not all) people. Detecting the devices by polling the serial ports might be possible, but not 100%. I'd be inclined to implement base functionality first (user chooses the model and the serial port it's connected to) before trying the autodetection.

vlasovskikh commented 7 years ago

@eduvik The port name might change depending on which USB port you used for connecting your device. Auto-detection could be handy in this case.

Since auto-detection already works at least for WEMOS D1 mini, I'm going to proceed with other features for this device, see the roadmap at #3. Later on I might return to adding the field for the port name combining it with auto-detection capabilities.

costastf commented 7 years ago

Hi, @vlasovskikh I think that @eduvik is right about the autodetection. A wemos I happen to have with me shows up on my linux box as a ch341-uart serial to usb converter which of course is a very very generic component and I think that that would probably cause issues in the long run. Just for reference it shows up under lsusb as Bus 001 Device 009: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter

Also as mentioned esp01 do not have a usb interface at all and they are powered with 3.3 so they definitely require an adapter which means there is no way to auto detect them. I think the point here is that people who fiddle with stuff like that should have at least the basic understanding of serial, usb and such so autodetection might produce a lot of false positives and issues without providing too much in return. As @eduvik said I am all for trying to go for basic functionality first. Any news on the webcast for the development environment? I work with wemos d1 so I would be eager to help in any way I can.

vlasovskikh commented 7 years ago

Ok, let's add a field for entering the device port manually. Still I prefer it to be auto-detected if it's empty.

vlasovskikh commented 7 years ago

I need your help with a couple of tasks:

Please put a comment here if you'd like to contribute any parts of these.

vlasovskikh commented 7 years ago

@costastf I caught a cold, so won't be able to do the webcast in the next couple of days.

vlasovskikh commented 7 years ago

@costastf Have you managed to launch IntelliJ 2017.1 and import the project into it? I could answer your questions about the development environment setup here in the comments.

costastf commented 7 years ago

Hi Andrey,

Something personal came up and I will not be able to help out until next Tuesday. I am very invested on this and coming next week I will come on board and help out any way I can.

Kind regards Costas

On Jun 27, 2017 13:58, "Andrey Vlasovskikh" notifications@github.com wrote:

@costastf https://github.com/costastf Have you managed to launch IntelliJ 2017.1 and import the project into it? I could answer your questions about the development environment setup here in the comments.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/vlasovskikh/intellij-micropython/issues/2#issuecomment-311336758, or mute the thread https://github.com/notifications/unsubscribe-auth/AEbFa8xzyviSQfIivUm9ULd94Jjx_mf1ks5sIO5-gaJpZM4OFH6N .

vlasovskikh commented 7 years ago

We've just got an experimental provider for WEMOS D1 mini Pro. Thanks @lensvol for your PR #4!

vlasovskikh commented 7 years ago

I've created separate issues for:

eduvik commented 7 years ago

Nice to see movement happening, but I still think it's the wrong approach to use USB IDs here, for the following reasons:

I would suggest the following approach:

vlasovskikh commented 7 years ago

@eduvik Let's discuss it in a separate issue #7.

vlasovskikh commented 7 years ago

FYI Last weekend I gave a talk on MicroPython mentioning this plugin. Here are the slides: https://twitter.com/vlasovskikh/status/886600153767038977

elf55 commented 7 years ago

Well done. interesting details about uPython memory usage vs Python.

-Mike

On Jul 19, 2017, at 1:14 PM, Andrey Vlasovskikh notifications@github.com wrote:

FYI Last weekend I gave a talk on MicroPython mentioning this plugin. Here are the slides: https://twitter.com/vlasovskikh/status/886600153767038977

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

vlasovskikh commented 7 years ago

Meanwhile we've got basic support for Pyboard thanks to @stefanhoelzl.

You can try the plugin with ESP 8266 and Pyboard support from the master branch. What features are missing?

vlasovskikh commented 6 years ago

MicroPython plugin 1.0 provides initial support for ESP8266-based devices. Please send your feedback in new issues / pull requests.