Showing results for 
Search instead for 
Did you mean: 

Use CubeProgrammer as UART Mode

in mozbek we trust
Associate II

Hey there,

i want to reach my flash memory through UART. I can do this with ST-Link device but now i want to do it with UART. I use STM32F091CC MCU and as datasheet says i configured the UART pins(PA9-PA10) as Asynchronus UART in CubeMX.

My baud rate is 9600 bits/s- word legth 8bits - parity - even and stop bit is 1.

In boot mode configuration. I try to use all configurations but i cannot reach the flash memory.

I coded all options(set and clear bitss) in main.c program and when i click connect button in cube programmer it gives me an error like that:

Please help me how to solve this problem.



i programmed option bytes and check with debug mode with my IDE. 0690X000006CJj6QAG.png

Results looks OK(and power off/on reset after program to be sure). But cube programmer still makes an error.

Let me share my other options maybe i make a mistake when set uart options.



Clock Conf:


uart confs:


Please share me if you any mistakes

Just to be sure to understand - if device boots to system bootloader then your firmware is not running and it not depends what firmware is programmed into device (device can be empty). The embedded system bootloader (firmware in system memory) runs after reset and it configures the UART according the specification (AN2606) - bootloader then communicates with the host (computer connected to UART) by commands for read/write/erase operations. So - firmware is not important - the firmware cannot run because system bootloader is running. If your firmware is running then the boot mode is not correctly set - please check.

I am now not sure if current version of CubeProgrammer supports UART connection to your STM32F091 device. I will check if STM32F091 is supported through UART in current version (check documentation for CubeProgrammer what devices are supported).

From hardware point of view: between computer and the device must be direct UART link: so some RS232 converter to 3V levels. On STM32F091 device must be there connection to its UART pins (RxD, TxD) which are supported in system bootloader (see AN2606 for STM32F091 pins supported by bootloader).

It seems your option bytes setting is correct and the bootloader should run after device reset. Baudrate is automatically detected by bootloader - so host can use any baudrate (for example 9600 baud).

Hey igor,

i am sure device is not empty there is some data in its memory (i can show you when connect with the st-link)


When UART option firmware is not running. You told me embedded system bootloader runs after reset. I have no reset button i short circuit my reset pin then click connect with uart maybe problem is there what do you think about it?

Did you check cube prog supports stmf091 uart? Same problem occur in "Flash Loader Demonstrator Program in ST"

You told me to PC and device shoul connect directly i use ST CVT100 RS232 Converter between MOXA and Device because of the voltage levels

maybe i should not use that ?

Please try to use "Flash Loader Demonstrator" - it should work correctly with embedded bootloader.

Just program correctly option bytes, set BOOT0 pin to high level, then re-power the device and then connect to device by UART using "Flash Loader Demonstrator". Use supported UART pins according AN2606 application note.

This should work.

No it does not work. My BOOT0 pin is connected PF11. i write this code for boot mode

 if(HAL_GPIO_ReadPin( GPIOF, GPIO_PIN_11) == 1)





I programmed this code to my device via stlink then i close all reset my device.

Then i pulled high my boot0 pin and power on/off my device.

I open flash loader demonstrator then try to connect uart and my uart pins are supported uart pins according an2006.

What is inside device is not important - please erase the device and program only option bytes by STlink. Please don't load any code inside (there is risk that your code incorrectly programs back option bytes).

Do you have experiences with bootloader? Because the mistake can be in more objects: RS232 converter, option bytes setting, BOOT0 pin level, software setting (Flash loader demonstrator), ... . Why do you want to use USART connection with bootloader? For starting is good to use STlink. The bootloader is good to use in final application.

Yes i am experienced with bootloader in st devices and my project end and it is final application i want to independent with stlink. I just create a new project that includes only uart configuration and still same error.

-i trust rs232 converter because i can use it with terminal program and check with oscillator signals are received and transmitted.

-Option bytes settings are system memory mode with nBOOT1 =1 boot0 pin pulled high - boot_sel = 1 nboot0 = x

-Where should i code option bytes? User code begin1 - user code begin init or user code begin sysinit.

When i see the peripheral examples in stm32f091cc flash example includes :

FLASH_Unlock() and FLASH_OB_Unlock() function should i code that in my project?

D you have any suggestion to me.

I think i code wrong place in code. When BOOT0 is enable my main code does not work as expected. I write selection byte codes into main function. I think i have to code it in the another place. Where should i code

I tried to use STM32F091 with UART connection and STM32CubeProgrammer. I used UART pins PA2 and PA3. I used Nucleo board with integrated USB to UART virtual COM port (VCP). Connection is correct - no problem. See attached screenshots: see there given UART configuration, option bytes configuration (I just set externally BOOT0 pin to VDD), device memory is empty (no code inside). Please check this configuration in your side.

0690X000006CKuPQAW.png 0690X000006CKuUQAW.png