How to program multiple STM32Fs on same PCB
If hardware design is done correctly and assuming UART is used for programming, the steps would be roughly as follows:
- The main CPU resets a selected MCU.
- The CPU then brings the required BOOT pins to an appropriate state and releases the reset.
- The MCU bootloader starts and waits for data to come in on the appropriate UART line.
- The CPU send the binary data over the UART and resets the MCU when done.
- The MCU runs with a new firmware.
Here's an image showing bootloader selection for STM32F10xxx parts:
The same steps would be repeated for each MCU.
The main processor can be updated in numerous ways, but it usually goes like so:
- Firmware is downloaded into a local storage (FLASH, RAM, SD Card etc.)
- The CPU reboots and the bootloader discovers the upgrade code.
- The CPU bootloader reads the data, checks that the binary is valid and programs the appropriate FLASH sectors.
- The CPU reboots itself again and loads with the new firmware.
Update.
Based on your current hardware, you'd have to execute the bootloader by jumping to the appropriate memory address (see page 20 of AN2606). I don't know a great deal about this, but your hardware designer should be able to figure it out. Not having the control of the reset line is a bit of an oversight though.
I suspect you need to load the AM5718 firmware via JTAG, however I'm not far too familiar with this CPU family.
The STM32 (like many other ARM CPU's these days) have a ROM bootloader built in by ST. On some STM32 series this is done by holding BOOT0 pin high during reset. To boot your normal program you need to hold the pin low. This however is conveniently not always in the datasheet, but often in the user manual.
The ST bootloader often supports several protocols, and UART is a very common one. Not all UARTs or pin locations on the STM32 chip are supported though - so you need to choose the serial port pins. This document is very helpful if you can find the right family.
The procedure Armandas describes is correct. If you have some spare pins on your AM5718 CPU you could automate the activation of ST's bootloader via software. This does cost some GPIO pins on the CPU - in theory 1 additional reset line for every CPU added. You may also need to consider how your board will boot-up in this setup while the AM5718 is not completely running.
A little caveat: on some STM32 parts the ROM bootloader is turned off once you enable read protection. You can still access the chip via JTAG (after erase), but not via the bootloader. Additionally if you cannot make the automated activation seem fit in hardware, you may need to do it manually via jumpers & a paper procedure. This however is only practical to do in the factory - it is not a very field serviceable solution.
Both reasons may steer you towards an in-house bootloader which can be activated via a serial command. It also adds the advantage of 'protecting' of your firmware images via encryption, given that you handle decryption inside the bootloader itself.
If all parts are JTAG-compliant, and are all in the same power domain (or otherwise in a state that guarantees chain integrity), you can construct a scan chain and use that to hit each part in turn.
However, it sounds like the project is done and you're in management :), so I think the UART option is the best route. To be clear, each STM has its own UART to the large processor, or do they share (which is a bit odd...)? If the latter, as the other posters said, you'll need one GPIO per to select who is active.