TinyCircuits Forum

TinyCircuits Products => TinyLily => Topic started by: jusp on April 19, 2021, 01:19:01 PM

Title: Programming the tinylily directly via avrdude
Post by: jusp on April 19, 2021, 01:19:01 PM
Hi, I have been programming my atmega328 processors using an adafruit tinyusb board for a while, and am about to try a tinylily using its mini USB board.
What programmer type should I pass to avrdude? I optimistically tried tinyusb, but got the following error:


sudo avrdude -c usbtiny                         -p m328p -b 115200 -U flash:w:a.hex:a
avrdude: Error: Could not find USBtiny device (0x1781/0xc9f)
Title: Re: Programming the tinylily directly via avrdude
Post by: lennevia on April 20, 2021, 07:32:14 PM
Hello,

This is the command that gets run by the Arduino IDE:
avrdude -v -patmega328p -carduino -PCOM1 -b57600 -D -Uflash:w:a.hex:i

You can test this by following this tutorial https://learn.tinycircuits.com/TinyLily/Processor_TinyLily_Tutorial/ and then going to File->Preferences in the Arduino IDE and checking the boxes for “Show verbose output during: compilation upload” in the window that pops up.

Hope that does the trick! Thanks!
Title: Re: Programming the tinylily directly via avrdude
Post by: jusp on April 20, 2021, 11:32:12 PM
Yes, that gets me further. I am running on ubuntu, so COM1 does not exist, so tried the following instead:

sudo avrdude -v -patmega328p -carduino   -b57600 -D -Uflash:w:a.hex:i

This gets into the error "avrdude: ser_open(): can't set attributes for device "/dev/ttyS1": Inappropriate ioctl for device", which seems to mean that I am connecting to the wrong device (/dev/ttyS0). At ;east, I get the same error when explicitly trying to connect to other /dev/ttySnn using option -P.

lsusb lists the miniusb board as follows:

Bus 001 Device 018: ID 0403:6015 Future Technology Devices International, Ltd Bridge(I2C/SPI/UART/FIFO)

How can I find out the proper -D option?





Title: Re: Programming the tinylily directly via avrdude
Post by: jusp on April 22, 2021, 06:59:58 PM
This issue is solved with help from @lennevia (thanks!).

The avrdude command that in the end worked for me on the Ubuntu machine that I am using is as follows:

         sudo avrdude -P /dev/ttyUSB0 -v -patmega328p -carduino  -b57600 -D -Uflash:w:a.hex:i

First, the baudrate is important, 115200 does not work.  Second, to get going I had soldered a programming header on the back pads of the tinylily so that I could program it with an SPI- based programmer. After success with that programmer I overwrote, as I usually do, the processor fuses with the settings that I need. This also reverted the prescaling of the system clock that is programmed into fuse settings by which the tinylilies are shipped. But changing the clock prescaling throws off the baudrate settings in the tinylily's bootloader. So be careful with changing the fuses.
Third, the linux port (/dev/ttyUSB0 in the command above) can be identified by the following shell command after plugging in the programmer cable: "dmesg | grep tty"