This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

GSM Modem Sample Project on nRF 5340 App

Hi. I am trying to get the gsm modem sample project to work with an nRF 5340 app and a Nimbelink LTE modem, NL-SW-LTE-TC4NAG. The only change I made to the project was to add a new file in the boards directory for the 5340. The nrf5340dk_nrf5340_cpuapp.overlay file is below.

The problem is that `uart_dev` is null. The console output I get is below.

I'm not sure if this is a configuration issue or if the modem is not up when `device_get_binding()` is called. What am I missing?

sample_gsm_ppp: Board 'nrf5340dk_nrf5340_cpuapp' APN 'internet' UART 'UART_1' device (nil) (modem_gsm)

&uart0 {
    compatible = "zephyr,gsm-ppp"; // also tried: gsm_ppp,MODEM_GSM_PPP,modem_gsm
    label = "UART_1";
	status = "okay";
	current-speed = <115200>;

	gsm: gsm-modem {
		compatible = "zephyr,gsm-ppp";
		label = "gsm_ppp";
	};
};

Parents
  • code-magic said:
    Thank you so much for the details and links. I will try and test this soon. 

    My pleasure! :-)

    code-magic said:
    Can the modem be run asynchronously? If not, what is the best practice to run the modem on the app core without blocking other processes?

    I’m not familiar with the Nimbelink LTE modem, so not sure if I can provide you with an answer here. But looking at the Software Guideline, I get the impression that everything will be controlled by AT commands via UART. So my first thought would be to use interrupt driven UART, as this will not block the application on the nRF53 and serve incoming data right away.

    Regards,

    Markus

Reply
  • code-magic said:
    Thank you so much for the details and links. I will try and test this soon. 

    My pleasure! :-)

    code-magic said:
    Can the modem be run asynchronously? If not, what is the best practice to run the modem on the app core without blocking other processes?

    I’m not familiar with the Nimbelink LTE modem, so not sure if I can provide you with an answer here. But looking at the Software Guideline, I get the impression that everything will be controlled by AT commands via UART. So my first thought would be to use interrupt driven UART, as this will not block the application on the nRF53 and serve incoming data right away.

    Regards,

    Markus

Children
  • I'm still confused. Both with (1) is UART_0 or UART_1 being used and (2) I cannot get this working with either UART_0 or UART_1.

    The overlay was set for UART_0 (&uart0), but the code sets it to UART_1. When I try setting UART_0 in prj.conf there is a fatal error and nothing is output to the console. So I set the modem to UART_0 in main.c.

    UART_1: device_get_binding() returns null

     //prj.conf
     CONFIG_MODEM_GSM_UART_NAME="UART_1"
     
     //get_device_binding()
     const struct device *uart_dev =
    				device_get_binding(CONFIG_MODEM_GSM_UART_NAME);
     
     //output
     <inf> sample_gsm_ppp: Board 'nrf5340dk_nrf5340_cpuapp' APN 'internet' UART 'UART_1' device (nil) (modem_gsm)

    UART_0: device_get_binding() returns a device

    Using your overlay and getting the device binding for "UART_0" here is my output. Also, this shows that there are no modems found.

    //device_get_binding()
    const struct device *uart_dev =
    			device_get_binding("UART_0");
    
    //output
    <inf> sample_gsm_ppp: Board 'nrf5340dk_nrf5340_cpuapp' APN 'internet' UART 'UART_1' device 0x200001f0 (modem_gsm)
    uart:~$ modem list
    Modem receivers:
    None found.
    uart:~$ sample resume
    Please wait for network connection.

    I was optimistic that even though the uart command `modem list` did not return this modem that maybe it is registered in the system. So I moved code from the http_get sample project to this modem project to make an HTTP request, but it failed to get a network connection.

    I'm not sure where to go from here. Is there an option for phone support or is it strictly forum support available?

    Thanks

    Edit:

    To add on to this reply, I uncommented a few items in the prj.conf file. The most notable output to me is `modem_gsm.gsm_init: iface uart error -19`.

    Please note the modem is connected via a multiplexor that must be switched on to select the modem; which is why there's log output for 'mux_cell_wifi: Select Cell GSM Modem'. This is being switched (selected) before any calls to get_device_binding().

    Maybe specific calls must be made after the switch to the modem to properly configure the device and make it available?

    Uncommented in prj.conf:

    CONFIG_LOG_BUFFER_SIZE=16384
    CONFIG_LOG_STRDUP_BUF_COUNT=200
    CONFIG_MODEM_LOG_LEVEL_DBG=y
    CONFIG_NET_PPP_LOG_LEVEL_DBG=y
    CONFIG_NET_L2_PPP_LOG_LEVEL_DBG=y
    CONFIG_NET_MGMT_EVENT_LOG_LEVEL_DBG=y
    CONFIG_NET_CONNECTION_MANAGER_LOG_LEVEL_DBG=y

    New Output:

    uart:~$ *** Booting Zephyr OS build v2.6.0-rc1-ncs1  ***
    
    
    [00:00:00.398,803] <dbg> net_ppp.ppp_driver_init: [0x20001d48] dev 0x200001d0
    [00:00:00.398,895] <dbg> modem_gsm.gsm_init: Generic GSM modem (0x200006f0)
    [00:00:00.398,925] <dbg> modem_gsm.gsm_init: iface uart error -19
    [00:00:00.398,986] <dbg> net_mgmt.net_mgmt_event_init: (main): Net MGMT initialized: queue of 2 entries, st          ack size of 768
    [00:00:00.398,986] <dbg> net_ppp.ppp_iface_init: [0x20001d48] iface 0x20000500
    [00:00:00.399,017] <dbg> net_l2_ppp.net_ppp_init: (main): Initializing PPP L2 0x20001b18 for iface 0x200005          00
    [00:00:00.399,078] <dbg> net_l2_ppp.ppp_startup: (sysworkq): PPP 0x20001b18 startup for interface 0x2000050          0
    [00:00:00.399,078] <dbg> net_l2_ppp.ipcp_init: (sysworkq): proto IPCP (0x8021) fsm 0x20001c30
    [00:00:00.399,108] <dbg> net_l2_ppp.lcp_init: (sysworkq): proto LCP (0xc021) fsm 0x20001b60
    [00:00:00.403,717] <dbg> net_mgmt.net_mgmt_add_event_callback: (conn_mgr): Adding event callback 0x20003298
    [00:00:00.403,717] <dbg> net_mgmt.net_mgmt_add_event_callback: (conn_mgr): Adding event callback 0x200032ac
    [00:00:00.403,747] <dbg> conn_mgr.conn_mgr_handler: (conn_mgr): Connection Manager started
    [00:00:00.403,747] <dbg> net_l2_ppp.tx_handler: (tx_handler_thread): PPP TX started
    [00:00:00.403,778] <inf> mux_cell_wifi: Configured: PIN_MUX_CELL_WIFI_ENABLE
    [00:00:00.403,778] <inf> mux_cell_wifi: Configured: PIN_MUX_CELL_WIFI_SWITCH
    [00:00:00.403,778] <inf> mux_cell_wifi: Select Cell GSM Modem
    [00:00:00.403,808] <inf> gsm_modem: Configured: PIN_GSM_MODEM_STATUS
    [00:00:00.403,808] <inf> gsm_modem: Configured: PIN_GSM_MODEM_DTR
    [00:00:00.403,808] <inf> gsm_modem: Configured: PIN_GSM_MODEM_ON_OFF
    [00:00:00.403,808] <inf> gsm_modem: Configured: PIN_GSM_MODEM_RESET
    [00:00:00.403,808] <inf> gsm_modem: Turning gsm modem on via 1500ms sleep time.
    [00:00:00.403,808] <inf> gsm_modem: Successfully set gsm_modem On/Off pin 1 = 1. The modem will take approx          imately 20 seconds to turn on and be ready for AT commands.
    [00:00:01.903,900] <inf> sample_gsm_ppp: Board 'nrf5340dk_nrf5340_cpuapp' APN 'internet' UART 'UART_1' devi          ce 0x20000188 (modem_gsm)
    [00:00:01.903,930] <dbg> net_mgmt.net_mgmt_add_event_callback: (main): Adding event callback 0x20002510
    uart:~$ modem list
    Modem receivers:
    None found.
    

  • My apologies for the long previous post and another post. The deeper I get the more I learn something. I found a command to list all devices. The output is below. Notice that `modem_gsm` is disabled.

    I have a feeling this might be my issue. How do I enable modem_gsm?

    `device list`

    uart:~$ device list
    devices:
    - CLOCK (READY)
    - UART_0 (READY)
    - CRYPTOCELL (READY)
    - sys_clock (READY)
    - ppp (READY)
    - GPIO_0 (READY)
    - GPIO_1 (READY)
    - modem_gsm (DISABLED)

    `device levels` (just in case it's useful)

    uart:~$ device levels
    PRE KERNEL 1:
    - CLOCK
    - UART_0
    - CRYPTOCELL
    PRE KERNEL 2:
    - sys_clock
    POST_KERNEL:
    - ppp
    - GPIO_0
    - GPIO_1
    APPLICATION:
    - None

  • I finally got my head wrapped around the different UART interfaces: UART_0: terminal output, UART_1: modem. I setup the pins on UART_1; shown below.

    It doesn't look like the driver knows what to use for the modem. The ppp driver, modem_gsm, and my code all show different pointers for the device.

    .

    Maybe all that I'm lacking is telling the ppp driver what device to use? I thought that was covered with 'compatible="zephyr,gsm-ppp"` in the overlay file.

    &uart0 {
        status = "okay";
    };
    
    &uart1 {
    	status = "okay";
        tx-pin = 3;
    	rx-pin = 8;
    	rts-pin = 2;
    	cts-pin = 7;
    	current-speed = 115200;
    	gsm: gsm-modem {
    		status = "okay";
    		compatible = "zephyr,gsm-ppp";
    		label = "modem_gsm";
    	};
    };

    .

    .

    .

    Below is the output log from the application.

    [00:00:00.400,268] <dbg> net_ppp.ppp_driver_init: [0x20001d88] dev 0x20000214
    [00:00:00.400,360] <dbg> modem_gsm.gsm_init: Generic GSM modem (0x20000730)
    [00:00:00.400,390] <dbg> modem_gsm.gsm_init: iface->read 0x1594f iface->write 0x15985
    [00:00:00.400,421] <dbg> modem_gsm.gsm_rx: starting
    [00:00:00.400,482] <dbg> modem_gsm.gsm_configure: Starting modem 0x20000730 configuration
    [00:00:00.400,695] <dbg> net_mgmt.net_mgmt_event_init: (main): Net MGMT initialized: queue of 2 entries, stack size of 768
    [00:00:00.400,695] <dbg> net_ppp.ppp_iface_init: [0x20001d88] iface 0x20000544
    [00:00:00.400,726] <dbg> net_l2_ppp.net_ppp_init: (main): Initializing PPP L2 0x20001b58 for iface 0x20000544
    [00:00:00.405,303] <dbg> net_mgmt.net_mgmt_add_event_callback: (conn_mgr): Adding event callback 0x200032d8
    [00:00:00.405,303] <dbg> net_mgmt.net_mgmt_add_event_callback: (conn_mgr): Adding event callback 0x200032ec
    [00:00:00.405,334] <dbg> conn_mgr.conn_mgr_handler: (conn_mgr): Connection Manager started
    [00:00:00.405,364] <dbg> net_l2_ppp.tx_handler: (tx_handler_thread): PPP TX started
    
    // everthing above is before main()
    
    [00:00:00.405,364] <inf> mux_cell_wifi: Configured: PIN_MUX_CELL_WIFI_ENABLE
    [00:00:00.405,364] <inf> mux_cell_wifi: Configured: PIN_MUX_CELL_WIFI_SWITCH
    [00:00:00.405,395] <inf> mux_cell_wifi: Select Cell GSM Modem
    [00:00:00.405,395] <inf> gsm_modem: Configured: PIN_GSM_MODEM_STATUS
    [00:00:00.405,395] <inf> gsm_modem: Configured: PIN_GSM_MODEM_DTR
    [00:00:00.405,395] <inf> gsm_modem: Configured: PIN_GSM_MODEM_ON_OFF
    [00:00:00.405,395] <inf> gsm_modem: Configured: PIN_GSM_MODEM_RESET
    [00:00:00.405,395] <inf> gsm_modem: Turning gsm modem on via 1500ms sleep time.
    [00:00:00.405,426] <inf> gsm_modem: Successfully set gsm_modem On/Off pin 1 = 1. The modem will take approximately 20 seconds to turn on and be ready for AT commands.
    [00:00:01.905,487] <inf> sample_gsm_ppp: Board 'nrf5340dk_nrf5340_cpuapp' APN 'ATT' UART 'UART_1' device 0x200001b4 (modem_gsm)
    [00:00:01.905,487] <dbg> sample_gsm_ppp.init_gsm_modem: GSM Device: 0x2000025c
    [00:00:01.905,517] <dbg> net_mgmt.net_mgmt_add_event_callback: (main): Adding event callback 0x20002550
    [00:00:02.400,726] <dbg> modem_gsm.gsm_configure: modem not ready -116
    [00:00:02.400,756] <dbg> net_l2_ppp.ppp_startup: (sysworkq): PPP 0x20001b58 startup for interface 0x20000544
    [00:00:02.400,756] <dbg> net_l2_ppp.ipcp_init: (sysworkq): proto IPCP (0x8021) fsm 0x20001c70
    [00:00:02.400,787] <dbg> net_l2_ppp.lcp_init: (sysworkq): proto LCP (0xc021) fsm 0x20001ba0
    [00:00:02.400,787] <dbg> modem_gsm.gsm_configure: Starting modem 0x20000730 configuration
    [00:00:04.401,062] <dbg> modem_gsm.gsm_configure: modem not ready -116
    . . . . . . 
    [00:00:04.401,092] <dbg> modem_gsm.gsm_configure: Starting modem 0x20000730 configuration
    [00:00:06.401,336] <dbg> modem_gsm.gsm_configure: modem not ready -116
    . . . . . .

Related