-
Notifications
You must be signed in to change notification settings - Fork 7.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Guru Meditation Error: Core 0 panic'ed (Interrupt wdt timeout on CPU0) with modbus and autosleep (IDFGH-13961) #14792
Comments
Hi, @juantxorena According to my investigation, the direct cause of this problem is that the clock source selected by the modbus component when initializing the UART peripheral is Currently the modbus stack does not support the use with esp_pm's autolightsleep, please set |
Hi @esp-wzh, thanks for the update. So I'm a bit confused by the modbus uart thing, according to the docs, this clock source is only set in the legacy UART driver, whatever that means. Should I open a bug report in the esp-modbus project then about this? Why is forcing this clock and not another? I also will have the 32kHz external oscillator, and I will use it as the main root clock, but I was testing stuff in a breadboard and I didn't had it there. Would this help somehow? Other than that, I need the autolightsleep, so I would need a workaround. Actually I only use modbus for reading data every X minutes (like 5 minutes or so), so I have some ideas:
Of course, the ideal thing would be to fix this problem. Would any of these solutions work? |
Actually this problem should be fixed in the sleep process, I'm working on it.
Set the uart clock source to
When the UART clock source is PLL, the wake-up process will be stuck at the resume UART peripheral. This is a bug in the sleep code and has nothing to do with whether the application layer UART reads data.
I think this is feasible.
The modbus stack is too large for ULP. It is too hard to implement it.
As mentioned above, HP UART supports XTAL clock source, just select it, but there is no exported configuration, you need to manually modify the modbus code. |
/cc @alisitsyn |
Hi @juantxorena, The UART autolightsleep feature is suppose to wakeup when the UART receives the certain number of logic 1. The assumptions that can be checked for this feature to work:
Depending on the baud rate, a few characters after that will also not be
You may open the separate issue against esp-modbus and link it with this one. This is not a bug actually but unsupported feature of esp-modbus. The esp-modbus is component which works with many supported targets, and it is hard to address all possible issues on all targets with all features and their options due to legacy code interface. It is supposed that in some specific cases these issues can be resolved on user side.
The Modbus can use LP_UART as well (checked). However, the UART configuration needs to be changed. We can talk about other solutions after this. Thanks. |
@alisitsyn I've tried this and apparently it works, so thanks for the help. It's hard to tell because as I said before, this problem happens only sometimes, but I've left the device reading from modbus every 2 minutes for 40 minutes and it didn't happen a single time. For reference, I used the following config:
Which is the values from the portserial_m.c and my values, with the RC_FAST as clock, which according to the docs it's never powered down.
I've seen in the docs that they recommend to send some data via UART to wake it up, but I don't know how to do this with modbus. For now I haven't got any problem, though, maybe because my code is the one always starting the communication with the modbus device. The next step for me will be to try to use it with the LP UART. How would it work? Simply using the same uart_param_config trick as before? I'm not sure since the port will be now LP_UART_NUM_0, not UART_NUM_X, I don't know if modbus needs to check stuff there when configuring. Thanks for the help anyway. |
Update about the LP UART: apparently it works. I had to configure a normal UART with the same pins for modbus, and then I used the following:
and it seems to be working. I had to disable the UART output and use USB/JTAG instead, and now I'm relying in the published messages to mqtt with the modbus data to check if it's working (since the auto sleep will be disabled while the jtag is connected). If I tried to configure modbus with the LP_UART port it failed and went into a reboot loop, so I had to do this not-so-clean way. It would be great if modbus could be configured directly with the LP_UART, but of course specifying then that it won't work with RS485, only with RS232. |
You can use the
Unfortunately, it will be impossible to override the clocks on application level because with
Yes, this may be a reason.
This is possible to do this for Modbus on your custom devices with preamble but this will not satisfy the standard.
I was thinking about it already but unfortunately I had hard time to workaround all the legacy issues to allow the Modbus stack to work on all supported esp-idf versions with all possible UART configuration options. And yes, the RS485 is not supported in LP_UART but it can be used with the auto-switching RS485 variant. |
Do you have any updates related to this issue? Have you been able to solve the issues in your application? I think it is better to leave the code unchanged for now and address the PW in your application. The update to address the PW in esp-modbus is added into todo list. Would you agree with this? |
@alisitsyn sorry for my late answer. Yes, it is fixed, as you suggested, modifying the portserial_m.c file to make it use the LP_UART and its default clock was enough. I'll wait for the modbus component to be upgraded, but for now it's OK. |
Thank you for feedback. This will be added to my task list to update in esp-modbus v2 with low priority. Unfortunately, it will take some time and will not be implemented in esp-modbus v1.0.x. Please consider using of v2 beta. |
The issue is added as separate ticket and this issue is closed. |
Answers checklist.
IDF version.
v5.3.1
Espressif SoC revision.
esp32-c6
Operating System used.
Linux
How did you build your project?
VS Code IDE
If you are using Windows, please specify command line type.
None
Development Kit.
esp32-c6-devkitm-1
Power Supply used.
USB
What is the expected behavior?
When using modbus with uart and automatic sleep enabled, it should work without problems.
What is the actual behavior?
It breaks occasionally with the below errors and restarts.
Steps to reproduce.
This code configures the automatic sleep mode
The following code is the initialization of modbus, using UART 1:
I'm reading data like this:
This modbus thing is the only use I have in my application for UART.
Debug Logs.
More Information.
No response
The text was updated successfully, but these errors were encountered: