Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attiny 412 programming: UPDI initialization failed. #545

Closed
phil-barrett opened this issue Nov 9, 2021 · 12 comments
Closed

attiny 412 programming: UPDI initialization failed. #545

phil-barrett opened this issue Nov 9, 2021 · 12 comments

Comments

@phil-barrett
Copy link

phil-barrett commented Nov 9, 2021

Arduino 1.8.15, Win 10, megaTinyCore 2.4.2 installed via board manager. Windows board manager shows the USB port for the programmer.

Programmer Selected: SerialUPDI with serial 4.7K or diode 230400 baud
Programmer is CH340, first version. 470 ohm resistor on UPDI pin. diode between TX and RX. I don't know how to verify my serial programmer works correctly. I verified that the diode orientation is correct. It does pass the "loopback" test without the diode. If it's a bug in my programmer, not sure how to figure it out. Any help greatly appreciated.
Target board is my own design. Works with Atmel ICE.
Error trace back from Arduino: (sorry for the crappy formatting, Arduino IDE kinda sucks.)

cmd /C "C:\Users\philba\AppData\Local\Arduino15\packages\DxCore\tools\avr-gcc\7.3.0-atmel3.6.1-azduino4b/bin/avr-nm" --numeric-sort --line-numbers --demangle --print-size --format=s "C:\Users\philba\AppData\Local\Temp\arduino_build_642728/Blink.ino.elf" > "C:\Users\philba\AppData\Local\Temp\arduino_build_642728/Blink.ino.map"
"C:\Users\philba\AppData\Local\Arduino15\packages\DxCore\tools\avr-gcc\7.3.0-atmel3.6.1-azduino4b/bin/avr-size" -A "C:\Users\philba\AppData\Local\Temp\arduino_build_642728/Blink.ino.elf"
Sketch uses 632 bytes (15%) of program storage space. Maximum is 4096 bytes.
Global variables use 10 bytes (3%) of dynamic memory, leaving 246 bytes for local variables. Maximum is 256 bytes.
C:\Users\philba\AppData\Local\Arduino15\packages\megaTinyCore\tools\python3\3.7.2-post1/python3 -u C:\Users\philba\AppData\Local\Arduino15\packages\megaTinyCore\hardware\megaavr\2.4.2/tools/prog.py -t uart -u COM5 -b 230400 -d attiny412 --fuses 2:0x02 6:0x04 8:0x00 -fC:\Users\philba\AppData\Local\Temp\arduino_build_642728/Blink.ino.hex -a write
SerialUPDI
UPDI programming for Arduino using a serial adapter
Based on pymcuprog, with significant modifications
By Quentin Bolsee and Spence Konde
Version 1.2.0 - June 2021
Using serial port COM5 at 230400 baud.
Target: attiny412
Set fuses: ['2:0x02', '6:0x04', '8:0x00']
Action: write
File: C:\Users\philba\AppData\Local\Temp\arduino_build_642728/Blink.ino.hex
Traceback (most recent call last):
File "C:\Users\philba\AppData\Local\Arduino15\packages\megaTinyCore\hardware\megaavr\2.4.2/tools/prog.py", line 282, in
main()
File "C:\Users\philba\AppData\Local\Arduino15\packages\megaTinyCore\hardware\megaavr\2.4.2/tools/prog.py", line 131, in main
return_code = pymcuprog_basic(args, fuses_dict)
File "C:\Users\philba\AppData\Local\Arduino15\packages\megaTinyCore\hardware\megaavr\2.4.2/tools/prog.py", line 198, in pymcuprog_basic
args_start)
File "C:\Users\philba\AppData\Local\Arduino15\packages\megaTinyCore\hardware\megaavr\2.4.2\tools\libs\pymcuprog\pymcuprog_main.py", line 544, in _start_session
backend.start_session(sessionconfig)
File "C:\Users\philba\AppData\Local\Arduino15\packages\megaTinyCore\hardware\megaavr\2.4.2\tools\libs\pymcuprog\backend.py", line 362, in start_session
sessionconfig.interface_speed)
File "C:\Users\philba\AppData\Local\Arduino15\packages\megaTinyCore\hardware\megaavr\2.4.2\tools\libs\pymcuprog\programmer.py", line 83, in setup_device
options=self.options)
File "C:\Users\philba\AppData\Local\Arduino15\packages\megaTinyCore\hardware\megaavr\2.4.2\tools\libs\pymcuprog\nvm.py", line 42, in get_nvm_access_provider
accessprovider = NvmAccessProviderSerial(transport, device_info, baud=frequency)
File "C:\Users\philba\AppData\Local\Arduino15\packages\megaTinyCore\hardware\megaavr\2.4.2\tools\libs\pymcuprog\nvmserialupdi.py", line 53, in init
self.avr = UpdiApplication(port, baud, self.dut)
File "C:\Users\philba\AppData\Local\Arduino15\packages\megaTinyCore\hardware\megaavr\2.4.2\tools\libs\pymcuprog\serialupdi\application.py", line 79, in init
datalink.init_datalink()
File "C:\Users\philba\AppData\Local\Arduino15\packages\megaTinyCore\hardware\megaavr\2.4.2\tools\libs\pymcuprog\serialupdi\link.py", line 44, in init_datalink
raise PymcuprogError("UPDI initialisation failed")
pymcuprog.pymcuprog_errors.PymcuprogError: UPDI initialisation failed
pymcuprog.pymcuprog_errors.PymcuprogError: UPDI initialisation failed

@SpenceKonde
Copy link
Owner

SpenceKonde commented Nov 9, 2021 via email

@phil-barrett
Copy link
Author

phil-barrett commented Nov 9, 2021

It was a 1N4148 like the UPDI docs call out. But, that isn't a schottky by the way. It's just a fast switching silicon diode. I do have some real schottky diodes I could use. But, it sounds like the 4.7K resistors works so I'll go with that. Put it between RX and TX on the serial adapter, right?

Yeah, my CH340 adapter has a 1.5K R on TX

Thanks for getting back to me. I know you've got lots on your plate and appreciate your attention.

@SpenceKonde
Copy link
Owner

SpenceKonde commented Nov 9, 2021 via email

@phil-barrett
Copy link
Author

It's here.

Tell you what, once I get it working with the resistor, I will try out a schottky diode and let you know.

@SpenceKonde
Copy link
Owner

SpenceKonde commented Nov 10, 2021 via email

@SpenceKonde
Copy link
Owner

SpenceKonde commented Nov 18, 2021 via email

@SpenceKonde
Copy link
Owner

worth noting that 2.5.0 (formerly 2.4.3) is coming out VERY soon.

@SpenceKonde
Copy link
Owner

No comments from OP in over a week. Closing under assumption that this is resolved.

@dejavu1987
Copy link

dejavu1987 commented Apr 20, 2023

Well I have tried using an smd switching diode and a the resistor of 1k and my CH340 adapter to program my first ATTiny424, and it worked without a hitch, I tried twice and worked like a charm.

Tx --------- |<|-----/------/\/\/\-------- UPDI
Rx ----------------/             1k

Now today a month later I tried literally same Hardware, same sketch, and same config, and it is not working anymore.
Did anything change in the library, I can still see the same version in the terminal tho Version 1.2.3 - Jan 2022.

Really confused.
I am getting same pymcuprog.pymcuprog_errors.PymcuprogError: UPDI initialisation failed

I have recorded a video which is on youtube which shows that the configs look similar too.

Using serial port /dev/cu.usbserial-210 at 230400 baud.
Delaying next op after each page write command by 1.0ms (-wd).
Target: attiny424
Set fuses: ['0:0b00000000', '2:0x02', '6:0x04', '7:0x00', '8:0x00']

Here is the video https://www.youtube.com/shorts/w51bsm1D_dc
I have changed resistance value from 100Ohm, 1k and 4k7 but none made any difference.

full error stack trace:

Traceback (most recent call last):
  File "/Users/anilmaharjan/Library/Arduino15/packages/megaTinyCore/hardware/megaavr/2.6.5/tools/prog.py", line 286, in <module>
    main()
  File "/Users/anilmaharjan/Library/Arduino15/packages/megaTinyCore/hardware/megaavr/2.6.5/tools/prog.py", line 128, in main
    return_code = pymcuprog_basic(args, fuses_dict)
  File "/Users/anilmaharjan/Library/Arduino15/packages/megaTinyCore/hardware/megaavr/2.6.5/tools/prog.py", line 199, in pymcuprog_basic
    status = pymcu._start_session(backend,
  File "/Users/anilmaharjan/Library/Arduino15/packages/megaTinyCore/hardware/megaavr/2.6.5/tools/libs/pymcuprog/pymcuprog_main.py", line 545, in _start_session
    backend.start_session(sessionconfig)
  File "/Users/anilmaharjan/Library/Arduino15/packages/megaTinyCore/hardware/megaavr/2.6.5/tools/libs/pymcuprog/backend.py", line 359, in start_session
    self.programmer.setup_device(
  File "/Users/anilmaharjan/Library/Arduino15/packages/megaTinyCore/hardware/megaavr/2.6.5/tools/libs/pymcuprog/programmer.py", line 78, in setup_device
    self.device_model = get_nvm_access_provider(self.transport,
  File "/Users/anilmaharjan/Library/Arduino15/packages/megaTinyCore/hardware/megaavr/2.6.5/tools/libs/pymcuprog/nvm.py", line 42, in get_nvm_access_provider
    accessprovider = NvmAccessProviderSerial(transport, device_info, baud=frequency, options=options)
  File "/Users/anilmaharjan/Library/Arduino15/packages/megaTinyCore/hardware/megaavr/2.6.5/tools/libs/pymcuprog/nvmserialupdi.py", line 54, in __init__
    self.avr = UpdiApplication(port, baud, self.dut)
  File "/Users/anilmaharjan/Library/Arduino15/packages/megaTinyCore/hardware/megaavr/2.6.5/tools/libs/pymcuprog/serialupdi/application.py", line 79, in __init__
    datalink.init_datalink()
  File "/Users/anilmaharjan/Library/Arduino15/packages/megaTinyCore/hardware/megaavr/2.6.5/tools/libs/pymcuprog/serialupdi/link.py", line 44, in init_datalink
    raise PymcuprogError("UPDI initialisation failed")
pymcuprog.pymcuprog_errors.PymcuprogError: UPDI initialisation failed
Failed programming: uploading error: exit status 1

@SpenceKonde
Copy link
Owner

drop the resistor back to 220 ohms or so and it should work on a CH340, I use those all the time without issue,

@dejavu1987
Copy link

Okay realised, my CH340 had Tx and Rx in reverse.
Woked both with 1k and 330 res.
In addition, I was using another board where UPDI pin was connected with a .1uF cap to the ground for some reason, that was also one reason it did not work.

@wholder
Copy link

wholder commented Aug 12, 2023

To barge in on this thread, In an attempt to minimize issues with diode voltage drop, my idea was to use a tri-state buffer (sn74lvc1g125) where the enable pin (active low) is tied to the TX output of a CH340N and the sn74lvc1g125's input pin is tied low. In turn, the output pin of the sn74lvc1g125 is connected to the CH340N's RX pin and then to the UPDI pin on an ATtiny212, like , ilke this:
UPDI Buffer 2
However, this does not seem to work... Specifically, the ATtiny212 does not respond to any queries I try sending.

The signal output from the sn74lvc1g125 looke fine on my scope, so I'm not sure what the problem might be. It seems like having a tri-state output from the TX line would be ideal, but I must be missing something. Any thoughts?

Note: I was able to use the diode scheme, but found that I kept getting garbled responses (parity errors, etc.) on the RX line

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants