Looking for kernel source overrides for EM12-G

Hi,
I realize that I cannot use upstream Linux kernel module for qmi_wwan.ko and qcserial.ko
Our Linux is based on:

Please provide the corresponding source code for:
drivers/net/usb/qmi_wwan.c (qmi_wwan_q.c)
drivers/usb/serial/qcserial.c
drivers/net/usb/cdc_mbim.c
Preferably also your latest update for:
drivers/usb/serial/option.c

My email is chencheng@wittra.se

Thanks!
BR/Chencheng

except the qmi_wwan_q.c should be provided from Quectel, all the other drivers should be got from the rpi.

I will provide the qmi_wwan_q via message.

Why did you say that?

For miq_wwan.ko I was missing mqi_wwan_q.
For qcserial.ko I guess there is no impact since I am not using EC20 module?

You don’t need the qcserial at all. I think.

If you just use the upstream Linux 5.15. the qmi_wwan should also works well.
Make sure that
{QMI_MATCH_FF_FF_FF(0x2c7c, 0x0512)}, /* Quectel EG12/EM12 */
is already in qmi_wwan.c.

OK thanks for your information. I think I looked at a document which is too old:
WCDMA&LTE_Linux_USB_Driver_User_Guide_V1.8

If I use kernel 6.1, is it the same qmi_wwan_q.c I can use which you have sent m?

Yes.
The qmi_wwan_q I sent also works on Kernel 6.x.

Thank you! I will test it a bit more.

Hi again, I got kernel crash after I built the new kernel based on 6.1.20-v8 with your file.
kconfig added:
CONFIG_USB=y
CONFIG_USB_ACM=y
CONFIG_USB_NET_CDC_MBIM=y
CONFIG_USB_NET_CDC_NCM=y
CONFIG_USB_NET_CDC_SUBSET=y
CONFIG_USB_NET_CDC_SUBSET_ENABLE=y
CONFIG_USB_NET_DRIVERS=y
CONFIG_USB_NET_QMI_WWAN=y
CONFIG_USB_SERIAL=y
CONFIG_USB_SERIAL_OPTION=y
CONFIG_USB_SERIAL_QUALCOMM=y
CONFIG_USB_SERIAL_WWAN=y
CONFIG_USB_USBNET=y
CONFIG_USB_WDM=y
CONFIG_QCOM_QMI_HELPERS=y
CONFIG_PPP=y
CONFIG_PPP_ASYNC=y
CONFIG_PPP_SYNC_TTY=y
CONFIG_PPP_DEFLATE=y
CONFIG_WWAN=y

Kernel patch:
0001-Quectel-hacks.patch (83.2 KB)

After my ofono brings the modem online, I did “ifconfig wwan0 up”, then:

[ 85.797740] audit: type=1334 audit(1707401417.445:199): prog-id=215 op=LOAD
[ 85.805205] audit: type=1334 audit(1707401417.453:200): prog-id=216 op=LOAD
[ 709.231041] Unable to handle kernel NULL pointer dereference at virtual address 000000000000059b
[ 709.239980] Mem abort info:
[ 709.242813] ESR = 0x0000000096000006
[ 709.246620] EC = 0x25: DABT (current EL), IL = 32 bits
[ 709.252014] SET = 0, FnV = 0
[ 709.255106] EA = 0, S1PTW = 0
[ 709.258285] FSC = 0x06: level 2 translation fault
[ 709.263233] Data abort info:
[ 709.266155] ISV = 0, ISS = 0x00000006
[ 709.270048] CM = 0, WnR = 0
[ 709.273055] user pgtable: 4k pages, 39-bit VAs, pgdp=00000000674af000
[ 709.279585] [000000000000059b] pgd=0800000067518003, p4d=0800000067518003, pud=0800000067518003, pmd=0000000000000000
[ 709.290368] Internal error: Oops: 0000000096000006 [#1] PREEMPT SMP
[ 709.296732] Modules linked in: g_mass_storage usb_f_mass_storage libcomposite tun rfcomm cmac algif_hash aes_arm64 aes_generic algif_skcipher af_alg bnep hci_uart btbcm bluetooth ecdh_generic ecc libaes brcmfmac brcmutil spidev bcm2835_codec(C) cfg80211 rpivid_hevc(C) rfkill bcm2835_isp(C) bcm2835_v4l2(C) bcm2835_mmal_vchiq(C) v4l2_mem2mem videobuf2_dma_contig videobuf2_vmalloc videobuf2_memops videobuf2_v4l2 rtc_pcf85063 raspberrypi_hwmon videobuf2_common dwc2 vc_sm_cma(C) videodev roles spi_bcm2835 mioty_hat(O) mc uio_pdrv_genirq uio sch_fq_codel fuse ipv6
[ 709.347033] CPU: 3 PID: 0 Comm: swapper/3 Tainted: G C O 6.1.20-v8 #1
[ 709.354810] Hardware name: Raspberry Pi Compute Module 4 Rev 1.1 (DT)
[ 709.361341] pstate: 400000c5 (nZcv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=–)
[ 709.368409] pc : arch_stack_walk+0x38/0x250
[ 709.372668] lr : arch_stack_walk+0xc/0x250
[ 709.376819] sp : ffffffc0080bbca0
[ 709.380174] x29: ffffffc0080bbca0 x28: ffffff80402c0000 x27: ffffffc009863f50
[ 709.387424] x26: ffffffc0098ebc80 x25: 0000000000000000 x24: ffffffc009863f10
[ 709.394678] x23: ffffffd726938a4c x22: ffffff804001bc80 x21: ffffffc0080bbd88
[ 709.401918] x20: 00000000d5384101 x19: ffffff80402abd80 x18: 0000000000000000
[ 709.409164] x17: 0000000000000000 x16: 0000000000000000 x15: 0000007fb0a7dbf0
[ 709.416415] x14: 0000000000000000 x13: 0000000000000000 x12: 0000000000000000
[ 709.423662] x11: 0000000000000000 x10: 0000000000001a60 x9 : ffffffd725d4a118
[ 709.430921] x8 : ffffffc0080bbd38 x7 : 0000000000000000 x6 : 00000008ec5d930a
[ 709.438173] x5 : 00ffffffffffffff x4 : ffffffc0080b8000 x3 : ffffff804001bc80
[ 709.445420] x2 : 000000000000059b x1 : ffffffc0080bbd88 x0 : 00000000d5384101
[ 709.452680] Call trace:
[ 709.455158] arch_stack_walk+0x38/0x250
[ 709.459048] return_address+0x40/0x80
[ 709.462767] trace_hardirqs_on+0x88/0x1fc
[ 709.466846] tick_nohz_idle_enter+0x78/0xb0
[ 709.471105] do_idle+0x38/0x2e0
[ 709.474298] cpu_startup_entry+0x30/0x3c
[ 709.478274] secondary_start_kernel+0x128/0x150
[ 709.482874] __secondary_switched+0xb0/0xb4
[ 709.487138] Code: f9001bf7 aa0303f6 aa1e03f7 f9401264 (f9400045)
[ 709.493329] —[ end trace 0000000000000000 ]—
[ 709.498014] Kernel panic - not syncing: Oops: Fatal exception
[ 709.503845] SMP: stopping secondary CPUs
[ 709.507835] Kernel Offset: 0x171dc00000 from 0xffffffc008000000
[ 709.513847] PHYS_OFFSET: 0x0
[ 709.516771] CPU features: 0x20000,2013c080,0000421b
[ 709.521728] Memory Limit: none
[ 709.524834] Rebooting in 30 seconds…
SIG pieeprom.sig af35fea295e99ea26d7028af2e44e97684dbcaa6798d9f50e2c64448eec15240 1657839122
SELF-UPDATE timestamp current 1657839122 new 1657839122 skip
Read start4.elf bytes 2241440 hnd 0x36a5
Read fixup4.dat bytes 5411 hnd 0x1b63
Firmware: 51215b4f6e3966401ecd99652a35cf1c25069113 Sep 30 2021 19:21:03
0x00c03141 0x00000000 0x00000fff
MEM GPU: 76 ARM: 948 TOTAL: 1024
Starting start4.elf @ 0xfec00200 partition 0

There are some more information:
root@wittragw-G01231A8CC109FA3FEE:/usr/lib/ofono/test# ./list-modems
[ /mbim_0 ]
Online = 1
Powered = 1
Lockdown = 0
Emergency = 0
Serial = 869710030108686
SystemPath = /sys/devices/platform/soc/fe980000.usb/usb1/1-1/1-1.4
Interfaces = org.ofono.NetworkRegistration org.ofono.SmartMessaging org.ofono.PushNotification org.ofono.MessageManager org.ofono.ConnectionManager org.ofono.AllowedAccessPoints org.ofono.SimManager
Features = net sms gprs sim
Type = hardware
[ org.ofono.NetworkRegistration ]
Status = registered
Mode = auto-only
Technology = lte
MobileCountryCode = 240
MobileNetworkCode = 08
Name = Telenor SE
Strength = 9
[ org.ofono.SmartMessaging ]
[ org.ofono.PushNotification ]
[ org.ofono.MessageManager ]
ServiceCenterAddress = +46708000708
UseDeliveryReports = 0
Bearer = cs-preferred
Alphabet = default
[ org.ofono.ConnectionManager ]
Attached = 1
Bearer = lte
RoamingAllowed = 0
Powered = 1
Suspended = 0
[ org.ofono.AllowedAccessPoints ]
[ org.ofono.SimManager ]
Present = 1
SubscriberIdentity = 240084714807761
FixedDialing = 0
BarredDialing = 0
SubscriberNumbers =
LockedPins = pin2
PinRequired = pin2
Retries = [pin2 = 3]
CardSlotCount = 1
ActiveCardSlot = 1

root@wittragw-G01231A8CC109FA3FEE:/usr/lib/ofono/test# ifconfig wwan0
wwan0 Link encap:Ethernet HWaddr F2:E0:36:96:31:CE
inet6 addr: fe80::f0e0:36ff:fe96:31ce/64 Scope:Link
UP BROADCAST RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:9 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:1360 (1.3 KiB)

There is no ipv4. Kernel just crash and system restart.

Hi again,
I tried to use networkmanager with modemmanager instead of connman with ofono.
Then I get a different kernel crash:
[ 35.804546] ------------[ cut here ]------------
[ 35.809300] NETDEV WATCHDOG: wwan0 (cdc_mbim): transmit queue 0 timed out
[ 35.816292] WARNING: CPU: 2 PID: 0 at net/sched/sch_generic.c:525 dev_watchdog+0x278/0x280
[ 35.824714] Modules linked in: cmac algif_hash aes_arm64 aes_generic algif_skcipher af_alg bnep hci_uart btbcm bluetooth ecdh_generic ecc libaes tun 8021q garp stp llc bcm2835_codec(C) bcm2835_isp(C) bcm2835_v4l2(C) rpivid_hevc(C) bcm2835_mmal_vchiq(C) v4l2_mem2mem spidev videobuf2_vmalloc videobuf2_dma_contig videobuf2_memops videobuf2_v4l2 videobuf2_common brcmfmac dwc2 rtc_pcf85063 raspberrypi_hwmon brcmutil videodev vc_sm_cma(C) roles mc spi_bcm2835 mioty_hat(O) cfg80211 rfkill uio_pdrv_genirq uio sch_fq_codel fuse ipv6
[ 35.871902] CPU: 2 PID: 0 Comm: swapper/2 Tainted: G C O 6.1.20-v8 #1
[ 35.879672] Hardware name: Raspberry Pi Compute Module 4 Rev 1.1 (DT)
[ 35.886202] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=–)
[ 35.893264] pc : dev_watchdog+0x278/0x280
[ 35.897331] lr : dev_watchdog+0x278/0x280
[ 35.901398] sp : ffffffc008013d90
[ 35.904753] x29: ffffffc008013d90 x28: ffffffd15bbb6324 x27: ffffffc008013eb0
[ 35.911995] x26: ffffffd15c2ac008 x25: 0000000000000000 x24: ffffffd15c5f9878
[ 35.919237] x23: ffffffd15c5f7000 x22: 0000000000000000 x21: ffffff8064c893dc
[ 35.926476] x20: ffffff8064c89000 x19: ffffff8064c89488 x18: 0000000000000006
[ 35.933716] x17: ffffffaf9f4f9000 x16: ffffffc008014000 x15: 076d0773076e0761
[ 35.940956] x14: 077207740720073a x13: 076d0773076e0761 x12: 077207740720073a
[ 35.948196] x11: 0720072007200720 x10: ffffffd15c670df8 x9 : ffffffd15b105f54
[ 35.955436] x8 : 00000000ffffefff x7 : ffffffd15c670df8 x6 : 80000000fffff000
[ 35.962677] x5 : ffffff80fb7a79c8 x4 : 0000000000000105 x3 : ffffffd15c2ac008
[ 35.969917] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffffff80402a9ec0
[ 35.977158] Call trace:
[ 35.979632] dev_watchdog+0x278/0x280
[ 35.983348] call_timer_fn+0x3c/0x1cc
[ 35.987060] __run_timers+0x258/0x314
[ 35.990770] run_timer_softirq+0x38/0x60
[ 35.994745] __do_softirq+0x198/0x4d8
[ 35.998456] ____do_softirq+0x18/0x24
[ 36.002168] call_on_irq_stack+0x2c/0x54
[ 36.006144] do_softirq_own_stack+0x24/0x3c
[ 36.010384] __irq_exit_rcu+0xd4/0x120
[ 36.014184] irq_exit_rcu+0x18/0x50
[ 36.017718] el1_interrupt+0x38/0x70
[ 36.021342] el1h_64_irq_handler+0x18/0x2c
[ 36.025493] el1h_64_irq+0x64/0x68
[ 36.028938] arch_cpu_idle+0x18/0x2c
[ 36.032561] default_idle_call+0x54/0x19c
[ 36.036627] do_idle+0x26c/0x2e0
[ 36.039897] cpu_startup_entry+0x30/0x3c
[ 36.043873] secondary_start_kernel+0x128/0x150
[ 36.048468] __secondary_switched+0xb0/0xb4
[ 36.052710] —[ end trace 0000000000000000 ]—

It looks like wwan0 is up:
wwan0 Link encap:Ethernet HWaddr F2:E0:36:96:31:CE
inet addr:169.254.39.255 Bcast:169.254.255.255 Mask:255.255.0.0
inet6 addr: fe80::73ee:1417:17c4:db6e/64 Scope:Link
UP BROADCAST RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:17 errors:5 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:2490 (2.4 KiB)

But there is no Internet and I cannot ping any dns server.

Hi again,
Now I also tried quectel-cm. But I cannot get to internet even wwan0 seems to show up.
qcm.txt (60 KB)

wwan0     Link encap:Ethernet  HWaddr F2:E0:36:96:31:CE
          inet addr:10.101.160.18  Bcast:0.0.0.0  Mask:255.255.255.252
          inet6 addr: fe80::f0e0:36ff:fe96:31ce/64 Scope:Link
          UP BROADCAST RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:25 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:3534 (3.4 KiB)

# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
ping: sendto: Network is unreachable

Hi again,
I am following the reference for running AT commands. Only the most basic AT commands are OK, but many others are failing:

Terminal ready
AT
OK
AT+QNWINFO=?
ERROR
ATI
Quectel
EM12
Revision: EM12GPAR01A21M4G

OK
AT+GMR
ERROR
AT+CGMI=?
ERROR

Hi again,
Here is the latest kernel crash I have when I am using ofono 2.3 since I could not get the wwan0 up with quectel-cm.

[  430.908962] ------------[ cut here ]------------
[  430.913687] NETDEV WATCHDOG: wwan0 (cdc_mbim): transmit queue 0 timed out
[  430.920690] WARNING: CPU: 3 PID: 0 at net/sched/sch_generic.c:525 dev_watchdog+0x278/0x280
[  430.929112] Modules linked in: 8021q garp stp llc rfcomm g_mass_storage usb_f_mass_storage libcomposite tun cmac algif_hash aes_arm64 aes_generic algif_skcipher af_alg bnep hci_uart btbcm bluetooth ecdh_generic ecc libaes bcm2835_isp(C) brcmfmac spidev bcm2835_codec(C) rpivid_hevc(C) v4l2_mem2mem bcm2835_v4l2(C) brcmutil videobuf2_dma_contig bcm2835_mmal_vchiq(C) videobuf2_vmalloc cfg80211 videobuf2_memops videobuf2_v4l2 dwc2 videobuf2_common vc_sm_cma(C) roles videodev rtc_pcf85063 rfkill spi_bcm2835 raspberrypi_hwmon mc mioty_hat(O) uio_pdrv_genirq uio sch_fq_codel fuse ipv6
[  430.981068] CPU: 3 PID: 0 Comm: swapper/3 Tainted: G         C O       6.1.20-v8 #1
[  430.988837] Hardware name: Raspberry Pi Compute Module 4 Rev 1.1 (DT)
[  430.995368] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[  431.002431] pc : dev_watchdog+0x278/0x280
[  431.006498] lr : dev_watchdog+0x278/0x280
[  431.010564] sp : ffffffc00801bd90
[  431.013921] x29: ffffffc00801bd90 x28: ffffffec1f9b6324 x27: ffffffc00801beb0
[  431.021163] x26: ffffffec200ac008 x25: 0000000000000000 x24: ffffffec203f9878
[  431.028406] x23: ffffffec203f7000 x22: 0000000000000000 x21: ffffff80432e73dc
[  431.035646] x20: ffffff80432e7000 x19: ffffff80432e7488 x18: 0000000000000006
[  431.042886] x17: ffffff94db716000 x16: ffffffc00801c000 x15: 076d0773076e0761
[  431.050126] x14: 077207740720073a x13: 076d0773076e0761 x12: 077207740720073a
[  431.057366] x11: 0720072007200720 x10: ffffffec20470df8 x9 : ffffffec1ef05f54
[  431.064605] x8 : 00000000ffffefff x7 : ffffffec20470df8 x6 : 80000000fffff000
[  431.071846] x5 : ffffff80fb7c49c8 x4 : 0000000000000105 x3 : ffffffec200ac008
[  431.079086] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffffff80402abd80
[  431.086327] Call trace:
[  431.088803]  dev_watchdog+0x278/0x280
[  431.092519]  call_timer_fn+0x3c/0x1cc
[  431.096231]  __run_timers+0x258/0x314
[  431.099942]  run_timer_softirq+0x38/0x60
[  431.103918]  __do_softirq+0x198/0x4d8
[  431.107630]  ____do_softirq+0x18/0x24
[  431.111341]  call_on_irq_stack+0x2c/0x54
[  431.115317]  do_softirq_own_stack+0x24/0x3c
[  431.119560]  __irq_exit_rcu+0xd4/0x120
[  431.123361]  irq_exit_rcu+0x18/0x50
[  431.126898]  el1_interrupt+0x38/0x70
[  431.130522]  el1h_64_irq_handler+0x18/0x2c
[  431.134674]  el1h_64_irq+0x64/0x68
[  431.138121]  arch_cpu_idle+0x18/0x2c
[  431.141745]  default_idle_call+0x54/0x19c
[  431.145812]  do_idle+0x26c/0x2e0
[  431.149083]  cpu_startup_entry+0x30/0x3c
[  431.153060]  secondary_start_kernel+0x128/0x150
[  431.157655]  __secondary_switched+0xb0/0xb4
[  431.161898] ---[ end trace 0000000000000000 ]---

Modem status:

/usr/lib/ofono/test# ./list-modems
[ /mbim_0 ]
    Online = 1
    Powered = 1
    Lockdown = 0
    Emergency = 0
    Serial = 869710030108686
    SystemPath = /sys/devices/platform/soc/fe980000.usb/usb1/1-1/1-1.4
    Interfaces = org.ofono.NetworkRegistration org.ofono.SmartMessaging org.ofono.PushNotification org.ofono.MessageManager org.ofono.ConnectionManager org.ofono.AllowedAccessPoints org.ofono.SimManager
    Features = net sms gprs sim
    Type = hardware
    [ org.ofono.NetworkRegistration ]
        Status = roaming
        Mode = auto-only
        Technology = lte
        MobileCountryCode = 240
        MobileNetworkCode = 08
        Name = Telenor CXN
        Strength = 9
    [ org.ofono.SmartMessaging ]
    [ org.ofono.PushNotification ]
    [ org.ofono.MessageManager ]
        ServiceCenterAddress = +46731260010
        UseDeliveryReports = 0
        Bearer = cs-preferred
        Alphabet = default
    [ org.ofono.ConnectionManager ]
        Attached = 1
        Bearer = lte
        RoamingAllowed = 1
        Powered = 1
        Suspended = 0
    [ org.ofono.AllowedAccessPoints ]
    [ org.ofono.SimManager ]
        Present = 1
        SubscriberIdentity = 240422606727266
        FixedDialing = 0
        BarredDialing = 0
        SubscriberNumbers =
        LockedPins = pin2
        PinRequired = pin2
        Retries = [pin2 = 3]
        CardSlotCount = 1
        ActiveCardSlot = 1

If there occur the
NETDEV WATCHDOG: wwan0 (cdc_mbim): transmit queue 0 timed out
The only way what we could do is restart the modem.

It means that there is something wrong with the communication and cannot recover.
Make sure that set up data call first and then try to use the cdc_mbim usbnet intertface.

Please check the:
route -n
if you could not ping the 8.8.8.8
make sure that the wwan0 is in the default

Please follow the Quectel AT user guide.
Not all the 3GPP AT command are implemented.
For example to check the firmware version,
it is better to try ATI or AT+QGMR

Thanks for the help. It was some HW problem.
Also works in kernel 6.1.x.
Now it is solved. You can close the ticket now.