[I can’t squeeze any more acronyms into this title]

It’s probably very easy to setup an STM32F4 as a virtual com port (VCP) with the CubeMX software, but I’m getting old and new tricks are getting increasingly hard to learn, so I did it with the standard peripherals library (SPL). Here’s how:

Download the STM32 SPL USB OTG host and device library.

Unzip to somewhere. It should give you a directory like this:


Download the USB CDC VCP Loopback firmware and place the zip-file in the above directory and unzip.

Set the HSE-frequency in:


Modify this file:


Specifically line 98. Change the declaration of *pIf_DataTx from
uint16_t (*pIf_DataTx) (void);
uint16_t (*pIf_DataTx) (uint8_t* Buf, uint32_t Len);

You will of course need the gcc-arm-none-eabi compiler, and put it in your path, so add a line similar to this to .bashrc:

export PATH=/home/user/gcc-arm-none-eabi-4_9-2015q1/bin:$PATH

(of course change “/home/user” and the version number).

After that it should simply be a matter of entering the directory of the firmware and typing make.

Let me know if it’s not working for you..

ps. I realize there’s a more straighth-forward example in the project-directory of USB library, but I just couldn’t get it working.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.