Feature #2206
openNote 2 LTE modem on mainline kernel
Added by Joey Hewitt over 3 years ago. Updated 9 months ago.
0%
Description
I'll track work on LTE modems on mainline kernel. The attached patch goes in the kernel. Build and install https://github.com/technexion-android/platform_external_libgpiod, then run the following script:
pin_name() {
sed 's/-/ /' /sys/firmware/devicetree/base/soc/pinctrl@*/$1/samsung,pins
}
gpioset $(pin_name ap2mdm-soft-reset-n)=0
sleep .005
gpioset $(pin_name ap2mdm-soft-reset-n)=1
sleep .010
gpioset $(pin_name ap2mdm-status)=1
The modem should now appear in lsusb, in QDL mode. I am trying to figure out how to boot it. I'm using https://git.replicant.us/contrib/scintill/external_modem-boot/ with some obsolete pieces stripped out, but now the modem sends a non-existent command 0. I don't know why, but some guesses are that the HSIC is buggy in this kernel, or the old kernel does something I don't know about to get the modem in the right state.
Files
Updated by Joey Hewitt over 3 years ago
P.S. Credit to https://github.com/fourkbomb/linux/tree/modem for the HSIC devicetree code.
Updated by Kurtis Hanna over 3 years ago
Denis is doing some upstream modem work in this repo that continues on the work forkbomb was doing at the link above: https://git.replicant.us/contrib/GNUtoo/kernel_replicant_linux/log/?h=replicant-11-i9300-modem
Updated by Jack K over 2 years ago
Joey Hewitt wrote:
I'll track work on LTE modems on mainline kernel. The attached patch goes in the kernel. Build and install https://github.com/technexion-android/platform_external_libgpiod, then run the following script:
[...]
The modem should now appear in lsusb, in QDL mode. I am trying to figure out how to boot it. I'm using https://git.replicant.us/contrib/scintill/external_modem-boot/ with some obsolete pieces stripped out, but now the modem sends a non-existent command 0. I don't know why, but some guesses are that the HSIC is buggy in this kernel, or the old kernel does something I don't know about to get the modem in the right state.
Hi Joey - have you done any more work? I am interested in getting LTE up and running, and would appreciate liaising with you over this - are you on IRC at all?
Many thanks,
Jack K
Updated by Jack K about 2 years ago
I added a couple of USB IDs from smdk4412 kernel in qcserial driver:
diff --git a/drivers/usb/serial/qcserial.c b/drivers/usb/serial/qcserial.c index c18bf8164bc2..e20443289df6 100644 --- a/drivers/usb/serial/qcserial.c +++ b/drivers/usb/serial/qcserial.c @@ -116,6 +116,8 @@ static const struct usb_device_id id_table[] = { {USB_DEVICE(0x03f0, 0x371d)}, /* HP un2430 Gobi 3000 QDL */ {USB_DEVICE(0x05c6, 0x920c)}, /* Gobi 3000 QDL */ {USB_DEVICE(0x05c6, 0x920d)}, /* Gobi 3000 Composite */ + {USB_DEVICE(0x05c6, 0x9048)}, /* MDM9x15 device */ + {USB_DEVICE(0x05c6, 0x904C)}, /* MDM9x15 device */ {USB_DEVICE(0x1410, 0xa020)}, /* Novatel Gobi 3000 QDL */ {USB_DEVICE(0x1410, 0xa021)}, /* Novatel Gobi 3000 Composite */ {USB_DEVICE(0x413c, 0x8193)}, /* Dell Gobi 3000 QDL */
And got this in dmesg:
[ 82.194645] qcserial 1-2:1.0: Qualcomm USB modem converter detected [ 82.194939] usb 1-2: Qualcomm USB modem converter now attached to ttyUSB0
I think this might be a step in the right direction.
Updated by Josh Branning 10 months ago
I can confirm I was able to get the modem showing with lsusb and dmesg using the patches provided.
Thank you everyone.
I was, however, unable to 'list' the modem using postmarketos on the device (which was an i9305 with the same modem, not the note), be it either using ofono or network manager. Perhaps I need modem boot code?
Either way I reproduced the results, see here:
Updated by Josh Branning 10 months ago
Josh Branning wrote in #note-6:
I can confirm I was able to get the modem showing with lsusb and dmesg using the patches provided.
Thank you everyone.
I was, however, unable to 'list' the modem using postmarketos on the device (which was an i9305 with the same modem, not the note), be it either using ofono or network manager. Perhaps I need modem boot code?
Either way I reproduced the results, see here:
I since addded external_modem-boot package to the repository.
Despite the modem showing with lsusb and dmesg, when I run "mdm9k-boot" command, I get:
failed to open modem device
Looking at the external_modem_boot code it seems it requires /dev/mdm and /dev/ttyUSB0 nodes which aren't present (ie. with these patches).
Updated by Josh Branning 10 months ago
I tried adding the following udev rules to /etc/udev/rules.d/90-mdm9k-modem.rules
ACTION=="add", KERNEL=="mdm", OWNER="root", GROUP="root", MODE="0660"
ACTION=="add", KERNEL=="ttyUSB0", OWNER="root", GROUP="root", MODE="0660"
but it didn't make a difference: I was still unable to see a node at /dev/mdm
Updated by Josh Branning 9 months ago
Josh Branning wrote in #note-8:
I tried adding the following udev rules to /etc/udev/rules.d/90-mdm9k-modem.rules
ACTION=="add", KERNEL=="mdm", OWNER="root", GROUP="root", MODE="0660"
ACTION=="add", KERNEL=="ttyUSB0", OWNER="root", GROUP="root", MODE="0660"but it didn't make a difference: I was still unable to see a node at /dev/mdm
I made an external_modem-boot package for pmos. I found out that because of a patch to external_modem-boot, I might be able to do without a /dev/mdm node by setting CFLAGS="-DSKIP_MDM_DEVICE_IOCTL=1" whilst compiling this package.
I noticed that the pins in the patch that Joey provided are for the t0 only, so I looked in the smdk4412 kernel and created this table for the devices with the pins. https://raw.githubusercontent.com/publicsite/i9305-modem-postmarketos/main/doc/porting-matrix.txt
I then created some modem dtbs https://github.com/publicsite/i9305-modem-postmarketos/tree/main/mainline-patches/modem_configs
After testing the modified i9305 dtb, I was still unable to get the gpio set to work, although the pins looked as if they were correctly shown at /sys/firmware/devicetree/base/soc/pinctrl@*
I believe it is possible because libgpiod in alpine linux is old and the package hasn't been updated recently, and pmos inherits the libgpiod package from alpine.
I am yet to test with an updated version of libgpiod to see if I can get a /dev/ttyUSB0 node by running gpioset and then boot the modem with external_modem-boot but I have updated the repository (https://github.com/publicsite/i9305-modem-postmarketos) in the mean time.
Updated by Josh Branning 9 months ago
I updated a libgpiod package to v2.1 within the i9305-modem-postmarketos repository. Unfortunately I can't get gpioset to go.
#using libgpiod v2.1...
$ gpioset gpl2 5=1
gpioset: invalid line value: 'gpl2'#looking at gpioinfo I see that 'gpl2' corresponds to gpiochip19
$ gpioset gpiochip19 5=1
gpioset: invalid line value: 'gpiochip19'#I try prefixing with /dev/
$ gpioset /dev/gpiochip19 5=1
gpioset: invalid line value: '/dev/gpiochip19'#I try just the number
$ gpioset 19 5=1
gpioset: invalid line value: '/dev/gpiochip19'
EDIT: RESULT IS THE SAME USING SUDO
Updated by Josh Branning 9 months ago
Josh Branning wrote in #note-10:
I updated a libgpiod package to v2.1 within the i9305-modem-postmarketos repository. Unfortunately I can't get gpioset to go.
#using libgpiod v2.1...
$ gpioset gpl2 5=1
gpioset: invalid line value: 'gpl2'#looking at gpioinfo I see that 'gpl2' corresponds to gpiochip19
$ gpioset gpiochip19 5=1
gpioset: invalid line value: 'gpiochip19'#I try prefixing with /dev/
$ gpioset /dev/gpiochip19 5=1
gpioset: invalid line value: '/dev/gpiochip19'#I try just the number
$ gpioset 19 5=1
gpioset: invalid line value: '/dev/gpiochip19'EDIT: RESULT IS THE SAME USING SUDO
The syntax changed in v2.0=<, the following seems to work setting some of the gpio pin:
pin_name() { thePin="$(cat /sys/firmware/devicetree/base/soc/pinctrl@*/$1/samsung,pins)" theBankName="$(printf "%s" "$thePin" | cut -d '-' -f 1)" theRelativePin="$(printf "%s" "$thePin" | cut -d '-' -f 2)" theBankNumber="$(sudo gpiodetect | grep ".* \[${theBankName}\].*" | head -n 1 | cut -d ' ' -f 1)" printf "%s %s" "${theBankNumber}" "${theRelativePin}" } echo "Starting modem ..." echo "Running gpioset -z -c $(pin_name ap2mdm-soft-reset-n)=0 ..." gpioset -z -c $(pin_name ap2mdm-soft-reset-n)=0 sleep .005 echo "Running gpioset -z -c $(pin_name ap2mdm-soft-reset-n)=1 ..." gpioset -z -c $(pin_name ap2mdm-soft-reset-n)=1 sleep .010 echo "Running gpioset -z -c $(pin_name ap2mdm-status)=1 ..." gpioset -z -c $(pin_name ap2mdm-status)=1 sleep .010
With the following output:
Starting modem ... Running gpioset -z -c gpiochip19 5=0 ... Running gpioset -z -c gpiochip19 5=1 ... gpioset: unable to request lines on chip '/dev/gpiochip19': Resource busy Running gpioset -z -c gpiochip8 6=1 ...
I still don't see a /dev/ttyUSB0 node.
mdm9k-boot doesn't work I guess because I don't got a /dev/ttyUSB0 node.
EDIT: A longer sleep does not solve the "Resource busy" problem
Updated by Josh Branning 9 months ago
I reverted the libgpiod package to v1.6
The gpioset commands now work using the modified pinname function.
I run lsusb and I now get:
Bus 001 Device 002: ID 05c6:9008
appear, however, this is different from the device ids in Jack K's patch.
There is a node at /dev/ttyUSB0
When I run:
sudo mdm9k-boot
I get:
error receiving hello, received command 4
failed to do hello handshake
error while sending files
If I run mkm9k-boot more than once, I get:
opened modem tty device
failed waiting to read
failed to configure serial interface
I will try to consult on IRC.