espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.79k stars 7.31k forks source link

esp32c6 temperature_sensor: Exceeding temperature measure range after adc_oneshot_del_unit (IDFGH-11828) #12921

Closed AxelLin closed 10 months ago

AxelLin commented 10 months ago

Answers checklist.

IDF version.

v5.1.2-534-gbbd8d13f93

Espressif SoC revision.

ESP32C6

Operating System used.

Linux

How did you build your project?

Command line with idf.py

If you are using Windows, please specify command line type.

None

Development Kit.

Custom Board

Power Supply used.

USB

What is the expected behavior?

temperature_sensor should still work after adc_oneshot_del_unit.

What is the actual behavior?

Always got "temperature_sensor: Exceeding temperature measure range" after adc_oneshot_del_unit

Steps to reproduce.

Test using ADC1 ADC_CHANNEL_4. (Note: it works if using ADC_CHANNEL_2 or ADC_CHANNEL_3, only ADC_CHANNEL_4 has this issue)

Attached the modified code to reproduce the issue , copy it to replace examples/peripherals/adc/oneshot_read/main/oneshot_read_main.c oneshot_read_main.c.txt

Debug Logs.

I (248) cpu_start: Min chip rev:     v0.0
I (253) cpu_start: Max chip rev:     v0.99
I (257) cpu_start: Chip rev:         v0.0
I (262) heap_init: Initializing. RAM available for dynamic allocation:
I (269) heap_init: At 4080AF90 len 00071680 (453 KiB): D/IRAM
I (276) heap_init: At 4087C610 len 00002F54 (11 KiB): STACK/DIRAM
I (282) heap_init: At 50000004 len 00003FE4 (15 KiB): RTCRAM
I (290) spi_flash: detected chip: generic
I (293) spi_flash: flash io: dio
I (298) sleep: Configure to isolate all GPIO pins in sleep state
I (304) sleep: Enable automatic switching of GPIO sleep configuration
I (311) coexist: coex firmware version: c02915e
I (317) coexist: coexist rom version 5b8dcfa
I (322) app_start: Starting scheduler on CPU0
I (326) main_task: Started on CPU0
I (326) main_task: Calling app_main()
I (326) EXAMPLE: Install temperature sensor, expected temp ranger range: 10~50 ℃
I (336) temperature_sensor: Range [-10°C ~ 80°C], error < 1°C
I (346) EXAMPLE: Enable temperature sensor
I (346) EXAMPLE: Read temperature
I (356) EXAMPLE: Temperature value 7.00 ℃
I (1356) EXAMPLE: Temperature value 7.00 ℃
I (2356) EXAMPLE: Temperature value 8.00 ℃
I (3356) EXAMPLE: Temperature value 8.00 ℃
I (4356) EXAMPLE: Temperature value 8.00 ℃
I (5356) gpio: GPIO[2]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (5356) gpio: GPIO[4]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (5356) EXAMPLE: calibration scheme version is Curve Fitting
I (5366) EXAMPLE: Calibration Success
I (5366) EXAMPLE: calibration scheme version is Curve Fitting
I (5376) EXAMPLE: Calibration Success
I (5376) EXAMPLE: Temperature value 8.00 ℃
I (6386) EXAMPLE: Temperature value 8.00 ℃
I (7386) EXAMPLE: Temperature value 8.00 ℃
I (8386) EXAMPLE: Temperature value 8.00 ℃
I (9386) EXAMPLE: Temperature value 8.00 ℃
I (10386) EXAMPLE: ADC1 Channel[2] Raw Data: 1089
I (10386) EXAMPLE: ADC1 Channel[2] Cali Voltage: 1095 mV
I (11386) EXAMPLE: ADC1 Channel[4] Raw Data: 1
I (11386) EXAMPLE: ADC1 Channel[4] Cali Voltage: 1 mV
I (12386) EXAMPLE: ADC1 Channel[2] Raw Data: 1073
I (12386) EXAMPLE: ADC1 Channel[2] Cali Voltage: 1079 mV
I (13386) EXAMPLE: ADC1 Channel[4] Raw Data: 1
I (13386) EXAMPLE: ADC1 Channel[4] Cali Voltage: 1 mV
I (14386) EXAMPLE: ADC1 Channel[2] Raw Data: 1105
I (14386) EXAMPLE: ADC1 Channel[2] Cali Voltage: 1111 mV
I (15386) EXAMPLE: ADC1 Channel[4] Raw Data: 0
I (15386) EXAMPLE: ADC1 Channel[4] Cali Voltage: 0 mV
I (16386) EXAMPLE: ADC1 Channel[2] Raw Data: 1104
I (16386) EXAMPLE: ADC1 Channel[2] Cali Voltage: 1110 mV
I (17386) EXAMPLE: ADC1 Channel[4] Raw Data: 0
I (17386) EXAMPLE: ADC1 Channel[4] Cali Voltage: 0 mV
I (18386) EXAMPLE: ADC1 Channel[2] Raw Data: 1088
I (18386) EXAMPLE: ADC1 Channel[2] Cali Voltage: 1094 mV
I (19386) EXAMPLE: ADC1 Channel[4] Raw Data: 1
I (19386) EXAMPLE: ADC1 Channel[4] Cali Voltage: 1 mV
I (20386) EXAMPLE: deregister Curve Fitting calibration scheme
I (20386) EXAMPLE: deregister Curve Fitting calibration scheme
E (20386) temperature_sensor: Exceeding temperature measure range.
ESP_ERROR_CHECK failed: esp_err_t 0x103 (ESP_ERR_INVALID_STATE) at 0x42005926
0x42005926: app_main at /home/axel/esp/esp-idf/examples/peripherals/adc/oneshot_read/main/oneshot_read_main.c:72 (discriminator 1)

file: "/IDF/examples/peripherals/adc/oneshot_read/main/oneshot_read_main.c" line 176
func: app_main
expression: temperature_sensor_get_celsius(temp_sensor, &tsens_value)

abort() was called at PC 0x40804011 on core 0
0x40804011: _esp_error_check_failed at /home/axel/esp/esp-idf/components/esp_system/esp_err.c:50

Stack dump detected
Core  0 register dump:
MEPC    : 0x408004de  RA      : 0x4080401c  SP      : 0x4080de80  GP      : 0x408096b0
0x408004de: panic_abort at /home/axel/esp/esp-idf/components/esp_system/panic.c:472

0x4080401c: __ubsan_include at /home/axel/esp/esp-idf/components/esp_system/ubsan.c:313

TP      : 0x40804bac  T0      : 0x37363534  T1      : 0x7271706f  T2      : 0x33323130
0x40804bac: prvInitialiseTaskLists at /home/axel/esp/esp-idf/components/freertos/FreeRTOS-Kernel/tasks.c:4661
 (inlined by) prvAddNewTaskToReadyList at /home/axel/esp/esp-idf/components/freertos/FreeRTOS-Kernel/tasks.c:1280

S0/FP   : 0x4080debc  S1      : 0x4080dea0  A0      : 0x4080debc  A1      : 0x4080de9e
A2      : 0x00000000  A3      : 0x4080dee9  A4      : 0x00000001  A5      : 0x4080b000
A6      : 0x00000000  A7      : 0x76757473  S2      : 0x00000001  S3      : 0x42013000
S4      : 0x00000000  S5      : 0x4080b000  S6      : 0x4080b000  S7      : 0x42013000
S8      : 0x42013000  S9      : 0x4080ab40  S10     : 0x4080b000  S11     : 0x4080b000
T3      : 0x6e6d6c6b  T4      : 0x6a696867  T5      : 0x66656463  T6      : 0x62613938
MSTATUS : 0x00001881  MTVEC   : 0x40800001  MCAUSE  : 0x00000007  MTVAL   : 0x00000000
0x40800001: _vector_table at ??:?

MHARTID : 0x00000000

Backtrace:

panic_abort (details=details@entry=0x4080debc "abort() was called at PC 0x40804011 on core 0") at /home/axel/esp/esp-idf/components/esp_system/panic.c:472

More Information.

Note, I already manually applied the fix from https://github.com/espressif/esp-idf/issues/12864

AxelLin commented 9 months ago

Just remind v5.1 and v5.2 need this fix.

AxelLin commented 8 months ago

@mythbuster5 v5.1.3 does not include this fix.