{"action":"created","issue":{"url":"https://api.github.com/repos/espressif/arduino-esp32/issues/1501","repository_url":"https://api.github.com/repos/espressif/arduino-esp32","labels_url":"https://api.github.com/repos/espressif/arduino-esp32/issues/1501/labels{/name}","comments_url":"https://api.github.com/repos/espressif/arduino-esp32/issues/1501/comments","events_url":"https://api.github.com/repos/espressif/arduino-esp32/issues/1501/events","html_url":"https://github.com/espressif/arduino-esp32/issues/1501","id":332764829,"node_id":"MDU6SXNzdWUzMzI3NjQ4Mjk=","number":1501,"title":"FreeRTOS EventGroups ","user":{"login":"hreintke","id":4587225,"node_id":"MDQ6VXNlcjQ1ODcyMjU=","avatar_url":"https://avatars2.githubusercontent.com/u/4587225?v=4","gravatar_id":"","url":"https://api.github.com/users/hreintke","html_url":"https://github.com/hreintke","followers_url":"https://api.github.com/users/hreintke/followers","following_url":"https://api.github.com/users/hreintke/following{/other_user}","gists_url":"https://api.github.com/users/hreintke/gists{/gist_id}","starred_url":"https://api.github.com/users/hreintke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hreintke/subscriptions","organizations_url":"https://api.github.com/users/hreintke/orgs","repos_url":"https://api.github.com/users/hreintke/repos","events_url":"https://api.github.com/users/hreintke/events{/privacy}","received_events_url":"https://api.github.com/users/hreintke/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-06-15T13:01:49Z","updated_at":"2018-06-16T13:28:19Z","closed_at":null,"author_association":"NONE","body":"### Hardware:\r\nBoard:\t\t\t\t\t\t\tNano32\r\nCore Installation/update date:\t\t15/06/2018\r\nIDE name:\t\t\t\t\t\tSloeber eclipse\r\nFlash Frequency:\t\t\t\t\t80Mhz\r\nUpload Speed:\t\t\t\t\t230400\r\n\r\n\r\n### Description:\r\nExperimenting with events groups from freertos. \r\nNow using an example from the freeRTOS documentation.\r\nBut this gets into the Guru Meditation Errors.\r\n\r\nAny hints where I should be looking to solve this ?\r\n\r\n### Sketch:\r\n```cpp\r\nextern \"C\"\r\n{\r\n#include \"freertos\\freeRTOS.h\"\r\n#include \"freertos\\task.h\"\r\n#include \"freertos/event_groups.h\"\r\n}\r\n\r\nvoid loop()\r\n{\r\n}\r\n\r\n/* Definitions for the event bits in the event group. */\r\n#define mainFIRST_TASK_BIT ( 1UL << 0UL ) /* Event bit 0, set by the first task. */\r\n#define mainSECOND_TASK_BIT ( 1UL << 1UL ) /* Event bit 1, set by the second task. */\r\n#define mainTHIRD_TASK_BIT ( 1UL << 2UL ) /* Event bit 2, set by the third task. */\r\n\r\n/* Declare the event group used to synchronize the three tasks. */\r\nEventGroupHandle_t xEventGroup;\r\n\r\nstatic void vSyncingTask( void *pvParameters )\r\n{\r\n    const TickType_t xMaxDelay = 2000 ;// pdMS_TO_TICKS( 4000UL );\r\n    const TickType_t xMinDelay = 500 ;//pdMS_TO_TICKS( 200UL );\r\n\r\n    TickType_t xDelayTime;\r\n    EventBits_t uxThisTasksSyncBit;\r\n    const EventBits_t uxAllSyncBits = ( mainFIRST_TASK_BIT | mainSECOND_TASK_BIT | mainTHIRD_TASK_BIT );\r\n\r\n    /* Three instances of this task are created - each task uses a different event bit in the synchronization.\r\n     * The event bit to use is passed into each task instance using the task parameter. Store it in the uxThisTasksSyncBit variable. */\r\n    uxThisTasksSyncBit = ( EventBits_t ) pvParameters;\r\n\r\n    for( ;; )\r\n    {\r\n        /* Simulate this task taking some time to perform an action by delaying for a pseudo-random time.\r\n         * This prevents all three instances of this task from reaching  the synchronization point at the same time,\r\n         * and so allows the example's behavior to be observed more easily. */\r\n //       xDelayTime = ( rand() % xMaxDelay ) + xMinDelay;\r\n    \t\txDelayTime = random(xMinDelay,xMaxDelay);\r\n    \t//        vTaskDelay( xDelayTime );\r\n    \tSerial.printf(\"%s delay is %d\\r\\n\",pcTaskGetTaskName( NULL ),xDelayTime);\r\n        delay(xDelayTime);\r\n        /* Print out a message to show this task has reached its synchronization  point.\r\n         * pcTaskGetTaskName() is an API function that returns the name assigned to the task when the task was created. */\r\n        Serial.printf(\"%s reached sync point at : %d\\r\\n\",pcTaskGetTaskName( NULL ),(int)millis());\r\n\r\n        /* Wait for all the tasks to have reached their respective synchronization points. */\r\n        xEventGroupSync( /* The event group used to synchronize. */ xEventGroup,\r\n        \t\t        /* The bit set by this task to indicate it has reached the synchronization point. */ uxThisTasksSyncBit,\r\n\t\t\t\t\t\t/* The bits to wait for, one bit for each task taking part in the synchronization. */ uxAllSyncBits,\r\n\t\t\t\t\t\t/* Wait indefinitely for all three tasks to reach the synchronization point. */ portMAX_DELAY );\r\n\r\n        /* Print out a message to show this task has passed its synchronization point.\r\n         * As an indefinite delay was used the following line will only be executed after all the tasks reached their respective synchronization  points. */\r\n        Serial.printf(\"%s exited sync point at : %d\\r\\n\",pcTaskGetTaskName( NULL ),(int)millis());\r\n    }\r\n}\r\n\r\n\r\nvoid setup()\r\n{\r\n\tSerial.begin(115200);\r\n    /* Before an event group can be used it must first be created. */\r\n    xEventGroup = xEventGroupCreate();\r\n\r\n    /* Create three instances of the task. Each task is given a different name, which is later printed out to give a visual indication of which task is executing. The event bit to use when the task reaches its synchronization point is passed into the task using the task parameter. */\r\n\r\n    xTaskCreatePinnedToCore( vSyncingTask, \"Task 1\", 1000, (void*)mainFIRST_TASK_BIT, 1, NULL,1);\r\n    xTaskCreatePinnedToCore( vSyncingTask, \"Task 2\", 1000, (void*)mainSECOND_TASK_BIT, 1, NULL,1 );\r\n    xTaskCreatePinnedToCore( vSyncingTask, \"Task 3\", 1000, (void*)mainTHIRD_TASK_BIT, 1, NULL,1 );\r\n}\r\n\r\n```\r\n\r\n### Debug Messages:\r\n\r\nSerial output is : \r\n```\r\nRebooting...\r\nets Jun  8 2016 00:22:57\r\n\r\nrst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)\r\nconfigsip: 0, SPIWP:0xee\r\nclk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00\r\nmode:DIO, clock div:1\r\nload:0x3fff0018,len:4\r\nload:0x3fff001c,len:812\r\nload:0x40078000,len:0\r\nload:0x40078000,len:11572\r\nentry 0x40078a5c\r\nTask 1 delay is 1509\r\nTask 3 delay is 751\r\nTask 2 delay is 735\r\nGuru Meditation Error: Core  0 panic'ed (StoreProhibited)\r\n. Exception was unhandled.\r\nCore 0 register dump:\r\nPC      : 0x40086e0d  PS      : 0x00060033  A0      : 0x80085dde  A1      : 0x3ffc0590\r\nA2      : 0x3ffc5da8  A3      : 0x00000000  A4      : 0x00000005  A5      : 0x00000020\r\nA6      : 0x00000020  A7      : 0x00000000  A8      : 0x00000002  A9      : 0xa5a5a5a5\r\nA10     : 0x3ffc5fdc  A11     : 0x00000000  A12     : 0x00060021  A13     : 0x00000001\r\nA14     : 0x00060021  A15     : 0x3ffc6814  SAR     : 0x0000001d  EXCCAUSE: 0x0000001d\r\nEXCVADDR: 0xa5a5a5ad  LBEG    : 0x00000000  LEND    : 0x00000000  LCOUNT  : 0x00000000\r\nCore 0 was running in ISR context:\r\nEPC1    : 0x40086e0d  EPC2    : 0x00000000  EPC3    : 0x00000000  EPC4    : 0x40085645\r\n\r\nBacktrace: 0x40086e0d:0x3ffc0590 0x40085ddb:0x3ffc05b0 0x400845d7:0x3ffc05d0 0x40086afd:0x3ffc05f0 0x400815d2:0x3ffc0600 0x400d2fab:0x00000000\r\n```\r\n\r\nDecoder output : \r\n```\r\nDecoding 12 results\r\n0x40086e0d: uxListRemove at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/freertos/./list.c line 214\r\n0x40086e0d: uxListRemove at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/freertos/./list.c line 214\r\n0x40085645: xTaskGetCurrentTaskHandle at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/freertos/./tasks.c line 3529\r\n0x40086e0d: uxListRemove at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/freertos/./list.c line 214\r\n0x40085ddb: xTaskIncrementTick at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/freertos/./tasks.c line 3529\r\n0x400845d7: xPortSysTickHandler at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/freertos/./port.c line 374\r\n0x40086afd: _frxt_timer_int at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/freertos/./portasm.S line 303\r\n0x400815d2: _xt_lowint1 at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/freertos/./xtensa_vectors.S line 1105\r\n0x400d2fab: esp_vApplicationIdleHook at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/esp32/./freertos_hooks.c line 85\r\n```"},"comment":{"url":"https://api.github.com/repos/espressif/arduino-esp32/issues/comments/397812319","html_url":"https://github.com/espressif/arduino-esp32/issues/1501#issuecomment-397812319","issue_url":"https://api.github.com/repos/espressif/arduino-esp32/issues/1501","id":397812319,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NzgxMjMxOQ==","user":{"login":"hreintke","id":4587225,"node_id":"MDQ6VXNlcjQ1ODcyMjU=","avatar_url":"https://avatars2.githubusercontent.com/u/4587225?v=4","gravatar_id":"","url":"https://api.github.com/users/hreintke","html_url":"https://github.com/hreintke","followers_url":"https://api.github.com/users/hreintke/followers","following_url":"https://api.github.com/users/hreintke/following{/other_user}","gists_url":"https://api.github.com/users/hreintke/gists{/gist_id}","starred_url":"https://api.github.com/users/hreintke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hreintke/subscriptions","organizations_url":"https://api.github.com/users/hreintke/orgs","repos_url":"https://api.github.com/users/hreintke/repos","events_url":"https://api.github.com/users/hreintke/events{/privacy}","received_events_url":"https://api.github.com/users/hreintke/received_events","type":"User","site_admin":false},"created_at":"2018-06-16T13:28:19Z","updated_at":"2018-06-16T13:28:19Z","author_association":"NONE","body":"Found the problem.\r\n\r\nI executed the same in esp-idf and got the errormessage : \r\n```\r\nEventGroup test\r\nThis is ESP32 chip with 2 CPU cores, WiFi/BT/BLE, silicon revision 1, 4MB external flash\r\ntasks startedTask 2 delay is 2433\r\nTask 2 reached sync point at\r\n***ERROR*** A stack overflow in task Task 2 has been detected.\r\nabort() was called at PC 0x400873f4 on core 1\r\n\r\nBacktrace: 0x40087204:0x3ffb7690 0x400873db:0x3ffb76b0 0x400873f4:0x3ffb76d0 0x400840e4:0x3ffb76f0 0x40085ee4:0x3ffb7710 0x40085e9a:0x3ffb77b0\r\n```\r\n\r\nIncreasing the stacksize to 8192 : \r\n`xTaskCreatePinnedToCore( vSyncingTask, \"Task 1\", 8192, (void*)mainFIRST_TASK_BIT, 1, NULL,1);`\r\n\r\nSolved it\r\n\r\nIs there a way to detect stack overflow when using arduino-esp32 ?\r\n"}}
{"actor":{"display_login":"hreintke"}}