Skip to content

Contributed by iiv, curated by Ai-Thinker

Hello everyone. As the title says, this is a sharing post. I'll share a problem I recently ran into and the solution I came up with, for everyone's reference!

I found that every time I use FreeRTOS, LVGL, etc., I have to copy the corresponding configuration file into the current project directory, which is very annoying. Then I have to add it in cmake as well — a whole bunch of operations, too troublesome. Later I thought of a method: for our own hobby projects, since the code isn't often shared with others, we can directly save the configuration files or some library files we write ourselves in one place, and call them like components. We just set(xxx 1) to enable whichever one we want. After some research, I found it works.

Flowchart:

If you already understand it, you can stop reading; it's very simple.

Steps:

1:

Create a new file in the bSP folder of the SDK to store our own library (doing it elsewhere works the same way; this location is cleaner and easier for us to manage).

2:

In cmake.txt, copy an entry referring to the one above, then fill in the path we want to include in the parentheses. Roughly speaking, this adds the folder to our project.

3:

This needs to be created manually; the cmake file name must be this, everything else can be customized.

4:

In cmake.txt, add the header files we want to include. Roughly: when we set(CONFIG_FREERTOS 1) in the project, it adds the FreeRTOS configuration file to the current project. To use FreeRTOS, we need to enable this component in our project's proj.conf: set(CONFIG_FREERTOS 1). We can judge exactly this condition; the same applies to others.

5:

This is where we store the configuration files. Copy them all in here; we can also add libraries we write ourselves.

OK, that's it. Enable whichever one we need in the project's configuration file. This way, we don't have to copy a file into our project every time we create a new project, and we save the operations of adding paths in Cmake and so on.

Have questions?

For other questions, please visit the unified discussion area: Ai-Thinker Discussions

Released under the MIT License. Build Time 2026-09-11 14:52:23