Difference between revisions of "PineModems"

From PINE64
Jump to navigation Jump to search
(Removed html tags, fixed tables)
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
= PINE64 position on alternative firmware =
== PINE64 position on alternative firmware ==


PINE64 ships the PinePhone with a stock version of the Quectel EG25-G modem's firmware. Some administrative regions, in the EU and Asia in particular, require the entirety of the modem's firmware to be licensed. Therefore, the PinePhone cannot ship with an unlicensed firmware, and the PINE64 project cannot, officially encourage its userbase to use alternative modem firmware.     
PINE64 ships the PinePhone with a stock version of the Quectel EG25-G modem's firmware. Some administrative regions, in the EU and Asia in particular, require the entirety of the modem's firmware to be licensed. Therefore, the PinePhone cannot ship with an unlicensed firmware, and the PINE64 project cannot, officially encourage its userbase to use alternative modem firmware.     
Line 7: Line 7:
Quectel EG25-G is an LTE Cat 4 module optimized specially for M2M and IoT applications. It is used in the [[PinePhone]].
Quectel EG25-G is an LTE Cat 4 module optimized specially for M2M and IoT applications. It is used in the [[PinePhone]].


* Specifications:<br>[[File:Quectel_EG25-G_LTE_Standard_Specification_V1.3.pdf]]
* Specifications: [[File:Quectel_EG25-G_LTE_Standard_Specification_V1.3.pdf]]
* Hardware design:<br>[[File:Quectel_EG25-G_Hardware_Design_V1.4.pdf]]
* Hardware design: [[File:Quectel_EG25-G_Hardware_Design_V1.4.pdf]]
* AT Interface reference manual:
* AT Interface reference manual:
** 1.3 for EC25:<br>[[File:Quectel_EC25&EC21_AT_Commands_Manual_V1.3.pdf]]
** 1.3 for EC25: [[File:Quectel_EC25&EC21_AT_Commands_Manual_V1.3.pdf]]
** 2.0 for EC25 and EG25-G:<br>[[File:Quectel_EC2x&EG9x&EG2x-G&EM05_Series_AT_Commands_Manual_V2.0.pdf]]
** 2.0 for EC25 and EG25-G: [[File:Quectel_EC2x&EG9x&EG2x-G&EM05_Series_AT_Commands_Manual_V2.0.pdf]]
* AT Interface file operations:<br>[[File:Quectel_EC2xEG25-GEG9xEM05_FILE_AT_Commands_Manual_V1.0.pdf]]
* AT Interface file operations: [[File:Quectel_EC2xEG25-GEG9xEM05_FILE_AT_Commands_Manual_V1.0.pdf]]
* GNSS Application note:<br>[[File:Quectel_EC2x&EG9x&EG2x-G&EM05_Series_GNSS_Application_Note_V1.3.pdf]]
* GNSS Application note: [[File:Quectel_EC2x&EG9x&EG2x-G&EM05_Series_GNSS_Application_Note_V1.3.pdf]]


=== Specifications ===
=== Specifications ===


{| class="wikitable"
{| class="wikitable"
|           Processor Family || Qualcomm MDM9607
| Processor Family
| Qualcomm MDM9607
|-
|-
|                       CPU || Qualcomm MDM9207
| CPU
| Qualcomm MDM9207
|-
|-
|                     Cores || 1 ACPU Core, Qualcomm Hexagon DSP
| Cores
| 1 ACPU Core, Qualcomm Hexagon DSP
|-
|-
|                 Total RAM || 256Mb
| Total RAM
| 256Mb
|-
|-
|         Total flash space || 256Mb
| Total flash space
| 256Mb
|-
|-
| Available RAM for the ACPU || 160Mb
| Available RAM for the ACPU
| 160Mb
|}
|}


Line 38: Line 44:
! Description
! Description
|-
|-
| MTD0 || <code>SBL</code>
| MTD0
| <code>SBL</code>
| Secondary Bootloader, called from the BootROM. Used to start the TrustZone kernel and the Application Bootloader (LK). Also used to enter Quectel's recovery mode
| Secondary Bootloader, called from the BootROM. Used to start the TrustZone kernel and the Application Bootloader (LK). Also used to enter Quectel's recovery mode
|-
|-
| MTD1 || <code>mibib</code>
| MTD1
| <code>mibib</code>
| NAND Partition table
| NAND Partition table
|-
|-
| MTD2 || <code>EFS2</code>
| MTD2
| <code>EFS2</code>
| IMEI and settings used by the ADSP are stored here
| IMEI and settings used by the ADSP are stored here
|-
|-
| MTD3 || <code>sys_rev</code>
| MTD3
| <code>sys_rev</code>
| Unexplored
| Unexplored
|-
|-
| MTD4 || <code>rawdata</code>
| MTD4
| <code>rawdata</code>
| This is where FOTA update data exists before being commited to system or recoveryfs partitions
| This is where FOTA update data exists before being commited to system or recoveryfs partitions
|-
|-
| MTD5 || <code>tz</code>
| MTD5
| <code>tz</code>
| TrustZone kernel
| TrustZone kernel
|-
|-
| MTD6 || <code>rpm</code>
| MTD6
| <code>rpm</code>
| Resource / Power Manager
| Resource / Power Manager
|-
|-
| MTD7 || <code>cust_info</code>
| MTD7
| <code>cust_info</code>
| Unexplored
| Unexplored
|-
|-
| MTD8 || <code>aboot</code>
| MTD8
| <code>aboot</code>
| Application Bootloader. Uses [https://github.com/littlekernel/lk LK] (LittleKernel, LK embedded kernel) as the bootloader. By default it allows flashing unsigned images but won't allow booting them, soft-bricking the modem until you enter EDL mode
| Application Bootloader. Uses [https://github.com/littlekernel/lk LK] (LittleKernel, LK embedded kernel) as the bootloader. By default it allows flashing unsigned images but won't allow booting them, soft-bricking the modem until you enter EDL mode
|-
|-
| MTD9 || <code>boot</code>
| MTD9
| <code>boot</code>
| [https://www.openembedded.org/wiki/Main_Page OpenEmbedded] boot kernel + DTB
| [https://www.openembedded.org/wiki/Main_Page OpenEmbedded] boot kernel + DTB
|-
|-
| MTD10 || <code>recovery</code>
| MTD10
| <code>recovery</code>
| Recovery kernel (used for FOTA updates)
| Recovery kernel (used for FOTA updates)
|-
|-
| MTD11 || <code>modem</code>
| MTD11
| <code>modem</code>
| ADSP firmware blobs
| ADSP firmware blobs
|-
|-
| MTD12 || <code>misc</code>
| MTD12
| <code>misc</code>
| Some settings are stored here, along with commands that need to be picked by LK on next boot (to reboot to fastboot or recovery mode)
| Some settings are stored here, along with commands that need to be picked by LK on next boot (to reboot to fastboot or recovery mode)
|-
|-
| MTD13 || <code>recoveryfs</code>
| MTD13
| <code>recoveryfs</code>
| Recovery filesystem image (FOTA updates)
| Recovery filesystem image (FOTA updates)
|-
|-
| MTD14 || <code>usr_data</code>
| MTD14
| <code>usr_data</code>
| User data partition (<code>/data</code> when mounted by OpenEmbedded)
| User data partition (<code>/data</code> when mounted by OpenEmbedded)
|-
|-
| MTD15 || <code>sec</code>
| MTD15
| <code>sec</code>
| Used to blow fuses in the mdm9207 from images generated by Qualcomm Sectools
| Used to blow fuses in the mdm9207 from images generated by Qualcomm Sectools
|-
|-
| MTD16 || <code>system</code>
| MTD16
| <code>system</code>
| Linux OpenEmbedded root image, formatted in UBIFS (Unsorted Block Image File System, [https://en.wikipedia.org/wiki/UBIFS Wikipedia])
| Linux OpenEmbedded root image, formatted in UBIFS (Unsorted Block Image File System, [https://en.wikipedia.org/wiki/UBIFS Wikipedia])
|}
|}
Line 92: Line 115:
=== Firmware Recovery ===
=== Firmware Recovery ===


{{warning|1= The following instructions are directed towards expert-level users and developers!}}
{{Warning|The following instructions are directed towards expert-level users and developers!}}


The System partition is mounted as read-only mode, but the data partition is writable. It might be possible, if there's an unexpected reset or power is lost while running, that the data partition gets corrupt and thus unable to boot.
The System partition is mounted as read-only mode, but the data partition is writable. It might be possible, if there's an unexpected reset or power is lost while running, that the data partition gets corrupt and thus unable to boot.
Line 140: Line 163:
=== Bootloader unlocking ===
=== Bootloader unlocking ===


{{warning|1= The following instructions are directed towards expert-level users and developers!}}
{{Warning|The following instructions are directed towards expert-level users and developers!}}


The Modem has a locked bootloader. It won't allow to boot unsigned Kernel images, but will allow to flash them, making it easy to brick the modem. To fix this, you can flash an unlocked bootloader, which will then allow you to do as you please with the hardware.
The Modem has a locked bootloader. It won't allow to boot unsigned Kernel images, but will allow to flash them, making it easy to brick the modem. To fix this, you can flash an unlocked bootloader, which will then allow you to do as you please with the hardware.
Line 150: Line 173:
=== Custom Kernels and system images ===
=== Custom Kernels and system images ===


{{warning|1= The following instructions are directed towards expert-level users and developers!}}
{{Warning|The following instructions are directed towards expert-level users and developers!}}


Custom kernel builds and system images can be created for the modem, though they require a couple of things to be correctly built and be bootable.
Custom kernel builds and system images can be created for the modem, though they require a couple of things to be correctly built and be bootable.
Line 161: Line 184:


See its readme for infomations and instructions. Once downloaded, you should run the <code>init.sh</code> script, which will create all the base directories and download all the different repositories required to build. After the initial setup is complete, run<code>make</code> without arguments to list the available options.
See its readme for infomations and instructions. Once downloaded, you should run the <code>init.sh</code> script, which will create all the base directories and download all the different repositories required to build. After the initial setup is complete, run<code>make</code> without arguments to list the available options.
=== Upgrade/switch firmware via fwupd ===
https://fwupd.org/ is an open-source tool for managing the installation of firmware on Linux systems.
fwupd >= 1.7.6 (with the ModemManager plugin) supports writing/upgrading the https://github.com/Biktorgj/pinephone_modem_sdk firmware on the Quectel EG25-G modem.
https://wiki.postmarketos.org/wiki/Fwupd discusses how to use fwupd to do this.
More context:
* https://dylanvanassche.be/blog/2022/pinephone-modem-upgrade/
* https://gitlab.com/postmarketOS/pmaports/-/merge_requests/2760
* https://gitlab.com/linux-mobile/tracker/-/issues/11
=== Modem management ===
To allow PinePhones to receive calls while the PinePhone is suspended, the modem should be kept running. ModemManager and a eg25-specific manager must be used for the eg25-manager to work correctly.
==== ModemManager ====
[https://www.freedesktop.org/wiki/Software/ModemManager/ ModemManager] "is a DBus-activated daemon which controls mobile broadband (2G/3G/4G) devices and connections". Distributions should enable the <code>--test-quick-suspend-resume</code> flag, per https://gitlab.com/linux-mobile/tracker/-/issues/12.
Context: https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/321
==== eg25-specific manager ====
Some functionality is not built into ModemManager, and is instead managed via eg25-specific software. There are two variants of this, but only one should be used.
* [https://gitlab.com/mobian1/devices/eg25-manager eg25-manager] <b>recommended</b>, used in most distributions.
* [https://xnux.eu/devices/feature/modem-pp.html modem-power]
==== Testing ====
When a distribution makes a significant change to their modem management setup, they should consider testing the following:
* Modem is recognized by ModemManager on boot.
* Can make a call
* Can receive a call
* Can receive a call when asleep: <code>systemctl suspend</code>
== See also ==
* [https://dylanvanassche.be/blog/2021/pinephone-modem-myths/ "PinePhone modem myths" by Dylan Van Assche]


[[Category:PinePhone]]
[[Category:PinePhone]]

Latest revision as of 13:35, 16 March 2023

PINE64 position on alternative firmware

PINE64 ships the PinePhone with a stock version of the Quectel EG25-G modem's firmware. Some administrative regions, in the EU and Asia in particular, require the entirety of the modem's firmware to be licensed. Therefore, the PinePhone cannot ship with an unlicensed firmware, and the PINE64 project cannot, officially encourage its userbase to use alternative modem firmware.

Quectel EG25-G Modem

Quectel EG25-G is an LTE Cat 4 module optimized specially for M2M and IoT applications. It is used in the PinePhone.

Specifications

Processor Family Qualcomm MDM9607
CPU Qualcomm MDM9207
Cores 1 ACPU Core, Qualcomm Hexagon DSP
Total RAM 256Mb
Total flash space 256Mb
Available RAM for the ACPU 160Mb

NAND Partition table layout

Index Name Description
MTD0 SBL Secondary Bootloader, called from the BootROM. Used to start the TrustZone kernel and the Application Bootloader (LK). Also used to enter Quectel's recovery mode
MTD1 mibib NAND Partition table
MTD2 EFS2 IMEI and settings used by the ADSP are stored here
MTD3 sys_rev Unexplored
MTD4 rawdata This is where FOTA update data exists before being commited to system or recoveryfs partitions
MTD5 tz TrustZone kernel
MTD6 rpm Resource / Power Manager
MTD7 cust_info Unexplored
MTD8 aboot Application Bootloader. Uses LK (LittleKernel, LK embedded kernel) as the bootloader. By default it allows flashing unsigned images but won't allow booting them, soft-bricking the modem until you enter EDL mode
MTD9 boot OpenEmbedded boot kernel + DTB
MTD10 recovery Recovery kernel (used for FOTA updates)
MTD11 modem ADSP firmware blobs
MTD12 misc Some settings are stored here, along with commands that need to be picked by LK on next boot (to reboot to fastboot or recovery mode)
MTD13 recoveryfs Recovery filesystem image (FOTA updates)
MTD14 usr_data User data partition (/data when mounted by OpenEmbedded)
MTD15 sec Used to blow fuses in the mdm9207 from images generated by Qualcomm Sectools
MTD16 system Linux OpenEmbedded root image, formatted in UBIFS (Unsorted Block Image File System, Wikipedia)

Firmware Recovery

Warning: The following instructions are directed towards expert-level users and developers!

The System partition is mounted as read-only mode, but the data partition is writable. It might be possible, if there's an unexpected reset or power is lost while running, that the data partition gets corrupt and thus unable to boot.

PinePhone USB_BOOT test points

The modem has 4 different boot modes:

  • Normal boot
  • Recovery mode (used by the modem usually to install a FOTA update)
  • Fastboot mode
  • Qualcomm EDL Mode

If the modem is unable to boot, depending on the type of crash, it might:

  • not show anywhere (USB device missing)
  • or malfunction (no radio but USB working)
  • or enter EDL mode, if the entire flash is corrupt.

Boot the device in EDL mode

To check if the device is booted in EDL mode, run lsusb (a part of the usbutils package) in a terminal and inspect the output. You should see the following device listed:

Bus 003 Device 003: ID 05c6:9008 Qualcomm, Inc. Gobi Wireless Modem (QDL mode)

In any scenario, the modem can be triggered to enter EDL mode by shorting two test pins on the PinePhone motherboard.

  1. Power off the phone
  2. short the two test points
  3. boot the phone while keeping the test points shorted until fully booted up, at least until you hear the camera clicking twice (which is normally when the modem is powered).

Get the Firmware Recovery Package

The Firmware Recovery Package is at: https://github.com/Biktorgj/quectel_eg25_recovery

Either clone its repo with git, or download its archive & unzip it.

As you should have no access to the Internet on PinePhone when its modem need a Recovery, you can fetch it on other devices and copy it to the Pinephone.

Execute the Quectel QFirehose utility

Once in EDL mode, open a terminal, navigate to the root directory of the recovery package, and run:

  • If you use an ARM64 distribution (most likely): sudo ./qfirehose -f ./ or sudo ./qfirehose_arm64 -f ./
  • If you use an ARMHF (32 bit) distribution: sudo ./qfirehose_armhf -f ./

It will reboot the modem after finished. After about 30 seconds, it will get back up and running. To check the firmware version after that, use an AT command AT+QGMR like at PinePhone#Firmware_update.

Bootloader unlocking

Warning: The following instructions are directed towards expert-level users and developers!

The Modem has a locked bootloader. It won't allow to boot unsigned Kernel images, but will allow to flash them, making it easy to brick the modem. To fix this, you can flash an unlocked bootloader, which will then allow you to do as you please with the hardware.

Unlocked bootloader:

Custom Kernels and system images

Warning: The following instructions are directed towards expert-level users and developers!

Custom kernel builds and system images can be created for the modem, though they require a couple of things to be correctly built and be bootable.

  • The source code release for the kernel provided by the manufacturer is incomplete and won't build
  • Common Android tools like mkbootimg and dtbtool won't build a bootable image, even if the kernel is correctly compiled and all the DTBs attached.
  • Further, there's no source for the OpenEmbedded parts, so building a new system image must be done from scratch, and retrieving the mandatory binary blobs to use the ADSP part of the modem.

There's a work in progress SDK to allow creating custom kernels and system images, which can be downloaded from the following repository: https://github.com/Biktorgj/pinephone_modem_sdk

See its readme for infomations and instructions. Once downloaded, you should run the init.sh script, which will create all the base directories and download all the different repositories required to build. After the initial setup is complete, runmake without arguments to list the available options.

Upgrade/switch firmware via fwupd

https://fwupd.org/ is an open-source tool for managing the installation of firmware on Linux systems.

fwupd >= 1.7.6 (with the ModemManager plugin) supports writing/upgrading the https://github.com/Biktorgj/pinephone_modem_sdk firmware on the Quectel EG25-G modem.

https://wiki.postmarketos.org/wiki/Fwupd discusses how to use fwupd to do this.

More context:

Modem management

To allow PinePhones to receive calls while the PinePhone is suspended, the modem should be kept running. ModemManager and a eg25-specific manager must be used for the eg25-manager to work correctly.

ModemManager

ModemManager "is a DBus-activated daemon which controls mobile broadband (2G/3G/4G) devices and connections". Distributions should enable the --test-quick-suspend-resume flag, per https://gitlab.com/linux-mobile/tracker/-/issues/12.

Context: https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/321

eg25-specific manager

Some functionality is not built into ModemManager, and is instead managed via eg25-specific software. There are two variants of this, but only one should be used.

Testing

When a distribution makes a significant change to their modem management setup, they should consider testing the following:

  • Modem is recognized by ModemManager on boot.
  • Can make a call
  • Can receive a call
  • Can receive a call when asleep: systemctl suspend

See also