Detect and fix a failed upload

I use a nextion display with a C++ app and I have implemented the above upload protocol to update the screen if needs be.

I was putting on a new version that included a screen update and must have gotten a “blip” and I got the “Data error” screen. The only way I know how to fix this is with the tft file on a sdcard.

Is there anyway to detect this error and fix it with a serial connection only?

The screen is in a case and the sdcard slot is not available through the case. If I was to make this product for anyone else, I can’t give it to someone if a “blip” basically bricks the device and you need to strip it out of the case and put files on sdcards etc etc.

At this point you’ll need to fix it by uploading fresh firmware via Micro SD card. I make a product that uses a Nextion 3.2" Enhanced display which is also designed to be easily updated with new firmware in the field. I supply a small micro SD to USB stick with every device. The SD card contains instructions and PC software for uploading new firmware to the device as well as the display. When the user plugs the micro SD/USB stick into their computer it behaves just like a normal US drive where they can click on the PDF instructions or run the update program. In the case of Nextion updates, we email the new TFT file to the user and they just copy it to their USB stick which saves it to the micro SD card. The device has an externally accessible micro USB port and a quality USB A to micro USB cable is included in their kit. They plug the micro USB cable into the device and then connect a USB port on their PC. The 5V USB power from the computer powers up the device which then detects the presence of a USB connection and displays “Programming Mode” on the Nextion along with images showing the update process. The Nextion display tells them to run the PC software, click UPLOAD then select the firmware they want to send to the device. The Nextion display continuously runs a slideshow of screen captures showing each step of using the PC software to update the device (so the Nextion holds there hand and literally shows them where to click). Once they run the PC software, they click UPLOAD and the software sends the TFT file found in the root directory of the micro SD card. To update the Nextion display (rather than the firmware of the device’s MCU) the software sends a command over serial USB which places the device MCU into “pass thru” mode - the MCU sends “baud=912000” to the Nextion display for the quickest upload speed, signals to the PC that its ready and the computer sends the TFT file over serial using the usual Nextion Upload Protocol 1.1 which the MCU receives and passes on directly to the connected Nextion inside the device case. After the update is sent the device waits for the display to reset and power up then signals that the update is complete. Some people feel that a slower baud rate is less prone to bits corrupting and ruining the firmware update but I STRONGLY prefer the opposite- using the fastest possible baud rate because it greatly reduces the amount of time required to send over the new firmware so the user has much less chance of bumping the device or the USB cable and causing a break in the USB connection during this vulnerable time.

If the serial upload does fail for some reason (and it never actualy has in the field even after hundreds and hundreds of user updates) then they remove the back cover off the device, slide the micro SD card out of the USB stick and insert it in the micro SD extender running down from the Nextion display. Power up and they get the white SD update screen and any issues created by the bum serial update are fixed.

1 Like