2015-04-14 12:38 PM
In my application, I have a master chip and a slave chip, both identical STM32F407. From the master chip, I would like to flash the slave chip so that it has the exact same firmware as the master chip. From my understanding, this means cloning the contents of the flash onto the slave chip. (Right?) I do this with the following:
Any ideas? Many thanks.
2015-04-14 01:46 PM
I'd do a couple of things, I'd have code right at the ResetHandler entry to signal if it got there, perhaps set a GPIO/LED. I'd be very careful about being agnostic to reset conditions, the System Loader may call with the PLL running, perhaps even a WATCHDOG. Check the memory mapped at ZERO, and the vector table setting (SCB->VTOR)
What's the state of the BOOT0 pin when you do the GO?If I could get the GPIO/LED working in assembler, next I'd try configuring the clocks (HSI), gpio and usart in assembler to get a ''Hello World!'' type response. With a USART working I could push out whatever diagnostics I needed about the state of the chip, and the peripheral registers to understand why it couldn't get to SystemInit(), and later main().2015-04-14 03:09 PM
clive1, thanks for the response!
The BOOT0 pin is low (unconnected) during the GO command.My knowledge and skill with assembler on the STM32 is limited, so I may try a few other things before messing with ResetHandler.It seems like manually power cycling after programming instead of issuing the GO command may also yield something useful.Okay, off to try some more things. I'll report back if I find the issue.2015-04-22 09:51 AM
Tim:
I do this, but with F303, F100, and/or F051 parts as F407 slaves. I use two extra GPIO pins from the master for each slave beyond the TX and RX USART pins: -One F407 GPIO pin configured as Push-Pull drives the slaves BOOT0 pin (for safety, I also have a 22K to 0V connected to the BOOT0 pin). You never want the BOOT0 pin to float. -One F407 GPIO pin configured as Open Drain drives the slaves RESET pin (for normal slave reset functionality, I also have a 2.2K to Vdd connected to the RESET pin). Once I figured out the USART bootloader on the F303 did not function on the early date code parts, this has always been rock solid. -Patrick2015-04-23 07:32 PM
Patrick,
Thanks for the notes.I somehow missed needing a pulldown on BOOT0. Thank you for pointing that out. I'll have to fix that on the next rev. Regardless, that wasn't the issue here. Odd that it needs a pulldown if NRST can be left floating, but I'm sure someone smarter than me knows the reason.After going back through it, it seems that I miscalculated the length of the flash being used, so I was only partially programming the slave. This was easy to see when I used the ST-Link tool to compare HEX files on a reflashed slave versus the master. Once I fixed that, it all worked. :)For my config, I'll have up to 30 or so slaves and no extra GPIO pins, so I can't use any other pins. I'm using the USART1 stream to communicate between the masters and slaves. I use the 96-bit unique ID, an ADC channel, and some coding magic to identify each one individually. I really really wanted each slave to be absolutely identical in hardware and firmware for ease of use, but still need to differentiate each and be able to address them individually. Works well so far.Regards,Tim2015-04-27 10:28 AM
Tim:
Please keep in mind that NRST is not floating in any of the STM32Fxxx parts that I'm aware of. There is a weak pull-up resistor internally, so you can have a valid power-up reset event in most typical applications by just adding an external cap to 0V on the NRST pin. ''The NRST pin input driver uses CMOS technology. It is connected to a permanent pull-up resistor...'' Pull-up value is specified as roughly 40K +/- 10K and an external cap value of 0.1uF is suggested. I sometimes add an external NRST pull-up to my applications to help prevent application and environmental noise from falsely triggering the NRST line, as my applications are industrial, but this is not normally needed. In the case of a master controlling a slave's NRST, adding a series resistor between the master's GPIO pin and the slave's NRST pin, as well as retaining the slave's 0.1uF cap, helps protect the slave's NRST pin from any high speed pulses that might occur on the master's GPIO interface as ports are reconfigured. (Yes, one can mostly manage this by careful coding, but in a world of ''canned'' hardware abstraction layers, more programmers than ever are not directly coding GPIO ports.) This also can vastly reduce peak current flow (and thus noise) when the master GPIO interface discharges the slave's NRST capacitor. -Patrick