Skip to content
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

hint about stack space #147

Open
Narukara opened this issue Mar 4, 2023 · 5 comments
Open

hint about stack space #147

Narukara opened this issue Mar 4, 2023 · 5 comments

Comments

@Narukara
Copy link
Contributor

Narukara commented Mar 4, 2023

I suggest adding a hint somewhere in the book that in this environment, threads have very limited stack space. So you may often encounter stack overflow problems. The stack size can be specified in this way:

thread::Builder::new().stack_size(4096).spawn(|| {
    // do something
})?;
@gavincabbage
Copy link

Just starting the training and I found I needed to increase the system event task's stack size to get any the hardware-check example to work, otherwise I saw this error:

***ERROR*** A stack overflow in task sys_evt has been detected.

I added this line to sdkconfig.defaults after eventually finding this documentation:

CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=9216

It took me a while to piece this together so some hints for new users in the training materials themselves would be helpful for the next person struggling with this issue.

@SergioGasquez
Copy link
Member

to

Just starting the training and I found I needed to increase the system event task's stack size to get any the hardware-check example to work, otherwise I saw this error:

***ERROR*** A stack overflow in task sys_evt has been detected.

I added this line to sdkconfig.defaults after eventually finding this documentation:

CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=9216

It took me a while to piece this together so some hints for new users in the training materials themselves would be helpful for the next person struggling with this issue.

Which devkit were you using?

@gavincabbage
Copy link

gavincabbage commented May 17, 2023

@SergioGasquez I apologize I'm not sure how to answer your question , but here are the contents of the config files that hopefully include the info you're looking for:

cat .cargo/config.toml
[build]
target = "xtensa-esp32-espidf"

[target.xtensa-esp32-espidf]
linker = "ldproxy"
runner = "espflash --monitor"
# Future - necessary for the experimental "native build" of esp-idf-sys with ESP32C3
# See also https://github.com/ivmarkov/embuild/issues/16
rustflags = ["-C", "default-linker-libraries"]

[unstable]
build-std = ["std", "panic_abort"]
build-std-features = ["panic_immediate_abort"]

[env]
# Enables the esp-idf-sys "native" build feature (`cargo build --features native`) to build against ESP-IDF (v4.4.4)
ESP_IDF_VERSION = { value = "tag:v4.4.4" }

# These configurations will pick up your custom "sdkconfig.release", "sdkconfig.debug" or "sdkconfig.defaults[.*]" files
# that you might put in the root of the project
# The easiest way to generate a full "sdkconfig[.release|debug]" configuration (as opposed to manually enabling only the necessary flags via "sdkconfig.defaults[.*]"
# is by running "cargo pio espidf menuconfig" (that is, if using the pio builder)
#ESP_IDF_SDKCONFIG = { value = "./sdkconfig.release", relative = true }
#ESP_IDF_SDKCONFIG = { value = "./sdkconfig.debug", relative = true }
ESP_IDF_SDKCONFIG_DEFAULTS = { value = "./sdkconfig.defaults", relative = true }
# ESP-IDF will be installed in ~/.espressif so it can be reused across the different examples.
# See also https://github.com/esp-rs/esp-idf-sys#esp_idf_tools_install_dir-esp_idf_tools_install_dir
ESP_IDF_TOOLS_INSTALL_DIR = { value = "global" }

cat rust-toolchain.toml
[toolchain]
channel = "esp"

cat sdkconfig.defaults
# Rust often needs a bit of an extra main task stack size compared to C (the default is 3K)
CONFIG_ESP_MAIN_TASK_STACK_SIZE=14336
CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=9216

This setup is working for me as of a few days ago so I'll be continuing through the training materials soon.

@SergioGasquez
Copy link
Member

I see you are using an ESP32, do you know the name of the development board that you are using?

@gavincabbage
Copy link

Yes! It is a FireBeetle 2 from DFRobot.

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

No branches or pull requests

3 participants