Leon Anavi
IT Tips && Tricks

Mobile & Embedded

Created: 13.02.2026 06:04 Last Modified: 13.02.2026 06:14 Views: 6
Keywords: GPS, Linux, NEO-6M, OpenEmbedded, UART, Yocto

The Yocto Project on Raspberry Pi 5 Episode 12: Enabling UART on Raspberry Pi 5 with Yocto and Using a NEO-6M GPS Module

Working with hardware interfaces on embedded Linux becomes much more powerful when you control the entire software stack. In this episode of my video tutorial about the Yocto Project and OpenEmbedded, we will enable UART on a Raspberry Pi 5 running a custom Linux image and connect it to a U-Blox NEO-6M-0 GPS module. By the end, you will be able to read live NMEA GPS data over a serial interface.

The demonstration uses the Yocto LTS release Scarthgap and the meta-raspberrypi BSP layer. The GPS module is connected through the ANAVI Gardening uHAT using GPIO14 (Pin 8, TXD) and GPIO15 (Pin 10, RXD) on the Raspberry Pi 5 40-pin header.

Hardware Setup

The U-Blox NEO-6M-0 GPS module communicates over UART at 9600 baud by default. The wiring is as follows:

Raspberry Pi 5 GPIO14 (Pin 8, TXD) → GPS RX
Raspberry Pi 5 GPIO15 (Pin 10, RXD) → GPS TX
GND → GND
3.3V or 5V (depending on module requirements) → VCC

Step 1: Enable UART in Yocto (local.conf)

Edit your local.conf file in your Yocto build directory and add the following configuration:

ENABLE_UART = "1"

RPI_EXTRA_CONFIG:append = "\n\
dtoverlay=uart0\n\
"

IMAGE_INSTALL:append = " gpsd gps-utils"

This configuration:

Enables the UART interface.
Applies the uart0 device tree overlay.
Installs gpsd and gps-utils into the image.

After modifying local.conf, rebuild your image and flash it to the Raspberry Pi 5.

Step 2: Configure gpsd at Runtime

Once the system boots, edit the gpsd configuration file:

/ etc / default / gpsd

Modify it as follows:

START_DAEMON="true"
GPSD_OPTIONS=""
DEVICES=" / dev / ttyAMA0"
GPSD_SOCKET=" / run / gpsd.sock"

This tells gpsd to use the primary UART device /dev/ttyAMA0.

Step 3: Initialize the Serial Port

Before restarting gpsd, configure the serial interface manually to match the GPS module default baud rate (9600 8N1):

sudo systemctl stop gpsd

stty -F / dev / ttyAMA0 9600 cs8 -cstopb -parenb

sudo systemctl start gpsd

Now you can verify the GPS data using:

cgps -s

If the GPS module has a satellite fix, you should see live updates including position, time, and speed.

Troubleshooting: Viewing Raw NMEA Data

If you do not see data in cgps, check the raw UART output directly:

tail -f / dev / ttyAMA0

Example raw NMEA output:

root@raspberrypi5:~# tail -f / dev / ttyAMA0
$GPRMC,,V,,,,,,,,,,N*53
$GPVTG,,,,,,,,,N*30
$GPGGA,,,,,,0,00,99.99,,,,,,*48
$GPGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*30
$GPGSV,1,1,00*79
$GPGLL,,,,,,V,N*64

If you see NMEA sentences like the above, the UART interface is working correctly. Empty fields and status ?V? indicate no satellite fix yet. Move the GPS antenna outdoors or near a window and wait for a valid fix.

Conclusion

By enabling UART in Yocto and configuring gpsd correctly, you can reliably interface a Raspberry Pi 5 with a U-Blox NEO-6M GPS module. This setup is ideal for embedded applications requiring positioning, timing, or speed data, and demonstrates how flexible and powerful a custom Yocto-based Linux image can be.



  Home | About | Contact | Disclaimer | Sitemap © 2009-2022 Leon Anavi. All rights reserved.