Uploading to ATtiny1626

I am having difficulty uploading to an ATtiny1626. I have not used these chips before. From the information here, I gather that its possible to program the chips via UPDI using an FTDI board.

https://wolles-elektronikkiste.de/en/using-megatinycore

I have set up the chip in an adaptor which is plugged into a small breadboard. The chip is powered externally using a small PSU board which is also plugged into the breadboard and supplied from a 7.5V AC adapter. Finally there is the FTDI adapter. This is plugged into the board. Wire connections are as follows:

FTDI -> ATtiny
GND -> GND
RX0 -> via 330ohm to UPDI (PA0)
TX0 -> via 1N4148 diode to RX0

I have not connected VDD on the FTDI board to the positive rail because chip is being powered externally. Only ground is common. The selected voltage to be applied to the ATtiny1626 VDD is 5V. I have checked and confirmed that there is a 5V output.

I selected the SerialUPDI: SLOW (57600 baud) option as described here:

https://forum.arduino.cc/t/uploading-program-to-attiny-1616-via-serial-updi-and-ch340-programmer/1261787

I then used the Upload using programmer option to upload the sketch. Unfortunately, attempting to program the board just results in an error:

Sketch uses 3120 bytes (19%) of program storage space. Maximum is 15872 bytes.
Global variables use 219 bytes (10%) of dynamic memory, leaving 1829 bytes for local variables. Maximum is 2048 bytes.
"ERROR: Upload using programmer is not supported on optiboot boards""/home/johnc/.arduino15/packages/megaTinyCore/tools/python3/3.7.2-post1/python3" -u "/home/johnc/.arduino15/packages/megaTinyCore/hardware/megaavr/2.6.10/tools/prog.py"  -t uart -u /dev/ttyUSB0 -b 57600 -d attiny1626 --fuses 0:0x00 2:0x02 6:0x04 7:0x00 8:0x02 "-f/home/johnc/.cache/arduino/sketches/97DEB5240487D77338EC5D808F97A0DF/HF225-Interface-Base.ino.hex" -a write -v
Failed programming: cannot execute upload tool: fork/exec ERROR: Upload using programmer is not supported on optiboot boards""/home/johnc/.arduino15/packages/megaTinyCore/tools/python3/3.7.2-post1/python3: no such file or directory

I checked the path and file and it does exist.

Photo of my setup:

I tried removing and re-installing the library, but that didn't fix it.

Which board do you have selected?

ATtiny3226/3216/1626/1616/1606/826/816/806/426/416/406

or

ATtiny3216/1616/1606/816/806/416/406 w/Optiboot

If the latter, switch to the former and try again.

1 Like

Did you try the regular Upload option?

@DrAzzy any thoughts?

This one:

ATtiny13226/1626/826/428 w/Optiboot

So yes, it was one with Optiboot. Didn't spot that. This is a brand new chip so I don't think it would have the boot-loader burned onto it yet. So now have just tried:

ATtiny3226/3216/1626/1616/1606/826/816/806/426/416/406

as suggested. When compiling I now get a note:

In file included from /home/johnc/.arduino15/packages/megaTinyCore/hardware/megaavr/2.6.10/variants/txy6/pins_arduino.h:27:0,
                 from /home/johnc/.arduino15/packages/megaTinyCore/hardware/megaavr/2.6.10/cores/megatinycore/Arduino.h:719,
                 from /home/johnc/.arduino15/packages/megaTinyCore/hardware/megaavr/2.6.10/cores/megatinycore/wiring_private.h:32,
                 from /home/johnc/.arduino15/packages/megaTinyCore/hardware/megaavr/2.6.10/cores/megatinycore/wiring_digital.c:28:
/home/johnc/.arduino15/packages/megaTinyCore/hardware/megaavr/2.6.10/cores/megatinycore/timers.h:54:15: note: #pragma message: Note: This part does not have a TCD, hence there is no PWM from TCD available.
       #pragma message("Note: This part does not have a TCD, hence there is no PWM from TCD available.")
               ^~~~~~~
Sketch uses 3144 bytes (19%) of program storage space. Maximum is 16384 bytes.
Global variables use 219 bytes (10%) of dynamic memory, leaving 1829 bytes for local variables. Maximum is 2048 bytes.

There are no errors. Since I am not using PWD, so I went ahead and tried the upload and got the pop-up that says:

Request 'upload' failed.

But despite Show verbose output during: having upload checked, there are no error messages just:

Sketch uses 3144 bytes (19%) of program storage space. Maximum is 16384 bytes.
Global variables use 219 bytes (10%) of dynamic memory, leaving 1829 bytes for local variables. Maximum is 2048 bytes.

I didn't at the time, but with this board selection, using the standard Sketch -> Upload option does the same as above.

The chip didn't have the bootloader. You just told the software that it did. Which the software didn't like.

Upload or "Upload using programmer"?

Both. I am assuming that the correct method, since I am selecting a programmer from the list, is Upload using Programmer but because of the suggestion from @PaulRB I also tried Sketch -> Upload. Same result for both options. Also tried shutting down and restarting the IDE and running the upload again. Still the same: confirmation of successful compilation, upload failed pop-up, but no error messages to indicate why.

Since I moved on from the IDEs years back I have no input on why it might be doing... well, nothing, apparently.

However, you do have the command line that the IDE was outputting when you were earlier telling the software that your chip had a bootloader. It might be enlightening to try that from a command line and see what the IDE is hiding from you.

Good luck with your project.

When using Upload (without programmer) did you choose the right COM port? The one that appears when you plug in your USB-Serial adapter?

Fair question. yes, /dev/ttyUSB0 in this case. Its the only connected port.

1 Like

I'm out of ideas. I had hoped that @DrAzzy would chip in, but he hasn't posted in >1yr

I suspect you are using Linux and not a Windows PC ?

You may want to read this warning for Linux users from @DrAzzy

Clearly!

/dev/ttyUSB0 was indeed where my suspicion came from :slight_smile:

I am able to reproduce this, but only when I don't have a programmer selected from Arduino IDE's Tools > Programmer menu. Make sure you have Tools > Programmer > SerialUPDI - SLOW: 57600 baud selected from the Arduino IDE menus and then try uploading again.

Arduino IDE remembers the programmer selection on a per-board basis. So when you changed the board, the menu selection you had for the previous board was lost.

1 Like

Correct and I am aware of that comment. But just to confirm, for that and other reasons, I am NOT running a version of the IDE installed from a Linux distro repository. I am running the downloadable ZIP file packaged version of IDE 2.3.6, which has been downloaded directly from arduino.cc.

The sharp eyed will, of course have also spotted the path in the error messages and in the "file manager" screenshot... :wink: So yes, I am running the IDE on Linux, MX Linux 23.6 to be exact, in the event that this might have any bearing.

Spot on! I had set it, more than once, but it must have got unset when I changed boards earlier, as also did the Chip: option in the tools menu. I spotted the one but not the other. I just went back in and re-selected the programmer and it now does attempt an upload, but unfortunately fails with the following messages:

Sketch uses 3144 bytes (19%) of program storage space. Maximum is 16384 bytes.
Global variables use 219 bytes (10%) of dynamic memory, leaving 1829 bytes for local variables. Maximum is 2048 bytes.
"/home/johnc/.arduino15/packages/megaTinyCore/tools/python3/3.7.2-post1/python3" -u "/home/johnc/.arduino15/packages/megaTinyCore/hardware/megaavr/2.6.10/tools/prog.py"  -t uart -u /dev/ttyUSB0 -b 57600 -d attiny1626 --fuses 0:0b00000000 2:0x02 6:0x04 7:0x00 8:0x00 "-f/home/johnc/.cache/arduino/sketches/97DEB5240487D77338EC5D808F97A0DF/HF225-Interface-Base.ino.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.2.3 - Jan 2022
Using serial port /dev/ttyUSB0 at 57600 baud.
Target: attiny1626
Set fuses: ['0:0b00000000', '2:0x02', '6:0x04', '7:0x00', '8:0x00']
Action: write
File: /home/johnc/.cache/arduino/sketches/97DEB5240487D77338EC5D808F97A0DF/HF225-Interface-Base.ino.hex
pymcuprog.programmer - INFO - Setting up programming session for 'attiny1626'
pymcuprog.deviceinfo.deviceinfo - INFO - Looking for device attiny1626
pymcuprog.serialupdi.physical - INFO - Opening port '/dev/ttyUSB0' 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/ttyUSB0' 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 "/home/johnc/.arduino15/packages/megaTinyCore/hardware/megaavr/2.6.10/tools/prog.py", line 286, in <module>
    main()
  File "/home/johnc/.arduino15/packages/megaTinyCore/hardware/megaavr/2.6.10/tools/prog.py", line 128, in main
    return_code = pymcuprog_basic(args, fuses_dict)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/johnc/.arduino15/packages/megaTinyCore/hardware/megaavr/2.6.10/tools/prog.py", line 199, in pymcuprog_basic
    status = pymcu._start_session(backend,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/johnc/.arduino15/packages/megaTinyCore/hardware/megaavr/2.6.10/tools/libs/pymcuprog/pymcuprog_main.py", line 545, in _start_session
    backend.start_session(sessionconfig)
  File "/home/johnc/.arduino15/packages/megaTinyCore/hardware/megaavr/2.6.10/tools/libs/pymcuprog/backend.py", line 359, in start_session
    self.programmer.setup_device(
  File "/home/johnc/.arduino15/packages/megaTinyCore/hardware/megaavr/2.6.10/tools/libs/pymcuprog/programmer.py", line 78, in setup_device
    self.device_model = get_nvm_access_provider(self.transport,
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/johnc/.arduino15/packages/megaTinyCore/hardware/megaavr/2.6.10/tools/libs/pymcuprog/nvm.py", line 42, in get_nvm_access_provider
    accessprovider = NvmAccessProviderSerial(transport, device_info, baud=frequency, options=options)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/johnc/.arduino15/packages/megaTinyCore/hardware/megaavr/2.6.10/tools/libs/pymcuprog/nvmserialupdi.py", line 54, in __init__
    self.avr = UpdiApplication(port, baud, self.dut)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/johnc/.arduino15/packages/megaTinyCore/hardware/megaavr/2.6.10/tools/libs/pymcuprog/serialupdi/application.py", line 79, in __init__
    datalink.init_datalink()
  File "/home/johnc/.arduino15/packages/megaTinyCore/hardware/megaavr/2.6.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/ttyUSB0'
Failed programming: uploading error: exit status 1

A step forward in any case.

And it looks to me you have your series resistor at the UPDI pin side of the diode.

Should be the other side in the TX line.

It is also depending on the type of adapter. Yours is the one at the top of this picture?

Yup, that's the one. The resistor is between UPDI and TX on the FTDI board. The diode is between Rx and Tx with the band towards Tx. The article I linked as the board connections shown in a different order.

I've had best results with a Schottky diode here.

I found a BAT85 which is a Schottky diode and replaced the 1N4148 I was previously using. Unfortunately it hasn't made any difference.