1

I'm designing a custom dual-uC board, where I want there to be two Arduinos both running different programs - kind of dual core arduino. In order to load new programs onto the uCs, yes, I could have two USB ports each connected to one of the uCs (say a ATmega32u4). But I'm trying to work out strategies with just one USB port (and no usb-hub).

Also, I don't need the USB functionality for general use, only for program updates.

Option 1:

Switch access to each USB capable Arduino (e.g. ATmega32U). Program one uC, toggle switch, program other uC

EDIT: this is fine, however I ideally want to use zero additional end-user buttons - I want the end-user to do as little as possible.

Option 2:

The arduino UNO has two devices, ATmega16U2 and a ATmega328. During normal operation the 16U operates as a usb-to-serial. However, I'm aware that there are custom firmwares that allow different functionality (such as USB-Joystick etc) - it is possible to switch firmawares between a custom-firmware and default firmware, to allow the ATmega328 to be programmed normally but also to run the custom program. But it seems that Arduino.h doesn't support the ATmega16U2, so I would have to program this device using the AVR or another framework.

Alternatively, the ATmega32U4 is supported by Arduino.h but there doesn't seem to be Arduino usb-serial 'firmware' for the 32U (only the 8U & 16U)

Option 3:

Can I use a ATmega32u4 with Arduino-ISP programming an ATmega328p?

EDIT: above seems valid: https://petervanhoyweghen.wordpress.com/2012/09/16/arduinoisp-on-the-leonardo/

Other simple recommended approaches?

EDIT: the firmware update should be physically as hands off as possible, as to be used by end-user, and preference for solutions that require zero additional buttons/etc

UPDATE:

I tried the Arduino as ISP method (option 3), and it works

2
  • Since you don't need USB cable for general use, I strongly recommend 1) as it is very simple. But if you do need it after code has been uploaded, then things get complicated........ Commented Apr 20, 2015 at 16:07
  • You should be able to get the ATMega16u2 to work with the IDE relatively simple. I'd suggest option 1, but I'd add some headers for an external USB-to-Serial adapter. That way you don't require chips with usb support (cheaper). Either add two headers, one for each chip. Or add a triple pole, double throw switch (TX,RX,DTR). Or DPDT if you don't mind both chips resetting (which would actually be a nice feature).
    – Gerben
    Commented Apr 20, 2015 at 16:19

2 Answers 2

1

Provided that you are okay with producing a customized PC side tool (which you would probably want anyway for user convenience) automated target selection should be far superior to manual.

You should be able to use one ATmega16u2 with a minimally customized firmware as a front end to program two distinct ATmega328p's. This could be as simple as selecting the target based on the baud rate, having it hold the de-selected one in reset the whole time, and using some resistors on the shared TX lines for safety. Last I checked the stock firmware used a soft serial at some rates, and that can be put on different pins, so it could be another way to de-conflict and select targets.

Your idea of using a 32u4 both as a functional part and as a buddy-programmer for another part is perfectly valid too - you can do that programming to a serial bootloader (it should be a simple matter to port the 16u2 firmware, or find another example), or via the ISP pins.

Now that I think about it, there's been a version of this question here before, as I remember writing about an idea for using two ATmega328p's permanently wired to a stock USB-serial, but with their bootloaders customized to use unique baud rates, and a little logic added so that on reset each would leave its serial TX pin tristated if it didn't detect bootloader traffic at its individually unique baudrate, thus allowing the other to be programmed without interference.

1

Option 1 using three header pins and a jumper wouldn't take up much board space, is simple to implement, and easy to use. Even easier if the jumper has a handle.

Pins & jumper enter image description here

4
  • You'd need two set of these. One for D+ and one for D-. I'd suggest a DPDT switch.
    – Gerben
    Commented Apr 20, 2015 at 16:22
  • Header pins and jumper for what ? Commented Apr 20, 2015 at 16:48
  • Rx & Tx from the USB->Serail converter, for which two sets will be needed as @Gerben points out, to Rx & Tx of one or the other of the '328s.
    – JRobert
    Commented Apr 20, 2015 at 16:53
  • 1
    this is fine, however I want this to be idiot proof
    – Chendy
    Commented Apr 20, 2015 at 16:54

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.