How to Update Firmware Using a USB-to-Serial Interface

Introduction

This article provides a detailed, step-by-step guide to updating the firmware of NCD sensors (Gen 2) via a USB-serial interface using a Python script. The process is designed to be simple and straightforward, making it accessible even for those new to firmware updates, while ensuring reliability for seasoned users. Both the necessary firmware files and the Python script are conveniently available in GitHub repositories, streamlining the setup and empowering you to enhance your NCD sensors with the latest features and improvements.

Overview

This is an overview of updating the firmware on your NCD sensor using a USB-to-serial converter. To get started, you’ll need to download the Python script and the latest firmware file from our GitHub repository. Next, connect the USB-to-serial device to your NCD sensor, and then run the Python script to kick off the firmware update process.

Firmware Update USB Serial Overview

Requierements

In order to perform a firmware update via USB Serial some requiremets are necessaries, here we describe each necesary tool you need to have:

Procedure

Step 1. First you will need to download:

  • Vxx_PRxx_xx.ncd
  • ncd_py_bootloader_v2.py

Navigate to the ncd-io/Enterprise-Sensor-Firmware repository, click on the Code button, and select the Download ZIP option.

NCD Firmware Update Repository
Click to Expand

Step 2. After download the files you should see some similar to this in your Downloads folder:

Click to Expand

Step 3. The next step is to extract the contents of the ZIP folder.‬

Click to Expand

Step 4. After extracting the contents, you should see something like this:‬

Click to Expand

Step 5. Next, navigate to the PRxx-xxx-main folder and find the ncd_py_bootloader_v2 file. Move this file to the same location as the Vx_PRxx-xx.ncd file. If you’re using the Enterprise-Sensor-Firmware-main, the ncd_py_bootloader_v2 file should already be in place. For simplicity, we recommend using the /Downloads folder as your working directory. Once this step is complete, your file setup should look something like this:

Firmware update usb serial py bootloader file
Click to Expand
NCD Firmware update Enterprise Sensor Firmware Repository
Click to Expand

Step 6. Access to inside the NCD sensor by opening the white box by removing the four screws.

firmware update opening sensor
Click to Expand

Step 7. Locate the debugger port connector and connect the USB Programmer flat cable:

Click to Expand
Click to Expand

Step 8. Before proceeding, ensure that your PC has the necessary USB-to-serial driver installed. To confirm this, connect the USB-to-serial adapter to your PC and open Device Manager. If the driver is installed correctly, you’ll see a COM port number listed, similar to the example below:

Firmware update USB Serial Driver
Click to Expand

Step 9. Navigate to the /Downloads folder, assuming this is where your downloaded files are stored. Once there, click on the address bar at the top (which shows the current file path), type cmd, and press Enter to open a Command Prompt window.

firmware update usb serial folder
Click to Expand
firmware update usb serial folder
Click to Expand

Step 10. This action will open a Command Prompt window at the “/Downloads” location.

Firmware update usb serial command prompt window
Click to Expand

Step 11. To start the firmware update, enter the following command, replacing “xx” with your specific values:

				
					python ncd_py_bootloader_v2.py  ./Vxx_PRxx_xx.ncd 240
				
			

For example:

				
					python ncd_py_bootloader_v2.py COM4 ./V10_PR55-4.ncd 240
				
			

Step 12. Press the Enter key to initiate the firmware update process.

Click to Expand

Step 13. You should then see the message: “Waiting for startup msg…

Click to Expand

Step 14. At this point, press and release the RESET button on the sensor.

Click to Expand

Step 15. After pressing the reset button, look for the messages Startup msg received and Manifest store success! to appear. Once these are displayed, the firmware update process will start automatically.

Click to Expand

Step 16. Wait for the process to complete. Once finished, you should see the message ‘Sending Reboot’, indicating that the device will reboot.

Step 17. At the end of the procedure, you can safely disconnect the USB programmer.

Drawbacks

Sometimes you need to install the: python or the pyserial module. You can check the Python version on Windows operating systems by typing the following command in a Command Prompt window:

				
					python --version
				
			

If Python is not already installed on your Windows PC, you will need to install it.

Installing Python on windows

Step 1. First, go to the following link:

Step 2. Click on the appropriate installer option (32-bit or 64-bit):‬

Click to Expand

Step 3. Once the installer is downloaded, you will need to execute it:‬

Click to Expand

Step 4: Click the Install Now option to begin the installation process.

Step 5: Once the Setup was successful message appears, click the Close button to finish.

Step 6: After completing the Python installation, verify it by opening a new Command Prompt window and typing: 

				
					python --version
				
			

Press Enter to check that Python is installed correctly.

Step 7: Running the command should display the installed Python version, such as:

				
					Python 3.8.x.
				
			

‭Installing PySerial

If you attempt to run the Python script and encounter the error No module named ‘serial’, it means you likely need to install the pyserial module.
NCD Firmware update python no module named serial
Click to Expand

To install the pyserial module, open a new Command Prompt window and enter the following command:

				
					‭py -m pip install pyserial‬
				
			
Click to Expand

Once you’ve completed the pyserial module installation, close the Command Prompt window. Then, open a new Command Prompt window and attempt to run the NCD Python script for the firmware update again.

‭Could not open port COM‬

If you try to run the Python script and see the error could not open port ‘COMx’, it indicates that the script cannot communicate with the device through the specified COM port. This problem may stem from several possible causes. To resolve it, we recommend the following steps:
NCD Firmware Update Python Port issue message
Click to Expand
  • Check for Other Applications Using the COM Port: Ensure that no other applications on your computer, such as XCTU, Node-RED, or similar tools, are currently using the COM port. If any are, close them temporarily while performing the firmware update.
  • Inspect the USB Cable: Confirm that the USB cable is in good working condition. If you suspect an issue, try swapping it with a different USB cable and test the connection again.

Summary

This article walks you through the process of updating the firmware on your NCD sensor using a USB-to-serial converter and a Python script. Start by downloading the necessary Python script and firmware file from our GitHub repository, then connect your USB-to-serial adapter to the sensor. Ensure Python 3.8 is installed with the pyserial module, and organize the files in your /Downloads folder. Run the script from a Command Prompt window to initiate the update, pressing the reset button to begin the process—look for confirmation messages like Startup msg received and Manifest store success!. If you encounter errors such as No module named ‘serial’ or could not open port ‘COMx’, troubleshoot by installing missing modules, checking for COM port conflicts, or inspecting your USB cable. With these steps, you’ll have your NCD sensor’s firmware updated smoothly and efficiently.

Thanks, NCD Team

Share this on:

Facebook
X
LinkedIn
Reddit
Email