Skip to main content
dchen
Associate III
January 24, 2023
Solved

How to add new folders and get them compiled in CubeIDE?

Hi,

I am trying to add new folders in CubeIDE and get them compiled.

Taking STM32CubeU5 as an example.

I imported a GPIO example, under the file tree, it will show:

--include

--Application

--Startup

--User

--Drivers

--BSP

--CMSIS

--STM32U5xx_HAL_Driver

Now, what I want to do is to change the folders under Application folder:

--Application

--api

--inc

--src

--test

--inc

--src (contains main.c)

In order to make this structure work, how do I modify the project settings?

Thank you for the help

This topic has been closed for replies.
HCohe.1
HCohe.1Best answer
Associate III
February 7, 2023

Your Makefile will need to include compiler options to include debugging information in the .o and .elf files and will also want to disable or reduce compiler optimizations. Here's a snippet that I used:

# debug build?
DEBUG ?= yes
# optimization
ifeq ($(DEBUG),yes)
OPT = -O0 -ggdb3 -gdwarf
else
OPT = -Os
endif

4 replies

dchen
dchenAuthor
Associate III
January 24, 2023

Also I have a working project, and would like to import it into CubeIDE by the option"Existing Code as Makefile Project". How do I configure it so that I can use ST-Link for debugging?

Pavel A.
January 24, 2023

Please see the CubeIDE User manual (UM2609) ch. 3.8. This will create new makefile-based Eclipse project and let you debug the executable produced by your makefile.

HCohe.1
HCohe.1Best answer
Associate III
February 7, 2023

Your Makefile will need to include compiler options to include debugging information in the .o and .elf files and will also want to disable or reduce compiler optimizations. Here's a snippet that I used:

# debug build?
DEBUG ?= yes
# optimization
ifeq ($(DEBUG),yes)
OPT = -O0 -ggdb3 -gdwarf
else
OPT = -Os
endif

JMala.3
Associate III
February 7, 2023

The easy method is to add the folders outside the IDE, and once you have the structure you want, just right click on the project in project explorer, select refresh and the newly added files will be added to your project