USB to update firmware on standalone MCU board?

Hello,
I have a project with a standalone ATMEGA328p. I have been programming it using an AVR MKII ISP programmer. However, it would be great to not have to use this programmer for updating the firmware "in the field". For example, lets say I have new firmware and want the customer using this project in another country to update it with only a USB cable and connection to a computer. Is there a way to simply add a USB connector on this project and connect it to the ATMEGA in some way to allow for this? I assume I would need to burn a bootloader for this (which is fine as I have plenty of program space and startup time isn't critical). I really don't want the expense of having to add an FTDI chip on the project, so that would be a non starter.

Thank you

It is possible to do "bit banged" USB on your ATmega328P, but this is really not ideal. Adafruit did it on their Trinket (ATtiny85) and Pro Trinket (ATmega328P) boards and this is what they have to say about it:

Deprecation Warning: The Pro Trinket bit-bang USB technique it uses doesn't work as well as it did in 2014, many modern computers won't work well. So while we still carry the Pro Trinket so that people can maintain some older projets, we no longer recommend it. Please check out the Metro Mini (ATmega328 @ 5V 16 MHz), ItsyBitsy 32u4 5V 16MHz, ItsyBitsy 32u4 @ 3.3V 8MHz or ItsyBitsy M0 @ 3V 48MHz. All have built-in USB and are comparable in price!

pert:
It is possible to do “bit banged” USB on your ATmega328P, but this is really not ideal. Adafruit did it on their Trinket (ATtiny85) and Pro Trinket (ATmega328P) boards and this is what they have to say about it:
Adafruit Pro Trinket - 5V 16MHz : ID 2000 : $9.95 : Adafruit Industries, Unique & fun DIY electronics and kits

pert you saved me a lot of headaches :slight_smile:

I’ll stick with ISP programming for now

Another possibility is an SD card bootloader. The customer would download the new firmware file from you, copy it to an SD or microSD card, and insert the card into the SD slot on your project. When powered up, your bootloader would detect the presence of the card, open the file, flash the new firmware, then shut down. Customer then removes the card, or maybe there's a switch to turn off the card's Vdd pin, and powers up again running the new firmware. Of course this would be a substantially bigger bootloader than the typical UART version because it would have to navigate the file system on the card. Writing this from scratch would be a challenge but a search for Arduino SD card bootloader should give you several examples.

For the cost of a few dollars, you can add a CP2104 USB to serial chip and the required circuitry to give your arduino a USB connection. Unless someone can say otherwise, the "customer" would still need to download the Arduino IDE and your sketch to upload to their unit though.

John_S:
For the cost of a few dollars, you can add a CP2104 USB to serial chip and the required circuitry to give your Arduino a USB connection. Unless someone can say otherwise, the "customer" would still need to download the Arduino IDE and your sketch to upload to their unit though.

I believe the driver behind the IDE, "avrdude" can be simply invoked with a command line to upload a sketch using the bootloader. The sketch hex file and avrdude can be zipped and autorun. You may have to install the USB driver though - which applies to any such solution.

The whole idea of using a "standalone ATMEGA328p" and then complaining about programming it is rather perverse. A generic "Nano" costs $3 or less; you just mount it a as a daughterboard on your custom PCB and it does the job.