1
\$\begingroup\$

I am currently designing a board for a STM32F102 chip which needs to be able to use the USB bus to transfer data while the chip is running. However I also want to be able to program the chip through usb while developing the software.

I want to make sure that while designing the board I wont do anything that makes this impossible later on, so I am asking for some clarification on some things.

First of all in accordance with the USB standard, because the STM32F1 supports full speed usb, I have a pull-up resistor on the D+ line.

Now, in order to boot from the main flash the boot0 pin must be logic 0, so I will connect that to a pull-down resistor on the board. In order to use the included bootloader (which I believe is what I need to program via usb) the boot0 pin must be logic 1 and the boot1 pin (which is a gpio however is an input on reset) should be logic 0.

Assuming I am understanding all of this information correctly, what would be the best way of going about being able to program the chip when a usb cable is plugged in? Can I use the usb V+ and GND to set the logic levels needed on the boot pin? or should I connect those to the boards V+ and GND and use a switch to set the boot pins accordingly?

If there is any other information required I'd be happy to help you understand what I need or am asking for better.

\$\endgroup\$
  • \$\begingroup\$ Consider looking at the schematics for the open source Arduino. It has the same USB functionality that you are looking for. With the USB, you can power it, program it and use it as a COM port. Between that schematic and the Arduino boot-loader, a lot of the work is done for you. It is worth a look. \$\endgroup\$ – Enemy Of the State Machine Aug 1 '14 at 4:32
  • \$\begingroup\$ Arduino uses an AVR, which does not give me the same troubles as the STM32 with the two Boot pins, however the STM32 is going to be a better fit for this project, so I am sticking with that. What to do with the two boot pins is my main trouble. \$\endgroup\$ – Nick Aug 1 '14 at 4:37
  • \$\begingroup\$ I'm not saying to use the Atmel uC, I'm just saying you could use the USB circuit design as a starting point. That and the bootloader would have to be ported to the STM32. Here is a "Arduino" using the STM32. It would have the exact functionality with USB that you want: emcu.it/ARDUINO-STM32/Arduino-and-STM32.html \$\endgroup\$ – Enemy Of the State Machine Aug 1 '14 at 4:55
  • \$\begingroup\$ Okay, i get what you are saying, i would still have trouble deciphering boot pin use but that link should be very helpful with that, thank you! \$\endgroup\$ – Nick Aug 1 '14 at 5:07
0
\$\begingroup\$

I have some bad news for you: the STM32F102 (and I suspect the STM32F1xx devices generally) don't have a USB bootloader, only a UART bootloader. You need an STM32F2xx or STM32F4xx to get a USB bootloader loaded into the system ROM image.

You have many alternatives, including:

  1. Use the UART bootloader, possibly with a USB-UART bridge IC like the FT232.
  2. Provide your own USB bootloader that you load in via some other mechanism.
  3. Use a JTAG/SWD programmer like the STLinkV2 (they're really cheap, but quite slow as far as JTAG goes). This is your best option because it means you can debug when coding.
\$\endgroup\$
  • \$\begingroup\$ STM32F3 generally has a USB bootloader as well, and may be only a few pins away from layout compatibility, though the programming interface to on-chip peripherals can be quite different. Definitley place a header for using a $10 discovery board as an SWD pod though - it's extremely handy. And a header for a UART for debug output when the software isn't working well enough to maintain USB. \$\endgroup\$ – Chris Stratton Aug 1 '14 at 12:07
  • \$\begingroup\$ Ah now I get why I was having trouble finding what I wanted, as long as usb can still be used for communication it is not a serious issue, thank you. \$\endgroup\$ – Nick Aug 1 '14 at 12:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.