Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arm64/pinephone: Add driver for PinePhone LTE Modem (Quectel EG25-G) #9304

Closed
wants to merge 1 commit into from

Conversation

lupyuen
Copy link
Member

@lupyuen lupyuen commented May 16, 2023

Summary

This PR adds the PinePhone Driver for Quectel EG25-G LTE Modem. When the driver is started, the LTE Modem accepts AT Commands over UART3 and /dev/ttyS1.

PinePhone's LTE Modem is explained in this article.

New Files in boards/arm64/a64/pinephone

src/pinephone_modem.c, pinephone_modem.h: Driver for Quectel EG25-G LTE Modem

configs/modem/defconfig: New Build Configuration pinephone:modem that enables the LTE Modem at UART3 and /dev/ttyS1

Modified Files in boards/arm64/a64/pinephone

Kconfig: Added Kconfig Setting PINEPHONE_MODEM to enable the LTE Modem at "Board Selection > Board-Specific Options > LTE Modem"

src/pinephone_bringup.c: Start the LTE Modem if PINEPHONE_MODEM is selected

src/Makefile: Added LTE Modem Driver to Makefile

Updated Documentation

platforms/arm/a64/boards/pinephone/index.rst: Added Build Configuration pinephone:modem that enables the LTE Modem

Impact

With this PR, NuttX Apps will be able to control the PinePhone LTE Modem with AT Commands over UART3 and /dev/ttyS1.

There is no impact on existing code because the driver is not used currently.

Testing

We tested the LTE Modem Driver on PinePhone by sending AT Commands. For Regression Testing, we tested PinePhone with the LTE Modem Driver disabled.

LTE Modem Test

To test the LTE Modem Driver, we selected the pinephone:modem Build Configuration:

tools/configure.sh pinephone:modem
make

We ran a Modem Test App that sends AT Commands to make phone calls and send SMS messages:

The modem responds correctly to our AT Commands:

Regression Test

For Regression Testing, we selected the pinephone:lvgl Build Configuration that disables the LTE Modem:

tools/configure.sh pinephone:lvgl
make

NuttX boots correctly and starts the LCD Display, with the LTE Modem disabled:

@lupyuen lupyuen marked this pull request as draft May 16, 2023 23:31
This PR adds the PinePhone Driver for Quectel EG25-G LTE Modem. When the driver is started, the LTE Modem accepts AT Commands over UART3 and `/dev/ttyS1`.

PinePhone's LTE Modem is explained in [this article](https://lupyuen.github.io/articles/lte).

`src/pinephone_modem.c`, `pinephone_modem.h`: Driver for Quectel EG25-G LTE Modem

`configs/modem/defconfig`: New Build Configuration `pinephone:modem` that enables the LTE Modem at UART3 and `/dev/ttyS1`

`Kconfig`: Added Kconfig Setting `PINEPHONE_MODEM` to enable the LTE Modem at "Board Selection > Board-Specific Options > LTE Modem"

`src/pinephone_bringup.c`: Start the LTE Modem if `PINEPHONE_MODEM` is selected

`src/Makefile`: Added LTE Modem Driver to Makefile

`platforms/arm/a64/boards/pinephone/index.rst`: Added Build Configuration `pinephone:modem` that enables the LTE Modem
@lupyuen
Copy link
Member Author

lupyuen commented May 17, 2023

Fixed the UART3 configuration. Sorry about that.

@lupyuen lupyuen marked this pull request as ready for review May 17, 2023 01:13
-----

Supports LTE Modem (EG25-G). Accepts AT Commands on UART3
at ``/dev/ttyS1``.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we make /dev/ttySx match the datasheet number(UARTx)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately UARTx won't match ttySx on PinePhone. Here are the upcoming UART ports:

  • UART0 (ttyS0): Serial Console
  • UART1 (ttyS1): Bluetooth Module (Realtek RTL8723CS, not integrated with NuttX yet)
  • UART2: Unused, wired to Light Sensor and Compass Sensor
  • UART3 (ttyS2): LTE Modem (Quectel EG25-G, integrated with NuttX)

More details here

I could modify modem/defconfig to enable UART1 on ttyS1 (Bluetooth). But UART3 will always map to ttyS2 (LTE Modem) because UART2 is unused.

Shall I make this change? Thanks.

Copy link
Contributor

@xiaoxiang781216 xiaoxiang781216 May 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to adjust the tty driver register code to skip the unused hardware and port number at the same time, or always register all possible tty devices even some mayn't use in the current state.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks I'll disable UART2 and /dev/ttyS2 for PinePhone, so that UART3 will map correctly to /dev/ttyS3. This should make our Modem Apps a lot easier to find the right /dev/tty.

bool "LTE Modem"
default n
---help---
Select to enable support for Quectel EG25-G LTE Modem.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we abstract a modem interface? So, the SoC can support the different modem, and the modem can support different SoC.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I need to do some research to see how the SoC can support other modems. I don't believe NuttX has a modem interface today?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some in drivers/modem, but I am not sure where the common driver interface exists or not. It will be good additional to unify the interface between apps and all possible modem hardware.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks let me take a look again. The last time I searched, I found AT Commands referenced in 2 places:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lupyuen I don't think there is a standard command driver for modems, because normally they are hardware dependent. Also I don't think these examples you cited are the right way to support Direct-IP modems on NuttX, Direct-IP modems need to use USRSOCK to integrated correctly with NuttX.

If this modem supports PPP protocol then this is a good way to go (even been a legacy protocol it is well supported on NuttX). I friend of mine (@duduita) is using BG770A and BG95 (Cat-M1 and NB-IoT) with PPP on NuttX and it works fine.

If this Quectel EG25-G is also connected to the USB and has support to MBIM protocol (MBIM and QMI are the most common protocols used on 4G modems) you can use the drivers/usbhost/usbhost_cdcmbim.c with it.

Copy link

@mu578 mu578 May 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@acassis EG25-G supports PPP and QMI. @reference for QMI handling https://github.com/sailfishos/ofono

@lupyuen lupyuen marked this pull request as draft May 17, 2023 06:53
@lupyuen
Copy link
Member Author

lupyuen commented May 17, 2023

Sorry I shall take some time to rethink and redo this PR:

  1. Create a Generic Modem Interface for NuttX that will support Modems for any SoC. It shall support PinePhone's Quectel EG25-G LTE Modem, including AT Commands over UART, AT Commands over USB, GNSS (NMEA 0183) over USB. And potentially other features like Direct-IP, USRSOCK, MBIM and QMI.
  2. It's probably my mistake to call this PR a "Modem Driver". All it does is to Power Up the Quectel LTE Modem by toggling some GPIOs. I wished we had a better way to do this without creating a Generic Modem Interface.
  3. Disable UART2 and /dev/ttyS2 for PinePhone, so that UART3 will map to /dev/ttyS3 for the Quectel LTE Modem. This will make it easier for NuttX Apps to access the LTE Modem.

If anyone has started working on the Generic Modem Interface for NuttX, I'm happy to join you :-) Meanwhile I'll check out whether Zephyr OS has something similar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants