Skip to contentSkip to conversation

Add NMEA GPS character device for PCIe MHI Quectel Module to read NMEA statements.

PATCH In review Muhammad Nuzaihan 3 participants 8 messages Jan 1, 2025 – Jan 3, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add NMEA GPS character device for PCIe MHI Quectel Module to read NMEA statements.

Hi netdev,

I am using a Quectel RM520N-GL *PCIe* (not USB) module which uses the MHI interface.

In /devices/pci0000:00/0000:00:1c.6/0000:08:00.0/mhi0 i can see "mhi0_NMEA" but the actual NMEA device is missing in /dev and needs a character device to be useful with tty programs.

NMEA statements are a stream of GPS information which is used to tell the current device location in the console (like minicom).

Attached is the patch to ensure a device is registered (as /dev/wwan0nmea0) so this device will stream GPS NMEA statements and can be used to be read by popular GPS tools like gpsd and then tracking with cgps, xgps, QGIS, etc.

Regards,
Muhammad Nuzaihan

drivers/net/wwan/iosm/iosm_ipc_chnl_cfg.c +4 -0
index bcfbc6b3d617..4d4fc3813c86 100644
@@ -60,6 +60,10 @@ static struct ipc_chnl_cfg modem_cfg[] = {
 	{ IPC_MEM_CTRL_CHL_ID_6, IPC_MEM_PIPE_12, IPC_MEM_PIPE_13,
 	  IPC_MEM_MAX_TDS_MBIM, IPC_MEM_MAX_TDS_MBIM,
 	  IPC_MEM_MAX_DL_MBIM_BUF_SIZE, WWAN_PORT_MBIM },
+	/* NMEA */
+	{ IPC_MEM_CTRL_CHL_ID_7, IPC_MEM_PIPE_14, IPC_MEM_PIPE_15,
+	  IPC_MEM_MAX_TDS_AT, IPC_MEM_MAX_TDS_AT, IPC_MEM_MAX_DL_AT_BUF_SIZE,
+	  WWAN_PORT_NMEA },
 	/* Flash Channel/Coredump Channel */
 	{ IPC_MEM_CTRL_CHL_ID_7, IPC_MEM_PIPE_0, IPC_MEM_PIPE_1,
 	  IPC_MEM_MAX_TDS_FLASH_UL, IPC_MEM_MAX_TDS_FLASH_DL,
drivers/net/wwan/mhi_wwan_ctrl.c +1 -0
index e9f979d2d851..e13c0b078175 100644
@@ -263,6 +263,7 @@ static const struct mhi_device_id mhi_wwan_ctrl_match_table[] = {
 	{ .chan = "QMI", .driver_data = WWAN_PORT_QMI },
 	{ .chan = "DIAG", .driver_data = WWAN_PORT_QCDM },
 	{ .chan = "FIREHOSE", .driver_data = WWAN_PORT_FIREHOSE },
+	{ .chan = "NMEA", .driver_data = WWAN_PORT_NMEA },
 	{},
 };
 MODULE_DEVICE_TABLE(mhi, mhi_wwan_ctrl_match_table);
drivers/net/wwan/wwan_core.c +6 -1
index a51e2755991a..0131d9795d6c 100644
@@ -342,6 +342,10 @@ static const struct {
 		.name = "MIPC",
 		.devsuf = "mipc",
 	},
+	[WWAN_PORT_NMEA] = {
+		.name = "NMEA",
+		.devsuf = "nmea",
+	},
 };
 
 static ssize_t type_show(struct device *dev, struct device_attribute *attr,
@@ -876,7 +880,8 @@ static long wwan_port_fops_ioctl(struct file *filp, unsigned int cmd,
 	struct wwan_port *port = filp->private_data;
 	int res;
 
-	if (port->type == WWAN_PORT_AT) {	/* AT port specific IOCTLs */
+	if (port->type == WWAN_PORT_AT ||
+			WWAN_PORT_NMEA) {	/* AT or NMEA port specific IOCTLs */
 		res = wwan_port_fops_at_ioctl(port, cmd, arg);
 		if (res != -ENOIOCTLCMD)
 			return res;
include/linux/wwan.h +2 -0
index 79c781875c09..9e794fc53a7e 100644
@@ -19,6 +19,7 @@
  * @WWAN_PORT_FASTBOOT: Fastboot protocol control
  * @WWAN_PORT_ADB: ADB protocol control
  * @WWAN_PORT_MIPC: MTK MIPC diagnostic interface
+ * @WWAN_PORT_NMEA: NMEA GPS statements interface
  *
  * @WWAN_PORT_MAX: Highest supported port types
  * @WWAN_PORT_UNKNOWN: Special value to indicate an unknown port type
@@ -34,6 +35,7 @@ enum wwan_port_type {
 	WWAN_PORT_FASTBOOT,
 	WWAN_PORT_ADB,
 	WWAN_PORT_MIPC,
+	WWAN_PORT_NMEA,
 
 	/* Add new port types above this line */
 
#1 lore raw

Hi netdev,

I made a mistake in choosing AT mode IPC, which is incorrect. For NMEA streams it should use LOOPBACK for IPC. If it uses AT, i noticed that using gpsd will cause intermittent IOCTL errors which is caused when gpsd wants to write to the device.

Attached is the patch.

Thank you.

Quoted 6 lines · Muhammad Nuzaihan

Hi netdev,

I am using a Quectel RM520N-GL *PCIe* (not USB) module which uses the MHI interface.

In /devices/pci0000:00/0000:00:1c.6/0000:08:00.0/mhi0 i can see "mhi0_NMEA" but the actual NMEA device is missing in /dev and needs a character device to be useful with tty programs.

Quoted 9 lines

NMEA statements are a stream of GPS information which is used to tell the current device location in the console (like minicom).

Attached is the patch to ensure a device is registered (as /dev/wwan0nmea0) so this device will stream GPS NMEA statements and can be used to be read by popular GPS tools like gpsd and then tracking with cgps, xgps, QGIS, etc.

Regards,
Muhammad Nuzaihan

drivers/net/wwan/iosm/iosm_ipc_chnl_cfg.c +4 -0
index bcfbc6b3d617..75b9f9a43f41 100644
@@ -60,6 +60,10 @@ static struct ipc_chnl_cfg modem_cfg[] = {
 	{ IPC_MEM_CTRL_CHL_ID_6, IPC_MEM_PIPE_12, IPC_MEM_PIPE_13,
 	  IPC_MEM_MAX_TDS_MBIM, IPC_MEM_MAX_TDS_MBIM,
 	  IPC_MEM_MAX_DL_MBIM_BUF_SIZE, WWAN_PORT_MBIM },
+	/* NMEA */
+	{ IPC_MEM_CTRL_CHL_ID_7, IPC_MEM_PIPE_14, IPC_MEM_PIPE_15,
+          IPC_MEM_MAX_TDS_LOOPBACK, IPC_MEM_MAX_TDS_LOOPBACK,
+          IPC_MEM_MAX_DL_LOOPBACK_SIZE, WWAN_PORT_NMEA },
 	/* Flash Channel/Coredump Channel */
 	{ IPC_MEM_CTRL_CHL_ID_7, IPC_MEM_PIPE_0, IPC_MEM_PIPE_1,
 	  IPC_MEM_MAX_TDS_FLASH_UL, IPC_MEM_MAX_TDS_FLASH_DL,
drivers/net/wwan/mhi_wwan_ctrl.c +1 -0
index e9f979d2d851..e13c0b078175 100644
@@ -263,6 +263,7 @@ static const struct mhi_device_id mhi_wwan_ctrl_match_table[] = {
 	{ .chan = "QMI", .driver_data = WWAN_PORT_QMI },
 	{ .chan = "DIAG", .driver_data = WWAN_PORT_QCDM },
 	{ .chan = "FIREHOSE", .driver_data = WWAN_PORT_FIREHOSE },
+	{ .chan = "NMEA", .driver_data = WWAN_PORT_NMEA },
 	{},
 };
 MODULE_DEVICE_TABLE(mhi, mhi_wwan_ctrl_match_table);
drivers/net/wwan/wwan_core.c +6 -1
index a51e2755991a..0131d9795d6c 100644
@@ -342,6 +342,10 @@ static const struct {
 		.name = "MIPC",
 		.devsuf = "mipc",
 	},
+	[WWAN_PORT_NMEA] = {
+		.name = "NMEA",
+		.devsuf = "nmea",
+	},
 };
 
 static ssize_t type_show(struct device *dev, struct device_attribute *attr,
@@ -876,7 +880,8 @@ static long wwan_port_fops_ioctl(struct file *filp, unsigned int cmd,
 	struct wwan_port *port = filp->private_data;
 	int res;
 
-	if (port->type == WWAN_PORT_AT) {	/* AT port specific IOCTLs */
+	if (port->type == WWAN_PORT_AT ||
+			WWAN_PORT_NMEA) {	/* AT or NMEA port specific IOCTLs */
 		res = wwan_port_fops_at_ioctl(port, cmd, arg);
 		if (res != -ENOIOCTLCMD)
 			return res;
include/linux/wwan.h +2 -0
index 79c781875c09..9e794fc53a7e 100644
@@ -19,6 +19,7 @@
  * @WWAN_PORT_FASTBOOT: Fastboot protocol control
  * @WWAN_PORT_ADB: ADB protocol control
  * @WWAN_PORT_MIPC: MTK MIPC diagnostic interface
+ * @WWAN_PORT_NMEA: NMEA GPS statements interface
  *
  * @WWAN_PORT_MAX: Highest supported port types
  * @WWAN_PORT_UNKNOWN: Special value to indicate an unknown port type
@@ -34,6 +35,7 @@ enum wwan_port_type {
 	WWAN_PORT_FASTBOOT,
 	WWAN_PORT_ADB,
 	WWAN_PORT_MIPC,
+	WWAN_PORT_NMEA,
 
 	/* Add new port types above this line */
 
#2 lore raw
Quoted 8 lines · Muhammad Nuzaihan

Hi netdev,

I made a mistake in choosing AT mode IPC, which is incorrect. For NMEA streams it should use LOOPBACK for IPC. If it uses AT, i noticed that using gpsd will cause intermittent IOCTL errors which is caused when gpsd wants to write to the device.

Attached is the patch.

This is not my area, so i cannot do a full review, but a few things to note.

Please start a new thread for each version of a patch, and wait at lest 24 hours between each version.

The commit message should be formal, since it will be part of the kernel history.

https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html

drivers/net/wwan/wwan_core.c static long wwan_port_fops_ioctl(struct file *filp, unsigned int cmd, · line 884

Quoted 7 lines
drivers/net/wwan/wwan_core.c +2 -1
@@ -876,7 +880,8 @@ static long wwan_port_fops_ioctl(struct file *filp, unsigned int cmd,
 	struct wwan_port *port = filp->private_data;
 	int res;
 
-	if (port->type == WWAN_PORT_AT) {	/* AT port specific IOCTLs */
+	if (port->type == WWAN_PORT_AT ||
+			WWAN_PORT_NMEA) {	/* AT or NMEA port specific IOCTLs */

This looks wrong. || WWAN_PORT_NMEA will always be true, assuming WWAN_PORT_NMEA is not 0.

Andrew

---
pw-bot: cr

#3 lore raw

Hi Andrew,

I'm actually new to netdev and the main kernel.org documentation on submitting patches (https://www.kernel.org/doc/html/v4.17/process/submitting-patches.html) was not clear on the commit message (or i've missed it).

Thank you for pointing me to the netdev maintainer process page.

Anyway, i will make a new v3 patch tomorrow on a new thread to address the issues you mentioned. I'll follow the guidelines as you required.

Sorry for the mess.

Thank you,
Muhammad Nuzaihan

Quoted 40 lines · Andrew Lunn
Quoted 11 lines · Muhammad Nuzaihan

Hi netdev,

I made a mistake in choosing AT mode IPC, which is incorrect. For
NMEA
streams it should use LOOPBACK for IPC. If it uses AT, i noticed
that using
gpsd will cause intermittent IOCTL errors which is caused when gpsd
wants to
write to the device.

Attached is the patch.

This is not my area, so i cannot do a full review, but a few things to note.

Please start a new thread for each version of a patch, and wait at lest 24 hours between each version.

The commit message should be formal, since it will be part of the kernel history.

https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html

Quoted 8 lines

@@ -876,7 +880,8 @@ static long wwan_port_fops_ioctl(struct file
*filp, unsigned int cmd,
struct wwan_port *port = filp->private_data; int res;

- if (port->type == WWAN_PORT_AT) { /* AT port specific IOCTLs */
+ if (port->type == WWAN_PORT_AT ||
+ WWAN_PORT_NMEA) { /* AT or NMEA port specific IOCTLs */

This looks wrong. || WWAN_PORT_NMEA will always be true, assuming WWAN_PORT_NMEA is not 0.

Andrew

---
pw-bot: cr

maintainer
#4 lore raw
In reply to Muhammad Nuzaihan

Hi Muhammad and welcome to netdev,

Quoted 5 lines · Muhammad Nuzaihan

Hi netdev,

I made a mistake in choosing AT mode IPC, which is incorrect. For NMEA streams it should use LOOPBACK for IPC. If it uses AT, i noticed that using gpsd will cause intermittent IOCTL errors which is caused when gpsd wants to write to the device.

Attached is the patch.

Do you had a chance to check this discussion: https://lore.kernel.org/all/CAMZdPi_MF=-AjTaBZ_HxtwpbQK5+WwR9eXsSvnvK_-O30ff+Tw@mail.gmail.com/

To summarize, an NMEA port suppose to be exported through the GNSS subsystem to properly indicate the device class. Still, the port needs to be exported through the WWAN subsystem to facilitate a corresponding control port discovery. Looks like that the WWAN changes going to be a bit more tricky.

Quoted 21 lines

Thank you.

Quoted 15 lines · Muhammad Nuzaihan

Hi netdev,

I am using a Quectel RM520N-GL *PCIe* (not USB) module which uses the MHI interface.

In /devices/pci0000:00/0000:00:1c.6/0000:08:00.0/mhi0 i can see "mhi0_NMEA" but the actual NMEA device is missing in /dev and needs a character device to be useful with tty programs.

NMEA statements are a stream of GPS information which is used to tell the current device location in the console (like minicom).

Attached is the patch to ensure a device is registered (as /dev/ wwan0nmea0) so this device will stream GPS NMEA statements and can be used to be read by popular GPS tools like gpsd and then tracking with cgps, xgps, QGIS, etc.

Regards,
Muhammad Nuzaihan

#5 lore raw

Hi Sergey,

So there is a separate GNSS subsystem in the linux kernel. I'll check that out.

I went through a bit of research to get this working. Went to quectel forums to figure out and quectel has their own set of drivers. They showed me their own source code and they have their own implementation of their NMEA interface in their driver with port at /dev/mhi_LOOPBACK.

But i was not quite happy because i have to use their connection manager instead of ModemManager since i am using it for my Lenovo laptop and not embedded which their software was designed for.

Went around /sys in the kernel and found:

root@muhammads-ThinkPad:/sys# find . -name 'mhi0*'
./devices/pci0000:00/0000:00:1c.6/0000:08:00.0/mhi0
./devices/pci0000:00/0000:00:1c.6/0000:08:00.0/mhi0/mhi0_DIAG
./devices/pci0000:00/0000:00:1c.6/0000:08:00.0/mhi0/mhi0_IP_HW0_MBIM
./devices/pci0000:00/0000:00:1c.6/0000:08:00.0/mhi0/mhi0_MBIM
./devices/pci0000:00/0000:00:1c.6/0000:08:00.0/mhi0/mhi0_NMEA
./devices/pci0000:00/0000:00:1c.6/0000:08:00.0/mhi0/mhi0_DUN
./bus/mhi/devices/mhi0
./bus/mhi/devices/mhi0_DIAG
./bus/mhi/devices/mhi0_IP_HW0_MBIM
./bus/mhi/devices/mhi0_MBIM
./bus/mhi/devices/mhi0_NMEA
./bus/mhi/devices/mhi0_DUN
./bus/mhi/drivers/mhi_wwan_mbim/mhi0_IP_HW0_MBIM
./bus/mhi/drivers/mhi_wwan_ctrl/mhi0_DIAG
./bus/mhi/drivers/mhi_wwan_ctrl/mhi0_MBIM
./bus/mhi/drivers/mhi_wwan_ctrl/mhi0_NMEA
./bus/mhi/drivers/mhi_wwan_ctrl/mhi0_DUN

So i figured it has mhi0_NMEA and that's how i thought of writing the patch to expose mhi0_NMEA after reading some linaro guy's presentation on MHI and his initial mhi0_QMI work with ModemManager.

With my patch, on bootup, it doesn't automatically attach nmea0 port at all, 5G works properly with modemmanager at boot but no nmea port.

To get that nmea0 port i had to unload all mhi_* and wwan modules and load them back again to ensure wwan0nmea0 gets attached to /dev.

After that i run commands with quectel's own AT commands at wwan0at0 with AT+QGPS+1 and then AT+QGPSGNMEA="RMC" (also AT+QGPSCFG="outport",usbnmea) and this starts the streaming of the NMEA gps statements. If i don't run the AT commands, even 5G connectivity with modemmananager do not work as well. After running it, all NMEA streams starts to come and 5G connectivity works.

After that i would only run gpsd to read /dev/wwan0nmea0 (the port can only be use/locked by one program) and run cgps (client gps) to make nmea values more easier to read.

All this is stable, i have been running "cgps" program for hours together with 5g on modemmanager and no issues. Just the above quirks about unloading and loading of kernel modules and running AT commands (i wrote a shell script to automate this)

I can try to help out as much as i can.

NMEA continous stream
---

Welcome to minicom 2.8

OPTIONS: I18n
Port /dev/wwan0nmea0, 22:50:48

Press CTRL-A Z for help on special keys

$GPRMC,172551.00,A,0607.736155,N,10217.012565,E,0.0,,020125,0.4,W,A,V*74 $GPRMC,172552.00,A,0607.736156,N,10217.012566,E,0.0,,020125,0.4,W,A,V*77 $GPGGA,172553.00,0607.736156,N,10217.012566,E,1,07,0.4,15.0,M,-7.3,M,,*47 $GPRMC,172553.00,A,0607.736156,N,10217.012566,E,0.0,,020125,0.4,W,A,V*76 $GPGGA,172554.00,0607.736157,N,10217.012567,E,1,07,0.4,15.0,M,-7.3,M,,*40 $GPRMC,172554.00,A,0607.736157,N,10217.012567,E,0.0,,020125,0.4,W,A,V*71 ... continuously

Regards,
Zaihan

Quoted 35 lines · Sergey Ryazanov

Hi Muhammad and welcome to netdev,

Quoted 5 lines · Muhammad Nuzaihan

Hi netdev,

I made a mistake in choosing AT mode IPC, which is incorrect. For NMEA streams it should use LOOPBACK for IPC. If it uses AT, i noticed that using gpsd will cause intermittent IOCTL errors which is caused when gpsd wants to write to the device.

Attached is the patch.

Do you had a chance to check this discussion: https://lore.kernel.org/all/CAMZdPi_MF=-AjTaBZ_HxtwpbQK5+WwR9eXsSvnvK_-O30ff+Tw@mail.gmail.com/

To summarize, an NMEA port suppose to be exported through the GNSS subsystem to properly indicate the device class. Still, the port needs to be exported through the WWAN subsystem to facilitate a corresponding control port discovery. Looks like that the WWAN changes going to be a bit more tricky.

Quoted 21 lines

Thank you.

Quoted 15 lines · Muhammad Nuzaihan 

Hi netdev,

I am using a Quectel RM520N-GL *PCIe* (not USB) module which uses the MHI interface.

In /devices/pci0000:00/0000:00:1c.6/0000:08:00.0/mhi0 i can see "mhi0_NMEA" but the actual NMEA device is missing in /dev and needs a character device to be useful with tty programs.

NMEA statements are a stream of GPS information which is used to tell the current device location in the console (like minicom).

Attached is the patch to ensure a device is registered (as /dev/ wwan0nmea0) so this device will stream GPS NMEA statements and can be used to be read by popular GPS tools like gpsd and then tracking with cgps, xgps, QGIS, etc.

Regards,
Muhammad Nuzaihan

#6 lore raw

Hi Sergey,

Quoted 29 lines · Muhammad Nuzaihan

Hi Sergey,

So there is a separate GNSS subsystem in the linux kernel. I'll check that out.

I went through a bit of research to get this working. Went to quectel forums to figure out and quectel has their own set of drivers. They showed me their own source code and they have their own implementation of their NMEA interface in their driver with port at /dev/mhi_LOOPBACK.

But i was not quite happy because i have to use their connection manager instead of ModemManager since i am using it for my Lenovo laptop and not embedded which their software was designed for.

Went around /sys in the kernel and found:

root@muhammads-ThinkPad:/sys# find . -name 'mhi0*'
./devices/pci0000:00/0000:00:1c.6/0000:08:00.0/mhi0
./devices/pci0000:00/0000:00:1c.6/0000:08:00.0/mhi0/mhi0_DIAG
./devices/pci0000:00/0000:00:1c.6/0000:08:00.0/mhi0/mhi0_IP_HW0_MBIM
./devices/pci0000:00/0000:00:1c.6/0000:08:00.0/mhi0/mhi0_MBIM
./devices/pci0000:00/0000:00:1c.6/0000:08:00.0/mhi0/mhi0_NMEA
./devices/pci0000:00/0000:00:1c.6/0000:08:00.0/mhi0/mhi0_DUN
./bus/mhi/devices/mhi0
./bus/mhi/devices/mhi0_DIAG
./bus/mhi/devices/mhi0_IP_HW0_MBIM
./bus/mhi/devices/mhi0_MBIM
./bus/mhi/devices/mhi0_NMEA
./bus/mhi/devices/mhi0_DUN
./bus/mhi/drivers/mhi_wwan_mbim/mhi0_IP_HW0_MBIM
./bus/mhi/drivers/mhi_wwan_ctrl/mhi0_DIAG
./bus/mhi/drivers/mhi_wwan_ctrl/mhi0_MBIM
./bus/mhi/drivers/mhi_wwan_ctrl/mhi0_NMEA
./bus/mhi/drivers/mhi_wwan_ctrl/mhi0_DUN
Quoted 1 line

So i figured it has mhi0_NMEA and that's how i thought of writing the patch to expose mhi0_NMEA after reading some linaro guy's presentation on MHI and his initial mhi0_QMI work with ModemManager.

The Linaro guy was Loic! Thank you. :) - https://static.linaro.org/connect/lvc21/presentations/lvc21-317.pdf

Quoted 32 lines

With my patch, on bootup, it doesn't automatically attach nmea0 port at all, 5G works properly with modemmanager at boot but no nmea port.

To get that nmea0 port i had to unload all mhi_* and wwan modules and load them back again to ensure wwan0nmea0 gets attached to /dev.

After that i run commands with quectel's own AT commands at wwan0at0 with AT+QGPS+1 and then AT+QGPSGNMEA="RMC" (also AT+QGPSCFG="outport",usbnmea) and this starts the streaming of the NMEA gps statements. If i don't run the AT commands, even 5G connectivity with modemmananager do not work as well. After running it, all NMEA streams starts to come and 5G connectivity works.

After that i would only run gpsd to read /dev/wwan0nmea0 (the port can only be use/locked by one program) and run cgps (client gps) to make nmea values more easier to read.

All this is stable, i have been running "cgps" program for hours together with 5g on modemmanager and no issues. Just the above quirks about unloading and loading of kernel modules and running AT commands (i wrote a shell script to automate this)

I can try to help out as much as i can.

NMEA continous stream
---

Welcome to minicom 2.8

OPTIONS: I18n
Port /dev/wwan0nmea0, 22:50:48

Press CTRL-A Z for help on special keys

$GPRMC,172551.00,A,0607.736155,N,10217.012565,E,0.0,,020125,0.4,W,A,V*74 $GPRMC,172552.00,A,0607.736156,N,10217.012566,E,0.0,,020125,0.4,W,A,V*77 $GPGGA,172553.00,0607.736156,N,10217.012566,E,1,07,0.4,15.0,M,-7.3,M,,*47 $GPRMC,172553.00,A,0607.736156,N,10217.012566,E,0.0,,020125,0.4,W,A,V*76 $GPGGA,172554.00,0607.736157,N,10217.012567,E,1,07,0.4,15.0,M,-7.3,M,,*40 $GPRMC,172554.00,A,0607.736157,N,10217.012567,E,0.0,,020125,0.4,W,A,V*71 ... continuously

Quoted 16 lines

Regards,
Zaihan

Quoted 12 lines · Sergey Ryazanov

Hi Muhammad and welcome to netdev,

Quoted 5 lines · Muhammad Nuzaihan

Hi netdev,

I made a mistake in choosing AT mode IPC, which is incorrect. For NMEA streams it should use LOOPBACK for IPC. If it uses AT, i noticed that using gpsd will cause intermittent IOCTL errors which is caused when gpsd wants to write to the device.

Attached is the patch.

Do you had a chance to check this discussion: https://lore.kernel.org/all/CAMZdPi_MF=-AjTaBZ_HxtwpbQK5+WwR9eXsSvnvK_-O30ff+Tw@mail.gmail.com/

I've read the discussion. Interesting that I had that i had the same thought of using AT interface to communicate with the NMEA.

There was a question about NMEA with MHI, not sure if what i did is identical to Slark's idea.

Quoted 2 lines
Quoted 2 lines

To summarize, an NMEA port suppose to be exported through the GNSS subsystem to properly indicate the device class. Still, the port needs to be exported through the WWAN subsystem to facilitate a corresponding control port discovery. Looks like that the WWAN changes going to be a bit more tricky.

Read about the GNSS subsystem, some really old article but it sounded it doesn't support all devices (and it only support dedicated GPS devices), not sure if there are improvements after that.

Should we be focusing on WWAN would be appropriate rather than duplicating work with GNSS?

The part that i am unsure is whether the MHI NMEA implementation i have currently supports features like showing a map of satellites like normal GPS hardware with Linux GNSS would and i don't see yet in my data.

Just for the start is to get the data like altitude, speed, mean sea level, climb rate, time, lat/lng - which i got.

I'll try to improve on my patches and see how i can load and fix the issues i encountered earlier.

Quoted 23 lines
Quoted 23 lines
Quoted 22 lines

Thank you.

Quoted 15 lines · Muhammad Nuzaihan 

Hi netdev,

I am using a Quectel RM520N-GL *PCIe* (not USB) module which uses the MHI interface.

In /devices/pci0000:00/0000:00:1c.6/0000:08:00.0/mhi0 i can see "mhi0_NMEA" but the actual NMEA device is missing in /dev and needs a character device to be useful with tty programs.

NMEA statements are a stream of GPS information which is used to tell the current device location in the console (like minicom).

Attached is the patch to ensure a device is registered (as /dev/ wwan0nmea0) so this device will stream GPS NMEA statements and can be used to be read by popular GPS tools like gpsd and then tracking with cgps, xgps, QGIS, etc.

Regards,
Muhammad Nuzaihan

#7 lore raw

Hi Sergey,

Apparently after a new recompilation the entire kernel and modules fixes the problem with wwan0nmea0 port get attached at bootup. I had previously only compiled modules without the kernel during development.

Before that i went to debug several wwan_core.c device wwan_create_port and wwan_create_dev functions to see what's going on not being loaded at bootup and seemed that a recompile the entire kernel and module fixes that. Checked my diffs and saw no changes.

So now, everything works perfectly at bootup and I have to tell ModemManager to ignore NMEA port type. So booting up with a fresh new kernel and module gets my 5G working automatically at boot.

No need to unload and reload of the kernel modules and configuring with AT commands to wwan0at0 with scripts, now everything works seamlessly.

So to ensure ModemManager can work with this setup, i would add a new udev rule for ModemManager to not probe wwan0nmea0 port (which i think i will submit this to ModemManger project):

# ModemManager ignore NMEA
ATTRS{vendor}=="0x1eac", ATTRS{device}=="0x1007", ATTR{type}=="NMEA", ENV{ID_MM_PORT_IGNORE}="1"

I'll submit the "cleaned up" v3 nmea patch later tomorrow, it's a pretty small patch. (It's 12AM now here in Malaysia)

- Zaihan

Quoted 6 lines · Muhammad Nuzaihan

Hi Sergey,

Quoted 2 lines · Muhammad Nuzaihan

Hi Sergey,