For starters I am working with ATTiny 1626 micros. I have been using an Arduino UNO to burn them from PlatformIO up until now. So, how can I get AvrDude to burn using serialudpi.

The Problem

Ok, because of it age avrdude that is built into PlatformIO is older and it does not know the type serialupdi

avrdude: Can't find programmer id "serialupdi"

One Solution

In the past, I just used defalt avrdude: jtagmkII to build with PlatformIO. However, I am sick of using a who UNO just as a programmer. Especially, since I had built a serialUDPI interface in the past. So, I had it and had to figure out how to do this in PlatformIO.

My Better Solution (for now)

Ok. for now. This is the solution that I have come up with to burn an ATTiny 1626. Now, there may be a better way, but for now this gets the job done.

Burn The Bootloader

Unfortunately, I have not found a way around this yet so I went and installed megaTinyCore on Arduino. Then, I pick that as the board type and ATTiny Series. Next, I set the chip and other options such as 20 MHZ tuned. Then once all items selected it is time to burn it to the Chip. Oh, almost forgot make sure you set the Port and also to use SerialUDPI for programmer as shown below in screen shot.

Burn the Program

Now, the chip is setup. It is time to move over to PlatfomIO. Pick ATTiny 1626 for the processor. Now, this will create a default that wants to use jtag via Arduino UNO for example. So, to fix this I have this below workaround to be place in the platformio.ini file for the project.

; Setup the avrdude.exe that is 2.14 or newer to program serialupdi as shown below.
upload_protocol = custom
upload_command = "C:\Program Files (x86)\AVRDUDESS\avrdude.exe" -c serialupdi -p t1626 -P COM3 -b 115200 -e -U flash:w:"$SOURCE":a 

Here is the complete platformio.ini as an more complete example

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:ATtiny1626]
platform = atmelmegaavr
board = ATtiny1626
framework = arduino

board_build.f_cpu = 20000000UL

; Setup the avrdude.exe that is 2.14 or newer to program serialupdi as shown below.
upload_protocol = custom
upload_command = "C:\Program Files (x86)\AVRDUDESS\avrdude.exe" -c serialupdi -p t1626 -P COM3 -b 115200 -e -U flash:w:"$SOURCE":a 

Also note the example has board_build.f_cpu = 20000000UL.

That is important so millis and delay works correctly in the programs. Make sure to set to the speed of the clock chosen when the bootloader was burned to micro. Im my case above that is 20 MHZ.

Example main.cpp

Below, is a simple example for that can be pasted into platform src/main.cpp file. To get pin 13 blinking on micro at 1 second on and off.

#include <Arduino.h>

#define LED_PIN 13

void setup() {
  // put your setup code here, to run once:
  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN, LOW);

}

void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(LED_PIN, HIGH);
  delay(1000);
  digitalWrite(LED_PIN, LOW);
  delay(1000);
}

Oh, here is a pinout of ATTiny1626. So, actual pin 15 should go from 0 to 5v every 1 second as coded above.

ATTiny1626 Pinout

Leave a Reply

Your email address will not be published. Required fields are marked *