Skip to main content
SA.17
Associate III
June 21, 2021
Question

How to not compile USB device ?

  • June 21, 2021
  • 1 reply
  • 644 views

Hi ,

I have added usb functionality in my code using stm32cubemx.

Now i don't want to compile it using #if or #ifdef

How to do it ?

I tried following:

I used #if to remove usb initializing function and not used usb in any code , but when i saw .map file still following files are getting compiled

usbd_conf.o

usbd_core.o

usbd_ctlreq.o

usbd_ioreq.o

This topic has been closed for replies.

1 reply

Paul1
Senior III
June 21, 2021

You would need to remove the files from linking,

exclude them in the project's file list.

Easier:

  • Copy ioc file (backup in case you want USB later, rename backup as ***_WithUSB.ioc)
  • Open in MX, disable/remove USB features, save project, regenerate code.
  • Build and check map file