Skip to content
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

rtl8710bn HLW8012 CHANGE interrupts not supported #155

Open
alexxx113 opened this issue Aug 11, 2023 · 17 comments
Open

rtl8710bn HLW8012 CHANGE interrupts not supported #155

alexxx113 opened this issue Aug 11, 2023 · 17 comments
Labels
bug Something isn't working esphome Strictly ESPHome related help wanted Extra attention is needed RTL8710B Realtek RTL87xxB family

Comments

@alexxx113
Copy link

alexxx113 commented Aug 11, 2023

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

@alexxx113 alexxx113 changed the title HLW8012... W [ 0.102] CHANGE interrupts not supported generic-rtl8710bn-2mb-788k HLW8012 CHANGE interrupts not supported Aug 11, 2023
@alexxx113 alexxx113 changed the title generic-rtl8710bn-2mb-788k HLW8012 CHANGE interrupts not supported rtl8710bn HLW8012 CHANGE interrupts not supported Aug 11, 2023
@kuba2k2 kuba2k2 added bug Something isn't working help wanted Extra attention is needed labels Aug 14, 2023
@alexxx113
Copy link
Author

Can I help?
logs?
tests?

@kuba2k2
Copy link
Member

kuba2k2 commented Aug 15, 2023

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?

@alexxx113
Copy link
Author

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

@kuba2k2 kuba2k2 added the esphome Strictly ESPHome related label Aug 18, 2023
@mihsu81
Copy link
Contributor

mihsu81 commented Aug 21, 2023

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

@mihsu81
Copy link
Contributor

mihsu81 commented Aug 21, 2023

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

@SuperXL2023
Copy link

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.

@appleimperio
Copy link

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.

@flohav
Copy link

flohav commented Feb 4, 2024

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 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.

@appleimperio
Copy link

appleimperio commented Feb 4, 2024

@flohav thank you it worked

@RF197
Copy link

RF197 commented Mar 3, 2024

Thanks a lot, this worked for me as well (on a BX chip)!

@raufaser
Copy link

raufaser commented Apr 5, 2024

@SuperXL2023 Thanks a lot. It worked.

@Jaco1990
Copy link
Contributor

@SuperXL2023 the solution worked for me aswell

@flohav
Copy link

flohav commented Jun 8, 2024

Do you know how to apply this fix to Home Assistant Esphome? I couldn't fine the correct file to modify...

@Jaco1990
Copy link
Contributor

Jaco1990 commented Jun 8, 2024

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

@kuba2k2
Copy link
Member

kuba2k2 commented Jun 8, 2024

Or you can probably use version: 1.6.0
Let me know if it works fine.

@flohav
Copy link

flohav commented Jun 9, 2024

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.

@foltifekiedu
Copy link

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.

Where can I find this .esphome folder?

I have a simple esphome folder that contains the yaml files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working esphome Strictly ESPHome related help wanted Extra attention is needed RTL8710B Realtek RTL87xxB family
Projects
None yet
Development

No branches or pull requests

10 participants