Skip to content

Commit fc1bd14

Browse files
committed
imx8dxl-sr-som: update gnss baudrate to 115200
Add a new setup command to execute before gpsd that reconfigures the MIA-M10Q gps receiver for 115200 baudrate and issues soft reset on warm boot. This is required before starting gpsd, to ensure the module is in a sane state as the gpsd ubx driver is not capable of cleanup and has buggy behaviour for baudrate switching.
1 parent 528a9c9 commit fc1bd14

6 files changed

Lines changed: 289 additions & 1 deletion

File tree

conf/machine/imx8dxl-sr-som.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS:append:imx8dxl-sr-som = " \
128128
kernel-module-usb-wwan \
129129
linux-firmware-bcm43455-sr \
130130
sr-v2x-lte-pwrseq \
131+
ubx-setup \
131132
"
132133

133134
# include nice-to-have utilities for peripherals

recipes-support/gpsd/files/imx8dxl-sr-som.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
START_DAEMON="TRUE"
2-
GPSD_OPTIONS="-s 38400 -n"
2+
GPSD_OPTIONS="-s 115200 -n"
33
#
44
# Devices:
55
# - /dev/pps0: pps from gpio
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
From 1f93034050b38029447a201bc5d4305fde70b1b7 Mon Sep 17 00:00:00 2001
2+
From: Josua Mayer <josua@solid-run.com>
3+
Date: Sun, 12 Oct 2025 18:26:40 +0200
4+
Subject: [PATCH] disable werror on linux port
5+
6+
Signed-off-by: Josua Mayer <josua@solid-run.com>
7+
---
8+
port/platform/linux/linux.cmake | 4 ++--
9+
1 file changed, 2 insertions(+), 2 deletions(-)
10+
11+
diff --git a/port/platform/linux/linux.cmake b/port/platform/linux/linux.cmake
12+
index e5233573..ebe3e11a 100644
13+
--- a/port/platform/linux/linux.cmake
14+
+++ b/port/platform/linux/linux.cmake
15+
@@ -24,8 +24,8 @@ message("UBXLIB_FEATURES will be \"${UBXLIB_FEATURES}\"")
16+
set(CMAKE_BUILD_TYPE Debug)
17+
# The Posix implementations require these libraries
18+
set(UBXLIB_REQUIRED_LINK_LIBS -lm -lssl -lpthread -lrt -lgpiod)
19+
-# Warnings are errors
20+
-add_compile_options(-Wall -Werror -Wno-format-truncation -Wno-stringop-truncation -funsigned-char)
21+
+# Warnings are warnings
22+
+add_compile_options(-Wall -Wno-format-truncation -Wno-stringop-truncation -funsigned-char)
23+
24+
# Add any #defines specified by the environment variable U_FLAGS
25+
if (DEFINED ENV{U_FLAGS})
26+
--
27+
2.51.0
28+
Lines changed: 221 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
From 691324f0991a45b88cd48eefc5ae8c7e85bddb1e Mon Sep 17 00:00:00 2001
2+
From: Josua Mayer <josua@solid-run.com>
3+
Date: Sun, 12 Oct 2025 15:09:53 +0200
4+
Subject: [PATCH] add example app to configure mia-m10q uart interface
5+
6+
Add example app to configure MIA-M10Q on SolidRun i.MX8DXL System on
7+
Module after (re-)boot.
8+
9+
It should issue soft reset (because the board cannot issue hard reset),
10+
and update baud-rate from default 38400 to 115200.
11+
12+
This application should be built with UBXLIB_FLAGS:
13+
- -DU_CFG_APP_GNSS_UART=2
14+
- -DU_CFG_APP_UART_PREFIX=/dev/ttyLP
15+
- -DU_CFG_APP_FILTER=GnssUartSetup"
16+
17+
Signed-off-by: Josua Mayer <josua@solid-run.com>
18+
---
19+
example/gnss/uart_setup.c | 190 ++++++++++++++++++++++++++++++++++++++
20+
1 file changed, 190 insertions(+)
21+
create mode 100644 example/gnss/uart_setup.c
22+
23+
diff --git a/example/gnss/uart_setup.c b/example/gnss/uart_setup.c
24+
new file mode 100644
25+
index 00000000..8b8a4393
26+
--- /dev/null
27+
+++ b/example/gnss/uart_setup.c
28+
@@ -0,0 +1,190 @@
29+
+/*
30+
+ * Copyright 2019-2023 u-blox
31+
+ * Copyright 2023-2025 Josua Mayer <josua@solid-run.com>
32+
+ *
33+
+ * Licensed under the Apache License, Version 2.0 (the "License");
34+
+ * you may not use this file except in compliance with the License.
35+
+ * You may obtain a copy of the License at
36+
+ *
37+
+ * http://www.apache.org/licenses/LICENSE-2.0
38+
+ *
39+
+ * Unless required by applicable law or agreed to in writing, software
40+
+ * distributed under the License is distributed on an "AS IS" BASIS,
41+
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
42+
+ * See the License for the specific language governing permissions and
43+
+ * limitations under the License.
44+
+ */
45+
+
46+
+/** @brief This example configures MIA-M10Q UART baud-rate consistently
47+
+ * after hot and cold boot for 115200.
48+
+ */
49+
+
50+
+// Bring in all of the ubxlib public header files
51+
+# include "ubxlib.h"
52+
+
53+
+// Bring in the application settings
54+
+# include "u_cfg_app_platform_specific.h"
55+
+
56+
+# ifndef U_CFG_DISABLE_TEST_AUTOMATION
57+
+// This purely for internal u-blox testing
58+
+# include "u_cfg_test_platform_specific.h"
59+
+# endif
60+
+
61+
+/* ----------------------------------------------------------------
62+
+ * COMPILE-TIME MACROS
63+
+ * -------------------------------------------------------------- */
64+
+
65+
+// For u-blox internal testing only
66+
+# ifdef U_PORT_TEST_ASSERT
67+
+# define EXAMPLE_FINAL_STATE(x) U_PORT_TEST_ASSERT(x);
68+
+# else
69+
+# define EXAMPLE_FINAL_STATE(x)
70+
+# endif
71+
+
72+
+# ifndef U_PORT_TEST_FUNCTION
73+
+# error if you are not using the unit test framework to run this code you must ensure that the platform clocks/RTOS are set up and either define U_PORT_TEST_FUNCTION yourself or replace it as necessary.
74+
+# endif
75+
+
76+
+/* ----------------------------------------------------------------
77+
+ * TYPES
78+
+ * -------------------------------------------------------------- */
79+
+
80+
+/* ----------------------------------------------------------------
81+
+ * VARIABLES
82+
+ * -------------------------------------------------------------- */
83+
+
84+
+// GNSS configuration.
85+
+static uDeviceCfg_t gDeviceCfg = {
86+
+ .deviceType = U_DEVICE_TYPE_GNSS,
87+
+ .deviceCfg = {
88+
+ .cfgGnss = {
89+
+ .moduleType = U_GNSS_MODULE_TYPE_M10,
90+
+ .pinEnablePower = -1, // not used
91+
+ .pinDataReady = -1 // Not used
92+
+ // There is an additional field here:
93+
+ // "i2cAddress", which we do NOT set,
94+
+ // we allow the compiler to set it to 0
95+
+ // and all will be fine. You may set the
96+
+ // field to the I2C address of your GNSS
97+
+ // device if you have modified the I2C
98+
+ // address of your GNSS device to something
99+
+ // other than the default value of 0x42,
100+
+ // for example:
101+
+ // .i2cAddress = 0x43
102+
+ },
103+
+ },
104+
+ .transportType = U_DEVICE_TRANSPORT_TYPE_UART,
105+
+ .transportCfg = {
106+
+ .cfgUart = {
107+
+ .uart = U_CFG_APP_GNSS_UART,
108+
+ .baudRate = 38400,
109+
+ .pinTxd = -1, // not relevant on Linux
110+
+ .pinRxd = -1, // not relevant on Linux
111+
+ .pinCts = -1, // not relevant on Linux
112+
+ .pinRts = -1, // not relevant on Linux
113+
+ .pPrefix = U_PORT_STRINGIFY_QUOTED(U_CFG_APP_UART_PREFIX)
114+
+ },
115+
+ },
116+
+};
117+
+
118+
+/* ----------------------------------------------------------------
119+
+ * STATIC FUNCTIONS
120+
+ * -------------------------------------------------------------- */
121+
+
122+
+/* ----------------------------------------------------------------
123+
+ * PUBLIC FUNCTIONS: THE EXAMPLE
124+
+ * -------------------------------------------------------------- */
125+
+
126+
+// The entry point, main(): before this is called the system
127+
+// clocks must have been started and the RTOS must be running;
128+
+// we are in task space.
129+
+U_PORT_TEST_FUNCTION("[example]", "GnssUartSetup")
130+
+{
131+
+ uDeviceHandle_t devHandle = NULL;
132+
+ int32_t ret;
133+
+
134+
+ // Try to open the device at 115200 baud (in case already configured)
135+
+ uPortInit();
136+
+ uDeviceInit();
137+
+ gDeviceCfg.transportCfg.cfgUart.baudRate = 115200;
138+
+ printf("opening gps at %d baud ...", gDeviceCfg.transportCfg.cfgUart.baudRate);
139+
+ ret = uDeviceOpen(&gDeviceCfg, &devHandle);
140+
+ if (ret == 0) {
141+
+ puts(" done\n");
142+
+
143+
+ // send hot reset
144+
+ puts("sending hot reset ...");
145+
+ uint8_t hot_rst_msg[] = { 0xb5, 0x62, 0x06, 0x04, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x0f, 0x66 };
146+
+ ret = uGnssMsgSend(devHandle, (void *)hot_rst_msg, sizeof(hot_rst_msg));
147+
+ if (ret != sizeof(hot_rst_msg)) {
148+
+ printf(" error: uGnssMsgSend sent %d, expected %zu\n", ret, sizeof(hot_rst_msg));
149+
+ goto deinit;
150+
+ }
151+
+ puts(" done\n");
152+
+
153+
+ // close device but keep it running
154+
+ uDeviceClose(devHandle, false);
155+
+ } else {
156+
+ printf(" error: uDeviceOpen failed with %d (expected on cold boot)\n", ret);
157+
+ }
158+
+ uDeviceDeinit();
159+
+ uPortDeinit();
160+
+
161+
+ // device is now at reset defaults
162+
+
163+
+ // Open the device at 38400 baud (reset defalt)
164+
+ uPortInit();
165+
+ uDeviceInit();
166+
+ gDeviceCfg.transportCfg.cfgUart.baudRate = 38400;
167+
+ printf("opening gps at %d baud ...", gDeviceCfg.transportCfg.cfgUart.baudRate);
168+
+ ret = uDeviceOpen(&gDeviceCfg, &devHandle);
169+
+ if (ret == 0) {
170+
+ puts(" done\n");
171+
+
172+
+ // reconfigure to 115200
173+
+ printf("configuring for %d baud ...", 115200);
174+
+ uint8_t prt_cfg_msg[] = {0x24, 0x50, 0x55, 0x42, 0x58, 0x2C, 0x34, 0x31, 0x2c, 0x31, 0x2c, 0x30, 0x30, 0x32, 0x33, 0x2c, 0x30, 0x30, 0x30, 0x33, 0x2c, 0x31, 0x31, 0x35, 0x32, 0x30, 0x30, 0x2c, 0x30, 0x2a, 0x31, 0x45, 0x0d, 0x0a};
175+
+ ret = uGnssMsgSend(devHandle, (void *)prt_cfg_msg, sizeof(prt_cfg_msg));
176+
+ if (ret != sizeof(prt_cfg_msg)) {
177+
+ printf(" error: uGnssMsgSend sent %d, expected %zu\n", ret, sizeof(prt_cfg_msg));
178+
+ goto deinit;
179+
+ }
180+
+
181+
+ // wait for gps reconfiguration completion
182+
+ uPortTaskBlock(100);
183+
+
184+
+ // close device but keep it running
185+
+ uDeviceClose(devHandle, false);
186+
+ } else {
187+
+ printf(" error: uDeviceOpen failed with %d\n", ret);
188+
+ goto deinit;
189+
+ }
190+
+ uDeviceDeinit();
191+
+ uPortDeinit();
192+
+
193+
+ // Open the device at 115200 baud
194+
+ uPortInit();
195+
+ uDeviceInit();
196+
+ gDeviceCfg.transportCfg.cfgUart.baudRate = 115200;
197+
+ printf("opening gps at %d baud ...", gDeviceCfg.transportCfg.cfgUart.baudRate);
198+
+ ret = uDeviceOpen(&gDeviceCfg, &devHandle);
199+
+ if (ret == 0) {
200+
+ puts(" done\n");
201+
+ } else {
202+
+ printf(" error: uDeviceOpen failed with %d\n", ret);
203+
+ goto deinit;
204+
+ }
205+
+
206+
+ /* TODO: apply advanced configuration */
207+
+
208+
+ // close device but keep it running
209+
+ uDeviceClose(devHandle, false);
210+
+
211+
+deinit:
212+
+ uDeviceDeinit();
213+
+ uPortDeinit();
214+
+
215+
+ EXAMPLE_FINAL_STATE(ret == 0);
216+
+}
217+
+
218+
+// End of file
219+
--
220+
2.51.0
221+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[Service]
2+
ExecStartPre=/usr/sbin/ubx-setup
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
DESCRIPTION = "SolidRun U-Blox GPS Setup Tool"
2+
LICENSE = "Apache-2.0"
3+
SECTION = ""
4+
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
5+
6+
FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
7+
8+
SRC_URI = " \
9+
git://github.com/u-blox/ubxlib.git;branch=${SRCBRANCH};protocol=https;name=ubxlib \
10+
git://github.com/ThrowTheSwitch/Unity.git;branch=master;protocol=https;name=unity;destsuffix=Unity \
11+
file://0001-disable-werror-on-linux-port.patch \
12+
file://0002-add-example-app-to-configure-mia-m10q-uart-interface.patch \
13+
file://gpsd-ubx-setup.conf \
14+
"
15+
SRCBRANCH = "master"
16+
SRCREV_ubxlib = "0237d5d3706ccb17419a8b9eac14bb568e80ad4c"
17+
SRCREV_unity = "cbcd08fa7de711053a3deec6339ee89cad5d2697"
18+
19+
S = "${WORKDIR}/git"
20+
21+
inherit cmake
22+
23+
DEPENDS = "libgpiod"
24+
OECMAKE_SOURCEPATH = "${S}/port/platform/linux/mcu/posix/runner"
25+
UBXLIB_FLAGS = "-DU_CFG_APP_GNSS_UART=2 -DU_CFG_APP_UART_PREFIX=/dev/ttyLP -DU_CFG_APP_FILTER=GnssUartSetup -DU_CFG_ENABLE_LOGGING=0"
26+
27+
do_configure:prepend() {
28+
export U_FLAGS="${UBXLIB_FLAGS}"
29+
}
30+
31+
do_install() {
32+
install -v -m755 -D ${B}/ubxlib_test_main ${D}/${sbindir}/ubx-setup
33+
install -v -m644 -D ${WORKDIR}/gpsd-ubx-setup.conf ${D}${systemd_system_unitdir}/gpsd.service.d/ubx-setup.conf
34+
}
35+
36+
FILES:${PN} += " ${systemd_system_unitdir}/gpsd.service.d/ubx-setup.conf "

0 commit comments

Comments
 (0)