# AT commands to a Sierra Wireless EM9291

Source: https://forum.modalai.com/topic/3563/at-commands-to-a-sierra-wireless-em9291
Category: ESCs, Sensors and Accessories (https://forum.modalai.com/category/15/escs-sensors-and-accessories)
Tags: cellular
Posted: 2024-06-18 21:17:18 UTC by groupo
Replies: 41 · Views: 26656

## groupo · 2024-06-18 21:17:18 UTC

Re: [Connecting to a private 5G network](/topic/984/connecting-to-a-private-5g-network)

I saw in the above post some steps for sending AT commands with a different modem than mine. How is this done with the EM9291 and where is/should this be done?

Another inquiry: I am trying to connect to a private 4G-LTE network. I ran "qmicli device=/dev/cdc-wdm0 --nas-network-scan" but my private network does not appear. I know it is up and running, and I have another phone connected to it to verify. After reading some Sierra forums, I am going to play around with some AT commands... but has anyone run into not seeing a network with --nas-network-scan before?

## Reply by groupo · 2024-06-18 21:20:55 UTC

After a little more digging, I suppose this is the same line of questioning here... which looks unanswered 

Re: [Serial communication with Sierra Wireless EM9291](/topic/3192/serial-communication-with-sierra-wireless-em9291)

## Reply by groupo · 2024-06-18 21:33:48 UTC

Looked thru the repo as suggested here

@Eric-Katzfey said in [Serial communication with Sierra Wireless EM9291](/post/15375):
> There are some scripts in our voxl-modem repo that use AT commands. https://gitlab.com/voxl-public/voxl-sdk/utilities/voxl-modem/-/tree/master/scripts?ref_type=heads

it looks like all examples of AT commands there are done by echoing to ttyUSB2 which, as I understand the scripts, is only applicable to a v2 modem, not the em9291. Am i overlooking something?

## Reply by groupo · 2024-06-20 17:07:44 UTC (in reply to groupo)

@groupo @tom @Eric-Katzfey @Alex-Kushleyev any traction on this? I am in a holding pattern with my project until i can establish how to send these AT commands. I have another post up on Sierra Wireless forums who want me to install MBPL USB driver but would like to talk to yall before I move forward with that

## Reply by Alex Kushleyev (ModalAI staff) · 2024-06-20 17:22:28 UTC (in reply to groupo)

@groupo , sorry, this is not my area of expertise, hopefully Tom and Eric can help!

Alex

## Reply by groupo · 2024-06-20 17:26:03 UTC (in reply to Alex Kushleyev)

@Alex-Kushleyev  Thank you, I figured... but I saw you were online and wanted to poke the devs ;)

## Reply by tom (ModalAI staff) · 2024-06-20 18:19:37 UTC (in reply to groupo)

@groupo I haven't been able to send AT commands to that flavor of Sierra modem, I've done everything via. `qmicli` at this point.

There's a good chance that driver would enable it but I haven't dug any deeper into it at this point.

## Reply by groupo · 2024-06-20 18:23:13 UTC (in reply to tom)

@tom thanks for getting back to me. My hesitation with installing it was messing up something you guys have put into place and having to reflash. Can you think of any easy gotchas before I go through with it?

## Reply by tom (ModalAI staff) · 2024-06-20 18:24:14 UTC (in reply to groupo)

@groupo Nah doesn't sound like anything too sketchy. It's easy to re-flash the SDK if you do mess anything up and I can help you through that if you get stuck.

## Reply by groupo · 2024-06-20 19:13:33 UTC (in reply to tom)

@tom Might you be able to help with the install? I have the drivers but I am a *not* very savvy with any software that isnt MATLAB. 

the readme is very straightforward, but I am running into issues:

1) run 'make' to install driver binaries
2) run 'make install' and reboot to install them

The makefile script looks for /lib/modules($shell uname -r)/build... which does not exist. I can mkdir it but I still get make errors. I am not even sure where I should place the folder 'usb' that these drivers are in.

I can provide the actual make script and anything else you'd wanna see... just want to see if youre able to help before dumping it all haha

## Reply by tom (ModalAI staff) · 2024-06-20 20:32:50 UTC (in reply to groupo)

@groupo Try this before building:

```
sudo ln -s /usr/src/header /lib/modules/$(uname -r)/build
```

## Reply by groupo · 2024-06-21 13:08:55 UTC (in reply to tom)

@tom 

Done but still get errors

```
voxl2:/$ sudo ln -s /usr/src/header/ /lib/modules/$(uname -r)/build 
voxl2:/$ cd usb
voxl2:/usb$ make
make -C /lib/modules/4.19.125/build M=/usb
make[1]: Entering directory '/lib/modules/4.19.125/build'
make[1]: *** No targets specified and no makefile found.  Stop.
make[1]: Leaving directory '/lib/modules/4.19.125/build'
Makefile:12: recipe for target 'all' failed
```

## Reply by groupo · 2024-06-21 15:10:09 UTC (in reply to tom)

@tom I see this is running libqmi 1.22.0. The latest, 1.32.0, has a [command for AT commands](https://www.freedesktop.org/software/libqmi/libqmi-glib/latest/#:~:text=Telit%20AT%20Relay%20Service%20(ATR)). Have you tried this new version internally? Could I upgrade mine?

## Reply by tom (ModalAI staff) · 2024-06-21 16:43:11 UTC (in reply to groupo)

@groupo Ooh cool, we haven't tried that before. Looks like you should be able to try upgrading it via. `apt`. Feel free to try that and let me know if you have luck!

## Reply by groupo · 2024-06-21 17:03:42 UTC (in reply to tom)

@tom just ```apt update libqmi``` ? Again sorry, but I am not very familiar with linux.

Another thing, I may have deleted the contents of /usr/src/header while trying to delete that symbolic link you had me make earlier. I swore there was stuff in /header, but I dont see anything in there now. I ran ```rm -r /lib/modules/###/build ``` which I thought should not touch anything past the link itself. If there is supposed to be stuff in there, can I get it back without reflashing?

## Reply by tom (ModalAI staff) · 2024-06-21 17:15:29 UTC (in reply to groupo)

@groupo I don't know of a way to get those files back without reflashing.

I just checked and it doesn't seem like there's a newer version available via. apt with the repos currently on there.

You may have to build and install it via. source

## Reply by groupo · 2024-06-21 17:22:58 UTC (in reply to tom)

@tom I was just typing a msg up to relay apt isnt showing any of them available for updating. I will try to reflash. 

I need to be able to connect to a private LTE network (MCC-MNC 001-01) which, as far as I have read, the EM9291 does not natively search for. I've read you can issue AT commands to tweak how the modem operates but am at a standstill trying to either install drivers to enumerate ttyUSB0 or update qmicli to the newest version so that I can issue AT commands that way. I think reflashing is necessary to get those files back and reestablish some ground truth with my drone. I should be able to go through those directions on my own. After that, are you able to assist me with either of the two avenues I discussed? I am grossly unfamiliar with the platform's architecture, but if I could get you on even a short call I think it would greatly accelerate this process for the two of us.

## Reply by tom (ModalAI staff) · 2024-06-21 17:26:57 UTC (in reply to groupo)

@groupo I can't provide a ton of help as I haven't tried it myself but you should be able to build and install a newer version of `libqmi` by following the instructions from here:

https://modemmanager.org/docs/libqmi/building/building-autotools/

In terms of which AT commands are required to send I can't really help there, it may require reading through Sierra's AT command docs

## Reply by groupo · 2024-06-21 17:36:22 UTC (in reply to tom)

@tom I am talking to a dev from Sierra Wireless who can help with the AT commands. there are some very useful forum posts there for connecting to 'test' LTE networks. I just need to send the AT commands to do so. I need your assistance in either installing that driver to enumerate the port or updating qmi. I will try to update qmi first, as that seems like the simpler approach. I need libqmi 1.34 which switched from GNU autotools to [Meson](https://modemmanager.org/docs/libqmi/building/building-meson/). That means nothing to me, I will just follow the steps, more FYI

## Reply by groupo · 2024-06-21 17:59:32 UTC (in reply to tom)

@tom need Meson to get newest libqmi. Tried installing that but ran into more errors, I hate feeling like I am asking to be spoonfed but I really could use some guided direction here - I am extremely out of my element

## Reply by tom (ModalAI staff) · 2024-06-21 18:18:09 UTC (in reply to groupo)

@groupo You can install `meson` and `ninja` with

```
sudo apt install meson ninja-build
```

## Reply by groupo · 2024-06-21 18:36:10 UTC (in reply to tom)

@tom I did that successfully, the error came with running the third line below

 ![0020794d-03f5-4ad3-9daa-20c7ce635d5f-image.png](https://forum.modalai.com/assets/uploads/files/1718994820914-0020794d-03f5-4ad3-9daa-20c7ce635d5f-image.png) 

```
voxl2:/$ sudo apt install meson ninja-build
Reading package lists... Done
Building dependency tree       
Reading state information... Done
ninja-build is already the newest version (1.8.2-1).
meson is already the newest version (0.45.1-2ubuntu0.18.04.2).
0 upgraded, 0 newly installed, 0 to remove and 37 not upgraded.
voxl2:/$ cd libqmi
voxl2:/libqmi(main)$ meson setup build --prefix=/usr
The Meson build system
Version: 0.45.1
Source dir: /libqmi
Build dir: /libqmi/build
Build type: native build

meson.build:223:10: ERROR: lexer
test_env = {
          ^

A full log can be found at /libqmi/build/meson-logs/meson-log.txt

```

## Reply by tom (ModalAI staff) · 2024-06-21 18:43:48 UTC (in reply to groupo)

@groupo Hmm meson isn't something I'm familiar with so I don't know how to debug that. 

Do you know if the version of libqmi has to be newer than 1.30? Otherwise you could try the older way to build using make

## Reply by groupo · 2024-06-21 18:49:18 UTC (in reply to tom)

@tom unfortunately, the ability to send AT commands via qmicli was introduced in 1.32. What about trying the drivers again? I goofed the symbolic linking earlier. I redid it and the make script gets farther, but still eventually fails.

How come PORT is initialized with certain modems in voxl-configure-modem but not with the em9291. It looks like you just set PORT to ttyUSB0 and echo to it to send AT commands. Can i not just add that into the em9291 logic flow?

## Reply by tom (ModalAI staff) · 2024-06-21 19:23:37 UTC (in reply to groupo)

@groupo `/dev/ttyUSB0` only enumerates if the driver recognizes the hardware of having said capability. In this case, the driver that controls that port doesn't recognize that modem hardware, likely the driver is from before that hardware existed.

In these cases we usually have to make custom tweaks to the linux kernel drivers in order to add the support for the hardware.

If you'd like to experiment with doing that you can, building custom kernels allows adding custom support for new or existing hardware.

You can read more about building a custom kernel here: https://docs.modalai.com/voxl2-kernel-build-guide/

## Reply by groupo · 2024-06-21 20:51:30 UTC (in reply to tom)

@tom I will explore the kernel stuff.

Re updating qmicli, I need meson >= 0.53.0 which is not supported on drone's ubuntu version. Is upgrading to a newer ubuntu on the drone an option?

## Reply by tom (ModalAI staff) · 2024-06-21 21:02:27 UTC (in reply to groupo)

@groupo It is not. Ubuntu 20 is on our road map but that's a while out

## Reply by groupo · 2024-06-24 17:20:09 UTC (in reply to tom)

@tom If I solely wanted to update the driver that controls that port is making a custom kernel the only way to do that? If that is the case, what is the least invasive way to do that? Where does that driver exists and what is the process for updating it? Which driver is responsible for that port? It looks like the guide shows you the things to download if you wanted to make your own kernel, but where do you change stuff to make it your own?

## Reply by groupo · 2024-06-24 22:10:45 UTC (in reply to tom)

@tom Found the drivers I believe I want to change. Do i change them inside or outside of the docker?

## Reply by Alex Kushleyev (ModalAI staff) · 2024-06-25 03:06:34 UTC (in reply to groupo)

@groupo , all the source code for the kernel will exist on your host system. When you enter the docker container, it maps your current directory into the docker container. `qrb5165-sync.sh` and `qrb5165-patch.sh` commands (executed inside docker) will download all the required sources to the shared folder and will be accessible on host system and inside the docker container.

You should make sure you can build the original kernel according to the standard instructions (sync, patch, build). Then make change to your driver either manually or apply your custom diff / patch and build again (do not sync or patch the whole project again).

Alex

## Reply by groupo · 2024-06-25 19:52:46 UTC (in reply to Alex Kushleyev)

@Alex-Kushleyev @tom 

Yeah I was able to sync, patch, and build successfully. When making those changes, is it done inside or outside of the docker? I can see the drivers I want to change in qrb5165-kernel-...sh, but that is outside the docker. I dont find the driver files insiede the docker.

For any driver I want to edit, my understanding is that I change it in the qrb5165-kernel-...sh folder outside the docker, then I go into the docker and build. Is that correct?

## Reply by groupo · 2024-06-26 14:56:38 UTC (in reply to Alex Kushleyev)

@Alex-Kushleyev @tom 

hey have made some good progress on the drivers - still curious about the docker question but because they are mounted, does it not matter which side of the docker (inside or outside) I change them?

anyways other question:
![99f21ee5-b703-4d4d-9760-b979d0fa63e6-image.png](https://forum.modalai.com/assets/uploads/files/1719413731444-99f21ee5-b703-4d4d-9760-b979d0fa63e6-image.png) 

I see in the repo README it discusses debug messages, and I can see debug msgs in the code for drivers like below:

![23f5d123-be3b-4283-8b05-3bab2a3b3276-image.png](https://forum.modalai.com/assets/uploads/files/1719413771981-23f5d123-be3b-4283-8b05-3bab2a3b3276-image.png) 

How can I print these out/where are they printed so I can read thru them?

## Reply by Alex Kushleyev (ModalAI staff) · 2024-06-26 15:06:14 UTC (in reply to groupo)

@groupo , it does not matter where you edit the files (inside the docker container or the host). On the host side, there will be a new folder created for the kernel source files (`workspace`), where you can find all the source files and build output. In the docker container, the same files will be in `/home/user/build_mount`, as specified here : https://gitlab.com/voxl-public/system-image-build/qrb5165-kernel-build-docker/-/blob/qrb5165-ubun1.0-14.1a/docker-run-image.sh?ref_type=heads#L9

If you build the kernel in debug mode, you can use `dmesg` command to print out all the kernel messages. Even  with non-debug kernel, there will be some essential messages from kernel there. If you are looking for a particular string, you can use grep to filter the messages:

```
dmesg -w | grep "Num Interfaces"
```

If the messages from your driver have some common string, you can use that string to filter the `dmesg` output.

Alex

## Reply by groupo · 2024-06-26 15:29:42 UTC (in reply to Alex Kushleyev)

@Alex-Kushleyev 
 
Thanks for the explanation - I am still getting the hang of Docker. 

I think logging was turned off in all the drivers I am curious about. I think I just turned it on. 

Do i need to run ./qrb-clean.sh every time before I run ./qrb-build.sh? I see you use it in the example on the documentation, but I am unclear if its necessary for what I am doing (make changes -> build -> flash -> repeat if not working)

## Reply by Alex Kushleyev (ModalAI staff) · 2024-06-26 16:31:36 UTC (in reply to groupo)

@groupo,

When in doubt, it is better to do a full clean before re-building. Especially when you are changing configuration like debug or non-debug version of the kernel.

For simple changes inside your kernel module / driver, you can test by trial and error to see if you need to re-build when you make a small code change. Once you have the debug prints working, this will be easy to test.

Alex

## Reply by groupo · 2024-06-26 16:35:07 UTC (in reply to Alex Kushleyev)

@Alex-Kushleyev 

Some further investigation, I grep'd inside the docker for one of the driver files I am trying to edit (qcserial.c) and find it in a few locations, all of which are in the build_mount.

I vim'd all files and none of them reflect the changes I made to qcserial.c located in qrb5165-kernel-v1.1.7.4.... am I changing this file in the wrong place?

Again, my process is 

* Change files in mydir/qrb5165-kernel-v1.1.7.4

* Enter mydir/qrb5165-kernel-build-docker-qrb5165-ubun1.0-14.1a

* run ./docker-run-image.sh

* (in docker) run ./qrb5165-build.sh

* once that is done, I follow the steps listed here https://docs.modalai.com/voxl2-kernel-build-guide/#flashing-guide

I assume I am not changing qcserial in the right place?

Also, one of the places Grep returns is in patches. I can see you guys have made edits to that driver too. Will the version in patches override anything else I try to do?

## Reply by Alex Kushleyev (ModalAI staff) · 2024-06-26 17:08:14 UTC (in reply to groupo)

@groupo , I will ask my colleagues to help answer this question..

Are the changes that you are making being undone after you run the build? This will tell you if the build process is patching the files again, but i would assume that the patching step (`/qrb5165-patch.sh`) applies the patches and no more patching is done.

You can look at what the patch is doing and modify the file that is the patch is patching. and then clean and rebuild.

Another way to check if your change is being compiled or not, is to modify the .c source file and add something with a syntax error (some stray characters), so that the build should fail. If the build does not fail, then your changes are not being compiled.

Alex

## Reply by groupo · 2024-06-26 18:27:51 UTC (in reply to Alex Kushleyev)

@Alex-Kushleyev No there are no changes to the files in mydir/qrb5165-kernel-v1.1.7.4

 I am not sure what my drone shipped with, but I assume 1.1.3 or 1.2 as we received them in May. I did have to reflash at one point and grabbed SDK 1.3.0. I followed the kernel build guide to the letter, which has steps for 1.1.3 and tags 1.7.4. I assume this is another issue of mine. It looks like I need tag 1.7.8 for SDK 1.3.0... can you confirm? Do all the steps defined in kernel-build-guide still hold save the tag differnece?

the c syntax error is a good idea. I will try that once I get back to a workable state

for clariity here is what my start up screen says
![c455623d-3feb-4aaa-a4f4-94ef4e756065-image.png](https://forum.modalai.com/assets/uploads/files/1719426622993-c455623d-3feb-4aaa-a4f4-94ef4e756065-image.png) 
looks like my image and voxl-suite are good, but I def followed the kernel steps for 1.7.4 so that kernel I just put on there I believe is outdated - if you think that would matter.

## Reply by groupo · 2024-06-26 21:26:19 UTC (in reply to groupo)

@Alex-Kushleyev You can ignore most of my last post - I believe I understand now that running qrb-sync just pulls all assets (qrb5165-kernel, voxl2, etc.). I pulled them myself and had them sitting outside the docker on my host machine making changes assuming somehow your build script was mounting them. I am running out of time today but I do believe that when I went through through the kernel build steps and flashed the drone it did not work properly. I want to repeat the drone flashing process again to ensure I am not missing something before I broach this though

## Reply by modaltb (ModalAI staff) · 2024-06-27 15:45:10 UTC

@groupo jumping in a bit and hopefully am in context.

We do mount from host to docker here:
   https://gitlab.com/voxl-public/system-image-build/qrb5165-kernel-build-docker/-/blob/qrb5165-ubun1.0-14.1a/docker-run-image.sh?ref_type=heads#L9

During the build, you'll get 'copies' of everything at something like:
   qrb5165-build-docker/workspace/qrb5165-ubun-1-0_amss_oem/lu.um.1.2.1/apps_proc/build-qti-distro-ubuntu-fullstack-perf/

Don't edit those...

If you edit files in say this dir directly:
   apps_proc/src/kernel/msm-qrb5165-4.19/drivers/

Then they should get picked up by the build.  Easy way to tell, throw a compiler error on purpose in a file and try to build it.

## Reply by groupo · 2024-06-27 17:00:52 UTC (in reply to modaltb)

@modaltb hey Travis, thanks for chiming in. I can confirm that throwing in a syntax error in files in that path does break the build - so now I know where those changes need to be made. I appreciate the clarity.

## Reply by groupo · 2024-06-28 21:57:13 UTC (in reply to tom)

hey not sure if this is an @tom or @modaltb inquiry, but when following the steps for the kernel build guide, stuff is off with the drone. It boots up and I can adb fine, but there are issues with the wifi, similar to another post Tom helped me with two weeks ago, but for definitely not the same hardware-related reason. The wifi adaptable does not turn on and when you run voxl-wifi the mac address is undefined. I remember stepping through those scripts while troubleshooting the hardware issues and recall that script queries to find its mac address, which must be returning something invalid. 

I have tested this with both of my drones. I can very easily flash them back with https://docs.modalai.com/sentinel-factory-reset/ and they operate as expected. While my desire is to edit part of the usb driver scripts, the kernel I am attempting to put on the drone is the unchanged version following the steps here https://docs.modalai.com/voxl2-kernel-build-guide/. The only deviation from the guide is that the guide is written for SDK 1.1.3. I have put 1.3.0 on both of my drones, and from my understanding the docker scripts pull the default branch of each repo which has the same commit tags as 1.7.8. I have included the output of dmesg for both the 1.3.0 image available from the downloads page, and the results when following the custom kernel build steps. 

https://drive.google.com/drive/folders/14L5gLbAOfF2OcSW2rHFTI4VIoREkTCFJ?usp=sharing
