- I (0) cpu_start: Starting scheduler on APP CPU.
- Guru Meditation Error: Core 1 panic'ed (IllegalInstruction). Exception was unhandled.
- Memory dump at 0x400824e8: e5f875a1 f01d0227 52006136
- Core 1 register dump:
- PC : 0x400824ee PS : 0x00060230 A0 : 0x3ffb6ed4 A1 : 0x3ffb6650
- A2 : 0x3ffae978 A3 : 0x00000004 A4 : 0x00060e20 A5 : 0x00060e23
- A6 : 0x00000001 A7 : 0x00000000 A8 : 0x800824ee A9 : 0x3ffb6630
- A10 : 0x3ffb21e4 A11 : 0x00060023 A12 : 0x00060020 A13 : 0x00000000
- A14 : 0x00000000 A15 : 0x00000000 SAR : 0x00000000 EXCCAUSE: 0x00000000
- EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000
- Backtrace:0x400824eb:0x3ffb6650 0x3ffb6ed1:0x3ffb6670 |<-CORRUPTED
I'm using the ESP-IDF with PlatformIO for a small project on ESP32. I should use mutexes but I keep getting a runtime error. To understand FreeRTOS mutexes from scratch, I created a test project with code from the freeRTOS book:
- #include "freertos/FreeRTOS.h"
- #include "freertos/task.h"
- #include "freertos/semphr.h"
- #include "stdio.h"
- SemaphoreHandle_t xMutex = NULL;
- static void prvNewPrintString( const char *pcString );
- static void prvPrintTask( void *pvParameters );
- static void prvPrintTask( void *pvParameters )
- {
- char *pcStringToPrint;
- const TickType_t xMaxBlockTimeTicks = 0x20;
- pcStringToPrint = ( char * ) pvParameters;
- for( ;; )
- {
- prvNewPrintString( pcStringToPrint );
- vTaskDelay( ( rand() % xMaxBlockTimeTicks ) );
- }
- }
- static void prvNewPrintString( const char *pcString )
- {
- xSemaphoreTake( xMutex, portMAX_DELAY );
- {
- printf( "%s", pcString );
- fflush( stdout );
- }
- xSemaphoreGive( xMutex );
- }
- void app_main() {
- xMutex = xSemaphoreCreateMutex();
- if( xMutex != NULL )
- {
- xTaskCreate( prvPrintTask, "Print1", 1000,
- "Task 1 ***************************************\r\n", 1, NULL );
- xTaskCreate( prvPrintTask, "Print2", 1000,
- "Task 2 ---------------------------------------\r\n", 2, NULL );
- }
- for( ;; );
- }
Code: Select all
vTaskStartScheduler();
Unfortunately, this code crashes. Here is the panic message:
I have also no idea how to decode the register dump and the backtrace is not very helpful.
Can you tell me what's wrong here?
Thanks,
MatPy