espressif / esp-qcloud

基于 ESP-IDF 原生开发接入腾讯 IoT Explorer,支持 ESP32/ESP32S2,快速实现腾讯连连控制。
Apache License 2.0
70 stars 35 forks source link

我增加了一个uart读取数据,初始化出了问题 #10

Closed jenking closed 3 years ago

jenking commented 3 years ago

你好,我单独使用esp-qcloud的时候正常,准备增加uart1来读取传感器,在初始化的时候出了问题,提示如下: I (742) esp_qcloud_log: log initialized successfully E (755) app_main: The device has been restarted abnormally I (758) uart: queue free spaces: 20 E (759) MB_PORT_COMMON: xMBMasterPortTimersInit(114): timer set value failure, timer_isr_register() returned (0x105). E (769) MB_CONTROLLER_MASTER: mbc_serial_master_start(107): mb stack initialization failure, eMBInit() returns (0x3). E (781) MB_CONTROLLER_MASTER: mbc_master_start(184): Master start failure, error=(0x103) (ESP_ERR_INVALID_STATE). E (791) MASTER_TEST: master_init(298): mb controller start fail, returns(0x103).ESP_ERROR_CHECK failed: esp_err_t 0x103 (ESP_ERR_INVALID_STATE) at 0x4002a52c 0x4002a52c: _esp_error_check_failed at D:/esp/esp-idf/components/esp_common/src/esp_err.c:41

file: "../main/app_main.c" line 318 func: app_main expression: master_init()

abort() was called at PC 0x4002a52f on core 0 0x4002a52f: _esp_error_check_failed at D:/esp/esp-idf/components/esp_common/src/esp_err.c:42

Backtrace:0x4002c24b:0x3ffd6040 0x4002caed:0x3ffd6060 0x40033802:0x3ffd6080 0x4002a52f:0x3ffd60f0 0x4008bfc8:0x3ffd6110 0x4013877b:0x3ffd61f0 0x4002eb1d:0x3ffd6210 0x4002c24b: panic_abort at D:/esp/esp-idf/components/esp_system/panic.c:349

0x4002caed: esp_system_abort at D:/esp/esp-idf/components/esp_system/system_api.c:106

0x40033802: abort at D:/esp/esp-idf/components/newlib/abort.c:46

0x4002a52f: _esp_error_check_failed at D:/esp/esp-idf/components/esp_common/src/esp_err.c:42

0x4008bfc8: app_main at d:\esp\esp-qcloud-master\examples\led_light\build/../main/app_main.c:318 (discriminator 1)

0x4013877b: main_task at D:/esp/esp-idf/components/freertos/xtensa/port.c:537 (discriminator 2)

0x4002eb1d: vPortTaskWrapper at D:/esp/esp-idf/components/freertos/xtensa/port.c:170

ELF file SHA256: a7de6de0f43a41af

I (830) esp_core_dump_flash: Save core dump to flash... I (836) esp_core_dump_elf: Found tasks: 7 I (841) esp_core_dump_flash: Erase flash 12288 bytes @ 0x3c0000 I (951) esp_core_dump_flash: Write end offset 0x26d8, check sum length 4

请问是不是qcloud-console使用的uart0和和我增加的uart1冲突造成这个错误呢?

shixinkee commented 3 years ago

您好,我通过检查函数原型发现您似乎添加了 modbus 例程,我尝试将其添加到 esp-qcloud 测试,并未复现所述的情况,我所使用的 idf 为 release/v4.2,commit: 8cd16b。通过 log 判断,这个并非为 qcloud console 的问题,可以通过配置 [] The device will be in debug mode 关闭 console 功能加以验证。您可以提供所使用的 idf 版本,以及相关改动吗?我这边尝试复现一下。

jenking commented 3 years ago

你好!根据你的建议,我原本是使用df4.3 commit 494a124d961c4c755685b22fe986c31826d6f503 来编译,昨晚的换成idf4.2 commit c40f2590bf759ff60ef122afa79b4ec04e7633d2来编译,问题依然出现。 具体的modbus例程我并没有修改。只是在qcloud中添加了ESP_ERROR_CHECK(master_init());初始化。 昨晚我尝试把uart_echo_rs485的例程添加到qcloudiot里面,运行正常。 我把具体涉及的2个程序上传上来,看看能不能还原我的情况。

jenking commented 3 years ago

ESP-ROM:esp32s2-rc4-20191025 Build:Oct 25 2019 rst:0x1 (POWERON),boot:0x9 (SPI_FAST_FLASH_BOOT) SPIWP:0xee mode:DIO, clock div:1 load:0x3ffe6100,len:0x4 load:0x3ffe6104,len:0x19d8 load:0x4004c000,len:0x1a6c load:0x40050000,len:0x2100 entry 0x4004c35c I (46) boot: ESP-IDF v4.2-dirty 2nd stage bootloader I (46) boot: compile time 11:00:33 I (46) boot: chip revision: 0 I (48) qio_mode: Enabling default flash chip QIO I (53) boot.esp32s2: SPI Speed : 80MHz I (58) boot.esp32s2: SPI Mode : QIO I (63) boot.esp32s2: SPI Flash Size : 4MB I (67) boot: Enabling RNG early entropy source... I (73) boot: Partition Table: I (76) boot: ## Label Usage Type ST Offset Length I (84) boot: 0 nvs WiFi data 01 02 0000d000 00008000 I (91) boot: 1 fctry WiFi data 01 02 00015000 00004000 I (99) boot: 2 log_status WiFi data 01 02 00019000 00004000 I (106) boot: 3 otadata OTA data 01 00 0001d000 00002000 I (114) boot: 4 phy_init RF data 01 01 0001f000 00001000 I (121) boot: 5 ota_0 OTA app 00 10 00020000 001d0000 I (129) boot: 6 ota_1 OTA app 00 11 001f0000 001d0000 I (136) boot: 7 coredump Unknown data 01 03 003c0000 00010000 I (144) boot: 8 log_info Unknown data 01 fe 003d0000 00010000 I (151) boot: 9 reserved Unknown data 01 ff 003e0000 00020000 I (159) boot: End of partition table I (163) boot: No factory image, trying OTA 0 I (168) esp_image: segment 0: paddr=0x00020020 vaddr=0x3f000020 size=0x31484 (201860) map I (214) esp_image: segment 1: paddr=0x000514ac vaddr=0x3ffc95b0 size=0x04830 ( 18480) load I (218) esp_image: segment 2: paddr=0x00055ce4 vaddr=0x40024000 size=0x00404 ( 1028) load 0x40024000: _WindowOverflow4 at D:/esp/espidf42/esp-idf-v4.2/components/freertos/xtensa/xtensa_vectors.S:1730

I (221) esp_image: segment 3: paddr=0x000560f0 vaddr=0x40024404 size=0x09f28 ( 40744) load I (239) esp_image: segment 4: paddr=0x00060020 vaddr=0x40080020 size=0xba19c (762268) map 0x40080020: _stext at ??:?

I (377) esp_image: segment 5: paddr=0x0011a1c4 vaddr=0x4002e32c size=0x0b278 ( 45688) load 0x4002e32c: xQueueGenericSendFromISR at D:/esp/espidf42/esp-idf-v4.2/components/freertos/queue.c:1162 (discriminator 1)

I (400) boot: Loaded app from partition at offset 0x20000 I (444) boot: Set actual ota_seq=1 in otadata[0] I (445) boot: Disabling RNG early entropy source... I (445) cache: Instruction cache : size 16KB, 4Ways, cache line size 16Byte I (452) cpu_start: Pro cpu up. I (456) cpu_start: Application information: I (460) cpu_start: Project name: led_light I (466) cpu_start: App version: 1 I (470) cpu_start: Compile time: Feb 19 2021 11:00:16 I (476) cpu_start: ELF file SHA256: 5dfc231ecb8827a6... I (482) cpu_start: ESP-IDF: v4.2-dirty I (487) cpu_start: Single core mode I (492) heap_init: Initializing. RAM available for dynamic allocation: I (499) heap_init: At 3FFD2FB8 len 00029048 (164 KiB): DRAM I (505) heap_init: At 3FFFC000 len 00003A10 (14 KiB): DRAM I (511) cpu_start: Pro cpu start user code I (573) spi_flash: detected chip: generic I (573) spi_flash: flash io: qio I (573) esp_core_dump_flash: Init core dump to flash I (576) esp_core_dump_flash: Found partition 'coredump' @ 3c0000 65536 bytes I (585) esp_core_dump_flash: Found core dump 15776 bytes in flash @ 0x3c0000 I (591) cpu_start: Starting scheduler on PRO CPU. D (607) esp_qcloud_reboot: reboot unbroken count: 2 D (608) esp_qcloud_reboot: version_fallback_task exit V (612) esp_qcloud_mem: <esp_qcloud_log : 162> Alloc ptr: 0x3ffd8fd8, size: 16, heap free: 158200 W (621) esp_qcloud_log_flash: NVS open for log_status log_info log_info failed V (630) esp_qcloud_mem: <esp_qcloud_log_flash : 157> Alloc ptr: 0x3ffd9c28, size: 24, heap free: 155040 I (788) esp_qcloud_log_flash: LOG flash initialized successfully I (788) esp_qcloud_log_flash: Log save partition subtype: label: log_info, addr:0x3d0000, offset: 0, size: 65536 I (794) esp_qcloud_log: log initialized successfully E (807) app_main: The device has been restarted abnormally I (812) wifi:wifi driver task: 3ffde6c0, prio:23, stack:6656, core=0 I (812) system_api: Base MAC address is not set I (817) system_api: read default base MAC address from EFUSE I (828) wifi:wifi firmware version: 1865b55 I (828) wifi:wifi certification version: v7.0 I (831) wifi:config NVS flash: enabled I (835) wifi:config nano formating: disabled I (839) wifi:Init data frame dynamic rx buffer num: 24 I (844) wifi:Init management frame dynamic rx buffer num: 24 I (849) wifi:Init management short buffer num: 32 I (854) wifi:Init dynamic tx buffer num: 24 I (857) wifi:Init static rx buffer size: 1600 I (862) wifi:Init static rx buffer num: 8 I (865) wifi:Init dynamic rx buffer num: 24 I (870) wifi_init: rx ba win: 16 I (873) wifi_init: tcpip mbox: 32 I (877) wifi_init: udp mbox: 32 I (881) wifi_init: tcp mbox: 32 I (885) wifi_init: tcp tx win: 28000 I (889) wifi_init: tcp rx win: 28000 I (893) wifi_init: tcp mss: 1440 I (897) wifi_init: WiFi IRAM OP enabled I (902) wifi_init: WiFi RX IRAM OP enabled I (1030) phy: phy_version: 603, 72dfd77, Jul 7 2020, 19:57:05, 0, 2 I (1031) wifi:enable tsf I (1032) wifi:mode : sta (7c:df:a1:08:32:44) I (1394) wifi:new:<13,2>, old:<1,0>, ap:<255,255>, sta:<13,2>, prof:1 I (1395) wifi:state: init -> auth (b0) I (1414) wifi:state: auth -> assoc (0) I (1419) wifi:state: assoc -> run (10) I (1446) wifi:connected with FAST, aid = 5, channel 13, 40D, bssid = 0c:d8:6c:99:07:6c I (1447) wifi:security: WPA2-PSK, phy: bgn, rssi: -32 I (1449) wifi:pm start, type: 1

I (1451) wifi:AP's beacon interval = 102400 us, DTIM period = 1 I (2310) esp_netif_handlers: sta ip: 192.168.2.107, mask: 255.255.255.0, gw: 192.168.2.1 I (2311) esp_qcloud_wifi: Connected with IP Address:192.168.2.107 I (2316) esp_qcloud_timesync: Initializing SNTP. Using the SNTP server: pool.ntp.org I (2325) esp_qcloud_mqtt: Initialising MQTT I (2330) esp_qcloud_mqtt: Connecting to mqtts://9LCJWKYZEY.iotcloud.tencentdevices.com:8883 I (2339) esp_qcloud_mqtt: Waiting for MQTT connection. This may take time. I (3386) esp_qcloud_mqtt: MQTT Connected I (3387) app_main: QCloud Initialised I (3389) esp_qcloud_iothub: mqtt_subscribe, topic: $log/operation/result/9LCJWKYZEY/esp32_test I (3395) esp_qcloud_iothub: mqtt_publish, topic: $log/operation/9LCJWKYZEY/esp32_test, data: {"type":"get_log_level","clientToken": "9LCJWKYZEY-76905"} I (3409) esp_qcloud_iothub: mqtt_subscribe, topic: $thing/down/property/9LCJWKYZEY/esp32_test I (3417) app_main: Report id: power_switch, val: 1 or 0.00 I (3423) app_main: Report id: s_airflow, val: 34 or 0.00 I (3429) app_main: Report id: s_temp, val: 63 or 0.00 I (3435) app_main: Report id: s_ph, val: 44 or 0.00 I (3440) app_main: Report id: s_do, val: 34 or 0.00 I (3446) app_main: Report id: value, val: 30 or 0.00 I (3451) app_main: Report id: saturation, val: 1 or 0.00 I (3457) app_main: Report id: hue, val: 9 or 0.00 I (3466) esp_qcloud_iothub: mqtt_publish, topic: $thing/up/property/9LCJWKYZEY/esp32_test, method: report, data: {"method":"report","clientToken":"esp32_test-60615","params":{"power_switch":1,"s_airflow":34,"s_temp":63,"s_ph":44,"s_do":34,"value":30,"saturation":1,"hue":9}} I (3487) esp_qcloud_iothub: log_callback, topic: $log/operation/result/9LCJWKYZEY/esp32_test, payload: {"clientToken":"9LCJWKYZEY-76905","log_level":0,"result":0,"timestamp":1613703666,"type":"get_log_level"}

I (3507) esp_qcloud_iothub: log_level: 0 I (3517) esp_qcloud_ota: mqtt_subscribe, topic: $ota/update/9LCJWKYZEY/esp32_test I (3521) esp_qcloud_ota: mqtt_publish, topic: $ota/report/9LCJWKYZEY/esp32_test, data: {"type":"report_version","report":{"version":"0.0.1"}} I (3532) esp_qcloud_iothub: property_callback, topic: $thing/down/property/9LCJWKYZEY/esp32_test, payload: {"method":"report_reply","clientToken":"esp32_test-60615","code":0,"status":"success"} I (3556) uart: queue free spaces: 20 E (3557) MB_PORT_COMMON: xMBMasterPortTimersInit(115): timer set value failure, timer_isr_register() returned (0x105). E (3567) MB_CONTROLLER_MASTER: mbc_serial_master_start(107): mb stack initialization failure, eMBInit() returns (0x3). E (3578) MB_CONTROLLER_MASTER: mbc_master_start(211): SERIAL master start failure error=(0x103) (ESP_ERR_INVALID_STATE). E (3590) MASTER_TEST: master_init(410): mb controller start fail, returns(0x103). ESP_ERROR_CHECK failed: esp_err_t 0x103 (ESP_ERR_INVALID_STATE) at 0x4002a364 0x4002a364: _esp_error_check_failed at D:/esp/espidf42/esp-idf-v4.2/components/esp_common/src/esp_err.c:45

file: "../main/app_main.c" line 343 func: app_main expression: master_init()

abort() was called at PC 0x4002a367 on core 0 0x4002a367: _esp_error_check_failed at D:/esp/espidf42/esp-idf-v4.2/components/esp_common/src/esp_err.c:46

Backtrace:0x4002b4a7:0x3ffd6ab0 0x4002bd25:0x3ffd6ad0 0x400322ee:0x3ffd6af0 0x4002a367:0x3ffd6b60 0x400887b0:0x3ffd6b80 0x40086917:0x3ffd6c60 0x4002bd2d:0x3ffd6c90 0x4002b4a7: panic_abort at D:/esp/espidf42/esp-idf-v4.2/components/esp_system/panic.c:330

0x4002bd25: esp_system_abort at D:/esp/espidf42/esp-idf-v4.2/components/esp_system/system_api.c:106

0x400322ee: abort at D:/esp/espidf42/esp-idf-v4.2/components/newlib/abort.c:46

0x4002a367: _esp_error_check_failed at D:/esp/espidf42/esp-idf-v4.2/components/esp_common/src/esp_err.c:46

0x400887b0: app_main at d:\esp\esp-qcloud-master\examples\led_light\build/../main/app_main.c:343 (discriminator 1)

0x40086917: main_task at D:/esp/espidf42/esp-idf-v4.2/components/esp32s2/cpu_start.c:453 (discriminator 2)

0x4002bd2d: vPortTaskWrapper at D:/esp/espidf42/esp-idf-v4.2/components/freertos/xtensa/port.c:143

ELF file SHA256: 5dfc231ecb8827a6

I (3629) esp_core_dump_flash: Save core dump to flash... I (3635) esp_core_dump_elf: Found tasks: 11 I (3640) esp_core_dump_flash: Erase flash 16384 bytes @ 0x3c0000 I (3796) esp_core_dump_flash: Write end offset 0x3da8, check sum length 4 I (3796) esp_core_dump_flash: Core dump has been saved to flash. Rebooting...

shixinkee commented 3 years ago

我复现出了你的问题,QCloudled 组件使用了定时器组 0 的 T0 定时器,这与 modbus 所使用的定时器冲突,更改下 modbus 定时器即可。

(Top) → Component config → Modbus configuration
(0) Modbus Timer group number
(1) Modbus Timer index in the grou
jenking commented 3 years ago

你好,问题已经解决。