core13: An Arduino core for the Attiny13 *testers wanted*

I was creating ATtiny13 library install for Arduino IDE 1.6.0 ( from smeezekitty library ), just extract in sketchbook/hardware folder.
It has some new feature like change GCC Optimisation flags from IDE directly. I added -O1 flag because with new compiler in some cases can produce smaller .hex file ( must do some experimenting )

This is the boards i include ( you can change it from board.txt )

and burn Bootloader ( only use to change fuse settings, no real bootloader ) works fine from IDE.

tiny13_for_1.6.0_IDE.zip (42.6 KB)

Tanks for this share :grin: :grin: :grin:

common_ground:

Thank you very much for IDE 1.6.0 version, works out of the box, which is helpful for beginners like myself. However, a strange recurring feature for all my atmega chips - if I try to burn the bootloader first (only fuses, I know, I know), it fails with some out-of-sync or something. Uploading the blink sketch works (though the sketch produces longer blick delays). Burning the bootloader-fuses after that - works, and the uploading the blick sketch again works perfectly as expected. I encountered that while programing the atmega328 chip and thought i made a mistake somewhere. But now it repeated again with your compilation for attiny13! Am I missing something?

grigorym: However, a strange recurring feature for all my atmega chips

I'm not sure i understand you completely. This installation is only for ATtiny13 and has nothing to do with atmega mcu (they use a settings that is in a different location). Can you explain it more clearly. What programmer you use? If you use USBTinyISP then maybe flash timing is problem and here you have a solution for this: ATTiny flash timing problem

I use Arduino as ISP and USBTinyISP and it works well with both.

common_ground: I'm not sure i understand you completely. This installation is only for ATtiny13 and has nothing to do with atmega mcu (they use a settings that is in a different location). Can you explain it more clearly. What programmer you use?

  1. I am using Arduino as ISP (using Nano board). Only the wierd behaviour (having to upload sketch first, and only then setting the fuses worked) on ATtiny13 matched the one I noticed on 328, so I mentioned it here.

  2. Are you sure your configuration option "attiny13.name=Attiny13 @ 128 KHz (internal watchdog oscillator)" works as expected? In my case IDE says it is missing "upload.tool=arduino:avrdude" and ".bootloader.tool=arduino:avrdude". However, having added those I must have locked my ATtiny13, it does not respond anymore.

P.S. May I take some more time to read the whole thread? :) I definitely must not be the only one to try this 128KHz option :)

grigorym: 2. Are you sure your configuration option "attiny13.name=Attiny13 @ 128 KHz (internal watchdog oscillator)" works as expected? In my case IDE says it is missing "upload.tool=arduino:avrdude" and ".bootloader.tool=arduino:avrdude". However, having added those I must have locked my ATtiny13, it does not respond anymore.

128 KHz option was just copied from a previous settings and I did not adjust it for 1.6.x, and it can not be used with a standard Arduino as ISP , as a rookie you should avoid using internal watchdog oscillator , I'm sorry i have not been thinking, this option had to be deleted, and who knows how to use it, can easily be set manually. If you tried, it means your ATtiny13 is locked and here you have a good procedure how to unlock :reset-clock-fuse-bits on ATTiny13, i tried this procedure, works well and it's easy to use, only instead

avrdude -p attiny13 -P usb -c usbtiny -tuF

you should put

avrdude -p attiny13 -P usb -c arduino -tuF

But others fuse settings should work with Arduino as ISP without problems , i just tried them all again.

grigorym: 2. Are you sure your configuration option "attiny13.name=Attiny13 @ 128 KHz (internal watchdog oscillator)" works as expected? In my case IDE says it is missing "upload.tool=arduino:avrdude" and ".bootloader.tool=arduino:avrdude". However, having added those I must have locked my ATtiny13, it does not respond anymore.

P.S. May I take some more time to read the whole thread? :) I definitely must not be the only one to try this 128KHz option :)

I've used the 128KHz many times. The issue here is the tiny13 cpu clock is too slow for some ISP programmers SCK clock speeds.

In order to program at these very low speeds is you need an ISP programmer that will support the Bitclock rate adjustment from avrdude -B option. There are several programmers that will support this option, AVRispMKII, USBtinyISP(some versions may not work correctly), and USBASP(new firmware versions). I've even add my own 16KHz clock rate option that works with this bitclock rate adjustment.

ArduinoasISP will not work at these very slow speeds.

For avrdude -B option, you should specify at least -B50.

To program via the IDE, then you will need to change the Global defaults in the avrdude.conf file. Some where around line 335:

#
# Overall avrdude defaults; suitable for ~/.avrduderc
#
default_parallel   = "lpt1";
default_serial     = "com1";
# default_bitclock = 2.5;
default_bitclock = 50;

hiduino: ArduinoasISP will not work at these very slow speeds.

As I have no other programmer, but Arduino Nano as ArduinoISP, does that mean I technically can not repair that 128KHz issue?

grigorym: As I have no other programmer, but Arduino Nano as ArduinoISP, does that mean I technically can not repair that 128KHz issue?

Try Arduino ISP with boot-time selectable slow SPI

It may help, but I have not tested it.

common_ground: Try Arduino ISP with boot-time selectable slow SPI

Tried already, no luck. Both burning bootloader and trying to upload says: "avrdude: Device signature = 0x000000 avrdude: Yikes! Invalid device signature."

OK, i find solution for Arduino as ISP and ATTINY13 on 128 KHz :

open in some text editor:

sketchbook\hardware\tiny13\avr\boards.txt

Close IDE and change Attiny13 @ 128 KHz section with this :

attiny13.name=Attiny13 @ 128 KHz (internal watchdog oscillator)
attiny13.upload.tool=arduino:avrdude
attiny13.upload.using=arduino:arduinoisp
attiny13.upload.maximum_size=1024
attiny13.upload.maximum_data_size=64
attiny13.upload.speed=250

attiny13.bootloader.tool=arduino:avrdude
attiny13.bootloader.low_fuses=0x7B
attiny13.bootloader.high_fuses=0xFF

attiny13.build.mcu=attiny13
attiny13.build.f_cpu=128000
attiny13.build.core=core13

download zipped Arduino_slow_ISP sketch, then start IDE ( i tried on 1.6.1 only ) and install sketch on your arduino programmer ( i tried on breadboard atmega328 on 8MHz ) connect attiny13 as you usual do
and this version of - Arduino_slow_ISP sketch - is sufficiently slow to burn 128KHz fuse and upload sketch, and also change to other fuses as well, I just tried all options.

Arduino_slow_ISP.zip (3.78 KB)

common_ground: OK, i find solution for Arduino as ISP and ATTINY13 on 128 KHz :

No change. I think it's time to try something new. Tomorrow I'll take another attiny13 to replace the current one and see if it is going to programmed, just in case I screwed something with schematic or managed to shortcut my poor attiny :). I will also try to find an AVR-fan-neighbor to borrow an external programmer.

grigorym: No change. I think it's time to try something new. Tomorrow I'll take another attiny13 to replace the current one and see if it is going to programmed, just in case I screwed something with schematic or managed to shortcut my poor attiny :). I will also try to find an AVR-fan-neighbor to borrow an external programmer.

Only if you damage attiny13.Try with new one.

I just lock one ATTiny13 with standard ArduinoISP and unlock with Arduino_slow_ISP , work 100%. That makes using Arduino as excellent ISP programmer of choice. I'll make one to be permanent, no need to buy anything else.

I program them at 128K all the time. I modified the Ardunio ISP program to run at a very low SPI rate and it works with no problems. Make sure your wire connections are good.

smeezekitty:
I program them at 128K all the time. I modified the Ardunio ISP program to run at a very low SPI rate
and it works with no problems. Make sure your wire connections are good.

I was planning to disappear silently, but bad conscience brought me back to report my stupidity. Common_ground, I was trying to recover with your slow ISP not the attiny13, but the 555 timer chip :)). Surprisingly, it refused to be programmed :). @@@@!

So, reporting. Slow version of Arduino ISP successfully sets the fuses back and programs the chip. After that I was able to switch back to ordinary Arduino ISP. I went the whole process once again: programming with ordinary Arduino ISP the fuses for 128KHz, loosing control of the chip, uploading slow version of Arduino ISP and reprogramming the fuses and the sketch back.

Thank you very much for your assistance and patience. I’ll mention the solution on a couple of places, where beginners like me stumbled upon 128KHz option.

As for USBTinyISP programmers, we do not have to change default_bitclock only in avrdude.conf, but we can change the parameters directly from the IDE environment (at least from 1.6.1), without changing avrdude.conf.

Open arduino-1.6.1\hardware\arduino\avr\programmers.txt in some text editor and change usbtiny section with this :

usbtinyisp.name=USBtinyISP -B10 (Default)
usbtinyisp.protocol=usbtiny
usbtinyisp.program.tool=avrdude
usbtinyisp.program.extra_params=

############ > 4.8 MHz ##################

usbtinyisp_2.name=USBtinyISP -B2 (> 4.8 MHz)
usbtinyisp_2.protocol=usbtiny
usbtinyisp_2.program.tool=avrdude
usbtinyisp_2.program.speed=2
usbtinyisp_2.program.extra_params=-B{program.speed}

############ < 4.8 MHz ##################

usbtinyisp_4.name=USBtinyISP -B4 (> 0.6 <= 4.8 MHz)
usbtinyisp_4.protocol=usbtiny
usbtinyisp_4.program.tool=avrdude
usbtinyisp_4.program.speed=4
usbtinyisp_4.program.extra_params=-B{program.speed}

############ 128 KHz ##################

usbtinyisp_50.name=USBtinyISP -B50 (= 128 KHz)
usbtinyisp_50.protocol=usbtiny
usbtinyisp_50.program.tool=avrdude
usbtinyisp_50.program.speed=50
usbtinyisp_50.program.extra_params=-B{program.speed}

##########################################

restart IDE and we have USBTinyISP options for diferrent bitclocks :

I just try some values and this is empirical result ( no upload error ) i get.

2us for > 4.8 MHz 4us for > 0.6 <= 4.8 MHz 10us - default settings for => 0.6 MHz 50us - for 128 KHz

Because i use often usbtiny for ATTINY85 too, upload speed improving the lot, for example :

avrdude: Using SCK period of 10 usec
avrdude: writing flash (8070 bytes):
Writing | ######################################### | 100% 21.05s
Reading | ########################################  | 100% 24.73s

avrdude: Setting SCK period to 2 usec
avrdude: writing flash (8070 bytes):
Writing | ######################################### | 100% 7.33s
Reading | ########################################  | 100% 8.19s

instead of 46 seconds I get the upload for 16 seconds for 8 Kb .hex file on 8 MHz attiny85.

With only 1K of memory, upload time isn't a big deal.

ElectroNick: 1.2K is a lot of bytes for a blink! The code must be not well optimized or sometin' . You can do plenty of useful things with 1K of command space. For example, here is a code for a 10-LED light chaser (can convert it into Cylon eyes or some other such blinking toy) and it compiles into only 562 bytes. In fact, there might even be some saving there still, I just didn't have too much time to optimize it.

I agree, 1.2k is a lot, i put an entire irrigation system in  some 700 bytes in an attiny13  AND it has a blinking LED :-)

Can anyone share with their boards.txt file?

gneil90: Can anyone share with their boards.txt file?

There are quite a few floating around the internet. Here's one I've made up. It works as of today on Arduino 1.6.3.

menu.cpu=Processor
menu.clock=Clock

attiny.name=ATtiny
attiny.bootloader.tool=arduino:avrdude
attiny.bootloader.unlock_bits=0xFF
attiny.bootloader.lock_bits=0xFF
attiny.build.core=arduino:arduino
attiny.build.board=attiny
attiny.upload.tool=arduino:avrdude

attiny.menu.cpu.attiny45=ATtiny45
attiny.menu.cpu.attiny45.upload.maximum_size=4096
attiny.menu.cpu.attiny45.build.mcu=attiny45
attiny.menu.cpu.attiny45.build.variant=tiny8

###############################################################

attiny.menu.cpu.attiny85=ATtiny85
attiny.menu.cpu.attiny85.upload.maximum_size=8192
attiny.menu.cpu.attiny85.build.mcu=attiny85
attiny.menu.cpu.attiny85.build.variant=tiny8

###############################################################

attiny.menu.cpu.attiny44=ATtiny44
attiny.menu.cpu.attiny44.upload.maximum_size=4096
attiny.menu.cpu.attiny44.build.mcu=attiny44
attiny.menu.cpu.attiny44.build.variant=tiny14

###############################################################

attiny.menu.cpu.attiny84=ATtiny84
attiny.menu.cpu.attiny84.upload.maximum_size=8192
attiny.menu.cpu.attiny84.build.mcu=attiny84
attiny.menu.cpu.attiny84.build.variant=tiny14

###############################################################

attiny.menu.clock.internal1=1 MHz (internal)
attiny.menu.clock.internal1.bootloader.low_fuses=0x62
attiny.menu.clock.internal1.bootloader.high_fuses=0xDF
attiny.menu.clock.internal1.bootloader.extended_fuses=0xFF
attiny.menu.clock.internal1.build.f_cpu=1000000L

###############################################################

attiny.menu.clock.internal8=8 MHz (internal)
attiny.menu.clock.internal8.bootloader.low_fuses=0xE2
attiny.menu.clock.internal8.bootloader.high_fuses=0xDF
attiny.menu.clock.internal8.bootloader.extended_fuses=0xFF
attiny.menu.clock.internal8.build.f_cpu=8000000L

###############################################################

attiny.menu.clock.external8=8 MHz (external)
attiny.menu.clock.external8.bootloader.low_fuses=0xFE
attiny.menu.clock.external8.bootloader.high_fuses=0xDF
attiny.menu.clock.external8.bootloader.extended_fuses=0xFF
attiny.menu.clock.external8.build.f_cpu=8000000L

###############################################################

attiny.menu.clock.external16=16 MHz (external)
attiny.menu.clock.external16.bootloader.low_fuses=0xFE
attiny.menu.clock.external16.bootloader.high_fuses=0xDF
attiny.menu.clock.external16.bootloader.extended_fuses=0xFF
attiny.menu.clock.external16.build.f_cpu=16000000L

###############################################################

attiny.menu.clock.external20=20 MHz (external)
attiny.menu.clock.external20.bootloader.low_fuses=0xFE
attiny.menu.clock.external20.bootloader.high_fuses=0xDF
attiny.menu.clock.external20.bootloader.extended_fuses=0xFF
attiny.menu.clock.external20.build.f_cpu=20000000L

#################################################

attiny13.name=ATtiny13
attiny13.bootloader.tool=arduino:avrdude
attiny13.bootloader.unlock_bits=0xFF
attiny13.bootloader.lock_bits=0xFF
attiny13.build.core=arduino:arduino
attiny13.build.board=attiny
attiny13.upload.tool=arduino:avrdude
attiny13.upload.using=arduino:arduinoisp
attiny13.build.mcu=attiny13

attiny13.menu.cpu.attiny13=ATtiny13
attiny13.menu.cpu.attiny13.upload.maximum_size=1024
attiny13.menu.cpu.attiny13.build.mcu=attiny13
attiny13.menu.cpu.attiny13.build.variant=core13

#################################################
attiny13.menu.clock.internal128=128KHz (internal)
attiny13.menu.clock.internal128.bootloader.low_fuses=0x7B
attiny13.menu.clock.internal128.bootloader.high_fuses=0xFF
attiny13.menu.clock.internal128.bootloader.extended_fuses=0xFF
attiny13.menu.clock.internal128.build.f_cpu=128000L

################################################

attiny13.menu.clock.internal600=600KHz (internal)
attiny13.menu.clock.internal600.bootloader.low_fuses=0x69
attiny13.menu.clock.internal600.bootloader.high_fuses=0xFF
attiny13.menu.clock.internal600.bootloader.extended_fuses=0xFF
attiny13.menu.clock.internal600.build.f_cpu=600000L

################################################

attiny13.menu.clock.internal12=1.2MHz (internal)
attiny13.menu.clock.internal12.bootloader.low_fuses=0x6A
attiny13.menu.clock.internal12.bootloader.high_fuses=0xFF
attiny13.menu.clock.internal12.bootloader.extended_fuses=0xFF
attiny13.menu.clock.internal12.build.f_cpu=1200000L

################################################


attiny13.menu.clock.internal48=4.8MHz (internal)
attiny13.menu.clock.internal48.bootloader.low_fuses=0x79
attiny13.menu.clock.internal48.bootloader.high_fuses=0xFF
attiny13.menu.clock.internal48.bootloader.extended_fuses=0xFF
attiny13.menu.clock.internal48.build.f_cpu=4800000L

################################################

attiny13.menu.clock.internal96=9.6MHz (internal)
attiny13.menu.clock.internal96.bootloader.low_fuses=0x7A
attiny13.menu.clock.internal96.bootloader.high_fuses=0xFF
attiny13.menu.clock.internal96.bootloader.extended_fuses=0xFF
attiny13.menu.clock.internal96.build.f_cpu=9600000L

################################################