> For the complete documentation index, see [llms.txt](https://nxp.gitbook.io/mobilerobotics/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/mobilerobotics/flashing-guide/fmurt6-board/demo-pixhawk-4-gps-module-with-zephyr.md).

# DEMO: Pixhawk-4 GPS Module with Zephyr

## Introduction

This tutorial describes how to operate the [Pixhawk-4 GPS Module](https://docs.px4.io/main/en/gps_compass/gps_holybro_m8n_m9n.html) (Ublox M8N) with [Zephyr](https://github.com/NXPHoverGames/Zephyr/tree/pr-mimxrt1062-fmurt6) on [FMURT6 board](https://www.nxp.com/part/RDDRONE-FMURT6#/).

## Items Needed

| NAME                                                                                           | QUANTITY |
| ---------------------------------------------------------------------------------------------- | -------- |
| [Holybro Pixhawk-4 GPS](https://holybro.com/products/pixhawk-4)                                | 1        |
| [RDDRONE-FMURT6 Board](https://www.nxp.com/part/RDDRONE-FMURT6#/)                              | 1        |
| [Pixhawk Debug Adapter](https://holybro.com/products/pixhawk-debug-adapter)                    | 1        |
| [J-Link EDU Mini](https://www.segger.com/products/debug-probes/j-link/models/j-link-edu-mini/) | 1        |
| USB-C to USB-A Cable                                                                           | 2        |
| Micro-USB to USB-A Cable                                                                       | 1        |
| [JST SH 10-Pin Cable](https://www.pcboard.ca/jst-sh-10-pin-cable)                              | 1        |
| [.05" 10-Pin Ribbon Cable](https://www.adafruit.com/product/1675)                              | 1        |

## Hardware Procedure

<figure><img src="/files/nY7DKH6kZ9B56ePUZtdh" alt=""><figcaption><p>Complete Hardware Setup</p></figcaption></figure>

<figure><img src="/files/JRRoNMiSlBvyTDWd4lQs" alt=""><figcaption><p>Block Diagram (Hardware)</p></figcaption></figure>

## Zephyr Software Procedure

#### Initialize west workspace and checkout branch

<pre><code><strong>west init -m git@github.com:NXPHoverGames/Zephyr.git zephyrproject
</strong><strong>cd zephyrproject
</strong><strong>west update
</strong><strong>cd zephyr
</strong><strong>git checkout pr-gps-fmurt6
</strong></code></pre>

#### Building and Flashing

```
west build -b mimxrt1062_fmurt6 samples/drivers/neo_m8 -p
west flash
```

#### Error Handling

1. if you get the following error (or similar): "fatal error: command exited with status 1: /opt/segger/jlink\_v788a/jlinkexe -nogui 1 -if swd -speed auto -device 'mimxrt1062xxx6a?bankaddr=0x60000000\&loader=hyperflash' -commanderscript /tmp/tmpgcx4mnhnjlink/runner.jlink -nogui 1", then simply run west flash again. Or unplug the board, then re-plug it. And then flash again.
2. if you get the following error: "fatal error: required program jlinkexe not found; install it or add its location to path", then download and install jlink from [here](https://www.segger.com/downloads/jlink/), and add its folder to the path using the following command: set PATH=%PATH%;\<path to Jlink.exe>
   * Note: this command only modifies the PATH variable for the current session.

## Running and Demonstration

#### Key Notes

* If any configuration API returns NACK (which can be seen from the debug logs), then it's recommended to run the application again.
* The reception of GPS data from the Pixhawk-4 GPS Module depends on the location of operation. According to our testing, this module doesn't work indoors, but only outdoors, or rooms with at least one open window.
* We may need to wait 3-5 minutes before our GPS module is able to receive data. As shown in 'Logs From Testing on GPS Module 2 (Success)', the module first senses the data on the 280th function call, but after that returns the correct data consistently. **According to our observations, the 'GPS Fix' Indicator LED will start blinking when GPS signals are available.**

#### Logs

{% file src="/files/wCCUvD4sqPCAm63ocmC5" %}
GPS Module Logs
{% endfile %}
