libretiny
libretiny copied to clipboard
rtl8710bn HLW8012 CHANGE interrupts not supported
libretiny:
board: generic-rtl8710bn-2mb-788k
framework:
version: dev
not work
libretiny:
board: generic-rtl8710bn-2mb-788k
framework:
version: 1.1.0
work good
error log
System_Init1
OSC8M: 7fea9f
boot reason: 1
System_Init2
I [ 0.000] LibreTiny v1.2.0+sha.e99c612 on generic-rtl8710bn-2mb-788k, compiled at Aug 12 2023 01:25:36, GCC 10.3.1 (-Os)
I [ 0.000] Reset reason: Unknown
I [ 0.007] Preferences initialized
[I][logger:302]: Log initialized
[C][ota:477]: There have been 9 suspected unsuccessful boot attempts.
[D][lt.preferences:104]: Saving 1 preferences to flash...
[D][lt.preferences:132]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[I][app:029]: Running through setup()...
[C][switch.gpio:011]: Setting up GPIO Switch 'Relay'...
[D][switch:016]: 'Relay' Turning OFF.
[D][switch:055]: 'Relay': Sending state OFF
[D][switch:016]: 'Relay' Turning OFF.
[C][status_led:055]: Setting up Status LED...
[C][light:035]: Setting up light 'statusled'...
[D][status_led:038]: 'statusled': Setting initial state
[D][status_led:049]: 'statusled': Setting state OFF
[D][light:036]: 'statusled' Setting:
[D][light:041]: Color mode:
[C][hlw8012:014]: Setting up HLW8012...
W [ 0.102] CHANGE interrupts not supported
Can I help? logs? tests?
Not really. Seems like CHANGE interrupts were "supported" previously, only due to a bug that produced undefined behavior. Realtek doesn't support CHANGE interrupts properly and that's why it's failing now.
When you tried 1.1.0, did it actually report correct energy measurements? Or just produced no warning?
version: 1.1.0 work no problem
sensor:
- platform: hlw8012 model: BL0937
log
01:12:01 | [D] | [sensor:093] | 'Voltage': Sending state 225.81564 V with 1 decimals of accuracy 01:12:01 | [D] | [sensor:093] | 'Power': Sending state 25.43914 W with 1 decimals of accuracy 01:12:01 | [D] | [sensor:093] | 'Energy': Sending state 541.63861 Wh with 1 decimals of accuracy 01:12:06 | [D] | [hlw8012:082] | Got power=22.6W, voltage=226.0V 01:12:06 | [D] | [sensor:093] | 'Voltage': Sending state 226.04918 V with 1 decimals of accuracy 01:12:06 | [D] | [sensor:093] | 'Power': Sending state 22.57724 W with 1 decimals of accuracy 01:12:06 | [D] | [sensor:093] | 'Energy': Sending state 541.66998 Wh with 1 decimals of accuracy
I'm encountering the same issue on a generic-rtl8710bx-4mb-980k with the hlw8012 platform.
[1B][0;36m[D][binary_sensor:034]: 'Power Button': Sending initial state OFF[1B][0m
[1B][0;36m[D][text_sensor:064]: 'MAC Wifi Address': Sending state '64:F2:FB:3B:AF:1C'[1B][0m
[1B][0;36m[D][text_sensor:064]: 'ESPHome Version': Sending state '2023.9.0-dev Aug 21 2023, 23:18:40'[1B][0m
[1B][0;35m[C][hlw8012:014]: Setting up HLW8012...[1B][0m
[1B][1;33mW [ 0.130] [1B][0mCHANGE interrupts not supported
[1B][1;33mW [ 0.136] [1B][0mCHANGE interrupts not supported
But for me LT 1.1.0 causes a Hard Fault Error when opening the web browser.
RTL8195A[HAL]: Hard Fault Error!!!!
RTL8195A[HAL]: R0 = 0x1
RTL8195A[HAL]: R1 = 0x50
RTL8195A[HAL]: R2 = 0x0
RTL8195A[HAL]: R3 = 0x10005bbc
RTL8195A[HAL]: R12 = 0x80000000
RTL8195A[HAL]: LR = 0x80380c3
RTL8195A[HAL]: PC = 0x0
RTL8195A[HAL]: PSR = 0x20000000
RTL8195A[HAL]: BFAR = 0xe000ed38
RTL8195A[HAL]: CFSR = 0x20000
RTL8195A[HAL]: HFSR = 0x40000000
RTL8195A[HAL]: DFSR = 0x0
RTL8195A[HAL]: AFSR = 0x0
RTL8195A[HAL]: PriMask 0x0
RTL8195A[HAL]: BasePri 0x0
RTL8195A[HAL]: SVC priority: 0x00
RTL8195A[HAL]: PendSVC priority: 0xf0
RTL8195A[HAL]: Systick priority: 0xf0
My guess is that it is related to the change introduced in 1.2.0 which adds preliminary support for RTL8720C.
https://github.com/kuba2k2/libretiny/blob/f3871388ce54bf277f2067370ee99c57b677e186/cores/realtek-amb/arduino/src/wiring_irq.c#L65
I found a temporary solution. Slightly modified the code in the file: < config dir >/.esphome/platformio/platforms/libretiny/cores/realtek-amb/arduino/src/wiring_irq.c
file: wiring_irq.c
...<other code>
62: #if LT_RTL8720C
63: event = IRQ_FALL_RISE; // <- BUG [ IRQ_FALL_RISE ] not defined, the compiler stops at this point with an error
64: #elif LT_RTL8710B
65: event = IRQ_RISE;
66: #else
67: LT_W("CHANGE interrupts not supported !!!!!!");
68: #endif
...<other code>
First I tried to add to line 62: #if LT_RTL8720C || LT_RTL8710B, but the compiler stopped here with the error IRQ_FALL_RISE not defined
after that, I added lines 64, 65 and everything compiled perfectly and worked.
I hope this bug will be fixed in the next version of the library, and I hope my temporary solution will help you.
Having the same issue on the WR3E using the RTL8710BN in ESPHome with a MOES iR and RF system. when use the PA12 pin which is the one for the ir receiver can't compile it this si the log.
OTAx SELE[fffffffc]
OTA1 USE
IMG2 DATA[0x80899c0:3844:0x10005000]
IMG2 SIGN[RTKWin(10005008)]
IMG2 ENTRY[0x10005000:0x803c7f9]
System_Init1
System_Init2
I [ 0.000] LibreTiny v1.4.1 on wr3e, compiled at Jan 28 2024 13:04:19, GCC 10.3.1 (-Os)
W [ 0.021] CHANGE interrupts not supported
<RTL8195A>ROM:[V0.1]
FLASHRATE:4
===== Enter Image 1 ====
Img2 Sign: RTKWin, InfaStart @ 0x0803c7f9
System_Init1
System_Init2
I [ 0.000] LibreTiny v1.4.1 on wr3e, compiled at Jan 28 2024 13:04:19, GCC 10.3.1 (-Os)
W [ 0.045] CHANGE interrupts not supported
io driver parameters error! file_name: rtl8711b_gpio_rom.c, line: 61
Any update on this issue?
Thank You.
Hi,
I had the exact same issue, and the following solution by SuperXL2023 works perfectly. Thanks !
I found a temporary solution. Slightly modified the code in the file: < config dir >/.esphome/platformio/platforms/libretiny/cores/realtek-amb/arduino/src/wiring_irq.c
file: wiring_irq.c ...<other code> 62: #if LT_RTL8720C 63: event = IRQ_FALL_RISE; // <- BUG [ IRQ_FALL_RISE ] not defined, the compiler stops at this point with an error 64: #elif LT_RTL8710B 65: event = IRQ_RISE; 66: #else 67: LT_W("CHANGE interrupts not supported !!!!!!"); 68: #endif ...<other code>First I tried to add to line 62:
#if LT_RTL8720C || LT_RTL8710B, but the compiler stopped here with the errorIRQ_FALL_RISE not definedafter that, I added lines 64, 65 and everything compiled perfectly and worked.I hope this bug will be fixed in the next version of the library, and I hope my temporary solution will help you.
@flohav thank you it worked
Thanks a lot, this worked for me as well (on a BX chip)!
@SuperXL2023 Thanks a lot. It worked.
@SuperXL2023 the solution worked for me aswell
Do you know how to apply this fix to Home Assistant Esphome? I couldn't fine the correct file to modify...
Do you know how to apply this fix to Home Assistant Esphome? I couldn't fine the correct file to modify...
A temporary fix was included in release v1.6.0. At the moment the only way to use this fix in Home Assistant and ESPHome is to add the following lines to your board declaration.
rtl87xx:
board: ${board}
framework:
version: dev
Or you can probably use version: 1.6.0 Let me know if it works fine.
It works fine, I used version: dev, updated via Esphome on HA and no issue at all.
Another issue however, since a few months I can't get any value from my HLW8012 whereas it used to work. But that's another issue I guess.
I found a temporary solution. Slightly modified the code in the file: < config dir >/.esphome/platformio/platforms/libretiny/cores/realtek-amb/arduino/src/wiring_irq.c
file: wiring_irq.c ...<other code> 62: #if LT_RTL8720C 63: event = IRQ_FALL_RISE; // <- BUG [ IRQ_FALL_RISE ] not defined, the compiler stops at this point with an error 64: #elif LT_RTL8710B 65: event = IRQ_RISE; 66: #else 67: LT_W("CHANGE interrupts not supported !!!!!!"); 68: #endif ...<other code>First I tried to add to line 62:
#if LT_RTL8720C || LT_RTL8710B, but the compiler stopped here with the errorIRQ_FALL_RISE not definedafter that, I added lines 64, 65 and everything compiled perfectly and worked.I hope this bug will be fixed in the next version of the library, and I hope my temporary solution will help you.
Where can I find this .esphome folder?
I have a simple esphome folder that contains the yaml files
Shouldn't this issue be closed now that PR #282 has been merged?
And wouldn't it be better to use a similar solution to the beken-72xx (i.e. switch the edge in the interrupt handler)? https://github.com/libretiny-eu/libretiny/blob/9114bc4c4961ab38ea41a1fdf21ec79eb97d9254/cores/beken-72xx/arduino/src/wiring_irq.c#L54
Yes, it would be better to have an actual solution, instead of the "workaround" which #282 is. This is perhaps why this issue is still open.
I've ordered a smart plug, when it arrives if I manage to open it and it has this chip I'll see if I can implement a proper solution.
Well, no joy, the aliexpress lottery sent me a plug based on the LN882HKI chip. Is that supported by libretiny or my only option is openbeken?
Well, no joy, the aliexpress lottery sent me a plug based on the LN882HKI chip. Is that supported by libretiny or my only option is openbeken?
LN882HKI support was recently added to ESPHome via LibreTiny & PR though there may be some bugs with compiling as boards get straightened out.