Provide sdkconfig with sketch

RobMeades
Posts: 85
Joined: Thu Nov 29, 2018 1:12 pm

Provide sdkconfig with sketch

Postby RobMeades » Fri Oct 01, 2021 2:12 pm

I have a sketch which requires more main task stack, i.e. I want to override CONFIG_ESP_MAIN_TASK_STACK_SIZE to be 8192 rather than 4096.

I want to do that for this specific sketch, I do not want to change the global value in the main sdkconfig file.

Is there a way to either (a) provide a specific sdkconfig file with this sketch or (b) override the value of CONFIG_ESP_MAIN_TASK_STACK_SIZE from the command-line (I am using arduino-cli for my builds)?

ESP_Sprite
Posts: 9730
Joined: Thu Nov 26, 2015 4:08 am

Re: Provide sdkconfig with sketch

Postby ESP_Sprite » Sat Oct 02, 2021 4:29 am

I don't think it's overridable in Arduino, but a workaround would be to use the main task to simply start up a new 'main' task that does the actual work, then use vTaskDelete to kill the original main task. As you start the new 'main' task yourself, you can specify the amount of stack it uses.

RobMeades
Posts: 85
Joined: Thu Nov 29, 2018 1:12 pm

Re: Provide sdkconfig with sketch

Postby RobMeades » Sat Oct 02, 2021 9:01 am

Understood, that's what I was going to do, just seems a bit of a shame to have to do it that way. I was wondering if I could put a copy of sdkconfig.h somewhere inside the application directory which would be picked in preference to the default.

ullixesp
Posts: 83
Joined: Wed Oct 16, 2019 9:34 am
Location: Germany

Re: Provide sdkconfig with sketch

Postby ullixesp » Sat Oct 02, 2021 2:23 pm

I struggled with the same stack size problem posted here: https://community.platformio.org/t/how- ... e/22769/18

But since I am on Platformio (highly recommended over Arduino!) the solution is easy. Simply add:

Code: Select all

build_flags =
    	-D CONFIG_ARDUINO_LOOP_STACK_SIZE=33333
to pio's config file "platformio.ini".

Since this config is activated first before the sdkconfig is called, you need to add this to the sdkconfig:

Code: Select all

    
#ifndef CONFIG_ARDUINO_LOOP_STACK_SIZE
#define CONFIG_ARDUINO_LOOP_STACK_SIZE 8192
#endif
With my ESP32 the default size is 8096.

RobMeades
Posts: 85
Joined: Thu Nov 29, 2018 1:12 pm

Re: Provide sdkconfig with sketch

Postby RobMeades » Sat Oct 02, 2021 3:07 pm

Oh no, another wrapper to get us closer to what we had before with Make and CMake :-)!

That's an interesting suggestion but unfortunately the reason we're adding support for Arduino is because we have one or more customers that use the Arduino IDE, and I guess wouldn't want to switch to using PlatformIO on top instead. In other words we're only contributing "driver" code, we aren't able to control what is above us. Since we're actually using arduino-cli for our testing we could pass a build flag in that way, as you have done, but of course we'd need to modify the single global sdkconfig as you have described and, again, that is really our customer's thing, it's not "ours", IYSWIM.

Personally it seems like Arduino makes things easier for anyone who doesn't know much about software but only for about 6 months: after 6 months they will find that they need the things that might have seemed complicated at first, which Arduino doesn't offer, and will end up having to switch to something rather more normal. Much better to bite the bullet and be normal from the outset. Easy for me to say of course...

RobMeades
Posts: 85
Joined: Thu Nov 29, 2018 1:12 pm

Re: Provide sdkconfig with sketch

Postby RobMeades » Mon Oct 04, 2021 8:36 pm

It appears that adopting @ESP_Sprite's solution is the best way forward, this one can be considered resolved.

Who is online

Users browsing this forum: Majestic-12 [Bot] and 86 guests