The more I fiddled with it, the more confused I became. I'll just dump a bunch of info and thoughts here in case it's useful for anyone who finds this thread or can point out where I'm going wrong...
What I noticed was that the custom "CONFIG_ULP_COPROC_RESERVE_MEM" seemed to have no effect *within* the ulp_process_macros_and_load scope.
I edited ulp.h to print debug output like printf("ULP Mem in ulp.h: %d",CONFIG_ULP_COPROC_RESERVE_MEM);
Then with code that looked something like this:
Code: Select all
#include "sdkconfig.h" //with CONFIG_ULP_COPROC_RESERVE_MEM set to 1024, for example
...
printf("ULP Mem in main app: %d",CONFIG_ULP_COPROC_RESERVE_MEM);
...
ulp_process_macros_and_load(...parameters...); //in which it also prints the debug output mentioned earlier
...
printf("ULP Mem in main app: %d",CONFIG_ULP_COPROC_RESERVE_MEM);
...
My output was something like this:
Code: Select all
ULP Mem in main app: 1024
ULP Mem in ulp.h: 512
ULP Mem in main app: 1024
So the sdkconfig.h is definitely being loaded, but it's as if the ulp.h is compiled *before* the custom CONFIG_ULP_COPROC_RESERVE_MEM is defined (ie. before sdkconfig.h is included) and/or it redefines it at some point back to the default 512.
This also explained why I was able to load the program with what I thought was a fixed version as noted in my earlier comment. I actually had copied that function into a new class I had made. I realise now that what was actually happening was that it was simply using the custom value because it was within my app 'scope', not the underlying framework where the value remains the 512 default.
I'm still a little too new to this to know if it's something I'm doing wrong or if there's an issue somewhere (and I only just made the switch to PlatformIO).
Other things: I can see in the value being used here:
https://github.com/espressif/arduino-es ... p32_out.ld
but here it's hardcoded as 512 (still shouldn't affect the definition though):
https://github.com/espressif/arduino-es ... p32_out.ld
I tried random things like different sizes, sprinkling "include sdkconfig.h" all over the place to make sure that was being loaded before it was needed. Unsurprisingly, no benefit.
Anyway, if you want a workaround you can either copy the function into your code, or just edit the function to skip the size check for now. It will load and run fine, it will just overflow into RTC slow memory so you'll need to manually write and read from the actual offset if you're using it (eg. anything with IRAM_DATA_ATTR). (Eventually, I just found another way to cram more work into 128 words so the ULP program fits in the default allocation.) That's all for now.