-->
Page 1 of 2

Raspberry Pi Driver for ESP8266/NodeMCU/WemosD1/etc CH340

PostPosted: Fri May 20, 2016 3:31 pm
by Andrew Grande
Hey all,

Wanted to hook up my ESP8266 boards to a Raspberry Pis USB port and do some IoT magic, but realized it wasn't that straightforward. Most of the boards are using the CH340 chip today, and driver is required.

I scavenged the internet for good solutions, but failed to find anything reliable, up-to-date and easy to consume. Scratching my own itch - I have compiled the CH340 UART kernel driver and now am able to both interact with my ESP8266 boards as a regular serial as well as program the firmware directly from Raspberry Pi! (I use PlatformIO for a cross-platform toolset, but any method will work).

https://github.com/aperepel/raspberrypi-ch340-driver

Re: Raspberry Pi Driver for ESP8266/NodeMCU/WemosD1/etc CH34

PostPosted: Fri May 20, 2016 3:55 pm
by martinayotte
That is strange that you had to use this driver, since it is already part of the core kernel, at least the one I'm using which is raspberrypi 4.1.13+.
It is also been part of the core kernel on my other board flavors, such as Olimex-A20, OrangePi-PC-H3, PineA64, BeagleBoneBlack.

Re: Raspberry Pi Driver for ESP8266/NodeMCU/WemosD1/etc CH34

PostPosted: Fri May 20, 2016 4:11 pm
by Andrew Grande
martinayotte wrote:That is strange that you had to use this driver, since it is already part of the core kernel, at least the one I'm using which is raspberrypi 4.1.13+.
It is also been part of the core kernel on my other board flavors, such as Olimex-A20, OrangePi-PC-H3, PineA64, BeagleBoneBlack.


I was surprised too. Saw 3-year old threads where people ran it fine on older kernels. But, no more. FYI, the latest kernel as of May didn't have any, and the version is 4.4.11-v7+

Also, I found there are 3 mainstream UART chips today for esp8266 boards:
  • FTDI232 - solid, but expensive, and quite unfriendly to many projects. Though my trusty BusPirate is using it, and RPI 'just worked'
  • CH340 - probably the sheer majority of all dev boards I came across are using this. And it is no more included in the default Raspbian Lite. Official Raspberry Pi discussion threads died with no resolution.
  • CP2102 - I bumped into it almost by accident, ordered a few boards similar to what I have (esp8266 collection anyone?) with cp2102 uart chip just to see how they work

Maybe it's recent kernels, or maybe the Raspbian Lite (I'm running headless without the desktop baggage). I just couldn't for the life of me find a deb package nor a good resource to resolve the problem, hope this helps some more poor chaps :)

Re: Raspberry Pi Driver for ESP8266/NodeMCU/WemosD1/etc CH34

PostPosted: Fri May 20, 2016 4:26 pm
by martinayotte
Maybe some pre-built kernel doesn't have it simply because the builder didn't enable it the kernel config.
Most of my board use kernel built myself, but I rarely had to turn-on those configs in /driver/usb/serial, they are usually already set by default as module.

My kernel versions vary from 3.10.101, 4.4.5, to 4.6 Mainline.
Looking at the history of the driver/usb/serial/ch341.c in linux kernel sources, it is dated back to 2007 for the initial commit.

BTW, the driver is ch341.ko, it is a superset of the family, which also works for CH340.

EDIT : looking at my RaspberryPi, it still on a prebuilt kernel, the 4.1.13-v7+.
(I will build a new one for it :-) )