Can someone check if this concept is sound? Programming multiple MCUs

Hi all,

This topic is an extension of a previous question I asked(Programming multiple ATMegas from one Arduino/FTDI? - Microcontrollers - Arduino Forum), but I've come up with a plan and I would love some input on if the concept is sound. I am, frankly, still very new to this, and I may be missing some obvious things. This is a combination of a few suggestions I received in the last thread, and some research on various ideas, so I could see me missing something obvious.

My goal is to be able to selectively program multiple MCUs from one USB connection. The inspiration for this idea came from the 16 arduino processor satellite, with supervisor, that was linked to in the last thread.

On the hardware side:
USB runs into ATMega16U2.
ATMega16U2 RX/TX run to the inputs of two demux with latches (I have seen some online, but I would love a recommendation if anyone has one in particular).
Demux run to a "Traffic controller" MCU, as well as all the MCUs to be programmed.
"Traffic controller" is connected to the selectors on both demux chips.
Resets of all MCU's, including "traffic controller" are tied together.

Software side:

  1. "Traffic controller" MCU selects itself as the output target from the demux chips on start.
  2. Java program interfaces with serial, allowing communication to the "traffic controller"
  3. Java program instructs "traffic controller" on which device it wishes to update.
  4. "Traffic controller" sets demuxes to point to the given device. Serial communication ends with "traffic controller"
  5. Java program calls AVR dude from command line to upload whatever sketch is to be sent.
  6. AVR dude updates target MCU.
  7. On reset, all MCUs receive reset and "traffic controller" boots, triggering it to return to step 1.

Again, I'm new, and this is advanced for me, but is the logic there? Are there corrections that would need to be made? Is there a better way to accomplish this that does not require physical switches?

Thanks!

Depending on the code space available, I would program all units with the same code. Then a hardwired input or an EEPROM setting tells each unit which function to perform.

Jiggy Ninja already suggested something like this on your other thread

I know you wanted to have multiple programmers working on this but give them each their own file with a very simple main sketch which calls the separate files:

#define EEPROM_UNIT_ADDRESS 0
uint8_t unitType = 0xFF;
void setup() {
  unitType = EEPROM.read(EEPROM_UNIT_ADDRESS );
}
void loop() {
  switch (unitType) {
    case 0xFF:
      //unprogrammed EEPROM will be FF, so this should prompt the user to enter the unit type over serial
      //assuming all devices have a working serial at some point in their life cycle
      pleaseEnterUnitType();
    break;
    case 1: 
      displayLoop();
    break;
    case 2:
      thingyLoop();
    break;
    case 3:
      somethingElseLoop();
    break;
    default:
      pleaseEnterUnitType();
    break;
  }
}

Hi Morgan,

I appreciate the feedback. As far as I understood, Jiggy Ninja was giving me a method for error checking the success of programming out multiple sketches to different locations. I might have misunderstood though!

Either way, I appreciate your feedback. I'm not sure that would work for my application due to the likely size of the software running on some of the components, but I appreciate the fresh view!

Thanks!