EmonTx4's unstable behavior

Well, so I’ll have to disassemble it… and probably solder a couple of pin headers, right?

Btw, here’s my fix for the missing 5V access.

Surgery done… what next ?

You now need to reflash the Arduino bootloader with a USB to UART adapter as outlined here. The AVR128DB uses DxCore for the Arduino portion, the installation documents are here. I’m afraid I’m not a huge help beyond here as I don’t have a Tx4/5 to hand and don’t have Arduino :frowning:

I bought this module: Adafruit UPDI Friend, USB Serial UPDI Programmer, 5879

Hope, that’ll do the job, even I could use a regular FTDI adapter.

BTW, it’s UPDI and not UDPI, right? Or are they both different?

Sorry, yes, UPDI :man_facepalming: That adapter will definitely work!

Great… btw, on the Tx4, the silkscreen is wrong :smiley: It shows “UDPI”.

1 Like

Just realized, there’s a HV also:
Adafruit High Voltage UPDI Friend

Hopefully, the “low voltage” I bought will work fine !

HV is needed if you lock yourself out by setting the fuses such that you block all access - the chip can be recovered with the HV, but not the LV. Just take a bit of care - the AVR128DBs aren’t as widely used as the ATmega328 so there are fewer helper applications available.

1 Like

Oh man, there’re so many options ! I fear to break my emontx !

Is that right, or should I select “no bootloarder” ?

There’re tons of settings in each sub-menu, and also what Programmer should I select?

Fred

@Robert.Wall is the person for this…

1 Like

Oh, sorry @FredM67 , I’d completely forgotten about this - away on holiday! You need to select the SerialUPDI programmer here.

  • BOD mode active
  • BOD level 3 (2.85 V)
  • Bootloader serial I think should be PB0 and PB1
  • printf needs float support

Otherwise I think the defaults are fine :slight_smile:

2 Likes

I was expecting Angus to respond… Oh, he has.

Here are the official instructions for normal use.

I cannot recommend Platfromio, in my book it’s malware - it moved my downloads from Github and broke my scripts that updated them.

1 Like

I thought it was the Arduino platform :rofl:

Sort-of. But it looks as if Fred’s bootloader is damaged. It’s definitely an AVR 128DB48, but not pure Arduino as per the ATMega '328P. With the Spence-Konde add-on, you can use the Arduino IDE.

1 Like

Sorry to disturb again, I don’t get it to work !!

I’m using an official UPDI Friend from Adafruit.

Here’s the log:

"C:\Users\frede\AppData\Local\Arduino15\packages\megaTinyCore\tools\python3\3.7.2-post1/python3" -u "C:\Users\frede\AppData\Local\Arduino15\packages\DxCore\hardware\megaavr\1.5.11/tools/prog.py" -t uart -u COM3 -b 230400 -d avr128db48 --fuses 0:0b00000000 1:0b01100101 2:0x00 5:0b11001000 6:0b00001100 7:0x00 8:0x01 -f "C:\Users\frede\AppData\Local\Arduino15\packages\DxCore\hardware\megaavr\1.5.11/bootloaders/hex/optiboot_128dx_ser3_extr.hex" -a write -v
SerialUPDI
UPDI programming for Arduino using a serial adapter
Based on pymcuprog, with significant modifications
By Quentin Bolsee and Spence Konde
Version 1.3.0.3 - Jul 2023
Using serial port COM3 at 230400 baud.
Target: avr128db48
Set fuses: ['0:0b00000000', '1:0b01100101', '2:0x00', '5:0b11001000', '6:0b00001100', '7:0x00', '8:0x01']
Action: write
File: C:\Users\frede\AppData\Local\Arduino15\packages\DxCore\hardware\megaavr\1.5.11/bootloaders/hex/optiboot_128dx_ser3_extr.hex
pymcuprog.programmer - INFO - Setting up programming session for 'avr128db48'
pymcuprog.deviceinfo.deviceinfo - INFO - Looking for device avr128db48
pymcuprog.serialupdi.physical - INFO - Opening port 'COM3' at '115200' baud
pymcuprog.serialupdi.link - INFO - STCS 08 to 0x03
pymcuprog.serialupdi.link - INFO - STCS 06 to 0x02
pymcuprog.serialupdi.link - INFO - LDCS from 0x00
pymcuprog.serialupdi.link - WARNING - UPDI init failed: Can't read CS register. likely wiring error.
pymcuprog.serialupdi.physical - INFO - extra-long break requested. Close serial port, reopen @ 300, send 0x00, receive the 0x00, and then proceed. 
pymcuprog.serialupdi.physical - INFO - Double-break sent. Re-initializeing USART to retry.
pymcuprog.serialupdi.physical - INFO - Opening port 'COM3' at '115200' baud
pymcuprog.serialupdi.link - INFO - STCS 08 to 0x03
pymcuprog.serialupdi.link - INFO - STCS 06 to 0x02
pymcuprog.serialupdi.link - INFO - LDCS from 0x00
pymcuprog.serialupdi.link - WARNING - UPDI init failed: Can't read CS register. likely wiring error.
Traceback (most recent call last):
  File "C:\Users\frede\AppData\Local\Arduino15\packages\DxCore\hardware\megaavr\1.5.11/tools/prog.py", line 287, in <module>
pymcuprog.serialupdi.physical - INFO - Closing port 'COM3'
    main()
  File "C:\Users\frede\AppData\Local\Arduino15\packages\DxCore\hardware\megaavr\1.5.11/tools/prog.py", line 129, in main
    return_code = pymcuprog_basic(args, fuses_dict)
  File "C:\Users\frede\AppData\Local\Arduino15\packages\DxCore\hardware\megaavr\1.5.11/tools/prog.py", line 202, in pymcuprog_basic
    args_start)
  File "C:\Users\frede\AppData\Local\Arduino15\packages\DxCore\hardware\megaavr\1.5.11\tools\libs\pymcuprog\pymcuprog_main.py", line 545, in _start_session
    backend.start_session(sessionconfig)
  File "C:\Users\frede\AppData\Local\Arduino15\packages\DxCore\hardware\megaavr\1.5.11\tools\libs\pymcuprog\backend.py", line 362, in start_session
    sessionconfig.interface_speed)
  File "C:\Users\frede\AppData\Local\Arduino15\packages\DxCore\hardware\megaavr\1.5.11\tools\libs\pymcuprog\programmer.py", line 83, in setup_device
    options=self.options)
  File "C:\Users\frede\AppData\Local\Arduino15\packages\DxCore\hardware\megaavr\1.5.11\tools\libs\pymcuprog\nvm.py", line 42, in get_nvm_access_provider
    accessprovider = NvmAccessProviderSerial(transport, device_info, baud=frequency, options=options)
  File "C:\Users\frede\AppData\Local\Arduino15\packages\DxCore\hardware\megaavr\1.5.11\tools\libs\pymcuprog\nvmserialupdi.py", line 54, in __init__
    self.avr = UpdiApplication(port, baud, self.dut)
  File "C:\Users\frede\AppData\Local\Arduino15\packages\DxCore\hardware\megaavr\1.5.11\tools\libs\pymcuprog\serialupdi\application.py", line 79, in __init__
    datalink.init_datalink()
  File "C:\Users\frede\AppData\Local\Arduino15\packages\DxCore\hardware\megaavr\1.5.11\tools\libs\pymcuprog\serialupdi\link.py", line 44, in init_datalink
    raise PymcuprogError("UPDI initialisation failed")
pymcuprog.pymcuprog_errors.PymcuprogError: UPDI initialisation failed
Failed to burn bootloader: uploading error: exit status 1

I’ve never tried to do this, however hopefully a silly question: do you have power to the emonTx4 and is it adequate? UDPI programmers have a Vcc pin that is used to sense supply voltage (but not provide it), so you must power your board yourself while using one of these new programmers.

Hi Robert,
Well, I’ve mainly tried without external power supply, but it did not help.
Adafruit UPDI Friend - USB Serial UPDI Programmer : ID 5879 : Adafruit Industries, Unique & fun DIY electronics and kits

That’s the programmer I’ve. Looking at the doc, it provides power, and btw, I saw the red led on the emontx4 on.

In the article from your link, some boards seem to have a resistor that must be removed, maybe that’s the point here? I’ll take a look at the schematic later on.

Fred

Well, it looks like it’s worse than I imagined.
It seems, the UPDI pin does not connect to the corresponding pin on the AVR.

I’ve checked all 3 pins (3.3V, UPDI, GND), both power pins are ok, but not the UPDI.

It should be - I can see it on the board render. It can be hard to check the connection to the microcontroller package, so it seems unlikely but that the programmer doesn’t find it suggests there is a problem. It’s directly connected, there’s no extra resistor.