-
Notifications
You must be signed in to change notification settings - Fork 149
register esp-idf kconfigs as rustc cfg attributes #378
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y | ||
| CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y | ||
|
|
||
| # Examples often require a larger than the default stack size for the main thread and for the sysloop event task. | ||
| CONFIG_ESP_TIMER_TASK_STACK_SIZE=4096 # Necessary when the `embassy-time-driver` feature is enabled | ||
| CONFIG_ESP_MAIN_TASK_STACK_SIZE=20000 | ||
| CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=8192 | ||
| CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT=8192 | ||
|
|
||
| # Go figure... | ||
| CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=4096 | ||
|
|
||
| # Enable WS support | ||
| CONFIG_HTTPD_WS_SUPPORT=y | ||
|
|
||
| # SPI Ethernet demo | ||
| CONFIG_ETH_SPI_ETHERNET_DM9051=y | ||
| CONFIG_ETH_SPI_ETHERNET_W5500=y | ||
| CONFIG_ETH_SPI_ETHERNET_KSZ8851SNL=y | ||
|
|
||
| # We don't have an example for classic BT - yet - we need to enable class BT | ||
| # specifically to workaround this bug in ESP IDF v5.2 (fixed in ESP IDF v5.2.1+): | ||
| # https://github.com/espressif/esp-idf/issues/13113 | ||
| CONFIG_BT_CLASSIC_ENABLED=y | ||
|
|
||
| # BLE with Bluedroid | ||
| CONFIG_BT_ENABLED=y | ||
| CONFIG_BT_BLUEDROID_ENABLED=y | ||
| CONFIG_BTDM_CTRL_MODE_BLE_ONLY=y | ||
| CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY=n | ||
| CONFIG_BTDM_CTRL_MODE_BTDM=n | ||
| CONFIG_BT_BLE_42_FEATURES_SUPPORTED=y | ||
| CONFIG_BT_BLE_50_FEATURES_SUPPORTED=n | ||
| CONFIG_BT_BTC_TASK_STACK_SIZE=15000 | ||
| CONFIG_BT_BLE_DYNAMIC_ENV_MEMORY=y | ||
|
|
||
| # Support for TLS with a pre-shared key. | ||
| CONFIG_ESP_TLS_PSK_VERIFICATION=y | ||
|
|
||
| CONFIG_LWIP_PPP_SUPPORT=y | ||
| CONFIG_LWIP_SLIP_SUPPORT=y | ||
|
|
||
| # Generic Thread functionality | ||
| CONFIG_OPENTHREAD_ENABLED=y | ||
|
|
||
| # Thread Border Router | ||
| CONFIG_OPENTHREAD_BORDER_ROUTER=y | ||
|
|
||
| # These are also necessary for the Joiner feature | ||
| CONFIG_MBEDTLS_CMAC_C=y | ||
| CONFIG_MBEDTLS_SSL_PROTO_DTLS=y | ||
| CONFIG_MBEDTLS_KEY_EXCHANGE_ECJPAKE=y | ||
| CONFIG_MBEDTLS_ECJPAKE_C=y | ||
|
|
||
| # Border Router again, LWIP | ||
| CONFIG_LWIP_IPV6_NUM_ADDRESSES=12 | ||
| CONFIG_LWIP_NETIF_STATUS_CALLBACK=y | ||
| CONFIG_LWIP_IPV6_FORWARD=y | ||
| CONFIG_LWIP_MULTICAST_PING=y | ||
| CONFIG_LWIP_NETIF_STATUS_CALLBACK=y | ||
| CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT=y | ||
| CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT=y | ||
| CONFIG_LWIP_HOOK_IP6_INPUT_CUSTOM=y | ||
| CONFIG_LWIP_HOOK_IP6_SELECT_SRC_ADDR_CUSTOM=y | ||
| CONFIG_LWIP_IPV6_AUTOCONFIG=y | ||
| CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=4096 | ||
|
|
||
| # Border Router again, mDNS | ||
| CONFIG_MDNS_MULTIPLE_INSTANCE=y | ||
|
|
||
| # Littlefs on SD cards example | ||
| CONFIG_LITTLEFS_SDMMC_SUPPORT=y | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # Examples often require a larger than the default stack size for the main thread and for the sysloop event task. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto? |
||
| CONFIG_ESP_TIMER_TASK_STACK_SIZE=4096 # Necessary when the `embassy-time-driver` feature is enabled | ||
| CONFIG_ESP_MAIN_TASK_STACK_SIZE=50000 | ||
|
|
||
| # BT-HCI only ( tested for esp32c3) - they may have different names on xtensa modems with dual stack bt | ||
| CONFIG_BT_ENABLED=y | ||
|
|
||
| CONFIG_BT_BLUEDROID_ENABLED=n | ||
| CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY=n | ||
| CONFIG_BTDM_CTRL_MODE_BTDM=n | ||
| CONFIG_BTDM_CTRL_MODE_BLE_ONLY=y | ||
|
|
||
| CONFIG_BT_CONTROLLER_ONLY=y | ||
| #CONFIG_BT_CONTROLLER_ENABLED=y | ||
| #CONFIG_BT_CTRL_HCI_MODE_VHCI=y | ||
| CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY=n | ||
| # following are only needed in flash only mode, and then the bt_config struct also needs to set the following values | ||
| #CONFIG_BT_CTRL_BLE_SCAN=y | ||
| #CONFIG_BT_CTRL_BLE_MASTER=y | ||
|
|
||
| CONFIG_BT_HCI_LOG_DEBUG_EN=y | ||
| CONFIG_LOG_DEFAULT_LEVEL_INFO=y | ||
| CONFIG_LOG_MAXIMUM_LEVEL_VERBOSE=y | ||
|
|
||
| CONFIG_APP_REPRODUCIBLE_BUILD=y # by not using it in bt_classic.defaults we get the compile_time_date for free | ||
| #CONFIG_APP_COMPILE_TIME_DATE=y # if CONFIG_APP_REPRODUCIBLE_BUILD this is always false | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,8 @@ use embuild::{bindgen as bindgen_utils, build, cargo, kconfig, path_buf}; | |
| mod common; | ||
| mod config; | ||
|
|
||
| mod rust_cfg; | ||
|
|
||
| // Features `native` and `pio` control whether the build is performed using the "native" ESP IDF CMake-based build, | ||
| // or via the PlatformIO `espressif32` module. They work as follows: | ||
| // - If neither the `native` nor the `pio` feature is specified, native build would be used | ||
|
|
@@ -194,6 +196,29 @@ fn main() -> anyhow::Result<()> { | |
| cfg_args.propagate(); | ||
| cfg_args.output(); | ||
|
|
||
| // Collect all valid esp-idf version git tags. | ||
| // Allowes for compile time verification of cfg attributes. | ||
| // | ||
| // Collection is done out of band using the generate_cfg.sh script. | ||
| #[cfg(feature = "__collect_git_tags")] | ||
| { | ||
| rust_cfg::collect_git_tags(); | ||
| } | ||
|
|
||
| // Collect all cfg attributes from the build system and register them as known rustc cfg attributes. | ||
| // | ||
| // This is limited to what the current run's sdkconfig will enable. Thats why we run this out of band for | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This sounds like a non-starter then? As in, we need an sdkconfig that is listing ALL possible configs. Wow. But if we go this route, we can just as well list ALL possible configs from ALL ESP-IDF versions and for ALL MCUs. And if we do the above, we need a single such file, and we don't have to run any build then, as well have everything already listed in this file? So, are you 100% sure, that iterating the kconfig data in the build.rs really only gives you those sdkconfig settings which are "enabled" (qurious also what this means for config values which are not boolean)? If yes, I'm starting to wonder if there is no better way to approach the whole problem. Like parsing the kconfig files themselves. There might even be some python tooling that might be doing this already, in ESP-IDF?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might be of interest: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/kconfig/configuration_structure.html The "kconfig parsing" alternative I'm talking about would be basically iterating all components in the esp-idf source tree, as well as all user-provided components and parsing their kconfig files, so as to gather all possible options. My point is some of this parsing code is likely to already exist as a python code in the esp-idf source tree. After all, |
||
| // all possible targets, and a variety of sdkconfig files enabling different kind of esp-idf feature sets. | ||
| // | ||
| // Collection is is done out of band using the generate_cfg.sh script. | ||
| #[cfg(feature = "__collect_cfg")] | ||
| { | ||
| rust_cfg::collect_cfg_args(cfg_args.args.iter().cloned()); | ||
| } | ||
|
|
||
| // Register every collected esp-idf config as a rustc cfg attribute. | ||
| rust_cfg::emit_check_cfg(); | ||
|
|
||
| // In case other crates need to have access to the ESP-IDF C headers | ||
| build_output.cincl_args.propagate(); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this specialized sdkconfig necessary?