Main Content

Set COM Port for Upload and Communication in Simulink

In most of the Pixhawk® boards, the COM port required to upload the firmware (bootloader COM port) and the COM port required to establish the connection with computer over MAVLink (Communications COM Port) are the same. You can use the same port to upload the firmware and communicate with the Pixhawk board after the firmware is uploaded. In such cases, you can use the Automatically determine serial port for firmware upload option in Simulink® Model settings to detect the COM port.

No additional settings are required in External Mode, Connected I/O or PIL tab for the corresponding simulation modes. You can continue to use the same serial port.

However, for some Pixhawk boards, the bootloader COM Port and the main communications COM Port are different. When you connect to such boards, the bootloader port appears first in the Device Manager. The port shows for a few seconds and then the main communications port appears. A sample GIF image is shown here. The bootloader COM port is needed for firmware upload and the communication port is needed for MAVLink communication.

Ensure that you specify the correct COM ports for firmware upload and MAVLink communication. You will be unable to upload the firmware if you specify the communication COM port value instead of bootloader COM port value for firmware upload. In such cases, perform the following steps to set the upload and communication port correctly for a Pixhawk board in the Simulink model for different modes of simulation.

Set Bootloader COM Port for Firmware Upload and Deploy

  1. For the Simulink model, launch the Model Settings.

    A sample image of the default settings for hardware implementation is shown here.

  2. Clear the Automatically determine serial port for firmware upload option and enter the bootloader serial port in Serial Port for firmware upload (This should be the bootloader port).

  3. Deploy the Simulink model. On the Hardware tab, in the Mode section, select Run on board and then click Build, Deploy & Start.

Set Communication COM Port for Monitor & Tune (External Mode)

  1. Perform the settings for Build options as shown in the topic Set Bootloader COM Port for Firmware Upload and Deploy.

  2. In External mode tab, clear the Use the same host serial port for External Mode as used for firmware upload option and mention the main communications port in Host Serial Port (this must be different from the bootloader port you mentioned earlier in Build options).

  3. Run External Mode for the model.

Set Communication COM Port for PIL

  1. Perform the settings for Build options as shown in the topic Set Bootloader COM Port for Firmware Upload and Deploy.

  2. In PIL Tab, clear the Use the same host serial port for PIL as used for firmware upload option and mention the main communications port in Host Serial port (this must be different from the bootloader port you mentioned earlier in Build options).

Set Communication COM Port for Connected IO

  1. Perform the settings for Build options as shown in the topic Set Bootloader COM Port for Firmware Upload and Deploy.

  2. In Connected I/O tab, clear the Use the same host serial port for Connected I/O as used for firmware upload option and mention the main communications port in Host Serial Port (this must be different than the bootloader port you mentioned earlier in Build options).