> For the complete documentation index, see [llms.txt](https://nxp.gitbook.io/vmu-rt1176/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://nxp.gitbook.io/vmu-rt1176/examples/testing-can3-in-px4.md).

# Testing CAN3 in PX4

At this point time (11/11/2024) CAN3 is not enabled to use DronCAN or UAVCAN by default in PX4.\
The port itself is enabled and can be exercised using CANSEND and CANDUMP commands\
&#x20;\
This tutorial describes how to enable the CAN3 Port on the NXP-VMU-RT117x in PX4-Autopilot, and demonstrates the transmission of CAN Frames between two VMU-RT117x using the can-utils module.

## ITEMS REQUIRED

<table data-full-width="true"><thead><tr><th width="100" align="center">S.No.</th><th>Name</th><th width="100" align="center">Quantity</th></tr></thead><tbody><tr><td align="center">1</td><td><a href="https://github.com/NXPHoverGames/NXP-FMUMRT">NXP-VMU-RT117x</a></td><td align="center">2</td></tr><tr><td align="center">2</td><td><a href="https://nxp.gitbook.io/mr-b3rb/archive/whats-in-the-box-pre-production-version/witb-mr-b3rb-bmf#j-link-edu-mini-debugger">J-Link EDU MINI DEBUGGER</a></td><td align="center">2</td></tr><tr><td align="center">3</td><td><a href="https://holybro.com/products/pixhawk-debug-adapter">Pixhawk Debug Adaptor</a></td><td align="center">2</td></tr><tr><td align="center">4</td><td><a href="https://www.apple.com/shop/product/HN892ZM/A/mophie-usb-a-cable-with-usb-c-connector-1-m">USB-C (Male) to USB-A (Male) Cable</a> [Connects VMU-RT117x and Pixhawk Adaptor with the host]</td><td align="center">4</td></tr><tr><td align="center">5</td><td><a href="https://in.rsdelivers.com/product/rs-pro/rs-pro-usb-20-cable-male-usb-a-to-male-micro-usb-b/1828498">Micro-USB (Male) to USB-A (Male) Cable</a> [Connects J-Link EDU Mini Debugger with the host]</td><td align="center">2</td></tr><tr><td align="center">6</td><td><a href="https://baskaerospace.com.au/shop/cables/jst-gh-4-pin-twisted-can-cable/">4-Pin JST-GH to 4-Pin JST-GH (Twisted CAN Cable)</a> [Connects the CAN3 Ports of VMU-RT117x]</td><td align="center">1</td></tr><tr><td align="center">7</td><td><a href="https://www.pcboard.ca/jst-sh-10-pin-cable">JST SH 10-Pin Cable</a> [Connects VMU-RT117x and Pixhawk Debug Adaptor]</td><td align="center">2</td></tr><tr><td align="center">8</td><td><a href="https://www.adafruit.com/product/1675">10-Pin 2x5 Socket-Socket IDC (SWD) Ribbon Cable</a> [Connects J-Link and Pixhawk Adaptor]</td><td align="center">2</td></tr></tbody></table>

{% hint style="info" %}
Note: We require 6 USB-A (Female) ports on the host machine for this setup. You may utilize a USB-HUB (USB-A Male to USB-A Female) to get multiple ports on your host machine.
{% endhint %}

## HARDWARE SETUP

The high level overview here is that we want to be able to both program and  gain console access to the MR-VMU-RT1176 so we can issue commands. Note that there are other valid ways to get a console, such as through an attached Telemetry radio.  Programming may also use MCU-LINK-MR.

<figure><img src="/files/3YNAbrezZoMQpuoBuQIu" alt=""><figcaption><p>Hardware Connections for Reference (Without USB Wires)</p></figcaption></figure>

<div><figure><img src="/files/uv8jSOEPBWArTRtROiNe" alt=""><figcaption><p>CAN3: 4-Pin JST-GH to 4-Pin JST-GH (Twisted CAN Cable) Connection with the CAN3 Port on VMU-RT117x</p></figcaption></figure> <figure><img src="/files/vekz1sIQt9QO3nzq10mN" alt=""><figcaption><p>USB-C Connection with the CAN3 Port on VMU-RT117x</p></figcaption></figure> <figure><img src="/files/Quk45CNWsR9mjNLD76CG" alt=""><figcaption><p>DEBUG: 10-Pin 2x5 Socket-Socket IDC (SWD) Ribbon Cable Connection with the Debug port on VMU-RT117x</p></figcaption></figure></div>

<figure><img src="/files/50hqQrubvZt00mM23djW" alt=""><figcaption><p>Block Diagram for Hardware Connections (Complete)</p></figcaption></figure>

## SOFTWARE SETUP

### PX4-Autopilot SETUP

```
cd ~
git clone git@github.com:PX4/PX4-Autopilot.git
cd PX4-Autopilot
make px4_fmu-v6xrt menuconfig
```

Select the following options:

1. Device Drivers → CAN Driver Support
2. License Setup → Use components that have GPL/LGPL licenses
3. Application Configuration → CAN Utilities → SocketCAN cansend tool
4. Application Configuration → CAN Utilities → SocketCAN candump tool

{% hint style="warning" %}
In file "\~/PX4-Autopilot/platforms/nuttx/init/imxrt/rc.board\_arch\_defaults", add the line "param set-default -s UAVCAN\_ENABLE 1" after line number 6.
{% endhint %}

<pre><code>cd ~/PX4-Autopilot

<strong>make px4_fmu-v6xrt
</strong>make px4_fmu-v6xrt_bootloader
</code></pre>

<figure><img src="/files/ANNkL4Ir3F1XQbRLbRP2" alt="" width="563"><figcaption><p>Successful Build Output for px4_fmu-v6xrt</p></figcaption></figure>

<figure><img src="/files/f6bZ99fKPHtFzS2Mo83z" alt="" width="563"><figcaption><p>Successful Build Output for px4_fmu-v6xrt_bootloader</p></figcaption></figure>

### FLASH PX4-Autopilot on VMU

{% hint style="danger" %}
For simplicity, connect only one setup at a time with your host machine, i.e. only 1 VMU-RT117x + Pixhawk Debug Adaptor + J-Link EDU MINI.

Alternatively, you may connect both the setups simultaneously and select the appropriate J-Link when running JLinkExe command.

<img src="/files/rzEOyrPxeia1VF9Dn4h3" alt="" data-size="original">
{% endhint %}

{% hint style="info" %}
Note: The following steps need to be run once for each of the two VMU-RT117x.
{% endhint %}

Open a new shell and perform the following steps for flashing PX4-Autopilot on VMU-RT117x.

{% code overflow="wrap" fullWidth="false" %}

```
cd ~/PX4-Autopilot
JLinkExe
connect
MIMXRT1176XXXA_M7
S
4000
loadbin boards/px4/fmu-v6xrt/extras/px4_fmu-v6xrt_bootloader.bin 0x30000000
loadbin build/px4_fmu-v6xrt_default/px4_fmu-v6xrt_default.bin 0x30020000
```

{% endcode %}

<div><figure><img src="/files/AfB14i1XYhhILsCVpfLe" alt=""><figcaption><p>Setting up J-Link for Flashing VMU-RT117x</p></figcaption></figure> <figure><img src="/files/imydBeeZb0myyTEtP4gI" alt=""><figcaption><p>Successful output for Flashing VMU-RT117x</p></figcaption></figure></div>

## EXECUTION STEPS

Get the serial shell of the two VMU-RT117x on your host machine.

{% hint style="warning" %}
Note: Baudrate for the serial console is **57600**.
{% endhint %}

<figure><img src="/files/3F0FzCkuFV5hG4sPKfuJ" alt=""><figcaption></figcaption></figure>

Execute `"`**`candump can2`**" on one shell and "**`cansend can2 123#1234567890`**" on the other.&#x20;

<figure><img src="/files/8GmdFEGD4s5rlZOePGYB" alt=""><figcaption></figcaption></figure>
