- #include <stdio.h>
- #include <stdint.h>
- #include "sdkconfig.h"
- #include "freertos/FreeRTOS.h"
- #include "freertos/task.h"
- #include "esp_system.h"
- #include "esp_spi_flash.h"
- #define START_TASK_PRIO 1 // 任务优先级
- #define START_STK_SIZE 1024 // 任务堆栈大小
- TaskHandle_t StartTask_Handler; // 任务句柄
- void start_task(void *pvParameters); // 任务函数
- #define TASK1_TASK_PRIO 2 // 任务优先级
- #define TASK1_STK_SIZE 2048 // 任务堆栈大小
- TaskHandle_t Task1Task_Handler; // 任务句柄
- void task1_task(void *pvParameters); // 任务函数
- #define TASK2_TASK_PRIO 3
- #define TASK2_STK_SIZE 2048
- TaskHandle_t Task2Task_Handler;
- void task2_task(void *pvParameters);
- static portMUX_TYPE my_mutex = portMUX_INITIALIZER_UNLOCKED;
- void app_main(void)
- {
- xTaskCreate(
- (TaskFunction_t) start_task,
- (const char*) "start_task",
- (uint16_t)START_STK_SIZE,
- (void*) NULL,
- (UBaseType_t) START_TASK_PRIO,
- (TaskHandle_t*) &StartTask_Handler
- );
- vTaskStartScheduler();
- while (1);
- }
- void start_task(void *pvParameters)
- {
- portENTER_CRITICAL(&my_mutex); // 进入临界区
- // create task1 task
- xTaskCreate(
- (TaskFunction_t) task1_task,
- (const char*) "task1_task",
- (uint16_t) TASK1_STK_SIZE,
- (void*) NULL,
- (UBaseType_t)TASK1_TASK_PRIO,
- (TaskHandle_t*) &Task1Task_Handler
- );
- // create task2 task
- xTaskCreate(
- (TaskFunction_t) task2_task,
- (const char*) "task2_task",
- (uint16_t) TASK2_STK_SIZE,
- (void*) NULL,
- (UBaseType_t)TASK2_TASK_PRIO,
- (TaskHandle_t*) &Task2Task_Handler
- );
- vTaskDelete(StartTask_Handler); // 删除开始任务
- portEXIT_CRITICAL(&my_mutex); // 退出临界区
- }
- void task1_task(void *pvParameters)
- {
- uint8_t task1_num = 0;
- while (1)
- {
- task1_num++;
- printf("任务 1 已经执行:%d 次\r\n",task1_num);
- if (task1_num == 5)
- {
- vTaskDelete(Task2Task_Handler); // 任务1执行5次删除任务2
- printf("任务 1 删除了任务 2 !\r\n");
- }
- vTaskDelay(1500); // 延时1.5s,也就是1500个时钟节拍
- }
- }
- void task2_task(void *pvParameters)
- {
- uint8_t task2_num = 0;
- while (1)
- {
- task2_num++;
- printf("任务 2 已经执行:%d 次\r\n",task2_num);
- vTaskDelay(1500); // 延时1.5s
- }
- }
'C:\Users\shiwe\esp-idf\tools\idf.py' '-p' 'COM37'"...
--- idf_monitor on COM37 115200 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ets Jul 29 2019 12:21:46
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:4
load:0x3fff0034,len:6928
ho 0 tail 12 room 4
load:0x40078000,len:13072
load:0x40080400,len:3896
0x40080400: _init at ??:?
entry 0x40080688
I (31) boot: ESP-IDF v4.1-dirty 2nd stage bootloader
I (31) boot: compile time 18:15:32
I (31) boot: chip revision: 3
I (34) boot_comm: chip revision: 3, min. bootloader chip revision: 0
I (41) boot.esp32: SPI Speed : 40MHz
I (46) boot.esp32: SPI Mode : DIO
I (51) boot.esp32: SPI Flash Size : 4MB
I (55) boot: Enabling RNG early entropy source...
I (60) boot: Partition Table:
I (64) boot: ## Label Usage Type ST Offset Length
I (71) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (79) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (86) boot: 2 factory factory app 00 00 00010000 00100000
I (94) boot: End of partition table
I (98) boot_comm: chip revision: 3, min. application chip revision: 0
I (105) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x05250 ( 21072) map
I (122) esp_image: segment 1: paddr=0x00015278 vaddr=0x3ffb0000 size=0x02154 ( 8532) load
I (126) esp_image: segment 2: paddr=0x000173d4 vaddr=0x40080000 size=0x00404 ( 1028) load
0x40080000: _WindowOverflow4 at C:/Users/shiwe/esp-idf/components/freertos/xtensa_vectors.S:1778
I (132) esp_image: segment 3: paddr=0x000177e0 vaddr=0x40080404 size=0x08838 ( 34872) load
I (156) esp_image: segment 4: paddr=0x00020020 vaddr=0x400d0020 size=0x128d4 ( 75988) map
0x400d0020: _stext at ??:?
I (185) esp_image: segment 5: paddr=0x000328fc vaddr=0x40088c3c size=0x00e7c ( 3708) load
0x40088c3c: rtc_wdt_set_length_of_reset_signal at C:/Users/shiwe/esp-idf/components/soc/esp32/rtc_wdt.c:136
I (192) boot: Loaded app from partition at offset 0x10000
I (193) boot: Disabling RNG early entropy source...
I (195) cpu_start: Pro cpu up.
I (198) cpu_start: Application information:
I (203) cpu_start: Project name: hello-world
I (208) cpu_start: App version: 1
I (213) cpu_start: Compile time: Sep 8 2020 18:15:06
I (219) cpu_start: ELF file SHA256: 7fa99573b4848c3c...
I (225) cpu_start: ESP-IDF: v4.1-dirty
I (230) cpu_start: Starting app cpu, entry point is 0x40081028
0x40081028: call_start_cpu1 at C:/Users/shiwe/esp-idf/components/esp32/cpu_start.c:271
I (0) cpu_start: App cpu up.
I (241) heap_init: Initializing. RAM available for dynamic allocation:
I (247) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (253) heap_init: At 3FFB2960 len 0002D6A0 (181 KiB): DRAM
I (260) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (266) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (272) heap_init: At 40089AB8 len 00016548 (89 KiB): IRAM
I (279) cpu_start: Pro cpu start user code
I (297) spi_flash: detected chip: generic
I (297) spi_flash: flash io: dio
I (298) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
任务 1 已经执行:1 次
任务 2 已经执行:1 次
Guru Meditation Error: Core 0 panic'ed (InstrFetchProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x800d0add PS : 0x00050033 A0 : 0x800d0add A1 : 0x3ffb4770
A2 : 0x00000000 A3 : 0x7fffffff A4 : 0x00000000 A5 : 0x454c4449
A6 : 0x3ffb0031 A7 : 0x00000000 A8 : 0x00000000 A9 : 0x00000400
A10 : 0x00000000 A11 : 0x00000001 A12 : 0x00000000 A13 : 0x800846b0
A14 : 0x3ffb47f0 A15 : 0x00000000 SAR : 0x00000000 EXCCAUSE: 0x00000014
EXCVADDR: 0x800d0adc LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000001
ELF file SHA256: 7fa99573b4848c3c
Backtrace: 0x400d0ada:0x3ffb4770 0x400d0ada:0x3ffb32ec |<-CORRUPTED
0x400d0ada: main_task at C:/Users/shiwe/esp-idf/components/esp32/cpu_start.c:565
0x400d0ada: main_task at C:/Users/shiwe/esp-idf/components/esp32/cpu_start.c:565
Rebooting...
ets Jul 29 2019 12:21:46
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:4
load:0x3fff0034,len:6928
ho 0 tail 12 room 4
load:0x40078000,len:13072
load:0x40080400,len:3896
0x40080400: _init at ??:?
entry 0x40080688
I (31) boot: ESP-IDF v4.1-dirty 2nd stage bootloader
I (31) boot: compile time 18:15:32