Closed M0uC0 closed 1 month ago
I cannot try this right now, but this should stop the BLE scan before starting the upload:
bluetooth_proxy:
id: ble_proxy
esp32_ble_tracker:
id: ble_tracker
script:
- id: !extend upload_tft
then:
- lambda: |-
static const char *const TAG = "CUSTOM.script.upload_tft";
ble_tracker->dump_config();
ESP_LOGD(TAG, "Stopping BLE Tracker scan...");
ble_tracker->stop_scan();
ESP_LOGD(TAG, "Disabling BLE Tracker scan...");
ble_tracker->set_scan_active(false);
ESP_LOGD(TAG, "State: %s", id(ble_proxy)->has_active() ? "Active" : "Passive");
while (ble_proxy->get_bluetooth_connections_limit() != ble_proxy->get_bluetooth_connections_free()) {
ESP_LOGD(TAG, "Connections: %i of %i", int(ble_proxy->get_bluetooth_connections_limit() - ble_proxy->get_bluetooth_connections_free()), int(ble_proxy->get_bluetooth_connections_limit()));
if (id(ble_proxy)->has_active()) {
ESP_LOGD(TAG, "Setting passive mode...");
ble_proxy->set_active(false);
}
vTaskDelay(pdMS_TO_TICKS(1000));
App.feed_wdt();
}
Could you please let me know if that helps (and please provide logs)?
At max speed gets to around 19% and panel reboots
This sounds like lack of memory. Could you please see the free heap
informed during the upload process (before the change I've proposed earlier)?
It was only after i made this post that i saw the comments around the "Bluetooth Proxy Customization" in the documentation. I thought that this was new problem because everything worked ok when i updated to 4.2.4. Although i hadn't read the sugestions... i tried the 1st one.. and it worked flawlessly.
I have 2 new panels to install in the next days... i'll flash one with bluetooth proxy enabled and see how it will work when updating the tft... and i'll collect the logs.
i tried the 1st one.. and it worked flawlessly.
Which one was that?
I've improved docs to suggest stopping the BLE scan before upload TFT, but we also solved a memory leak that could be affecting this:
I will close this for now to make the backlog a bit more clear, but please feel free to continue the comments here and reopen if the problem persists after updating to the new version (to be released).
Status update on this issue with v4.3
With the new version it got to 24.54% at max speed and the panel rebooted by itself.
[20:13:33][D][nextion.upload.idf:238]: Uploaded 24.38 %, remaining 5667532 bytes, free heap: 3568 bytes [20:13:33][D][nextion.upload.idf:238]: Uploaded 24.43 %, remaining 5663436 bytes, free heap: 5288 bytes [20:13:34][D][nextion.upload.idf:238]: Uploaded 24.49 %, remaining 5659340 bytes, free heap: 4972 bytes [20:13:34][D][nextion.upload.idf:238]: Uploaded 24.54 %, remaining 5655244 bytes, free heap: 6624 bytes
The other panels i have with bluetooth proxy off all had free heap around 140000 bytes and no problems uploading the tft file.
Here i go.. disabling proxy.. uploading tft.. enabling proxy.. :)
But do you have that code that stops the BLE when the upload TFT is called as shown here?
Not yet... i was trying to see if with the new version has is if it would upload :) I'll check if the script works later.
I think we still have some space to save some RAM, but it is getting hard to find those bytes.
I've just added the script part to my yaml customization area Updated firmware and tried the TFT upload. It didn't managed to fully upload the tft.. it rebooted.
[22:26:17][D][addon_upload_tft.script.nextion_upload:129]: Starting TFT upload... [22:26:17][D][nextion.upload.idf:275]: Nextion TFT upload requested [22:26:17][D][nextion.upload.idf:276]: Exit reparse: YES [22:26:17][D][nextion.upload.idf:277]: URL: http://192.168.99.10:8123/local/nspanel_eu.tft [22:26:17][D][nextion.upload.idf:298]: Baud rate: 9600 [22:26:17][D][nextion.upload.idf:301]: Exiting Nextion reparse mode [22:26:17][D][nextion.upload.idf:411]: TFT file size: 7494348 bytes [22:26:17][D][nextion.upload.idf:428]: Uploading Nextion [22:26:22][D][nextion.upload.idf:468]: Upgrade response is [] - 0 byte(s) [22:26:22][E][nextion.upload.idf:474]: Preparation for TFT upload failed 0 "" [22:26:22][D][nextion.upload.idf:475]: Close HTTP connection [22:26:22][D][nextion.upload.idf:537]: Nextion TFT upload finished: Preparation for TFT upload failed [22:26:22][E][nextion.upload.idf:557]: Nextion TFT upload failed [22:26:22][D][addon_upload_tft.script.nextion_upload:131]: TFT upload: Preparation for TFT upload failed
Am i doing something wrong?
Did you reflash the panel with cable to install esp-idf. If you did, it will likely reboot a couple of times when you upload the tft file to the panel
it was already on esp-idf.. i have changed to esp-idf sometime ago.. and flashed via cable when i did it... has it is recommended..
the problem was available memory with bluetooth proxy on. And it is solved disabling bluetooth proxy to upload the tft file.
the problem now with the script to disable proxy while uploading is:
[22:26:22][E][nextion.upload.idf:474]: Preparation for TFT upload failed 0 ""
It didn't managed to fully upload the tft.. it rebooted.
I didn't pasted the log because it's the same behaviour.. Around 20000 when starts.. and going down till around 5000 when it reboots.. It seems like nothing changed except the error I posted.
Looks like the new ESPHome will be even worse:
v2024.2.2:
RAM: [= ] 10.2% (used 33276 bytes from 327680 bytes)
Flash: [====== ] 61.6% (used 1130105 bytes from 1835008 bytes)
v2024.3.0b1:
RAM: [= ] 10.3% (used 33596 bytes from 327680 bytes)
Flash: [====== ] 64.1% (used 1175629 bytes from 1835008 bytes)
Let's forget this problem... just disable bluetooth proxy.. upload.. enable again. As long has bluetooth proxy doesn't make the panel unstable.. :)
But this is my main concern. You mentioned 20000 before upload, which is quite a few. If we keep loosing 320 on each ESPHome update it won't take long until this stops working.
Yes.. 20000 with bluetooth proxy.. and 140000 without.
When uploading without bluetooth proxy the heap is very stable... and always around 140000 during all the process. The problem with bluetooth is that it starts with 20000 but starts to decrease soon... and when it get bellow 5000 starts to slow down upload and finaly the panel reboots.
Am i missing something concerning the script !extend on upload_tft ?
Am i missing something concerning the script !extend on upload_tft ?
That was a try to stop BLE before starting the upload, but looks like that was not effective. I will try to investigate this further.
And it is solved disabling bluetooth proxy to upload the tft file.
I would recommend you also disable Upload TFT when BT proxy is enabled.
You can replace the packages like this:
substitutions:
# Settings - Editable values
device_name: "nsp-quarto"
wifi_ssid: !secret wifi_ssid
wifi_password: !secret wifi_password
nextion_update_url: "http://192.168.99.10:8123/local/nspanel_eu.tft" # Optional for `esp-idf` framework
# Add-on configuration (if needed)
# heater_relay: "1" # Possible values: "1" or "2"
# Customization area
##### My customization - Start #####
wifi:
networks:
- id: !extend wifi_default
- ssid: !secret wifi_ssid2
password: !secret wifi_password
power_save_mode: LIGHT
# Set Wi-Fi power save mode to "LIGHT" as required for Bluetooth on ESP32
# Encrypt the communication between ESPHome and Home Assistant
api:
encryption:
key: !secret api_key
reboot_timeout: 60min
# Use my global OTA password
ota:
password: !secret ota_key
# Enable Bluetooth proxy
bluetooth_proxy:
##### My customization - End #####
# Core and optional configurations
packages:
remote_package:
url: https://github.com/Blackymas/NSPanel_HA_Blueprint
ref: main
files:
# - nspanel_esphome.yaml # Basic package (core + tft upload)
- esphome/nspanel_esphome_core.yaml # Core package
# - esphome/nspanel_esphome_addon_upload_tft.yaml # Upload TFT package (disable when BT Proxy is enabled)
# Optional advanced and add-on configurations
# - advanced/esphome/nspanel_esphome_advanced.yaml
# - nspanel_esphome_addon_climate_cool.yaml
# - nspanel_esphome_addon_climate_heat.yaml
# - nspanel_esphome_addon_climate_dual.yaml
refresh: 300s
esp32:
framework:
type: esp-idf
packages:
core_package: !include
upload_tft_package: !include
...
This will remove all the Upload TFT engine and free-up quite a lot of memory, which will probably give you a more stable system.
I'll try it out. Thanks
Upgraded to ESPHome to v4.3.1 with bluetooth proxy on. Tried to update TFT like that.
Started with: [15:21:46][D][nextion.upload.idf:285]: File size: 7497824 bytes [15:21:46][D][nextion.upload.idf:286]: Free heap: 30776 [15:21:46][D][nextion.upload.idf:026]: Range start: 0 [15:21:51][D][nextion.upload.idf:091]: Uploaded 0.05 %, remaining 7493728 bytes, free heap: 27240 bytes [15:21:51][D][nextion.upload.idf:095]: recv_string [08.00.00.62.00 (5)] [15:21:51][I][nextion.upload.idf:101]: Nextion reported new range 6422528 [15:21:51][D][nextion.upload.idf:026]: Range start: 6422528 [15:21:51][D][esp-idf:000]: I (82860) HTTP_CLIENT: Body received in fetch header state, 0x3fff8b9f, 89 [15:21:51][D][nextion.upload.idf:091]: Uploaded 85.71 %, remaining 1071200 bytes, free heap: 20452 bytes [15:21:51][D][nextion.upload.idf:091]: Uploaded 85.77 %, remaining 1067104 bytes, free heap: 22148 bytes
Finished with: [15:22:13][D][nextion.upload.idf:091]: Uploaded 99.70 %, remaining 22624 bytes, free heap: 10436 bytes [15:22:13][D][nextion.upload.idf:091]: Uploaded 99.75 %, remaining 18528 bytes, free heap: 8744 bytes [15:22:13][D][nextion.upload.idf:091]: Uploaded 99.81 %, remaining 14432 bytes, free heap: 10436 bytes [15:22:13][D][nextion.upload.idf:091]: Uploaded 99.86 %, remaining 10336 bytes, free heap: 7036 bytes [15:22:13][D][nextion.upload.idf:091]: Uploaded 99.92 %, remaining 6240 bytes, free heap: 8736 bytes [15:22:13][D][nextion.upload.idf:091]: Uploaded 99.97 %, remaining 2144 bytes, free heap: 12516 bytes [15:22:13][D][nextion.upload.idf:091]: Uploaded 100.00 %, remaining 0 bytes, free heap: 17480 bytes [15:22:13][D][nextion.upload.idf:307]: Successfully uploaded TFT to Nextion! [15:22:13][D][nextion.upload.idf:309]: Close HTTP connection [15:22:13][D][nextion.upload.idf:317]: Nextion TFT upload finished: Upload successful [15:22:13][D][nextion.upload.idf:328]: Restarting ESPHome
Managed to update tft without problems.. :)
7kb of free heap is quite low. :( I will have to look on what is causing the memory issue. It could be something else running is parallel with the upload.
yes, it is low... and only managed to finish because it only needed to upload 15% of the file.
concerning the: packages: core_package: !include upload_tft_package: !include
I haven't tried it out.. i only have one panel with bluetooth proxy on.. and i don't have complaints regarding stability..
I ran some test uploading TFT in an almost clean system (only basic package, with TFT upload, but no BLE) and transferred files multiple times (alternating between US and US Land to force it starting from 0), always at 115kbps. I see the free memory going a bit down in the first 30%, but then it gets quite stable. It fluctuates, which is expected, but nothing point to a leak.
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">
| Run 1 | Run 2 | Run 3 | Run 4 -- | -- | -- | -- | -- Before: | 200728 | 200692 | 200576 | 199784 Min: | 98528 | 99624 | 100368 | 98256 Max: | 110444 | 111068 | 111732 | 110404 Diff: | 11916 | 11444 | 11364 | 12148 Avg: | 104674 | 104329 | 105123 | 104520 Median: | 105412 | 104980 | 105744 | 105128 Sdev: | 2005 | 2151 | 2122 | 2066
TFT Version
4.2.6
ESPHome Version
4.2.6
Blueprint Version
4.2.6
Panel Model
EU
What is the bug?
TFT Upload Fails when Bluetooth proxy is enabled
Steps to Reproduce
Updated to 4.2.6 (Blueprint and ESP32) when trying to update TFT it fails. At max speed gets to around 19% and panel reboots At 115200 gets to around 3% and panel reboots
Removed bluetooth_proxy: Reflashed ESP32 with v4.2.6.
No problems uploading TFT at max speed... gets to 100% without any errors or rebooting.
Your Panel's YAML
ESPHome Logs
No response
Home Assistant Logs
No response