SMS and GPRS: Multiplexing GSM module on BeagleBone Black using n_gsm
<p>I'm using simcom 800H cellular module with my BeagleBone Black which is very similar to the popular simcom 900. I want to do two main things with the simcom module </p>

<ul>
<li>Use AT commands to configure settings and send and receive messages </li>
<li>Use ppp to enable internet access on the BBB through GPRS. </li>
</ul>

<p>Now the obvious problem is that I cannot do both at the same time. I did a web search and found the following posts </p>

<ol>
<li><a href="https://stackoverflow.com/questions/19830279/using-gprs-and-gsm-simulatneously">Using GPRS and GSM Simulatneously</a></li>
<li><a href="https://stackoverflow.com/questions/28939656/sending-at-commands-to-sim900-whilst-pppd-is-active?lq=1">Sending AT commands to SIM900 whilst pppd is active</a></li>
</ol>

<p>The 2nd link has been particularly useful where one of the user has used the code on this <a href="https://github.com/Rtone/cmux" rel="nofollow noreferrer">repository</a>. </p>

<p>The common theme has been to use the <code>n_gsm</code> module. I tried to load the module using <code>modprobe n_gsm</code> and it failed. Like the user mentioned the BBB also doesn't include the n_gsm module as default so I had to go and build a new kernel with n_gsm added as a module. However I'm having issues with including the <code>n_gsm</code> as a module. Here are the steps I followed</p>

<ol>
<li>I followed <a href="http://derekmolloy.ie/writing-a-linux-kernel-module-part-1-introduction/" rel="nofollow noreferrer">this</a> tutorial and downloaded the right linux headers for my BBB. </li>
<li><p>I tried to compile the module as a Linux LKM (Loadable kernel module) as follows</p></li>
<li><p>I downloaded the n_gsm.c from <a href="https://github.com/torvalds/linux/blob/master/drivers/tty/n_gsm.c" rel="nofollow noreferrer">here</a></p></li>
<li>The <code>n_gsm.c</code> file had some includes which were missing in my BBB. So I downloaded them. </li>
<li>I created a makefile. My directory had <code>n_gsm.c</code> and <code>Makefile</code></li>
</ol>

<p>Makefile</p>

<pre><code>obj-m += n_gsm.o

all:
    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

clean:
    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
</code></pre>

<p>This generated errors as shown in figure <a href="https://i.stack.imgur.com/7wOdm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7wOdm.png" alt="n_gsm errors"></a></p>

<ul>
<li><p>I was able to successfully load a <strong>different module</strong> as shown in <a href="http://derekmolloy.ie/writing-a-linux-kernel-module-part-1-introduction/" rel="nofollow noreferrer">this</a> (the hello world of kernel modules). I also dont understand why I need to recompile the entire linux kernel to create a LKM.</p></li>
<li><p>I feel I'm making some obvious errors as it looks we people were able
to load this module successfully.</p></li>
<li><p>Is this the right way to load a module and specifically <code>n_gsm</code>. <strong>There isn't much document/tutorial on this</strong>.</p></li>
<li><p>Is there a simpler way to do this multiplexing in case all thisdoes not workout? I really like the idea of AT commands for SMS and PPP for GPRS (instead of AT commands for both). </p></li>
</ul>

<p>Any tips and suggestions will be really helpful! </p>

<p><strong>Edit1</strong> : Details about my BBB</p>

<ol>
<li>kernel - Linux beaglebone 3.8.13-bone79 </li>
<li>Distro - Debian 7.9 (wheezy)</li>
</ol>

<p><strong>Edit 2</strong> : Added details about GSM module</p>

<ol>
<li><a href="https://www.adafruit.com/product/1946" rel="nofollow noreferrer">This</a> is the GSM breakout board I'm using.</li>
<li>It uses <a href="http://www.simcom.eu/index.php?m=termekek&amp;prime=1&amp;sub=40&amp;id=0000000246" rel="nofollow noreferrer">this</a> module and you can checkout the <a href="https://cdn-shop.adafruit.com/product-files/1946/SIM800+Series_AT+Command+Manual_V1.09.pdf" rel="nofollow noreferrer">command manual</a> and <a href="https://cdn-shop.adafruit.com/product-files/1946/SIM800+Series_Multiplexer_Application+Note_V1.01.pdf" rel="nofollow noreferrer">multiplexing application note</a>. </li>
</ol>

<p><strong><em>Update 1</em></strong></p>

<ol>
<li>Thanks to @Serge, I was able to build the <code>n_gsm</code> module and add it without re-compiling the kernel. However, I still haven't been able to get the GSM module into mux mode.</li>
<li><code>AT+CMUX=?</code>, <code>AT+CMUX?</code> and <code>AT+CMUX=</code> geneated an error on the sim800H module. </li>
<li>Here's the de-bugging I have done

<ol>
<li>Played around with hardware/software and no flow. Didnt work in any mode.</li>
<li>Set TE-TA fixed local rate <code>AT+IPR</code> to auto, 115200 and still <code>AT+CMUX</code> generates an error</li>
<li>Tested <code>AT+CMUX?</code> on another sim900 module and that works. </li>
</ol></li>
</ol>

<p>Any idea why it does not work with sim800H?</p>