SpenceKonde / megaTinyCore

Arduino core for the tinyAVR 0/1/2-series - Ones's digit 2,4,5,7 (pincount, 8,14,20,24), tens digit 0, 1, or 2 (featureset), preceded by flash in kb. Library maintainers: porting help available!
Other
551 stars 142 forks source link

UPDI init failed: Can't read CS register #712

Closed second-string closed 2 years ago

second-string commented 2 years ago

I'm having issues using SerialUPDI to connect to an ATtiny414 on a very simple board. I'm powering the ATtiny from 5V coming through out of an LDO, and have a 0.1uF cap rated for 50V from Vcc to ground.

I've created a couple programmers with cheap CH340s and the recommended BAT54C schottky with the cathode towards TX soldered between the RX and TX pins on the bottom of the usb to serial board.

These are the settings in the arduino tools menu:

image

I've set the board, chip, port, and programmer, and I'm not sure if the others matter. These ATtinys are straight from a supplier, no bootloader burned onto them that I know of (so I'm assuming the reset pin is in UPDI mode although I might try the 12V battery hack tomorrow).

These are some scope shots of the UPDI attempted programming process (full output at bottom). The first is a wide view of the full initial sequence with channel 1 (yellow) on the UPDI pin and channel 2 (blue) on the Vcc pin of the ATtiny. DS1Z_QuickPrint1

Here's a zoom in to see the initial UPDI init low, then a chunk of data: DS1Z_QuickPrint2

And here's a closer zoom on that chunk of data to see that the transitions look nice and clean: DS1Z_QuickPrint3

If you look at the cursor measurement on that last image, one large thing that jumps out at me is that the UPDI line is only transitioning between a high of 3.6V and a low of 1.4V. Is this expected? Should a high be 5V or is 3.6V logic acceptable? Is 1.4V low enough to register an actual low on the ATtiny within the UPID pin?

Any thoughts?

Here's the full output from the Arduino upload log. Don't think it'll tell much, just that it tries to start the process and can't get a response from the board

SerialUPDI
UPDI programming for Arduino using a serial adapter
Based on pymcuprog, with significant modifications
By Quentin Bolsee and Spence Konde
Version 1.2.3 - Jan 2022
Using serial port /dev/cu.usbserial-1130 at 57600 baud.
Target: attiny414
Set fuses: ['2:0x02', '6:0x04', '8:0x00']
Action: write
File: /var/folders/sr/3ms7sks57hq80w8qt37pvqnh0000gn/T/arduino_build_208512/sketch_may18b.ino.hex
pymcuprog.programmer - INFO - Setting up programming session for 'attiny414'
pymcuprog.deviceinfo.deviceinfo - INFO - Looking for device attiny414
pymcuprog.serialupdi.physical - INFO - Opening port '/dev/cu.usbserial-1130' at '57600' 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.
pymcuprog.serialupdi.physical - INFO - Sending double break
pymcuprog.serialupdi.physical - INFO - Double-break sent. Retrying.
pymcuprog.serialupdi.physical - INFO - Opening port '/dev/cu.usbserial-1130' at '57600' 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.
Traceback (most recent call last):
  File "/Users/dot4qu/Library/Arduino15/packages/megaTinyCore/hardware/megaavr/2.5.10/tools/prog.py", line 285, in <module>
    main()
  File "/Users/dot4qu/Library/Arduino15/packages/megaTinyCore/hardware/megaavr/2.5.10/tools/prog.py", line 128, in main
    return_code = pymcuprog_basic(args, fuses_dict)
  File "/Users/dot4qu/Library/Arduino15/packages/megaTinyCore/hardware/megaavr/2.5.10/tools/prog.py", line 199, in pymcuprog_basic
    status = pymcu._start_session(backend,
  File "/Users/dot4qu/Library/Arduino15/packages/megaTinyCore/hardware/megaavr/2.5.10/tools/libs/pymcuprog/pymcuprog_main.py", line 545, in _start_session
    backend.start_session(sessionconfig)
  File "/Users/dot4qu/Library/Arduino15/packages/megaTinyCore/hardware/megaavr/2.5.10/tools/libs/pymcuprog/backend.py", line 359, in start_session
    self.programmer.setup_device(
  File "/Users/dot4qu/Library/Arduino15/packages/megaTinyCore/hardware/megaavr/2.5.10/tools/libs/pymcuprog/programmer.py", line 78, in setup_device
    self.device_model = get_nvm_access_provider(self.transport,
  File "/Users/dot4qu/Library/Arduino15/packages/megaTinyCore/hardware/megaavr/2.5.10/tools/libs/pymcuprog/nvm.py", line 42, in get_nvm_access_provider
    accessprovider = NvmAccessProviderSerial(transport, device_info, baud=frequency)
  File "/Users/dot4qu/Library/Arduino15/packages/megaTinyCore/hardware/megaavr/2.5.10/tools/libs/pymcuprog/nvmserialupdi.py", line 53, in __init__
    self.avr = UpdiApplication(port, baud, self.dut)
  File "/Users/dot4qu/Library/Arduino15/packages/megaTinyCore/hardware/megaavr/2.5.10/tools/libs/pymcuprog/serialupdi/application.py", line 79, in __init__
    datalink.init_datalink()
  File "/Users/dot4qu/Library/Arduino15/packages/megaTinyCore/hardware/megaavr/2.5.10/tools/libs/pymcuprog/serialupdi/link.py", line 44, in init_datalink
    raise PymcuprogError("UPDI initialisation failed")
pymcuprog.pymcuprog_errors.PymcuprogError: UPDI initialisation failed
pymcuprog.serialupdi.physical - INFO - Closing port '/dev/cu.usbserial-1130'
the selected serial port pymcuprog.serialupdi.physical - INFO - Closing port '/dev/cu.usbserial-1130'
 does not exist or your board is not connected
second-string commented 2 years ago

Happy to show the schematic of the board but essentially right now the only pieces of it I'm using are 5V into the LDO, The UPDI trace through a 470ohm resistor (there's a 1.5k resistor on the CH430 pins), and ground.

second-string commented 2 years ago

Oh shoot didn't see the whole discussions section sorry. Posted it over there, closing this