【RT-Thread】【ci】【scons】Using ci.attachconfig.yml with scons

4 min readApr 7, 2025

This article is contributed by alight.

Introduction

Have you ever encountered the following problem: you have enabled a certain feature, but due to compilation errors, you have to enter menuconfig to enable its dependency; or to enable a certain feature, you need to search for related options all over menuconfig, and sometimes you aren’t even sure how to correctly configure these features for a specific board.

To address these issues, we introduce the — attach feature of scons. By using the scons — attach command, you can quickly load pre-configured features (please note that these configurations have passed CI checks to ensure that compilation errors do not occur).

Practical Operation

Taking the RT-Spark (RT-Thread Spark -STM32F407 Embedded Learning and Development Board — AliExpress) development board as an example:

First, we need to check all the attachconfig options supported by the current BSP.


scons --attach=?

For example, if I want to quickly enable the configuration for the rw007 module, I can simply enter the following command in the terminal. This will enable rw007, and then I can compile using scons -j4.


scons --attach=peripheral.rw007

If I want to enable other features, I can repeat the above operation.

Finally, here is the command to restore the configuration.

scons --attach=default

When using the scons — attach=peripheral.rw007 command for the first time to enable the feature, it will automatically back up the current .config and rtconfig files. If you later need to restore the configuration, the system will revert the backed-up .config and rtconfig files to their state before the — attach command was used.

How to write attachconfig:

First, configure the desired options using menuconfig in the BSP (Board Support Package) that you just pulled.

After completing the configuration, press the d key to bring up the minimal configuration save page.

Press the Enter key again to save the current configuration.

Next, you will see a file named defconfig in the BSP directory. The contents of this file reflect the settings you just configured using menuconfig.

For example:

The line CONFIG_RT_USING_NANO=y indicates that I just enabled the nano configuration.

Then, locate the ci.attachconfig.yml file in the .ci/attachconfig directory of the current BSP.

For example, if I want to configure the attach for nano, I would add it to the attachconfig file in the following format.


nano:
kconfig:
- CONFIG_RT_USING_NANO=y

The <<: *scons is part of YAML syntax used to inherit the contents of another property.

The complete statement would look like this:

scons.args: &scons
scons_arg:
- '--strict'
nano:
<<: *scons
kconfig:
- CONFIG_RT_USING_NANO=y

Conclusion

I feel that attachconfig has great potential. It allows the menuconfig to retain the most basic configurations while placing more complex functional configurations into attachconfig. This not only ensures that the BSP obtained is a minimal system, but also maintains the flexibility of menuconfig, making system configurations more modular and easier to extend.

For lightweight development, use attachconfig, and for in-depth development, start from scratch with menuconfig.

In the future, it might be beneficial to create a graphical interface that categorizes functionalities, allowing each attach to be enabled through a checkbox.

Since this feature has just been introduced, most BSPs still do not have ready-to-use attachconfig, and some BSPs may not have attachconfig at all. Therefore, we still need everyone’s collaborative efforts to further refine and optimize it to ensure compatibility and usability across various projects.

This feature is only supported under ENV for RT-Thread.

--

--

RT-Thread IoT OS
RT-Thread IoT OS

Written by RT-Thread IoT OS

An Open-Source Community-Powered Real-Time Operating System (RTOS) Project! Let’s develop, DIY, create, share, and explore this new IoT World together!

No responses yet