Closed kinselp closed 2 years ago
hey, can you try this
autoexec.bec
(only the file with beC
as file ending)yep will try now
same result
21:12:56.895 QPC: Reset 21:12:56.935 MQT: stat/nspanel2/RESULT = {"Time":"2022-07-02T21:12:56","Uptime":"0T00:00:07","UptimeSec":7,"Heap":165,"SleepMode":"Dynamic","Sleep":0,"LoadAvg":310,"MqttCount":1,"Berry":{"HeapUsed":13,"Objects":217},"POWER1":"ON","POWER2":"ON","Wifi":{"AP":1,"SSId":"Panska_IOT","BSSId":"7E:8A:20:4C:55:B5","Channel":11,"Mode":"11n","RSSI":70,"Signal":-65,"LinkCount":1,"Downtime":"0T00:00:04"}} 21:12:57.010 MQT: stat/nspanel2/STATUS10 = {"StatusSNS":{"Time":"2022-07-02T21:12:56","ANALOG":{"Temperature1":27.9},"ESP32":{"Temperature":49.4},"TempUnit":"C"}} 21:12:59.869 MQT: tele/nspanel2/STATE = {"Time":"2022-07-02T21:12:59","Uptime":"0T00:00:10","UptimeSec":10,"Heap":163,"SleepMode":"Dynamic","Sleep":0,"LoadAvg":390,"MqttCount":1,"Berry":{"HeapUsed":13,"Objects":217},"POWER1":"ON","POWER2":"ON","Wifi":{"AP":1,"SSId":"Panska_IOT","BSSId":"7E:8A:20:4C:55:B5","Channel":11,"Mode":"11n","RSSI":70,"Signal":-65,"LinkCount":1,"Downtime":"0T00:00:04"}} 21:12:59.924 MQT: tele/nspanel2/SENSOR = {"Time":"2022-07-02T21:12:59","ANALOG":{"Temperature1":28.0},"ESP32":{"Temperature":49.4},"TempUnit":"C"} 21:13:07.830 CMD: FlashNextion http://nspanel.pky.eu/lui-us-l-release.tft 21:13:07.847 MQT: stat/nspanel2/RESULT = {"FlashNextion":"Done"} 21:13:07.896 FLH: host: nspanel.pky.eu, port: 80, get: /lui-us-l-release.tft 21:13:09.957 FLH: Something has gone wrong flashing display firmware [bytes('1AFFFFFF')] 21:13:10.058 FLH: Send (High Speed) flash start 21:13:10.470 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 0, "time_elapsed": 0}} 21:13:16.976 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 1, "time_elapsed": 6}} 21:13:19.926 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 2, "time_elapsed": 9}} 21:13:22.919 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 3, "time_elapsed": 12}} 21:13:25.851 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 4, "time_elapsed": 15}} 21:13:28.784 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 5, "time_elapsed": 18}} 21:13:31.604 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 6, "time_elapsed": 21}} 21:13:34.556 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 7, "time_elapsed": 24}} 21:13:37.463 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 8, "time_elapsed": 27}} 21:13:40.467 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 9, "time_elapsed": 30}} 21:13:43.429 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 10, "time_elapsed": 33}} 21:13:46.183 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 11, "time_elapsed": 36}} 21:13:49.259 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 12, "time_elapsed": 39}} 21:13:52.179 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 13, "time_elapsed": 42}} 21:13:55.164 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 14, "time_elapsed": 45}} 21:13:58.133 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 15, "time_elapsed": 48}} 21:14:00.987 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 16, "time_elapsed": 50}} 21:14:04.007 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 17, "time_elapsed": 53}} 21:14:07.087 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 18, "time_elapsed": 57}} 21:14:10.082 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 19, "time_elapsed": 60}} 21:14:13.008 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 20, "time_elapsed": 62}} 21:14:15.776 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 21, "time_elapsed": 65}} 21:14:18.701 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 22, "time_elapsed": 68}} 21:14:21.810 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 23, "time_elapsed": 71}} 21:14:24.731 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 24, "time_elapsed": 74}} 21:14:27.726 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 25, "time_elapsed": 77}} 21:14:30.632 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 26, "time_elapsed": 80}} 21:14:33.434 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 27, "time_elapsed": 83}} 21:14:38.327 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 28, "time_elapsed": 88}} 21:14:41.450 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 29, "time_elapsed": 91}} 21:14:44.423 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 30, "time_elapsed": 94}} 21:14:47.454 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 31, "time_elapsed": 97}} 21:14:50.219 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 32, "time_elapsed": 100}} 21:14:53.214 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 33, "time_elapsed": 103}} 21:14:56.173 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 34, "time_elapsed": 106}} 21:14:59.257 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 35, "time_elapsed": 109}} 21:15:02.161 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 36, "time_elapsed": 112}} 21:15:04.969 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 37, "time_elapsed": 114}} 21:15:07.916 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 38, "time_elapsed": 117}} 21:15:10.959 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 39, "time_elapsed": 120}} 21:15:14.019 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 40, "time_elapsed": 123}} 21:15:16.973 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 41, "time_elapsed": 126}} 21:15:19.750 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 42, "time_elapsed": 129}} 21:15:22.677 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 43, "time_elapsed": 132}} 21:15:27.370 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 44, "time_elapsed": 137}} 21:15:30.364 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 45, "time_elapsed": 140}} 21:15:33.504 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 46, "time_elapsed": 143}} 21:15:36.480 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 47, "time_elapsed": 146}} 21:15:39.375 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 48, "time_elapsed": 149}} 21:15:42.382 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 49, "time_elapsed": 152}} 21:15:45.360 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 50, "time_elapsed": 155}} 21:15:48.246 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 51, "time_elapsed": 158}} 21:15:51.390 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 52, "time_elapsed": 161}} 21:15:54.175 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 53, "time_elapsed": 164}} 21:15:57.113 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 54, "time_elapsed": 167}} 21:16:00.072 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 55, "time_elapsed": 170}} 21:16:03.008 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 56, "time_elapsed": 172}} 21:16:06.157 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 57, "time_elapsed": 176}} 21:16:08.912 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 58, "time_elapsed": 178}} 21:16:11.863 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 59, "time_elapsed": 181}} 21:16:14.809 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 60, "time_elapsed": 184}} 21:16:17.748 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 61, "time_elapsed": 187}} 21:16:20.660 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 62, "time_elapsed": 190}} 21:16:23.517 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 63, "time_elapsed": 193}} 21:16:26.464 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 64, "time_elapsed": 196}} 21:16:29.428 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 65, "time_elapsed": 199}} 21:16:32.328 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 66, "time_elapsed": 202}} 21:16:37.175 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 67, "time_elapsed": 207}} 21:16:40.018 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 68, "time_elapsed": 209}} 21:16:43.142 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 69, "time_elapsed": 213}} 21:16:46.052 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 70, "time_elapsed": 215}} 21:16:49.009 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 71, "time_elapsed": 218}} 21:16:51.925 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 72, "time_elapsed": 221}}
strange, are you using normal tasmota binary or the build for the nspanel?
https://tasmota.github.io/install/firmware/development/tasmota32-nspanel.bin
used the webinstaller with nspanel selected.
will try again. and see - but 99.9% sure it was nspanel
If the flashing is still not working, please send WebLog 3
in tasmota console and post the log output while the flashing stops working.
failed again - but no FLH: Something has gone wrong flashing display firmware [bytes('1AFFFFFF')] showing this time, but still fails at 72%. see attached log log.txt .
Looks like there is a potential bug if the download get's slower than the flashing. (could be due to bad wifi signal or so)
Can you give it a try with this in the autoexec.be? Changed the speed of the serial flashing (also delete .bec after changeing & restart tasmota)
# Sonoff NSPanel Tasmota Lovelace UI Berry Driver | code by joBr99
# based on;
# Sonoff NSPanel Tasmota (Nextion with Flashing) driver | code by peepshow-21
# based on;
# Sonoff NSPanel Tasmota driver v0.47 | code by blakadder and s-hadinger
# Example Flash
# FlashNextion http://ip-address-of-your-homeassistant:8123/local/nspanel.tft
# FlashNextion http://nspanel.pky.eu/lui.tft
class Nextion : Driver
static header = bytes('55BB')
static flash_block_size = 4096
var flash_mode
var flash_start_millis
var flash_size
var flash_written
var flash_buff
var flash_offset
var awaiting_offset
var tcp
var ser
var last_per
var url
def split_55(b)
var ret = []
var s = size(b)
var i = s-2 # start from last-1
while i > 0
if b[i] == 0x55 && b[i+1] == 0xBB
ret.push(b[i..s-1]) # push last msg to list
b = b[(0..i-1)] # write the rest back to b
end
i -= 1
end
ret.push(b)
return ret
end
def crc16(data, poly)
if !poly poly = 0xA001 end
# CRC-16 MODBUS HASHING ALGORITHM
var crc = 0xFFFF
for i:0..size(data)-1
crc = crc ^ data[i]
for j:0..7
if crc & 1
crc = (crc >> 1) ^ poly
else
crc = crc >> 1
end
end
end
return crc
end
# encode using custom protocol 55 BB [payload length] [payload length] [payload] [crc] [crc]
def encode(payload)
var b = bytes()
b += self.header
b.add(size(payload), 2) # add size as 2 bytes, little endian
b += bytes().fromstring(payload)
var msg_crc = self.crc16(b)
b.add(msg_crc, 2) # crc 2 bytes, little endian
return b
end
def encodenx(payload)
var b = bytes().fromstring(payload)
b += bytes('FFFFFF')
return b
end
def sendnx(payload)
import string
var payload_bin = self.encodenx(payload)
self.ser.write(payload_bin)
log(string.format("NXP: Nextion command sent = %s",str(payload_bin)), 3)
end
def send(payload)
var payload_bin = self.encode(payload)
if self.flash_mode==1
log("NXP: skipped command becuase still flashing", 3)
else
self.ser.write(payload_bin)
log("NXP: payload sent = " + str(payload_bin), 3)
end
end
def write_to_nextion(b)
self.ser.write(b)
end
def screeninit()
log("NXP: Screen Initialized")
self.sendnx("recmod=1")
end
def write_block()
import string
log("FLH: Read block",3)
while size(self.flash_buff)<self.flash_block_size && self.tcp.connected()
if self.tcp.available()>0
self.flash_buff += self.tcp.readbytes()
else
tasmota.delay(50)
log("FLH: Wait for available...",3)
end
end
log("FLH: Buff size "+str(size(self.flash_buff)),3)
var to_write
if size(self.flash_buff)>self.flash_block_size
to_write = self.flash_buff[0..self.flash_block_size-1]
self.flash_buff = self.flash_buff[self.flash_block_size..]
else
to_write = self.flash_buff
self.flash_buff = bytes()
end
log("FLH: Writing "+str(size(to_write)),3)
var per = (self.flash_written*100)/self.flash_size
if (self.last_per!=per)
self.last_per = per
tasmota.publish_result(string.format("{\"Flashing\":{\"complete\": %d, \"time_elapsed\": %d}}",per , (tasmota.millis()-self.flash_start_millis)/1000), "RESULT")
end
if size(to_write)>0
self.flash_written += size(to_write)
self.ser.write(to_write)
end
log("FLH: Total "+str(self.flash_written),3)
if (self.flash_written==self.flash_size)
log("FLH: Flashing complete - Time elapsed: %d", (tasmota.millis()-self.flash_start_millis)/1000)
self.flash_mode = 0
self.ser = nil
tasmota.gc()
self.ser = serial(17, 16, 115200, serial.SERIAL_8N1)
end
end
def every_100ms()
import string
if self.ser.available() > 0
var msg = self.ser.read()
if size(msg) > 0
log(string.format("NXP: Received Raw = %s",str(msg)), 3)
if (self.flash_mode==1)
var strv = msg[0..-4].asstring()
if string.find(strv,"comok 2")>=0
log("FLH: Send (High Speed) flash start")
self.flash_start_millis = tasmota.millis()
self.sendnx(string.format("whmi-wris %d,115200,res0",self.flash_size))
#self.sendnx(string.format("whmi-wris %d,921600,res0",self.flash_size))
#self.ser = serial(17, 16, 921600, serial.SERIAL_8N1)
elif size(msg)==1 && msg[0]==0x08
log("FLH: Waiting offset...",3)
self.awaiting_offset = 1
elif size(msg)==4 && self.awaiting_offset==1
self.awaiting_offset = 0
self.flash_offset = msg.get(0,4)
log("FLH: Flash offset marker "+str(self.flash_offset),3)
if self.flash_offset != 0
self.open_url_at(self.url, self.flash_offset)
self.flash_written = self.flash_offset
end
self.write_block()
elif size(msg)==1 && msg[0]==0x05
self.write_block()
else
log("FLH: Something has gone wrong flashing display firmware ["+str(msg)+"]",2)
end
else
var msg_list = self.split_55(msg)
for i:0..size(msg_list)-1
msg = msg_list[i]
if size(msg) > 0
if msg == bytes('000000FFFFFF88FFFFFF')
self.screeninit()
elif size(msg)>=2 && msg[0]==0x55 && msg[1]==0xBB
var jm = string.format("{\"CustomRecv\":\"%s\"}",msg[4..-3].asstring())
tasmota.publish_result(jm, "RESULT")
elif msg[0]==0x07 && size(msg)==1 # BELL/Buzzer
tasmota.cmd("buzzer 1,1")
else
var jm = string.format("{\"nextion\":\"%s\"}",str(msg[0..-4]))
tasmota.publish_result(jm, "RESULT")
end
end
end
end
end
end
end
def begin_nextion_flash()
self.flash_written = 0
self.awaiting_offset = 0
self.flash_offset = 0
self.sendnx('DRAKJHSUYDGBNCJHGJKSHBDN')
self.sendnx('recmod=0')
self.sendnx('recmod=0')
self.flash_mode = 1
self.sendnx("connect")
end
def open_url_at(url, pos)
self.url = url
import string
var host
var port
var s1 = string.split(url,7)[1]
var i = string.find(s1,":")
var sa
if i<0
port = 80
i = string.find(s1,"/")
sa = string.split(s1,i)
host = sa[0]
else
sa = string.split(s1,i)
host = sa[0]
s1 = string.split(sa[1],1)[1]
i = string.find(s1,"/")
sa = string.split(s1,i)
port = int(sa[0])
end
var get = sa[1]
log(string.format("FLH: host: %s, port: %s, get: %s",host,port,get))
self.tcp = tcpclient()
self.tcp.connect(host,port)
log("FLH: Connected:"+str(self.tcp.connected()),3)
var get_req = "GET "+get+" HTTP/1.0\r\n"
get_req += string.format("Range: bytes=%d-\r\n", pos)
get_req += string.format("HOST: %s:%s\r\n\r\n",host,port)
self.tcp.write(get_req)
var a = self.tcp.available()
i = 1
while a==0 && i<5
tasmota.delay(100*i)
tasmota.yield()
i += 1
log("FLH: Retry "+str(i),3)
a = self.tcp.available()
end
if a==0
log("FLH: Nothing available to read!",3)
return
end
var b = self.tcp.readbytes()
i = 0
var end_headers = false;
var headers
while i<size(b) && headers==nil
if b[i..(i+3)]==bytes().fromstring("\r\n\r\n")
headers = b[0..(i+3)].asstring()
self.flash_buff = b[(i+4)..]
else
i += 1
end
end
#print(headers)
# check http respose for code 200/206
if string.find(headers,"200 OK")>0 || string.find(headers,"206 Partial Content")>0
log("FLH: HTTP Respose is 200 OK or 206 Partial Content",3)
else
log("FLH: HTTP Respose is not 200 OK or 206 Partial Content",3)
print(headers)
return -1
end
# only set flash size if pos is zero
if pos == 0
# check http respose for content-length
var tag = "Content-Length: "
i = string.find(headers,tag)
if (i>0)
var i2 = string.find(headers,"\r\n",i)
var s = headers[i+size(tag)..i2-1]
self.flash_size=int(s)
end
log("FLH: Flash file size: "+str(self.flash_size),3)
end
end
def flash_nextion(url)
self.flash_size = 0
var res = self.open_url_at(url, 0)
if res != -1
self.begin_nextion_flash()
end
end
def init()
log("NXP: Initializing Driver")
self.ser = serial(17, 16, 115200, serial.SERIAL_8N1)
self.flash_mode = 0
end
end
var nextion = Nextion()
tasmota.add_driver(nextion)
def get_current_version(cmd, idx, payload, payload_json)
import string
var version_of_this_script = 4
var jm = string.format("{\"nlui_driver_version\":\"%s\"}", version_of_this_script)
tasmota.publish_result(jm, "RESULT")
end
tasmota.add_cmd('GetDriverVersion', get_current_version)
def update_berry_driver(cmd, idx, payload, payload_json)
def task()
import string
var cl = webclient()
cl.begin(payload)
var r = cl.GET()
if r == 200
print("Sucessfully downloaded nspanel-lovelace-ui berry driver")
else
print("Error while downloading nspanel-lovelace-ui berry driver")
end
r = cl.write_file("autoexec.be")
if r < 0
print("Error while writeing nspanel-lovelace-ui berry driver")
else
print("Sucessfully written nspanel-lovelace-ui berry driver")
var s = load('autoexec.be')
if s == true
var jm = string.format("{\"nlui_driver_update\":\"%s\"}", "succeeded")
tasmota.publish_result(jm, "RESULT")
else
var jm = string.format("{\"nlui_driver_update\":\"%s\"}", "failed")
tasmota.publish_result(jm, "RESULT")
end
end
end
tasmota.set_timer(0,task)
tasmota.resp_cmnd_done()
end
tasmota.add_cmd('UpdateDriverVersion', update_berry_driver)
def flash_nextion(cmd, idx, payload, payload_json)
def task()
nextion.flash_nextion(payload)
end
tasmota.set_timer(0,task)
tasmota.resp_cmnd_done()
end
def send_cmd(cmd, idx, payload, payload_json)
nextion.sendnx(payload)
tasmota.resp_cmnd_done()
end
def send_cmd2(cmd, idx, payload, payload_json)
nextion.send(payload)
tasmota.resp_cmnd_done()
end
tasmota.add_cmd('Nextion', send_cmd)
tasmota.add_cmd('CustomSend', send_cmd2)
tasmota.add_cmd('FlashNextion', flash_nextion)
trying now. really appreciate the help (twice in week - your a saint)
bingo. that seemed to work. really appreciate the help once again
PROBLEM DESCRIPTION
Flashing of TFT stops at 72% completed whether using Portrait or Landscape on a US Panel
REQUESTED INFORMATION
Make sure your have performed every step and checked the applicable boxes before submitting your issue. Thank you!
Log output here: 21:05:03.221 CMD: FlashNextion http://nspanel.pky.eu/lui-us-l-release.tft 21:05:03.241 MQT: stat/nspanel2/RESULT = {"FlashNextion":"Done"} 21:05:03.292 FLH: host: nspanel.pky.eu, port: 80, get: /lui-us-l-release.tft 21:05:05.015 FLH: Something has gone wrong flashing display firmware [bytes('1AFFFFFF')] 21:05:05.116 FLH: Send (High Speed) flash start 21:05:05.577 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 0, "time_elapsed": 0}} 21:05:11.974 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 1, "time_elapsed": 6}} 21:05:14.000 MQT: tele/nspanel2/RESULT = {"Flashing":{"complete": 2, "time_elapsed": 9}}
then fails at 72%