Emonupload doesn't detect USB ports

Hello,
I’m trying to upload the 3phase sketch to a new Emontx.
The download of the FW goes well. When I select the option to upload the 3phase sketch, I get an error “avrdude-original: usbdev_open(): did not find any USB device “usb” (0x03eb:0x2104).
Lsusb shows that there is a programmer connected:
“Bus 001 Device 004: ID 10c4:ea60 Cygnal Integrated Products, Inc. CP210x UART Bridge / myAVR mySmartUSB light”.
The option " view serial debug” works also. I’m using the programmer from the shop, it is connected to a USB port of the Raspberry. The cable is one that I got, not the one from the shop.

Any ideas?
Regards, Dirk.

When I look at the emonupload script it is looking at /dev/ttyUSBx.
When I connect the programmer, I get a ttyUSB0 device. The lsusb utility shows the programmer at /dev/bus/usb/001/004
Is there a way to read from these devices using a basic linux command in order to see that they react?

Regards, Dirk.

I think you have proved the device is actually there to be found with

Can you provide some output from the emonupload command?

Its is possible that the USB ports can only be accessed via superuser if you have not setup dial out users.

Try running emonupload with sudo to test:

$ sudo ./emonupload.py

putty.txt (38.6 KB)
Running as sudo doesn’t solve the issue.
The attached putty log shows the results of 3 tests:

  • as sudo, with -v added to the avrdude command, selected option x to upload the 3phase sketch.
  • replaced -P usb with -P /dev/ttyUSB0, selected option x to upload the 3phase sketch.
  • selected option s, serial output. That one works fine.

Regards, Dirk.

I think there maybe some cross wires somewhere that perhaps @glyn.hudson can shed some light on.

As I understand, you are using a shop bought programmer, that will be a USB to serial programmer type. The logs show “avrispmkII” specified in the avrdude command line which is an “ISP” type programmer. Since it appears the “Serial output” works I took to looking at the emonupload.py code as it cannot be a simple case of wrong programmer used/defined.

It would appear the serial upload will only work after a successful upload of a bootloader via an ISP, so it seems you need 2 programmers connected to the same device at the same time to complete a simple firmware update/change, in the process the bootloader will be changed each time.

I do not think that is the intended behaviour, perhaps @glyn.hudson can confirm, I think if the command to burn the bootloader was wrapped in a try/except it might allow the code to proceed rather than tripping up when there is no ISP attached.

As a quick test you could try adding a # to comment out line 255 of emonupload.py so it skips actually trying (it will still say it’s doing it but not action the command) to upload a bootloader via the ISP programmer that isn’t there and proceeds directly to attempting to upload the latest firmware hex via the serial adapter.

emonupload first attempts to upload a bootloader using an ISP programmer, if no ISP programmer is connected this fails then emonupload goes onto upload the compiled .hex via serial. This is nothing to worry about, as long as the serial upload part is working that is all the matters if uploading to a unit which already has an Arduino bootloader in place (as is the case with all the shop bought units).

Sorry for the late reply, I was off for the weekend.
When I comment out line 255, the serial upload works fine.
Thanks Paul and Glyn for your help!

This is log of the upload:

Enter lettercode for required function > 3

emonTx 3-phase Upload


Burning Bootloader

sudo avrdude -p atmega328p -c avrispmkII -P usb -e -U efuse:w:0x05:m -U hfuse:w:0xD6:m -U lfuse:w:0xFF:m -U flash:w:bootloaders/optiboot_atmega328.hex:i -Ulock:w:0x0f:m

Serial upload latest/openenergymonitor-emontx-3phase.hex:i

Found serial programmer on /dev/ttyUSB0
avrdude  -uV -c arduino -p ATMEGA328P -P/dev/ttyUSB0 -b 115200 -U flash:w:latest/openenergymonitor-emontx-3phase.hex:i
avrdude-original: Using autoreset DTR on GPIO Pin 7

avrdude-original: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude-original: Device signature = 0x1e950f
avrdude-original: NOTE: "flash" memory has been specified, an erase cycle will be performed
                  To disable this feature, specify the -D option.
avrdude-original: erasing chip
avrdude-original: reading input file "latest/openenergymonitor-emontx-3phase.hex"
avrdude-original: writing flash (13124 bytes):

Writing | ################################################## | 100% 2.03s

avrdude-original: 13124 bytes of flash written
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe

avrdude-original done.  Thank you.

No problem, thanks for coming back to us and confirming the test worked.

Perhaps @glyn.hudson can take another look at it.

Nice work, good to hear that your up and running.

However, please clarify that without line 255 commented emonupload fails to upload serial for you?

I often use emonupload without an ISP programmer connected to just upload via serial to units already with a bootloader. In my experience with no programmer connected emonupload prints a warning then continues to upload serial successfully.

Glyn,
Now I’ve completely lost track 
As said, I used the programmer from the shop, it connects the USB port on the Raspberry to the UART port on the Emontx, so this is a serial connection.
You say “with no programmer connected emonupload prints a warning then continues to upload serial successfully”.
How can I upload without using the programmer as a connection? I thought it is mandatory to transfer the sketches.
I’ve have little experience with this stuff so I’m afraid I’m lacking some knowledge here.

Regards, Dirk.

The ISP programmer connects to the 3 x 2 header, and is a totally different thing to the FTDI programmer, which is the one we think you have.

Your FTDI programmer from the shop needs a “bootloader” inside the Atmel ATMega 328P to be able to work.
The ISP programmer does not need that and is able to install the bootloader if you do not have one.

Robert, Glyn,
I had a look at the pcb of the emontx and it is correct I’m using the ftdi connector, not the 2x3 isp interface. To me it means that I use the same method as you do Glen. Here it works when I comment out the loading of the bootloader, with you it simply skips it.
If there would realy be a problem with the script, somebody else also would have reported it as well. So it looks l’m doing something different then you do.
I have a second, older emontx but I don’t have it at home now. I’ll run the upload on that one, just to try. That will only be in two weeks when I get the unit
Dirk.

I’m struggling with this too… I just ordered 2 EmonTx v3 and the USB > UART programmer from the shop. This is the output I get…

Enter lettercode for required function > 3


emonTx 3-phase Upload


Burning Bootloader..try avrispmkII

 avrdude -p atmega328p -c avrispmkII -P usb -e -U efuse:w:0x05:m -U hfuse:w:0xD6:m -U lfuse:w:0xFF:m -U flash:w:bootloaders/optiboot_atmega328.hex:i -Ulock:w:0x0f:m

avrdude done.  Thank you.


Burning Bootloader..try usbasp

 avrdude -p atmega328p -c usbasp -P usb -e -U efuse:w:0x05:m -U hfuse:w:0xD6:m -U lfuse:w:0xFF:m -U flash:w:bootloaders/optiboot_atmega328.hex:i -Ulock:w:0x0f:m
avrdude: error: could not find USB device with vid=0x16c0 pid=0x5dc vendor='www.fischl.de' product='USBasp'

avrdude done.  Thank you.


Serial upload latest/openenergymonitor-emontx-3phase.hex:i

ERROR: USB serial programmer NOT found

Error: Cannot connect to RFM69Pi receiver. Upload only...NO RF TEST

Done emonTx 3-phase upload. Press Enter to return to menu or (s) to view serial output>

This is the output of lsusb

parallels@parallels-Parallels-Virtual-Platform:~/OEM/emonupload$ lsusb
Bus 001 Device 003: ID 203a:fffa
Bus 001 Device 002: ID 203a:fffa
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 002: ID 203a:fff9
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 002: ID 10c4:ea60 Cygnal Integrated Products, Inc. CP210x UART Bridge / myAVR mySmartUSB light
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

If you didn’t spot, this is a virtual machine running a fresh install of Ubuntu 18.04. Linux is all pretty new to me, but I followed the instructions on GitHub - openenergymonitor/emonupload: Upload / update latest OpenEnergyMonitor firmware and got this far!

Can’t take the “comment out line 255” approach as it looks like the script has changed since the original post 11 months ago.

Any help appreciated.

Thanks
Barry

You shouldn’t need to be burning a bootloader. The emonTx already has it and the default sketch loaded, ready to go. All you should need is to compile and upload the 3-phase sketch using the Arduino IDE.

Hi Barry,

Can you see what USB port number is assigned to your programmer by looking at the output of dmesg after plugging in your programmer?

Is there a chance that your USB serial port requires root permissions?

Either chance the permissions or try running emonupload as sudo

I believe Barry is trying to upload the pre-compiled version of the emonTx-3phase .hex file. Uploading the pre-compiled version is a wise move as it negates the requirement to download all the required libs and avoid any possible errors introduced in the compiling process.

EmonUpload automatically download the latest pre-compiled version from github releases: Releases · openenergymonitor/emontx-3phase · GitHub

Sorry I wrote a response. Please delete it.

Hi,

So the sudo option has worked (well got me further down the line). I’m still getting an error, but it looks like there is no emonTx 3 phase hex file downloaded as it’s not in the “latest” folder as per the error stated here. There are plenty of others so the download appears to have worked? Is the file mis-named or missing?

Enter lettercode for required function > 3

emonTx 3-phase Upload

Burning Bootloader…try avrispmkII

avrdude -p atmega328p -c avrispmkII -P usb -e -U efuse:w:0x05:m -U hfuse:w:0xD6:m -U lfuse:w:0xFF:m -U flash:w:bootloaders/optiboot_atmega328.hex:i -Ulock:w:0x0f:m

avrdude done. Thank you.

Burning Bootloader…try usbasp

avrdude -p atmega328p -c usbasp -P usb -e -U efuse:w:0x05:m -U hfuse:w:0xD6:m -U lfuse:w:0xFF:m -U flash:w:bootloaders/optiboot_atmega328.hex:i -Ulock:w:0x0f:m
avrdude: error: could not find USB device with vid=0x16c0 pid=0x5dc vendor=‘www.fischl.de’ product=‘USBasp’

avrdude done. Thank you.

Serial upload latest/openenergymonitor-emontx-3phase.hex:i

Found serial programmer on /dev/ttyUSB0
avrdude -uV -c arduino -p ATMEGA328P -P/dev/ttyUSB0 -b 115200 -U flash:w:latest/openenergymonitor-emontx-3phase.hex:i

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: NOTE: “flash” memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file “latest/openenergymonitor-emontx-3phase.hex”
avrdude: can’t open input file latest/openenergymonitor-emontx-3phase.hex: No such file or directory
avrdude: read from file ‘latest/openenergymonitor-emontx-3phase.hex’ failed

avrdude done. Thank you.

Error: Cannot connect to RFM69Pi receiver. Upload only…NO RF TEST

Listing of “latest”

parallels@parallels-Parallels-Virtual-Platform:~/OEM/emonupload/latest$ ls
boblemaire-IoTaWatt-firmware.bin
boblemaire-IoTaWatt-firmware.elf
openenergymonitor-emonesp-firmware.bin
openenergymonitor-emonesp-spiffs.bin
openenergymonitor-emonpi.hex
openenergymonitor-emonth2.hex
openenergymonitor-emonth.hex
openenergymonitor-emontx3.hex
openenergymonitor-mqtt-wifi-mqtt-single-channel-relay.bin
openenergymonitor-open_evse-emonevse-3ph.hex
openenergymonitor-open_evse-emonevse.hex
openenergymonitor-open_evse-openevse.hex
OpenEVSE-ESP8266_WiFi_v2.x.bin

Seems to just skip over the 3phase tx firmware…

Latest openenergymonitor/emonpifirmware: V2.9.0
Downloading: latest.hex Bytes: 50332
50332 [100.00%]

Latest openenergymonitor/emontx3firmware: V3.1.0
Downloading: firmware.hex Bytes: 48585
48585 [100.00%]

Latest openenergymonitor/emontx-3phasefirmware: VV1.4.0
Latest openenergymonitor/emonespfirmware: V2.3.0
Downloading: firmware.bin Bytes: 432544
432544 [100.00%]