Page 1 of 2

STM32 ports not visible

Posted: Tue Jun 11, 2024 9:52 am
by criz
Few weeks back I bought a STM32F103C6T6A Board from an online vendor.When I first connected it to the laptop using a microusb cable,onboard led was blinking.I was only starting on the STM32 boards so I didn't know it doesn't come with a bootloader installed.Instead of using STLink, I decided to upload a bootloader to it using usb to ttl converter and upload code via a micro usb cable.However I didn't have a usb to ttl converter with me then.But I did have a raspberry pi from one of my friends.So I followed this youtube tutorial and uploaded a bootloader to the STM32 board(https://youtu.be/tCcxFMU1OFE?si=o91atYOOTsJs_8eu).After that the onboard led stop blinking.So I assumed the bootloader got installed.But when I connected the stm32 to computer and used an arduino ide to program it,the port were not visible.When I checked the windows device manager the port is not even being recognized there.So I assumed may be it is because the required drivers are not installed in the system.So I installed maple drivers for stm32 from github(https://github.com/rogerclarkmelbourne/ ... stallation).I followed before mentioned github page for driver installation.But even after that the ports were not visible.Later I bought a usb to ttl converter and installed bootloader on the stm32 using it.Then also the ports were not visible.So what's wrong in my method.What should I do to get the drivers installed in windows and get the ports visible.Or should I use a STLink to program STM32.

Re: STM32 ports not visible

Posted: Tue Jun 11, 2024 9:31 pm
by GonzoG
COM port is not visible because there is no COM port until you upload program that has COM port enabled.
Those bootloaders (maple bootloader and HID bootloader) do not use COM port for upload. They detect board by specific ID. COM port is needed only to reset board from Arduino IDE and enter bootloader.
You can boot into bootloader manually using boot pins.

Re: STM32 ports not visible

Posted: Wed Jun 12, 2024 4:30 am
by ag123
you need to install a sketch as like

Code: Select all

void setup() {
	Serial.begin();
	while(!Serial); // optional, wait for host to connect
	pinMode(LED_BUILTIN, OUTPUT); 
}

#define CR '\r'
#define LF '\n'

void loop() {
	Serial.println("hello world");
	if(Serial.available()) {
		int16_t c = Serial.read();
		while( c != CR || c != LF ) { // look for CR or LF
			Serial.print(c);
			c = Serial.read();
		}
	}
	delay(500);
	digitalWrite(LED_BUILTIN, ! digitalRead(LED_BUILTIN)); // blink the led
}

Re: STM32 ports not visible

Posted: Thu Jun 13, 2024 12:00 pm
by criz
ag123 wrote: Wed Jun 12, 2024 4:30 am you need to install a sketch as like

Code: Select all

void setup() {
	Serial.begin();
	while(!Serial); // optional, wait for host to connect
	pinMode(LED_BUILTIN, OUTPUT); 
}

#define CR '\r'
#define LF '\n'

void loop() {
	Serial.println("hello world");
	if(Serial.available()) {
		int16_t c = Serial.read();
		while( c != CR || c != LF ) { // look for CR or LF
			Serial.print(c);
			c = Serial.read();
		}
	}
	delay(500);
	digitalWrite(LED_BUILTIN, ! digitalRead(LED_BUILTIN)); // blink the led
}
How do I install a sketch to stm32 when there is no port available.How should I do this?Can you explain?Is it by USB to TTL converter I used to upload the bootloader?

Re: STM32 ports not visible

Posted: Thu Jun 13, 2024 12:55 pm
by STM32ardui
criz wrote: Thu Jun 13, 2024 12:00 pm How do I install a sketch to stm32 when there is no port available.
ST Link V2 connected to SWD interface.

Re: STM32 ports not visible

Posted: Thu Jun 13, 2024 2:09 pm
by criz
GonzoG wrote: Tue Jun 11, 2024 9:31 pm COM port is not visible because there is no COM port until you upload program that has COM port enabled.
Those bootloaders (maple bootloader and HID bootloader) do not use COM port for upload. They detect board by specific ID. COM port is needed only to reset board from Arduino IDE and enter bootloader.
You can boot into bootloader manually using boot pins.
Can you explain this?What should I do?

Re: STM32 ports not visible

Posted: Thu Jun 13, 2024 3:36 pm
by criz
STM32ardui wrote: Thu Jun 13, 2024 12:55 pm
criz wrote: Thu Jun 13, 2024 12:00 pm How do I install a sketch to stm32 when there is no port available.
ST Link V2 connected to SWD interface.
Is there any way to do it with usb to ttl converter.

Re: STM32 ports not visible

Posted: Thu Jun 13, 2024 4:19 pm
by STM32ardui
criz wrote: Thu Jun 13, 2024 3:36 pm Is there any way to do it with usb to ttl converter.
A STM32 board should have an interface with 4 pins: VCC, SWDIO, SWCLK, GND. There you can connect a ST Link V2. I'm using the actual package, not the old one of Roger Clark!

If you want to use an USB/TTL-connector, you need to know, on which pins UART1 is located.
Each STM32 chip should have a set of pins, which can be used alternatively as UART1 - if there is already a program on your board, how can you know, to which pins that program assigned UART1 or if RX/TX are still on default pins?

And you have to set your board into boot mode. For a BluePill or BlackPill it's easy done by the jumpers or the buttons. On modern boards it may not be possible, because they have so called "option bytes".


BTW:
COM or communication port is a serial interface at your PC. Nowadays you don't have D-sub connectors anymore at your PC and you use an USB socket. Your BluePill-board don't have a COM port, it has serial interfaces UART1, UART2 etc. At minimum you have to connect RX/TX to an USB/Serial-adapter. And inside a program you have to use Serial.begin() to open UART1, before you send data to this serial interface. If you have a connection to PC, you can receive data in terminal program via a COM port.
But such a COM port has nothing to do with your STM32-board. And UART1 exists even if you program don't open and send data to it.

In the moment you connect an USB/Serial-adpater via USB-cable to your PC, you will see in Device Manager a new COM port - you don't have to connect on the other side a STM32-board!

Re: STM32 ports not visible

Posted: Thu Jun 13, 2024 5:04 pm
by GonzoG
criz wrote: Thu Jun 13, 2024 2:09 pm
GonzoG wrote: Tue Jun 11, 2024 9:31 pm COM port is not visible because there is no COM port until you upload program that has COM port enabled.
Those bootloaders (maple bootloader and HID bootloader) do not use COM port for upload. They detect board by specific ID. COM port is needed only to reset board from Arduino IDE and enter bootloader.
You can boot into bootloader manually using boot pins.
Can you explain this?What should I do?
No COM port needed.
Reset board into USB bootloader (using boot pins), select correct upload method in arduino IDE, upload sketch.

Re: STM32 ports not visible

Posted: Thu Jun 13, 2024 5:51 pm
by ag123
criz wrote: Thu Jun 13, 2024 12:00 pm How do I install a sketch to stm32 when there is no port available.How should I do this?Can you explain?Is it by USB to TTL converter I used to upload the bootloader?
a few things, stm32f103c6t6 has very little sram and flash
https://www.st.com/en/microcontrollers- ... 103c6.html
Memories
16 or 32 Kbytes of Flash memory
6 or 10 Kbytes of SRAM
to run stm32duino in this size, it is normally 'for experts', i.e. newbies may very well struggle trying even to use it. Either *run out of sram* (this is invisible, it just crash, no signal no nothing) or flash, when you try to install anythiing, you get an error for not enough flash. Quite often you may be able to squeeze a 'blink' sketch into a small chip, but for anything 'real' you quickly run out of memory / flash.

stm32f103xx requires st-link v2 dongle
https://www.adafruit.com/product/2548
https://www.st.com/en/development-tools/st-link-v2.html
or a usb-uart (serial) dongle to program it, you cannot simply connect a usb cable and program it.

Advise is:
get something like:
https://github.com/stm32duino/Arduino_C ... -64-boards
STM32F401RE Nucleo F401RE
STM32F411RE Nucleo F411RE
or
Adafruit Feather STM32F405 Express 512k sram 1 MB flash, high performance + lots of on chip peripherals
https://www.adafruit.com/product/4382
or at least
stm32f401/f411 ccu or ceu boards
https://stm32-base.org/boards/STM32F401 ... -V1.2.html
https://github.com/WeActStudio/WeActStu ... iSTM32F4x1

for more 'formal' boards, get those Nucleo boards
for a high performance board/chip, try that Adafruit Feather STM32F405 Express
for 'cheap and good' get stm32f401/f411 'black pill boards', but this has less 'support'

stm32f4xx can be programmed using a usb cable it has DFU (device firmware update) built-in on chip, so you only need a usb (phone) cable to connect and program it. And normally, to program it this way, you need to be able to set boot0 (pin or button) and reset (pin or button)
for the Nucleo boards, those are 'formal' (original boards from ST), they have a st-link v2 built-in on the board itself, so it'd always be able to program the chip.

for 'newbies' it is better to start wit the stm32f4xx (or even g4xx very new less support for now) series
reason:
- more sram
- more flash
- has 'art accelerator' (on chip cache), normally to run from flash it may take like 3-8 wait states, if there is 'art accelerator' (on chip cache) and the code is in cache, it becomes 0 wait state, so if that instruction takes 1 cpu cycle to run, and cpu clock is 100 Mhz, you get 100 Mips (100 million instructions per seconds) no loss, no slower. that practically means all 'existing' chips are possibly 3-8 times slower running from flash without 'art accelerator', though it depends on the code being in cache to get 0 wait state.
^ but in short stm32f4xx is faster for the same hz vs say stm32f1xx or stm32f/g0xx
- has single precision FPU (this makes single precision maths like 5-10 or even much much more (100?) times faster fs stm32f103, stm32f030/g030 etc
this is especially if floating point maths say take 100 instructions to do that and if the fpu can do the same calc in 1 clock cycle in 1 instruction, that is 100 x faster (not always the case).
- and no less USB DFU (device firmware update) program simply using a usb (phone) cable (need to set boot0 and press reset)

And for all these benefits, the price of stm32f4xxg4xx is modestly higher vs stm32f103xx / f030xx
in short, newbies should start with a better chip/board if you don't want to be bogged down by tasks that need 'advanced' 'expert' level skills (in particular to deal with highly memory constrained e.g. 6 k sram and 32k flash) environment, just to program that microcontroller.

if you insist on stm32f103, get at least stm32f103c8 - 20k sram 64k flash or stm32f103cb 20k sram 128k flash
currently, it seemed for the price of stm32f103cb pill board, you can buy a stm32f401ccu 'pill board' in the online 'flea markets' e.g. Aliexpress
https://www.aliexpress.com/w/wholesale- ... 1ccu6.html
https://www.aliexpress.com/w/wholesale- ... 1ceu6.html
I'd simply choose stm32f401ccu
https://www.st.com/en/microcontrollers- ... 401cc.html
as this is 64k sram and 256k flash plus that art accelerator and FPU and USB DFU programming (only a phone usb cable is needed)