cancel
Showing results for 
Search instead for 
Did you mean: 

Control multiple STM32 simultaneusly

ATZ99
Associate II

Goodmorning,

I am tying to understand the following case:

I've got two STM32F4 both connected to a usb hub, this hub is then connected to my pc. Is there a way to select the micro in which I need to load my firmware? I am not able to solve this out.

Thank you!

18 REPLIES 18

https://learn.microsoft.com/en-us/windows-hardware/drivers/usbcon/communicating-with-a-usb-device

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

got it, thank you so much!

@ATZ99​ Without ST-LINK? Do you mean that STM32 will function as USB device and connect to a PC? The best option is to provide your own "USB serial numbers" in your firmware.

If you want to use the built-in ST bootloader, then it does not expose the "USB serial number" IIRC. Windows can handle multiple devices without "serial numbers", attached to hubs or not. You definitely don't want any kind of driver or other Windows voodoo unless there's a specific requirement.

@Pavel A.​  When I mentioned without st-link I meant downloading the firmware using only the rx and tx pins of the micro, directly overwriting of the old firmware using the built-in bootloader.

Now, I can't really figure out the serial number question at this point, can you try to get me an example?

Imagine we got two different stm32 with two main stand-alone firmwares which are running and doing whatever they need. These two micros are connected to an USB hub (let's keep the hub as example) with the rx and tx pins of the micros (so using just the two data pins of USB). After some time, I decided to update a part of the code in micros1, so I stop the micros, and I put them in the condition to load a new firmware through the built in bootloader, now from the PC I connect to the hub and I upload the firmware only on micros1 using some IDE which permits to chose the target.

This is the ideal situation which is running in my mind. Jumping over the motivation of such a complication, I'm wondering if it is even possible, because online I cannot find nothing so usefull to solved it out.

The key point in your plot is how to restart the device and force it to activate the built-in bootloader. It can be easier and just overall better to implement the update in your own firmware (which will have your own descriptors).

Windows does not have in-box driver for DFU class, so some voodoo will be needed to attach the winusb driver to the built-in bootloader. But this is doable.

I think that for the purpose I'm ready to develop the sort of vodoo circuit which could be able to restart the device and to activate the built-in bootloader, or at least try to do it. While when you say "It can be easier and just overall better to implement the update in your own firmware (which will have your own descriptors)"do you mean the classical way of handling one micros at time, don't you?

You are definitely getting my vison way more clear. It remains my last doubt, when will be created that voodoo circuit needed, do you think that the PC could recognise different devices, or I need for sure some circuit able to perform a sort of multiplexing with the device letting see from the PC just one device at time?

> do you mean the classical way of handling one micros at time, don't you?

Not at all. Windows can handle all attached USB devices at once, but your question was how to select a specific device? The "serial number" is the classical way for this.

By voodoo I meant the "filter drivers" and tricks with driver signing and certificates, that one can find in google. These things are powerful and can lead to trouble /*in unlucky hands*/

Not a circuit. You can add a USB function (as in a composite device) thru which your app can send the magic command to restart in update mode, or even to push new firmware in background.

You may also want to find a consultant to help with design of firmware update and subtle details of USB interface, and let you focus on what matters more to you project.

You do seem to randomly commingle a whole bunch of ideas/concepts.

USB doesn't have RX,TX pins it has D+/D- pins the interface works in one direction at a time, using the two wires as a differential pair.

USB typically identifies unique devices by serial numbers, such that you can find/address a specific device.

On the USB Host side you can determine which ports a device is attached too.

You could load software on your USB devices to model their behaviour.

If you are programming the devices, and have the ability to read/write the MCU's memory space you could presumably query the UNIQUE ID ST burns into every device at production time.

Similarly a USB Device could use this unique number to compute its own serial number.

Perhaps master USB at some level

Write some USB Device code

Use the USB DFU mode of the STM32 System Loader

Use the USB DFU examples to create a user/flash based implementation

Write some PC side application software to communicate with USB Devices via the USB Host of the PC

Write some Windows Filter Drivers, understand how they fit into the USB Stack, and how they can interact with applications.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
ATZ99
Associate II

It is a new side of uC's for me, so I am trying to put together some ideas and some informations picked up during university courses.

It seems that I have lots of gaps to fill, starting from that voodoo of @Pavel A.​ which I have totally misunderstood thinking about a circuit. I think as last question I would ask if you have any suggestion to where find a good explanation of all the materials, like some books, or some online courses.

Thank you for the help