RTL8710C interrupts seems not working, no values from BL0937
I recently flashed a chip (which reports as rtl8710C). I have it in a gosund SP112 with cuco z0 r v1.2 I flashed ESPhome using ltchiptool. After figuring all pin assignments, I found that there is no reading from BL0937. The Button, LEDs, relays are working. I measured the pins sel, cf and cf1 with an DSO and saw the signals are there. And also verified the traces to the pins at the board. I can even see the sel pin swapping high/low (controled by ESPhome firmware). I can just guess that it might be an issue with PWM inputs but I dont know how the hlw8012 platform treats the inputs. In ESPhome I used the board: "generic-rtl8720cf-2mb-992k". Hope one can give a hint.
In the meantime I tried the esphome pulse_counter and also the pulse_meter and both are not working. It randomly catches a pulse on the pin, so it seems to me that gpios working in polling mode instead of interrupt. Sorry for my missinterpretation in the first post, pointing an issue with PWM. Hope someone can give an advice what else I can try to solve the issue.
I have the exact same issue using the LN882H module. I know my BL0937 works, because it worked under original cloud Tuya. It also works if I flash with OpenBeken, but does not work under LibreTiny.
I have also tested pulse_counter. Does not work. It does work using CBU module (bk72xx). I also tested pulse_meter and I thought it was working, but the data is random. Testing was done with 1kHz signal injection.
Conclusion: possible interrupt issues for LN882H platform.
@illigtr are you sure you're using the latest version of libretiny? Interrupts on the ln882h have been fixed with this commit.
Ok, I will try again this week. Will it also fix for RTL8710C? And one more question: does OTA work now or do I still need the Prokoma fix?
no idea about the rtl8710c, that commit is only for the ln882h.
@olivluca Thanks for reminding me to double-check the version. Sure enough it was compiling with v1.9.1 even though I had this in my YAML:
ln882x:
board: wl2s
framework:
version: latest
family: LN882H
I changed to version: dev, cleared the cache and recompiled. That fixed the pulse_counter, pulse_meter and BL0937 issues. Thanks.
Now the only outstanding issue is to get the OTP MAC address recognized. Even though I burned a unique one in, it is never read, which means all my LN882X devices end up on the wireless network with the same MAC address. Not good.
#338
@makko81 Please check your version, you probably will discover the same issue I had. Use the version: dev directive.
So I tried again with the following settings: --------------‐----------------------------------------------- rtl87xx: board: generic-rtl8720cf-2mb-992k framework: #version: 0.0.0 version: dev #source: https://github.com/prokoma/libretiny#55aacc8 ##source: https://github.com/prokoma/libretiny #source: https://github.com/makko81/libretiny family: RTL8720C --------------‐----------------------------------------------- It doesnt work. I wanted to make a second try with "version: latest" but after flashing first try l lost ability of OTA. I rather guess that Interrupt issue is not solved for RTL8710C.
But please suggest further things I can try or at least what I can gather for you to find the cause.
@makko81, your yaml change would have caused you to pull from the main libretiny repo, which does not contian the OTA changes that are in prokoma's fork. This is why OTA no longer works for you.
Regarding the interrupt issue, it definitely seems like there is some kind of known issue with interrupts, since ESPHome's documentation says the following (https://esphome.io/components/binary_sensor/gpio/#configuration-variables):
use_interrupt (Optional, boolean): Use hardware interrupts instead of polling for better performance and lower CPU usage. Defaults to true for most platforms, but defaults to false for LibreTiny-based platforms (BK72xx, RTL87xx, LN882x) due to hardware limitations. Only supported on internal GPIO pins.
I don't know anything beyond that, but hopefully somebody more knowledgeable on the subject can provide further details.
FYI, I'm trying to get a RTL8710CF-based device running ESPHome using libre-tiny. I've got things mostly working, but I see random instability where the RTL8710CF's UART starts to transmit or receive junk. This can happen within an hour of reboot, or it may take days to occur. Given the random nature of this, I am suspecting some low-level race condition in libre-tiny or the Realtek Ameba SDK is responsible for this, quite possibly in the ISR. I don't want to derail your issue, just letting you know that even if you make progress on your issue, there are possibly more issues lurking. In fact, libre-tiny's own documentation lists the stability for the RTL8720C as "2/5" (https://docs.libretiny.eu/docs/status/supported/#feature-support)