Many Commercial customers use the Nextion display in their own business projects.
They may need to upload the Nextion firmware through their own MCU.
Here we disclose the upload protocol.

Users do not need to know anything about the Nextion Upload Protocol if
– they only upload firmware through Nextion Editor.
– they only upload firmware using the microSD card method.

In order to set up a serial connection between Nextion and your MCU,
– first users must know which serial port is the Nextion connected to,
– and figure out the connection parameters.
If you know it, skip step 1.

Step 1. Find your Serial port

Send a connect instruction in different connection parameters.

connect

Nextion will return data when the serial port and connection parameters are correct.
For example, NX4024T032_011R will return 8 groups (as below).

comok 1,101,NX4024T032_011R,52,61488,D264B8204F0E1828,16777216

Here’s the explanation.
comok: handshaking protocol is setup.
1: 1 model with touch panel, 0 model without touch panel
101: Reserved
NX4024T032_011R: Nextion device model
52: Firmware version
61488: MCU code
D264B8204F0E1828: Nextion device serial number
16777216: FLASH Size (in bytes)

Note 1: It is suggested to send an empty instruction before the connect instruction.
Note 2: Delay (1000000/baud rate)+30ms between each attempt.
example: If users try 9600bps, they should delay by 1000000/9600+30=134ms

Step 2. Upload firmware

Now as users know the serial port and current baud rate, they can send the upload command.

whmi-wri filesize,baud,res0

filesize: filesize of the tft file (byte)
baud: baud rate
res0: reserved, it can be filled with any ASCII character

Users can now send their binary tft file to the serial port after they receive it.
– First, send the properly formatted whim-wri instruction
– Nextion device will return 0x05 within 500ms of the whmi-wri instruction.
– Users should split the data into 4096 byte packets
– Nextion device will return 0x05 byte when each 4096 byte packet is received.
– Send the remaining data (<4096byte) in the final partial packet.
– Nextion device will return 0x05 byte when all data has been received.

To make your own upload code,
you can refer to the implementation released in the Iteadlib Arduino Nextion Library.

For Nextion Editor v0.53 and later, please refer to Nextion Upload Protocol v1.1