How to communicate with stm32 through the DP and DM pins? - Page 1
Forum section: electronics / general

author: teslinius
author_rank: Regular Contributor
timestamp: May 31, 2022, 06:03:17 pm
content: So i have a circuit with stm32f103rc and i connected micro usb connector like it's on the schematic, so d+ on dp and d- on dm like i found it's done in reference schematics, but what now?, when i connect it to pc it doesn't detect it on the arduino ide nor if i run lsblk in the terminal, do i have to set the boot jumpers differently currently i have boot0 to 1 and boot1 to 0.

author: bson
author_rank: Unknown
timestamp: May 31, 2022, 06:24:56 pm
content: You seem to not have connected the detection pin. You need to bring it down from 5V to 3.3V as well.

author: DavidAlfa
author_rank: Super Contributor
timestamp: May 31, 2022, 06:25:30 pm
content: Detected how? Are you trying to connect to the bootloader?F1 series don't have USB bootloader, use UART.If you're trying to make something with the USB in the firmware, you have to implement it.

author: pcprogrammer
author_rank: Super Contributor
timestamp: May 31, 2022, 06:32:12 pm
content: DavidAlfa beat me to the punchYou are booting system memory with your setting and that gives you the ability to load new firmware via USART1.When you like to have DFU on the F103 you can try this project:https://github.com/davidgfnet/stm32-dfu-bootloaderbut you need to incorporate it in your own code too if you want to repeatedly reprogram via DFU.To use the USB port of the F103 series take a look at my bare metal implementation of a CH340 emulation:https://github.com/pecostm32/STM32F103C8_USB_CH340The detection pin mentioned by bson is not needed. It is just a software thing.Edit: The connectivity line devices in the F1 series do support DFU, but these are the F105 and F107 series.

author: bson
author_rank: Unknown
timestamp: May 31, 2022, 06:42:26 pm
content: I'm pretty sure the ST-supplied boot loader has USB support. Obviously for anything else it needs firmware support, but the OEM boot loader can be used to install that.

author: pcprogrammer
author_rank: Super Contributor
timestamp: May 31, 2022, 06:54:56 pm
content: Unless ST changed their setup for the F1 series it is only via USART1 in the low, medium and high density devices.Attached is a screen cap from RM0008 the F1 series reference manual.

author: DavidAlfa
author_rank: Super Contributor
timestamp: May 31, 2022, 07:55:50 pm
content: Quote from: bson on May 31, 2022, 06:42:26 pmDon't be so sure and checkAN2606You'll find the bootloader in 10x series have no USB support, only UART1, except 105 and 107.

author: teslinius
author_rank: Regular Contributor
timestamp: May 31, 2022, 10:16:02 pm
content: So basically i want to use it like an arduino, just without the ch340 or ftdi ft232 chip, i saw a few articles on how to do that with the bluepill, also saw the schematic of it and it also uses dp and dm pins on the micro usb port. So the internal built in bootloader doesn't support this, i have to upload a different one?Recommendations bootloaders for stm32f103rct6?

author: teslinius
author_rank: Regular Contributor
timestamp: May 31, 2022, 10:17:20 pm
content: From which datasheet is that?The one i have doesn't have any of this info

author: DavidAlfa
author_rank: Super Contributor
timestamp: May 31, 2022, 10:25:27 pm
content: Everything is here:https://www.electronicshub.org/how-to-upload-stm32f103c8t6-usb-bootloader/

author: westfw
author_rank: Super Contributor
timestamp: May 31, 2022, 10:55:55 pm
content: The key point is that a microcontroller with USB support needs to contain a relatively substantial amount of software running on it before a PC will recognize it as some sort of device.This can be the user application (with a USB Library), a user-provided bootloader (like the Arduino bootloaders), or on SOME chips (not the STM32F10x series) a bootloader that the manufacturer has put in ROM.

author: pcprogrammer
author_rank: Super Contributor
timestamp: June 01, 2022, 04:46:51 am
content: Quote from: teslinius on May 31, 2022, 10:17:20 pmIt is not the datasheet it is the reference manual. This manual holds the information about all the peripherals on register level. The datasheet just provides a summery of the peripherals in the device, pin-outs and the electrical characteristics.All the manuals for the F103 series can be found here:https://www.st.com/en/microcontrollers-microprocessors/stm32f103.html#documentationThere are application notes on specific topics that might be of interest. Also programming manuals with information about the ARM Cortex and the FLASH memory.

author: pcprogrammer
author_rank: Super Contributor
timestamp: June 01, 2022, 04:59:38 am
content: Quote from: teslinius on May 31, 2022, 10:16:02 pmBare in mind that with the "Arduino" bootloader in the FLASH of the MCU you always have to use the Arduino IDE to do your development on. When uploading it takes care not to overwrite the bootloader and also during compilation it will use the correct addresses. It also means that on startup there is a delay before your code starts. It will first go into the bootloader and check if there is a request for programming. After that it jumps into your own code.When you create code outside of the Arduino IDE and don't take care of reserving space for where the bootloader lives it will overwrite the bootloader and can no longer be programmed via USB. You either have to switch back to system memory startup and reprogram via USART1 or use the ST-Link with SWD connection.The later is how I work with the STM32 devices. Bare metal programming and upload and debug via ST-Link with SWD. Way more control then with Arduino, although it might do debugging now. Have not checked the Arduino evolution for a while

author: westfw
author_rank: Super Contributor
timestamp: June 01, 2022, 09:32:52 am
content: Quotenonsense. It's easy enough to modify the build procedure for pretty much any other IDE or build environment to "know" enough about the bootloader to work just fine.

author: boyddotee
author_rank: Contributor
timestamp: June 10, 2022, 04:46:00 pm
content: Quote from: westfw on June 01, 2022, 09:32:52 amJust to elaborate for anyone not aware. Essentially a bootloader will execute it's code then go to/jump to a predefined location in memory. As long as you do not program over the bootloader and start programming your new code at this jump point the bootloader will still work.Not sure it can be specified under Arduino (As it's meant to be a easy entry for electronics ), but all professional grade IDEs/Programming Tools I've used allow you to specify the start address for programming.