I've made a prototype PCB containing an ATTINY 4313:

enter image description here

Each time I want to change the program, I upload it with an Arduino used with the "Arduino as ISP" sketch.

If one day I sell such a module to consumers, obviously I cannot ask them "please use an Arduino as ISP to update the new version of the firmware".

Which components should I add to a simple ATtiny to make the firmware updatable via a USB cable for end-customers?

The ideal UX for customers would be:

  • people download the new firmware
  • they connect the PCB to computer via USB
  • if possible with no software to install on their computer, they can update the firmware (maybe by just dropping a file on an USB appearing as a disk / flash drive?)
  • 2
    \$\begingroup\$ VTC - Your question is way too broad to be answered effectively here. You need to boil this down and get into the detailed design phase and then ask some questions regarding where you are problems with the design. As it is now you are asking architecture level questions that you need to answer for yourself based upon your usability requirements, cost factors and any special software requirements. \$\endgroup\$ Oct 5, 2019 at 9:59
  • 6
    \$\begingroup\$ I'd agree this is a bit broad, but honestly: This screams "The ATTiny is holding you back!". There's microcontrollers that integrate a serial or even a USB bootloader (and you can do exactly that, drop a file), which means you need zero external circuitry but a USB plug. The answer to your question is: "Add nearly a full arduino board to your board", and that's kind of stupid, since then you could just use the arduino and leave out the attiny. (BTW,the attiny 4313 is really not tiny,so I think picking it is not a wise choice for any application– you get an expensive but "poor" microcontroller) \$\endgroup\$ Oct 5, 2019 at 10:03
  • \$\begingroup\$ Research if the other way around is possible. The device upgrading automatically from a file on a SD card or USB drive. \$\endgroup\$
    – Jeroen3
    Oct 5, 2019 at 18:57

3 Answers 3


To program the Attiny via USB, you'll need an external programmer, as you've noted: something like your arduino.

Going that route makes no sense, because your programmer would be more capable than your target microcontroller, so you'd drop the ATTiny alltogether.

Instead, I'd recommend simply abandoning the ATTiny and go for one of the many microcontrollers that actually come with USB built in. Some even come with a USB bootloader, where upon power up, for a short duration, the MCU (without any help of you!) opens a virtual serial port where you can just write your new firmware to.

If you want the comfort you describe (dropping files), you'd use

  • a microntroller that has USB built in
  • a modern microcontroller RTOS that emulates a mass storage device where you can just drop a firmware file and reboot to use the new firmware.

I think mbed is an RTOS that offers that, and it for example runs on the inexpensive LPC series of NXP microcontrollers (and many, many, many other ARM MCUs).

So, what you want exists, but it's really not going to be based on the ATTiny4313 – by the way, a generally strange choice in platform, because you get the "resource poverty" of the ATTiny family for the price of a fully-fledged 32 bit ARM processor that would integrate USB.

  • 2
    \$\begingroup\$ Technically you don't need an external programmer for an ATtiny. The Digispark (ATtiny85-based) lets you just plug it straight into a USB port, and it bit-bangs USB well enough to support programming it that way. \$\endgroup\$ Oct 5, 2019 at 22:41
  • \$\begingroup\$ @JosephSible What is a Digispark exactly? (there are many references, can you add a link to the one you're speaking about?) \$\endgroup\$
    – Basj
    Oct 6, 2019 at 10:15
  • 1
    \$\begingroup\$ @Basj The Digispark is a small development board that has an ATtiny85 MCU on it, and plugs straight into a USB-port. The at85 then bit-bangs USB (that is, it interfaces USB without USB hardware support). It would perhaps be possible to do this on the at4313 as well, but it's not trivial to get the software USB implementation right. \$\endgroup\$
    – marcelm
    Oct 6, 2019 at 13:08

Take a look a the micronucleus bootloader...


It allows an ATTINY to accept a code download over a (slightly hackey) USB connection. It is widely used and well supported.

Here is an example of the hardware that uses only a handful of passives to add a minimal USB connection to an ATTINY...

enter image description here

From the excellent Digispark, one of the thousands of boards that use this technique.

Note that this does require some software on the host PC to download the code, but you can use either the Arduino IDE or the AVRDUDE utility - both of which are widely supported on all major platforms.


The simplest way to do this is to replace the ATtiny with a slightly better processor, which has USB support. You'll then need to program it to allow USB upload. I could just reccomend you a processor, but instead, I'll walk you through the process I would go through to pick one.

  1. It sounds like you've been working on the ATtiny and arduinos. These are both AVR 8-bit processors. So I'll assume you're familiar with the AVR world and I'll look for another AVR. Though you'd get a lot more bang for your buck looking at an ARM processor.

  2. AVRs were made by Atmel, who were bought by Microchip. So I go to the Microchip parametric search page and click the "all products button".

  3. Then I look for what (I assume) you want. Under "CPU type", I choose "8-bit AVR MCU", and under "number of USB modules" I pick 1. I click the "5k pricing" column to get them listed from cheapest to most expensive.

Top of the list is an ATmega8U2. If you have any other requirements I missed, you can change the selections and see what you get. For example, if the 20MHz clock is important, you can select that, and then the top option will be a ATxmega16C4.

The USB-equiped ATmegas work with Atmel's DFU bootloader and Atmel FLIP. It's not quite as simple as drag and drop - the customer would need to run a little program - but it is quick and easy to set up.

  • \$\begingroup\$ Thank you very much. Which software should the customer install, is it a lightweight tool? Also are there other ATmega which emulate a USB mass storage device, for which a drag n drop and reboot would be available? \$\endgroup\$
    – Basj
    Oct 5, 2019 at 10:59
  • \$\begingroup\$ The simplest (for you) option would be for the customer to use FLIP. Which would be a pain for them . But you could also write a script using the software that comes with FLIP. The customer would then just need to double click on it. The drag and drop thing is probably possible, I expect all the ATmegas have the necessary hardware, but I don't know of any existing firmware/libraries and it will be very complicated to write. I prefer the DFU option as it checks the firmware before copying it, so the customer can't e.g. accidentally upload the firmware without unzipping it. \$\endgroup\$
    – Jack B
    Oct 5, 2019 at 11:38
  • \$\begingroup\$ In case of FLIP, do they need to install a driver? Can I ship a version of their software (does their license allow this redistribution?) + my own script so that it's just a double click for them? \$\endgroup\$
    – Basj
    Oct 5, 2019 at 14:40
  • \$\begingroup\$ A driver is required. I think FLIP, or at least the scriptable libraries are redistributable. If not, then open source alternatives are also available. \$\endgroup\$
    – Jack B
    Oct 5, 2019 at 16:54
  • \$\begingroup\$ Thank you for this information. If this require to install a driver, a software, the actual firmware, it will probably be too much for the end user... would it be easier with DFU? I'll maybe try this software, how is called the DFU uploader? \$\endgroup\$
    – Basj
    Oct 5, 2019 at 17:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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