8

I want to use all six I/O pins of an ATtiny85, that means also using the reset pin as an I/O pin, however, I found out that if I disable the RESET pin, I can no longer program the ATtiny using an ISP programmer.

However, I found out that there are bootloaders for ATtiny which, as far as I understand, allow me to program the ATtiny through USB, without the need of the RESET pin.

My question is: How do I burn such a bootloader (such as micronucleus for example) to the ATtiny85? And how do I need to connect the ATtiny to USB after that (like this?)? How do I program it after that? Keep in mind that in terms of burning bootloaders and modifying fuses, I am a complete newbie.

Also, I'm using the ArduinoISP sketch as my ISP programmer since I don't have a real ISP programmer, but as far as I read, that won't be a problem.

EDIT: I do have this thing I bought for a couple dollars on eBay, which I don't know how and if I need to to use: enter image description here

  • Burning a bootloader is the same as burning any other program. But, if you get a bad one in there and change the reset fuse, you'll be stuck with it until you either get another chip or a high voltage programmer. So I'd recommend you test your USB bootloader before changing the fuse. Your software-USB code probably comes with a recommendation for a circuit to approximate the USB electrical interface. – Chris Stratton Oct 20 '14 at 19:47
1

I have just finished my Arduino-Plugin with full integration of TinySafeBoot (TSB) for ATtiny84A, ATtiny85 and ATmega328P.

The project can be found here:
https://mesom.de/atflash/index_english.html https://mesom.de/atflash/tinysafeboot/index_english.html

You could use it as it is now, and then use the Reset Pin as an analog in. Only watch for the voltage never to go below 0.6 * VCC.

As an alternative you could modify the fuses in boards.txt to have this pin available:
Go to Arduino Preferences and click on the link to preferences.txt (Mine: /Users/stefan/Library/Arduino15/preferences.txt). In this folder navigate to /packages/atflash/hardware/avr/0.1.0. Open the boards.txt and go to the section
ATTSB85.name=ATtiny85 (TSB)(Int. 8 MHz)

Change the line
ATTSB85.bootloader.high_fuses=0xdf
to
ATTSB85.bootloader.high_fuses=0x5f

Restart Arduino and burn bootloader via Arduino menu.


If you even then want to get another Pin from ATtiny85: you can change the bootloader to use just one Pin for RX and TX (see the TSB website). But why all the effort? Simply take the ATtiny84A. It has 14 Pins instead of 8 and costs nearly the same.

Stefan

2
  • Yes, there are USB interfaces for ATtiny85. Just look at one of the open hardware designs out there, e.g. Digispark.
  • An USB interface is going to require two pins, so using one to save one pin doesn’t strike me as cost effective.
  • I agree with @FAD, that you don’t really need an USB stack, and simply could do a time-delay-at-boot thing with the UART pins.
  • HVSP (the high voltage programming) is not hard to do. If you’re already comfortable with ArduinoISP, you can try ScratchMonkey, which uses the same approach (with a 12V power supply and one transistor) to do HVSP programming.
  • The USB interface can be shut down e.g. with a jumper when not programming, or can be put to a use that doesn't interfere with programming. Reprogramming is normally done immediately after a reset. – AMADANON Inc. Sep 10 '15 at 4:06
1

True, if you use the reset pin as IO then you need a special programmer that I believe provide high voltage (12v if i remember) or something like that to apply a 12v source to that pin to force it into programming mode then program using a normal programmer (or another arduino). However, what you are looking for is something like what is being done in the Arduino. The arduino is programmed with a special bootloader through ISP so when you power the microcontroller that bootloader will execute first and for few milliseconds will check the UART pins for activities and if it sees something valid it switched into programming mode where it waits for the new code to come through UART (not ISP) and write that into the program location, otherwise the bootloader will simply hand the code execution to the existing program if any.

Here is a simple explanation of how it works: Let say your microcontroller flash size is 1KB, and the bootloader is 100B so your program can be stored at location 101B+, and its max size is (1KB-100B). So when the bootloader starts and there is no activitiy on the UART pins it jumps to the location of your program (at 101B) while if programming activity is detected it starts reading the new code and overwrites the flash starting at 101B (so it won't over write itself).

And you will need the USBASP to program the bootloader for the first time. And you don't program the ATtiny85 through usb since that chip doesn't support USB, however, you use a USB to serial chip/module that emulates serial protocol over the USB. Some atmel microcontrollers have built in serial support and others can be done through software emulation.

  • And as Chris suggested, don't disable the reset pin until you test and validate that your bootloader works.
  • @IgnacioVazquez-Abrams, that is cool, and there are bootloaders implemented already with it. My information was kind of old then :). however, it is still same concept but direct communication with PC instead of usb-serial emulation. Thanks – FAD Oct 20 '14 at 22:32
  • You can also burn a bootloader to an ATtiny through a Arduino (UNO or equiv). Here are some instructions: highlowtech.org/?p=1695 or if you prefer a video: youtube.com/watch?v=qz-YMPY4_z0 – Sourcery Nov 20 '14 at 15:36
  • Here is a nice page about programming ATtiny4 5 9 10 20 and 40 using SPI from an Arduino so it is not ATtiny85 but I thought it is related. Also one thing the blog mentions is that if you use the reset pin as I/O all you need is 12v source to trigger programming mode and you still can program it the same way, so no special programmer as I thought before. junkplusarduino.blogspot.com/p/attiny10-resources.html – Fahad Alduraibi Nov 20 '14 at 16:18
  • @FAD, the 4/5/9/10 are completely different beasts from the ATtiny85. It’s true that they speak the same programming protocol (TPI) for high voltage and regular voltage programming, but that’s emphatically NOT true for any other ATxxx microcontroller. – microtherion Nov 20 '14 at 19:22
0

I do have this thing I bought for a couple dollars on eBay, which I don't know how and if I need to to use:

it is infinitely better than your arduinoisp.

google avrdude / avrdudess.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.