Skip to content

Kconfig for Marlin #27946

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: bugfix-2.1.x
Choose a base branch
from

Conversation

classicrocker883
Copy link
Contributor

@classicrocker883 classicrocker883 commented Jun 27, 2025

Description

Use KConfig for configurations

sudo apt install kconfig-frontends
-or use pip-
pip install kconfiglib

If you’re using Windows and Python 3.13 or earlier,
make sure windows-curses supports it.
Install with:
python3 -m pip install windows-curses

#27917

Usage:

  • make genkconfig to generate Kconfig/Kconfig_adv
  • To create the .config file and load Kconfig UI
    • make menukconfig for Configuration.h
    • make menukconfigadv for Configuration_adv.h
  • make writekconfig to generate Configuration.h/Configuration_adv.h for building firmware

Preliminary tests working

Needs work with additional #defines from config files.

Requirements

Benefits

Configurations

Related Issues

so far it works, except gives this warning

Kconfig_adv:11986:warning: multi-line strings not supported
Kconfig_adv:11996:warning: multi-line strings not supported
Kconfig_adv:12027:warning: multi-line strings not supported
Kconfig_adv:12069:warning: multi-line strings not supported
Kconfig_adv:12237:warning: multi-line strings not supported
Kconfig_adv:12247:warning: multi-line strings not supported

One main issue is when generating Kconfig_adv. This should take into account when things are enabled/disabled in Configuration.h, however some things are defined in Marlin/src/inc/Conditionals-6-type.h / MarlinConfig.h / MarlinConfigPre.h ect.

If we could find a way to incorporate things for example: such as HAS_MEDIA, which in Configuration_adv.h - #define SD_PROCEDURE_DEPTH 1 (and others) is in the same #if HAS_MEDIA block and enabled by, however, it is defined in Conditionals-1-LCD.h as so:

#if ENABLED(SDSUPPORT)
  #define HAS_MEDIA 1
#endif

So, basically, using the same code for Configuration.h it thinks things under that #if block are enabled|disabled (if it has #define | //#define) when it should "depend on" #if ENABLED(SDSUPPORT) / #define HAS_MEDIA 1

but there is no real way of knowing.

for anyone that is confused, like say if everything was combined into one Kconfig file. sure it might work fine for some things, but still wont for whatever is defined in other files.

I suppose we could arbitrarily set each one, and find a way for Kconfig_adv/Configuration_adv.h to link to Kconfig/Configuration.h, or make the code work flawlessly, or just redefine everything, or put those specifically defined in Configuration.h which lead into Configuration_adv.h as I was saying earlier and put those into another file.

@classicrocker883 classicrocker883 marked this pull request as ready for review June 29, 2025 05:57
rename kconfig.py to kconfig_gen.py
@thisiskeithb thisiskeithb linked an issue Jul 1, 2025 that may be closed by this pull request
@thinkyhead
Copy link
Member

thinkyhead commented Jul 19, 2025

One main issue is when generating Kconfig_adv. This should take into account when things are enabled/disabled in Configuration.h, however some things are defined in Marlin/src/inc/Conditionals-6-type.h / MarlinConfig.h / MarlinConfigPre.h ect.

You can study how I did it in https://github.com/MarlinFirmware/AutoBuildMarlin/blob/master/abm/js/schema.js … which is used to load and parse the data by https://github.com/MarlinFirmware/AutoBuildMarlin/blob/master/abm/editor.js

@classicrocker883
Copy link
Contributor Author

classicrocker883 commented Jul 26, 2025

well I suppose for now what I was able to do was make it work for Configuration_adv.h (make menukconfigadv) except I am currently having trouble getting options which happen to be disabled to stay as an option to choose from.
for instance:
from Configuration_adv.h

#if TEMP_SENSOR_0 == 1000
  #define HOTEND0_PULLUP_RESISTOR_OHMS    4700 // Pullup resistor
  #define HOTEND0_RESISTANCE_25C_OHMS   100000 // Resistance at 25C
  #define HOTEND0_BETA                    3950 // Beta value
  #define HOTEND0_SH_C_COEFF                 0 // Steinhart-Hart C coefficient
#endif

if TEMP_SENSOR_0 != 1000, these HOTEND0_ #define's get completely omitted from the Kconfig menu as an option (instead of being able to choose from) and set to disabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FR] Use KConfig as configuration source
2 participants