cancel
Showing results for 
Search instead for 
Did you mean: 

Need help with porting to other cellular modem in X-CUBE-CELLULAR

SL61
Associate II

Hi everyone,

I am working on adapting cellular connection example of X-CUBE-Azure to my custom board and SIM5360 is the cellular modem. I know X-CUBE-CELLULAR is used in X-CUBE-Azure. After digging in a little, I found porting to my modem is a little confusing.

In X-CUBE-CELLULAR cellular connectivity Expansion Package for STM32Cube - User manual (UM2426), it says Refer to the X-CUBE-CELLULAR cellular connectivity Expansion Package porting on other hardware application note (AN5249) for adaptation to other hardware such as the “Discovery IoT node cellular�? set. However, I can't find AN5249 as my porting reference so is there any porting guideline available? Basically I just need to change the modem. Thanks in advance~

SL61

1 ACCEPTED SOLUTION

Accepted Solutions
MJAC.1
ST Employee

Hi,

First, you have to consider 2 usecases:

- the IP stack is runnning in the modem (what we call "socket mode" in X-Cube-Cellular)

- the IP stack is running STM32-side with LwIP (what we call "LwIP mode" in X-Cube-Cellular)

If you are using "LwIP mode", adding a new modem should be easy because you can use standard AT commands.

If you want to use the "socket mode", it is more complicated. First, the modem has to support this mode.

Then each modem has its own proprietary implementation for "socket mode", with specific AT commands. 

As there may be huge differences between 2 modems, it's difficult to evaluate the amount of work in this case.

So, I recommend to use "LwIP mode", at least on first approach.

The disavantage of the LwIP solution is that it is more memory consuming in STM32 side.

Note: to use "LwIP mode", set USE_SOCKETS_TYPE to USE_SOCKETS_LWIP in the file plf_features.h

The easiest way is to use one existing modem implementation and 'hack' it.

I suggest to use 'MONARCH' as a starting point because its implementation is using more standard commands than Quectel's one 

(BG96 and UG96 are using optimized commands for some features).

All modifications you have to do are located in \Drivers\BSP\X_STMOD_PLUS_MODEMS\your_modem directory

So, in case of "LwIP mode", here are the main things to add a new modem:

STEP 1/ adapt the "hardware" interface with the modem 

This is done in the file sysctrl_specific.c 

You need to customize the funtions for Power ON, Power Off, Reset (Hardware reset) and sim selection.

There are certainly some timings to respect with GPIO during power ON and power Off sequences.

(note: some modems are using AT commands only for reset and sim selection).

STEP 2/ adapt the AT commands to use

This is done in the file at_custom_modem_specific.c 

At the beginning of this file, there is a commands Look-up table.

If you are using LwIP, it should work using only "GENERIC SPECIFIC COMMANDS" (from 3GPP TS 27.007 and GSM 07.07 and V25ter) which are implemented in at_modem_signalling.c (this file regroup functions to encode/decode standard AT commands).

In the function ATCustom_***_getCmd(), you may have to adapt following cases:

  • SID_CS_POWER_ON
  • SID_CS_RESET
  • SID_CS_POWER_OFF
  • SID_CS_INIT_MODEM

Indeed, these steps can use modem specific AT commands or custom AT commands sequence. 

You can also have to manage a modem 'start event' which is modem specific (+SYSSTART for the MONARCH), it''s not mandatory.

If you are using "MONARCH" as starting point, I think that in the Look-up table, you just have to replace fCmdBuild_ATD_MONARCH by fCmdBuild_ATD.

All other commands are already using standard commands if I'm not wrong...

and it should be almost all what you have to do !

NB: 

The file at_custom_modem_signalling.c contains only modem specific command (new features or override standard commands).

The file at_custom_modem_socket.c contains only modem specific for the socket mode.

You should not have to modify/use them for LwIP.

If you are using another STM32 board or if your modem is not using same GPIOs as the original project, you will have also to update the file plf_hw_config.h where are defined the UART settings and all the GPIOs used between the STM32 and the modem.

View solution in original post

7 REPLIES 7
Ronan GABOU
ST Employee

The AN5249 is not available but it won't help you because it explains how to port on another STM32 MCU / Nucleo-Disco boards. It does not explain how to change the modem.

I am going to contact someone and will provide you information to help you as soon as possible.

Hi Ronan,

Thanks for your reply.

SL61​

MJAC.1
ST Employee

Hi,

First, you have to consider 2 usecases:

- the IP stack is runnning in the modem (what we call "socket mode" in X-Cube-Cellular)

- the IP stack is running STM32-side with LwIP (what we call "LwIP mode" in X-Cube-Cellular)

If you are using "LwIP mode", adding a new modem should be easy because you can use standard AT commands.

If you want to use the "socket mode", it is more complicated. First, the modem has to support this mode.

Then each modem has its own proprietary implementation for "socket mode", with specific AT commands. 

As there may be huge differences between 2 modems, it's difficult to evaluate the amount of work in this case.

So, I recommend to use "LwIP mode", at least on first approach.

The disavantage of the LwIP solution is that it is more memory consuming in STM32 side.

Note: to use "LwIP mode", set USE_SOCKETS_TYPE to USE_SOCKETS_LWIP in the file plf_features.h

The easiest way is to use one existing modem implementation and 'hack' it.

I suggest to use 'MONARCH' as a starting point because its implementation is using more standard commands than Quectel's one 

(BG96 and UG96 are using optimized commands for some features).

All modifications you have to do are located in \Drivers\BSP\X_STMOD_PLUS_MODEMS\your_modem directory

So, in case of "LwIP mode", here are the main things to add a new modem:

STEP 1/ adapt the "hardware" interface with the modem 

This is done in the file sysctrl_specific.c 

You need to customize the funtions for Power ON, Power Off, Reset (Hardware reset) and sim selection.

There are certainly some timings to respect with GPIO during power ON and power Off sequences.

(note: some modems are using AT commands only for reset and sim selection).

STEP 2/ adapt the AT commands to use

This is done in the file at_custom_modem_specific.c 

At the beginning of this file, there is a commands Look-up table.

If you are using LwIP, it should work using only "GENERIC SPECIFIC COMMANDS" (from 3GPP TS 27.007 and GSM 07.07 and V25ter) which are implemented in at_modem_signalling.c (this file regroup functions to encode/decode standard AT commands).

In the function ATCustom_***_getCmd(), you may have to adapt following cases:

  • SID_CS_POWER_ON
  • SID_CS_RESET
  • SID_CS_POWER_OFF
  • SID_CS_INIT_MODEM

Indeed, these steps can use modem specific AT commands or custom AT commands sequence. 

You can also have to manage a modem 'start event' which is modem specific (+SYSSTART for the MONARCH), it''s not mandatory.

If you are using "MONARCH" as starting point, I think that in the Look-up table, you just have to replace fCmdBuild_ATD_MONARCH by fCmdBuild_ATD.

All other commands are already using standard commands if I'm not wrong...

and it should be almost all what you have to do !

NB: 

The file at_custom_modem_signalling.c contains only modem specific command (new features or override standard commands).

The file at_custom_modem_socket.c contains only modem specific for the socket mode.

You should not have to modify/use them for LwIP.

If you are using another STM32 board or if your modem is not using same GPIOs as the original project, you will have also to update the file plf_hw_config.h where are defined the UART settings and all the GPIOs used between the STM32 and the modem.

Hi MJAC.1,

Thanks for your detailed reply. I agree with that the first approach to go with "LwIP mode" and I will try that first. But I still want to know more about adopting "socket mode" due to memory constrains. Some of devices here are running without IP so I suppose these devices are using "socket mode". AT commands are modem-related I think, like configuring IP and sending/receiving socket. Could you give more info about it?

SL61

MJAC.1
ST Employee

Hi,

As I said, implementing socket mode is much more complicated.

If this mode is supported by the modem you are using, you will have to implement the specific AT commands (encoding and decoding).

Refer to the modem documentation on this point.

In Cellular Service, the functions used by the socket mode are all beginning with CDS_socket_...

Nothing to modify in this file but each of this function correspond to a "case" in at_custom_modem_specific.c (for exple SID_CS_SEND_DATA, ...)

You will have to update all these cases (for MONARCH, see the function ATCustom_MONARCH_getCmd()).

Socket mode can be tricky to implement. There may be big differences from one modem to another. 

The dynamic can be different and some cases hard to test (crossing cases when socket are closed by one side due to errors).

You may have to adapt the code to fill your needs. 

You can have a look on exising implementations (Quectel BG96/UG96 and Sequans Monarch) and use them as reference.

The easiest way is to use LwIP mode on a third-party modem. If you really want to use socket mode, the easiest way is to use an officially supported modem.

If you want to use a third-party modem with socket mode, do not under-estimate the difficulty and amount of work for socket mode implementation.

It requires a good software knowledge.

Hi MJAC.1,

Thanks for your suggestion.

SL61

NW27
Associate III

Hi MJAC.1 or Others,

I have a project using a STM32F767VGTx, where I'm connecting to the internet (Azure IoT Hub) via a Quectel BG96 (UART5).

In the CubeMX configuration tool, how do I enable the LWIP when I do not have a physical Ethernet connection?

The LWIP is grayed out.

How do I add all of the required folders, files etc to the project?

Thanks.