USB Bootloader

It came to my attention recently that there are AVR USB bootloaders available. For example: https://github.com/baerwolf/USBaspLoader

The page linked to above describes a firmware-only bootloader that runs on AVR processors, including the ATmega328P. Being firmware only, it does not require any USB hardware, other than a USB jack of course. It does essentially what a UART-based bootloader + an FTDI USB-to-UART interface IC does: it allows one to plug the device into a USB port on a PC in order to bootload software updates onto the target processor. A USB bootloader is generally an inexpensive solution since it does not require the FTDI chip or any other USB-related interface hardware. It is also available for free under the GPL.

The USB bootloader requires:

  • 2k of bootloader flash memory.
  • Crystal-controlled processor clock running at one of the supported frequencies.
Cost Considerations

Adding a crystal would add $0.50 to the current design, but would also require utilizing two of the port pins currently assigned to other tasks. The edge-triggered interrupt would require one more port pin. The shortage of port pins could be offset by including a port expander IC for an additional $1, plus some additional flash program space for software to support the port expander. Increased PCB space for the added components should also be considered: but it should be roughly the same as that occupied by an FT232R component and its ancillary circuitry, so we can consider board space to be a wash. The difference in current drain should also be negligible.

The FT232R FTDI USB-to-UART interface costs about $4. The UART RXD and TXD lines will still be needed for the Linkbus, so there is no impact to port pin count by adding the FTDI part.

It does appear from the above analysis that the BOM cost could be reduced by ~$2.50 by using a firmware-only USB bootloader instead of the FT232R FTDI USB-to-UART interface. Potential savings could be more if the project were to move to a more capable processor (more flash and port pins) for reasons unrelated to USB bootloading support, since doing so might eliminate the need for a port expander.

Bottom Line

From a pure BOM cost standpoint, going with a USB bootloader would likely result in a net savings greater than $2, and perhaps more than $4 if circumstances result in the needed processor port pins being available.

The USB firmware-only bootloader would require allocating an additional 1k of flash to the bootloader, and it is unclear right now whether the project can afford that.

There are non-recurring costs, such as software development time, testing and debugging, and schedule impact to consider. But the option to use a firmware-only USB bootloader solution should be kept in mind as we look for ways to optimize the design for cost savings.

Other Considerations

Although the USB firmware-only bootloader could replace the UART-based bootloader for uploading new software, it would not replace the UART for serial communications. Both the Linkbus and PC control functions are needed during normal device operation, not just during bootloading. The bootloader runs at start-up only, so USB Bootloader or not, we will continue to need the FTDI chip, or an FTDI cable, in the receiver and transmitter applications.

Leave a Reply