espressif / arduino-esp32

Arduino core for the ESP32
GNU Lesser General Public License v2.1
13.55k stars 7.39k forks source link

esp32-hal-misc.c infinite loop. #6632

Open dynamic21xx opened 2 years ago

dynamic21xx commented 2 years ago

Board

nodemcu-32s

Device Description

nodemcu-32s plain.

Hardware Configuration

No.

Version

latest master (checkout manually)

IDE Name

PlatformIO

Operating System

UbuntuLinux 20

Flash frequency

40Mhz

PSRAM enabled

no

Upload speed

115200,9600

Description

In my program used DallasTemperature, and onewire. espressif32 3.5 working fine. When I update espressif32 4.1, my program cannot run, and the program always reset. In first run 0 sensor attached, but espressif32 3.5 working fine. I found in esp32-hal-misc.c infinite loop. If I commented out these lines , espressif32 4.1 working. https://community.platformio.org/t/update-espressif32-4-1-dallastemperature-senzor-begin-freeze/27399 problem

Sketch

DallasTemperature
senzor.begin()

Debug Message

always reset

Other Steps to Reproduce

espressif32 3.5 working fine.

I have checked existing issues, online documentation and the Troubleshooting Guide

lbernstone commented 2 years ago

That's a finite loop. esp_timer_get_time() is a volatile function that (surprise) gives you the current number of microseconds since boot. You don't say what you are using for DallasTemperature, but wherever it is using delayMicroseconds seems more likely the source of your problem.

dynamic21xx commented 2 years ago

Thanks, but the dallastemperature call this timer in begin() method. I just call _senzor.begin(). In my debugger 'e' value is 2, and never going out that while-do cycle. This error only came, when I update espressif32 4.1. If I use espressif32 3.5 , no error. SilentTemperatureSensor::SilentTemperatureSensor(uint8_t pin): _oneWire( pin ), _sensors( &_oneWire ) { _pin = pin; _sensors.begin(); //freeze if I not commented in esp32-hal-misc.c that lines.

mrengineer7777 commented 2 years ago

Looks like you are using PIO. PIO targets arduino-esp32 version 1.0.4, based on espressif32 3.3.x. Most of us are manually targeting a newer version of Arduino core. I'm using 2.0.2.3, custom TASMOTA build:

framework = arduino
platform = https://github.com/tasmota/platform-espressif32/releases/download/v2.0.2.3/platform-espressif32-2.0.2.3.zip

Your Dallas library may not be compatible with the newer Arduino framework.

We'll need more info about your platform targets, or even better a sample program that duplicates the issue if you want help. I recommend creating a Github repository with the sample to make it easy for others to download the project and test.

mrengineer7777 commented 2 years ago

Here's how delayMicroseconds has changed between Oct 2019 and now: image Note the datatype change from uint32_t to uint64_t to prevent an overflow.

dynamic21xx commented 2 years ago

I'm so sorry for the "infinite loop" opinion, it's too early, in my debugging. I will try your suggestion. Thank you!

VojtechBartoska commented 2 years ago

any updates on this @dynamic21xx? Thanks!

VojtechBartoska commented 2 years ago

@dynamic21xx Any news?