ivmarkov / rust-esp32-std-demo

Rust on ESP32 STD demo app. A demo STD binary crate for the ESP32[XX] and ESP-IDF, which connects to WiFi, Ethernet, drives a small HTTP server and draws on a LED screen.
Apache License 2.0
784 stars 105 forks source link

sdkconfig files ignored #99

Closed karlri closed 11 months ago

karlri commented 2 years ago

I tried building on Windows and the stack always overflows after drawing text with feature ttgo. I tried cargo clean; cargo +esp build --release to no avail. CONFIG_ESP_MAIN_TASK_STACK_SIZE=20000 is set in sdkconfig.defaults and I tried duplicating it in sdkconfig.defaults.esp32, again clean and build but still no luck, still overflows, I also tried doubling that value, same result. Eventually I suspected that it's ignored.

I tested if the files actually get picked up by checking the stack size at runtime and as suspected, it's too small:

if esp_idf_sys::CONFIG_MAIN_TASK_STACK_SIZE < 20000 {
    error!("stack too small: {} bail!", esp_idf_sys::CONFIG_MAIN_TASK_STACK_SIZE);
    return Ok(());
}

Prints the idf-sdk default value: E (296) rust_esp32_std_demo: stack too small: 3584 bail!

The only non-standard conf I have is that I've set the following env var: $Env:CARGO_TARGET_DIR="C:/espt/" Because It's the only way I could get the paths short enogh to not get CMake build errors about path length. Perhaps that could be the cause. Any ideas?

karlri commented 2 years ago

I tried copying the sdkconfig files to C:/ and indeed that works, so I suppose they are assumed to be in target/.. I'll leave this open as the problem with path lengths causes this in the first place. Perhaps the problem with path length could be fixed somehow or perhaps it's possible to modify the build process to sdkconfig files are searched for in the project root rathet than target/..

xMAC94x commented 2 years ago

Hi i can reproduce this bug on linux too, is there any workaround to set the MAIN_TASK_STACK_SIZE on linux ?

ivmarkov commented 2 years ago

Hi i can reproduce this bug on linux too, is there any workaround to set the MAIN_TASK_STACK_SIZE on linux ?

Yes, just place your sdkconfig.defaults file in the parent directory of your target directory. Unless you've overridden the target directory with CARGO_TARGET_DIR as the original poster did, the parent of your target directory is the binary crate directory itself.

xMAC94x commented 2 years ago

i can confirm that unset CARGO_TARGET_DIR worked. i couldn't get it to work with one

Stenodyon commented 1 year ago

I'd like to add that if your binary is part of a cargo workspace, the sdkconfig.defaults file has to be in the root directory of the workspace and not of the binary (found that out through trial and error).

ivmarkov commented 11 months ago

I'd like to add that if your binary is part of a cargo workspace, the sdkconfig.defaults file has to be in the root directory of the workspace and not of the binary (found that out through trial and error).

That's true and that's usually the culprit.

kellerkindt commented 8 months ago

Just for forgetful people like me, digging up old projects which do not work anymore due to "ignored sdkconfig.defaults": Don't forget, that in .cargo/config.toml one can set funny things, such as:

[env]
ESP_IDF_VERSION = { value = "release/v4.4" }
ESP_IDF_TOOLS_INSTALL_DIR = {value = "global"}
ESP_IDF_SDKCONFIG_DEFAULTS = { value = "/path/to/sdkconfig.defaults" }
# or
# ESP_IDF_SDKCONFIG_DEFAULTS = { value = "sdkconfig.defaults", relative = true }