Fixing CH340 Problems On A NodeMCU V3 Board

A while back I bought a couple of NodeMCU V3 boards via EBay. They’ve sat among my “projects waiting to happen” until I pulled them out this past week intending to install MicroPython on one of them. However, when I connected the boards to my Linux laptop’s USB port they weren’t recognized. This board uses the CH340G USB-to-UART chip and when I ran dmesg I saw the errors shown below:

NodeMCU Error Messages

This is not an uncommon problem if the number of people posting questions with similar errors is any indication. Some saw it as a software driver problem. Some indicated changing to a different USB cable or using a powered hub fixed the problem. I believed it was a hardware problem since removing and reinserting the USB cable would occasionally result in different errors.

This was confirmed when I noticed the laptop would recognize the CH340G with no errors if I flexed the board’s microUSB connector while pressing the reset button. I suspect the problem was caused by a solder bridge on the board below the USB connector or a problem in the connector itself but ultimately the question was, how to fix it?

First I tried to reflow the connector’s solder using a hot air gun. When that didn’t work I decided to replace the connector with something a bit more substantial.

The result is shown below. The microUSB connector was removed and replaced with a 4 pin header attached to the board using super glue. The header pins were connected to appropriate locations on the NodeMCU board using wire-wrap wire as shown in the photo and specified in the accompanying list.

NodeMCU Error Messages
NodeMCU Header Connections
Header Pin Name USB Wire Color Board Connection
1 USB GND Black AMS1117 (3.3V Reg) Pin 1
2 USB D+ Green CH340G Pin 5
3 USB D- White CH340G Pin 6
4 USB 5V Red AMS1117 (3.3V Reg) Pin 3

Replacing the NodeMCU’s microUSB connector means a custom programming cable is needed for the board. That was easily accomplished by cutting the end off an old USB cable and replacing it with a 1X4 crimp connector. Now when the board is plugged in the laptop’s USB port the CH340G is recognized with no errors.

NodeMCU Error Messages

If you’re careful you may be able to just remove the existing microUSB connector and replace it with a new one. However, the board traces below the connector are tiny and pull up easily. Ultimately, it may be easier (and lesss frustrating) to go with with pin header replacement in the first place.


Creating A Portable Linux Installation On A Flash Drive (Part 2)

In the previous post I described how to create a Linux bootable USB flash drive. However, sometimes you may want to run this installation in conjunction with your normal desktop rather than have it take over the whole system. In that case, you can boot the flash drive from within VirtualBox.

Granting The Proper Permissions

For this to work, VirtualBox must have the proper flash drive permissions. There are multiple ways to approach this but the one I like best is described in the answer to this question on Stack Exchange.

All it takes is to change to the /etc/udev/rules.d directory and create a new rules file (e.g., usb_virtualbox.rules) containing the line:

SUBSYSTEM=="block", ATTRS{idVendor}=="1d6b", ATTRS{idProduct}=="0003", ACTION=="add", RUN+="/bin/setfacl -m g:vboxusers:rw- /dev/$name"

The idProduct and idVendor must be changed to match the flash drive’s PID and VID. In short, this rule grants members of the vboxusers group read/write permission for the USB flash drive with the corresponding PID/VID when the drive is plugged in.

Attaching The USB Flash Drive

VirtualBox does not have the capability to boot directly from a USB drive. Instead, you’ll need to create a virtual hard drive that redirects access. These instructions are based upon those provided in this thread.

Insert the flash drive. Once it mounts open a terminal and execute the command:

$ lsblk

You’ll be able to identify the device name from the resulting output. In the case shown below, the flash drive device is /dev/sdb.

lsblk Output

In the terminal, switch to the directory where you want to store the virtual hard drive and execute the command:

$ sudo vboxmanage internalcommands createrawvmdk -filename vd_filename.vmdk -rawdisk device_name

where vd_filename is the name you want to give the virtual disk and device_name is the device name obtained from the output of the lsblk command.

Use the chown command to change the created file’s owner to the currently logged in user:

$ sudo chown user:user vd_filename.vmdk

where user is the currently logged in user.

To attach the drive to the virtual machine, go back to the VirtualBox main menu, select the virtual machine you created previously, and click Storage. Click the ‘+’ sign next to Controller: IDE and when prompted click Choose existing disk and select the virtual drive you just created.

Choose Existing Disk

Go back to the VirtualBox main form and click Start to start the virtual machine. It should boot from the USB flash drive just as if you had restarted the system and selected it from the boot menu.

Creating A Portable Linux Installation On A Flash Drive (Part 1)

I like the idea behind Docker where you can set up applications to run within their own container. However the last time I played with it I had some trouble configuring it to my satisfaction and decided to look for another solution.

This led me to consider the use of USB flash drives. With their increasing capacity and decreasing cost it’s become more and more practical to install a complete system on one and dedicate it for a particular use. There are plenty of Live CD/USB distributions out there but what I’m really talking about is a portable installation upon which you can install all the support software you need and boot anywhere.

It turns out this is a lot easier to do than you might think.

Installing Linux To A USB Drive

WARNING!!! As you are doing this, be sure you are installing to the USB flash drive! Be careful and ensure you’re not overwriting your main drive by mistake! If you have any doubt, don’t do it!

The easiest way I’ve found to do this is using VirtualBox. Begin by obtaining a USB flash drive with enough capacity to comfortably hold a Linux installation and download the install media for the distribution of your choice. For this example, I’m using a 32 GB flash drive and Linux Mint 18.1.

Begin by starting VirtualBox and clicking New to create a new virtual machine. Specify a name, operating system type, and version. Click Next.

Create Virtual Machine

On the next screen specify the memory size. Linux Mint recommends at least 1 GB so that’s what I where I set it. Click Next.

Set Virtual Machine Memory

When asked if you want to create a hard disk, choose Do not add a virtual hard disk. Click Create and Continue.

Create Virtual Hard Disk

At this point you’ve created a virtual machine with no hard disk. From the VirtualBox main form click Storage and insert the installation media iso you downloaded into the virtual optical drive.

Load Install Media

From the VirtualBox main form click USB and enable the controller appropriate to the flash drive being used. If you cannot enable the required USB controller you’ll have to download and install the VirtualBox extension pack before proceeding.

Enable USB Controller

Once you’ve enabled the USB controller, click Start to start the virtual machine.

Once the virtual machine has started, right-click the USB icon in the VirtualBox tray and connect to your flash drive.

Enable USB

When the connection is complete perform a normal install to the USB flash drive. When the install is done, test it by rebooting you system from the drive you created. If all has gone well, you’ll have a fully functioning Linux system to which you can install any packages that will fit in the available space.

A blog about RTL-SDR (RTL2832) and cheap software defined radio

DuWayne's Place

Computers, Electronics, and Amateur Radio from KC3XM

QRP HomeBuilder - QRPHB -

Computers, Electronics, and Amateur Radio from KC3XM

Open Emitter

Computers, Electronics, and Amateur Radio from KC3XM

Ripples in the Ether

Emanations from Amateur Radio Station NT7S

m0xpd's 'Shack Nasties'

Computers, Electronics, and Amateur Radio from KC3XM