ESPHome flashed BK7231N glitching with debug logging enabled

Hi!

I’m encountering a peculiar Wi-Fi connectivity issue with BK-Chip Curtain Modules supported by the LibreTiny platform of esphome. The modules were flashed using tuya-cloudcutter. Out of the 9 modules I purchased, I’ve successfully flashed two without any issues. However, the third module is exhibiting strange behavior after flashing.

Environment:

  • Product Type: Wi-Fi Curtain Modules (BK-Chips)
  • Platform: LibreTiny (esphome)
  • Flashing Tool: tuya-cloudcutter
  • Total Devices: 9 (all from the same shop)

Observed Behavior:

  • On the third module, after flashing:
    • The status LED blinks continuously.
    • It connects to Wi-Fi but redirects to the Wi-Fi chooser page on the web interface.
  • Changing the logger level from INFO to DEBUG resolves the issue, and the module functions properly.
  • Reverting back to INFO logger level brings back the problem.
  • Recompiling with DEBUG logger level again makes the module work correctly.

Additional Information:

  • Another module from the same batch works fine with INFO logging level.
  • Suspected issue: Flash memory might be corrupted at certain addresses. Recompiling with DEBUG logging seems to shift the code, avoiding these addresses.

Request for Community Assistance:

  • Has anyone experienced similar issues with BK-Chip modules or similar hardware?
  • Could the logger level affect the stability or functionality of these modules in this manner?
  • Any suggestions or potential solutions to ensure stable operation with INFO logging level?

Additional Context:

  • I have concerns about running devices on DEBUG logging level due to past experiences with other devices.

Any insights, suggestions, or shared experiences would be greatly appreciated. Thank you in advance!

I have no clue but it’s probably worth sharing your config and some logs.

Sure, thanks for pointing this out.

Here is my config:

substitutions:
  devicename: living_room_roller_blind_3
  friendly_name: Living Room Roller Blind 3

esphome:
  name: $devicename
  friendly_name: "${friendly_name}"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # power_save_mode: HIGH

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "${friendly_name} AP"
    password: !secret backup_ap_password

captive_portal:

mdns:

debug:
  update_interval: 30s

# Enable logging
logger:
  baud_rate: 0
  level: **INFO**

text_sensor:
  - platform: debug
    reset_reason:
      name: Reset Reason

sensor:
  - platform: wifi_signal
    name: WiFi signal
    update_interval: 60s
  - platform: uptime
    name: Uptime

button:
  - platform: restart
    name: Restart

# Enable Home Assistant API
api:

ota:

web_server:

bk72xx:
  board: generic-bk7231n-qfn32-tuya

text_sensor:
  - platform: libretiny
    version:
      name: LibreTiny Version

light:
  - platform: status_led
    pin:
      number: GPIO10
    id: ${devicename}_led

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO23
      inverted: true
    id: "stop_button"
    on_press:
      then:
        - cover.stop: "${devicename}_cover"
  - platform: gpio
    pin:
      number: GPIO24
      inverted: true
    id: "open_button"
    on_press:
      then:
        - cover.open: "${devicename}_cover"
  - platform: gpio
    pin:
      number: GPIO26
      inverted: true
    id: "close_button"
    internal: true
    on_press:
      then:
        - cover.close: "${devicename}_cover"

switch:
  - platform: gpio
    pin: GPIO6
    id: "open_switch"
    interlock: [ close_switch ]
    interlock_wait_time: 0.1s
  - platform: gpio
    pin: GPIO7
    id: "close_switch"
    interlock: [ open_switch ]
    interlock_wait_time: 0.1s
    internal: true

cover:
  - platform: time_based
    device_class: shade
    has_built_in_endstop: false
    name: None
    id: "${devicename}_cover"
    open_action:
      - switch.turn_on: "open_switch"
    open_duration: 49s
    close_action:
      - switch.turn_on: "close_switch"
    close_duration: 40s
    stop_action:
      - switch.turn_off: "close_switch"
      - switch.turn_off: "open_switch"
    assumed_state: true

What concerns logs: when in debug log level, it boots up and works successfully. And there are no suspicious log entries. The same as in the other two (now three) devices.

We are more interested in logs when INFO logging is configured, as this is when device doesn’t work properly.

However, when in INFO log level - it pretends it did not connect to WiFi (which is false, as it gets the IP address and I land at web interface via my usual WiFi SSID). In this mode, I can only set up WiFi or upload new firmware (which I use to jailbreak from this state - upload firmware with logging set to debug).

In this mode logging doesn’t work (also not via esphome logs CLI command) - device simply doesn’t initialize the logging port. How do I get to the logs in such a case?