some insight about the stack i am using
1. PopOs 22.04
2. Vs Code
3. ESP-Idf V4.4
4. ESP32 Wroom-32D 16MB
The Problem:
I am trying to share a structure between two tasks. both are running on individual cpu cores. and the esp32 crashes with different errors.
Details About the tasks:
Task 1 running on cpu 0
Stack size is (1024 * 5)
Priority is 19
This task is intended to talk with a machine which is constantly communicating with the esp32 at every 25mS, i cannot put any longer delays in the task else the communication timing with the machine would not be maintained. with that i have had to even forcefully feed the task watchdog so it does not reset the CPU.
the task watchdog code i am using
- TIMERG0.wdt_wprotect = TIMG_WDT_WKEY_VALUE;
- TIMERG0.wdt_feed = 1;
- TIMERG0.wdt_wprotect = 0;
What Did I try?
Plan 1.
initial plan was to use the esp_event_loop library and i did the setting according to the documentation and made an individual task for the event loop to run on the CPU1, The reason why i did not try to run the event loop on the CPU 0 is because anything i do on CPU0 with a lower priority than my uart task, it would not go to attain it.
The problem with plan one:
Everytime when i would call the following function
- ESP_ERROR_CHECK(esp_event_post_to(mdbEventLoopHandler,
- ESP_MDB_EVENT,
- MDB_EVENT_ERROR,
- &mdbRuntimeFlags,
- sizeof(mdbRuntimeFlags_t),
- 1));
1. Heap memory error
2. spinLockError
3. portTickEnterCritical error
I did try to add delay to the esp event post but still it did not work.
Plan 2:
i tried to use queue to send the structure.
- xQueueSend(mdbSenderQueueHandler, &mdbRuntimeFlags, 1 / portTICK_PERIOD_MS);
with again different set of errors none being constant.
below is the latest error which i have received at the time of writing this post.
Code: Select all
assert failed: spinlock_acquire spinlock.h:122 (result == core_id || result == SPINLOCK_FREE)
The last plan was to go in the 8-Bit controllers style. where i could make a get function and it would simply return the structure when it would
be called by the main loop. more like the following.
- mdbRuntimeFlags_t getMdbFlags(void)
- {
- return mdbRunTimeFlags;
- }
so is there some solution to this? where i can read data from my tight loop running on the CPU0 ?
sorry in advance if my core topic for this post was not right. i would be happy to update the topic if there is any better suited suggestion.
thanks a lot in advance.