LwIP pppos (ppp over serial) for modems using FreeRTOS + SAM4E16E?

I am designing a gateway and on my ATSAM4E16E, I have connected the LTE modem(SARA-R412M) using a USART port. I can communicate (and i have activated data mode) with the modem using AT commands.

Now, I would like to use PPPos (PPP over serial) library from LWIP 2.1.2 as tcpip stack with freertos. FreeRTOS has to implement as this project will be running in a threaded environment.

I have essayed to use this example:

Can you please help me how you have tested this pppos_client (used for ESP32) and adapted it to SAM MCU ?

Can you send a sample example that you have test in your sam board please ?

Best regards

Do you have a question specific to how to adapt this to FreeRTOS, or is this more of an lwIP question? If the latter I would recommend asking on the lwIP mailing list.

It’s in the Lwip and freertos question:

  • If we have lwip integrated in freertos we don’t need to adapt our code each time to the type of microcontrollers low level function (such exemple usart_write for sam and other function for other type of mcu).

  • Lwip question because i see that the most pppos example used for specific mcu. (stm32, esp32, …).

As you know i think, already tcpip stack integrated in freertos but it still used for ethernet network interface. For me i need to use lwip point to point protocol over serial in order to use my sara-r21m connected using usart to my board based on sam4e16e. for this reason lwip already lwip has pppos functions implemented , and if you have seen the code that i shared describ an example of using lwip-pppos for esp32 using freertos os tasks.

I’m working in how to use pppos with freertos (threads, tasks), i have to figure out some errors about tcpip_init() and pppos_input_tcpip().
What i’m looking for and need help in, is how to adapt the code to works as part in freertos independent of the microcontrollers and hardware used.

Please don’t hesitate if you can help me specifically and added an other function most needed in freertos.


Here is an example application note of using lwip with SAME54. Please note it does not necessarily use freertos

Thank you for sharing this example for Ethernet as low layer but in my case I have usart as low network layer, (tcpip standard, osi…).

This example is using Ethernet as low level layer (connected to tcpip stack in our case lwip) of OSI Standard, I have already tested it.

My case i have my device based on sam4e16 mcu, this microcontroller connected to my lte modem sara-r413m via USART.

In order to connect my modem to tcpip stack lwip. I need point-to-point protocol over serial that allows to encapsulation ip packets to Serial.

I have dial-up my lte modem as ppp mode, my problem is to make it working using pppos.

There’s some examples for esp32, stm32 but not for SAM MCU

Best regards

The only other application note is UART to Ethernet gateway. Please check this out

Thank you for your response, i have not used usart-ethernet adapter. In my case ( no Ethernet used) sara-412m (sim card to Internet) modem is connected using usart to main microcontroller sam4e16e.
I have implemented those steps as described in this link:

  1. Activate data mode ATD99**1#
  2. tcpip init
  3. pppos session creation
  4. pppos connection (my problem is in this step, i got failed to connect)

If some one has already an example (PPP over serial, such as wired dialup modems or mobile telecommunications LTE modems), i appreciate your help.

Best regards

1 Like

Hi All.
I have arrived to run ppp protocol over serial (SYS_NO = 0 <=> OS FreeRTOS) via my LTE modem SARA-R412M.
Now i’m looking to use websockets in C
Can anyone have suggestion about supported websockets libraries most used with FreeRTOS ?


I would be great if you could zip up the project that is using websockets and attach it to your post in the forum - that way somebody wanting to do the same thing in the future would be able to use it as a reference.

Thank you for your proposition.
In my last comment i told that LTE modem connected using PPPoS.
I have attached picture of (trace) tcp/ip stack is running in FreerRTOS.
**I have not yet tested websockets, i’m working on it now. **

I still have to figure out the default value of remote IP address:
Why i receive the same remote IP address: defaulting to ?

After reading some documentation asking question specialist and searching i found that this is the expected behavior with cellular modems, most of them are not negotiating an IP interface for their side, IPCP RFC is permissive and does not disallow doing so from what I remember. As you can see in the
trace it is only a notification that we are using a dummy address because the peer did not provide one, it can then be safely ignored.

The thing is, PPP are non-broadcast interface type, there is only one single peer, as such we do not need to discover the data link address of the next hop IP router, therefore we don’t need the other side IP address to forward IP packets to the peer.

If you look at how PPP netif interface input and output are wired in lwIP (ppp_input() in low level PPP drivers and output callbacks in ppp_netif_init_cb()), you will see that we don’t need any data link resolution protocol, the network layer is wired straight to the PPP interface.

On the modem side, the PPP session is coupled to the cellular PDP session at the data link layer, it is either piggy backed on a previously existing PDP session or to a new one when PPP starts. PDP is non-broadcast as well so it does not need a data link discovery protocol
on the bridge.

Then the log that we see in the trace is the expected behavior.

Someone has an idea how to added web-sockets layer to lwip ppp (SAM4E device -> TCP/IP stack (lwip) -> PPP(lwip) -> serial (lwip))-> websockets)



I have arrived to run PPPoS (SYS_NO = 0 <=> OS FreeRTOS) via my LTE modem SARA-R412M using ATMEL SAM4E16E board.

LwIP “TCP/IP Stack” has been integrated based on PPPoS protocol as Link layer for our modem.

I have added mbedtls, lwip-2.2.0, freertos-10.3.0 used in my project to (ASF) /opt/xdk-asf-3.48.0/ in order to use by lws.

Then it works fine.
I have arrived to generate libwebsockets.a for atmel sam4e.

[100%] Linking C static library libwebsockets.a
[100%] Built target websockets
said@said build %

I have just generated Atmel sam4e’s libwebsockets.a from libwebsockets project.
I have arrived to test my libwebsockets.a lib. I have some issues testing it as ws-client.
You can see this link for more about adding (mbedtls to lws and add lws to asf ): https://github.com/warmcat/libwebsockets/issues/2025

I have tried to use ws-client when i compile it i got an mbedTLS error:
./lws/include/libwebsockets.h:262:29: fatal error: mbedtls/lws_config.h: No such file or directory
262 | #define MBEDTLS_CONFIG_FILE <mbedtls/lws_config.h>

I need help to compile just a simple ws-client for atmel (sam4e), do you have an idea about the reason for this error ?

All the best

Is this a FreeRTOS question? Looks like you are having difficulty building third party libraries provided by Atmel and it is unlikely anybody here will have experience with your setup. Did you check the header file in on the disk and in the compiler include path?

We are able too, connecting lwip over pppos.

Like Said suggested.