how to get started with stm32f103

Post here first, or if you can't find a relevant section!
nr4ps
Posts: 6
Joined: Sun Oct 30, 2022 7:20 pm

how to get started with stm32f103

Post by nr4ps »

Hello,

I have STM32F103C8T6 board and ST-Link v2 device from https://www.aliexpress.us/item/22518326 ... _shipto=US

I am very confused on how to get started programming it. I would like to be able to use the Arduino IDE and program it over USB like I would with an Arduino Nano or Uno.

I have used ST-Link to install hid_generic_pc13.bin over ST-Link V2. After putting the boot0 jumper back to 0 and plugging it into the USB port instead of ST-Link V2 device, the blue LED starts blinking rapidly. I thought this means it is ready to be programmed, but when I try to set up top connect the Arduino IDE there is no port discovered.

I have added the STM32 boards using https://github.com/stm32duino/BoardMana ... index.json. I previously tried the other rogerclarkmelbourne one, but I think that is older?

I've tried unplugging it and plugging it back in. I've tried resetting it. I've tried putting a 1.5K resistor between 3.3V and A12.

Arduino IDE v 2.0.1
Windows 10

I don't understand how to get started. Can anyone help?
GonzoG
Posts: 403
Joined: Wed Jan 15, 2020 11:30 am
Answers: 26
Location: Prudnik, Poland

Re: how to get started with stm32f103

Post by GonzoG »

If LED blinks fast, it means that board is in bootloader mode and it's ready to flash sketch. There won't be a COM port.

You'll see COM port only if you flash sketch with USB CDC enabled.
nr4ps
Posts: 6
Joined: Sun Oct 30, 2022 7:20 pm

Re: how to get started with stm32f103

Post by nr4ps »

GonzoG wrote: Mon Oct 31, 2022 12:58 am If LED blinks fast, it means that board is in bootloader mode and it's ready to flash sketch. There won't be a COM port.

You'll see COM port only if you flash sketch with USB CDC enabled.
Thank you for your response. USB is set to CDC. I do not understand hopw to flash the sketch.
Capture3.JPG
Capture3.JPG (77.62 KiB) Viewed 1713 times
Capture4.JPG
Capture4.JPG (68.29 KiB) Viewed 1713 times
Capture5.JPG
Capture5.JPG (76.35 KiB) Viewed 1713 times
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: how to get started with stm32f103

Post by ag123 »

select STM32 CubeProgrammer SWD if you are using st-link v2 dongle.
this (using st-link v2) is one of the 'easier' way to program a stm32f103 blue pill. you need to connect the wires correctly between st-link and the stm32f103 board, then simply flash away. if you use any other means e.g. usb-uart dongle, you may need to set boot0 jumper etc.
you can leave it connected till you decide not to program it further.

a common next step is to program a custom 'boot loader' using the same st-link on it. But first figure out how to flash a device properly using st-link.
there is 'less complication' compared to using a custom boot loader. with st-link your firmware is the main/only firmware on the device and it sits at the start of flash 0x8000000 on the device.
GonzoG
Posts: 403
Joined: Wed Jan 15, 2020 11:30 am
Answers: 26
Location: Prudnik, Poland

Re: how to get started with stm32f103

Post by GonzoG »

Use Arduino IDE 1.8. It works.
2.0 still has some bugs and some older tools does not work with 2.0.
nr4ps
Posts: 6
Joined: Sun Oct 30, 2022 7:20 pm

Re: how to get started with stm32f103

Post by nr4ps »

Thank you for the suggestions. I have switched to Arduino IDE 1.8 and set the upload method to STLink. I am able to upload a sketch to make the LED flash. I have to move the boot jumper back and forth for the sketch to persist across resets, but that is progress!

But Arduino 1.8 does not have any options regarding USB in the tools menu. How can I use Serial and view the device's output on Serial Monitor? It says "Board at COM7 is not available" whether I am plugged in through STLink or USB port.

Thank you for your help and your patience.
Capture.PNG
Capture.PNG (30.25 KiB) Viewed 1670 times
GonzoG
Posts: 403
Joined: Wed Jan 15, 2020 11:30 am
Answers: 26
Location: Prudnik, Poland

Re: how to get started with stm32f103

Post by GonzoG »

Those are settings for Roger's (Maple) core not STM core.
Install STM core: https://github.com/stm32duino/wiki/wiki/Getting-Started

Then flash HID bootloader and you will be able to upload with USB.
nr4ps
Posts: 6
Joined: Sun Oct 30, 2022 7:20 pm

Re: how to get started with stm32f103

Post by nr4ps »

Thanks. I've gone back and forth enough times that I get mixed up. But using the STM core and enabling USB CDC as shown I still cannot get a COM port to show up after I program it via STLink, switch the boot0 jumper back to 0, disconnect STLink, and connect USB cable. It's looking for a COM7 port that doesn't exist. (I also tried flashing the hid bootloader again as suggested, but I can't program it over the USB connection because "the selected serial port > Finish
does not exist or your board is not connected")
Capture2.PNG
Capture2.PNG (58.03 KiB) Viewed 1636 times
nr4ps
Posts: 6
Joined: Sun Oct 30, 2022 7:20 pm

Re: how to get started with stm32f103

Post by nr4ps »

Oh dear... Seems someone else (see below) couldn't get USB to work on boards purchased from a similar-named store. That doesn't bode well. I'll try contacting the seller. In the mean time, if anyone has any thoughts on narrowing down the root of the issue please let me know. I don't have a proper oscilloscope (just one of those 200 kHz toy scopes) so I can't check the 8 MHz crystal. Thanks for trying, everyone.

viewtopic.php?t=1046
dannyf
Posts: 446
Joined: Sat Jul 04, 2020 7:46 pm

Re: how to get started with stm32f103

Post by dannyf »

the ide will create a hex file. what about using the st link utility to upload it to the chip vs. swd?
Post Reply

Return to “General discussion”