2021-02-17 03:47 AM
Hi,
I design a custom USB - UART using STM32F042F6
This is my schematic
This is pin configuration in Cube MX
This is the board layout
When connect by USB cable, win10 pc recognized it as DFU device without problem.
I tried STLINK Utility to just connect to the device in attempt to flash the program, it failed
I tried combination of speeds and MCU reset options but nothing worked.
When I tried to flash the fw directly from STM32CubeIDE
I even tried DfuSe Demo tool to force the MCU to leave DFU mode but still couldn't connect to SWD.
My last resort is to use DFU mode and DFU utility to upload the fw, but I don't know how to compile into *.dfu file.
I can flash fw on STM32F051 and STM32F303 directly from CubeIDE without problem. I can flash fw from STLINK utility as well. That is with Just with 2 pin SWDIO and SWCLK from the MCU connect to ST-Link V2 dongle. I am not sure if I need NRST to hook up to ST-Link. I don't need it on my custom STM32F051K8T6 board (this MCU doesn't has USB hardware). I'll try to hook a small wire to NRST later.
The second problem is when I change the USB device type in cubeMX into "Virtual Com Port"
It became overflowed.
When turned on USART2 in cubeMX, now the flash became too big as well.
This STM32F042F6 has 6k of ram and 32k of flash.
There is a similar project that utilises this MCU as a USB-UART dongle, but this project is done using PlatformIO.
https://github.com/manuelbl/usb-serial
I probably can reuse the code of that project but I still cannot program the MCU.
I ran out of ideas. Any help is appreciated.
Thanks,
2021-02-18 01:49 AM
For now I am able to get a simple app to toggle 2 LEDs on my board and upload the program over DFU.
Pin#1 or PB8 does act as BOOT0. Set to LOW to run user application, and HIGH to run built-in bootloader (auto run DFU mode when USB detected)
Still unable to debug or program this MCU via SWD.