Migrating MQTT Sample to a Custom Board

Hi,

I have successfully built and ran the MQTT sample (/opt/nordic/ncs/v2.7.0/nrf/samples/net/mqtt) on the nRF9160-DK. I did have a few problems with SIM coverage and firmware versions which was sorted in this ticket.

 MQTT Sample Not Connecting on nRF9160 Board 

I would now like to move this code onto my own board.

When I run this code on my own board, I see this error.

*** Booting nRF Connect SDK v2.7.0-5cb85570ca43 ***
*** Using Zephyr OS v3.6.99-100befc70c74 ***
[00:00:00.431,610] <inf> network: Bringing network interface up and connecting to the network
[00:00:00.658,813] <inf> nrf_modem_lib_trace: Trace thread ready
[00:00:00.666,107] <inf> nrf_modem_lib_trace: Trace level override: 2
[00:00:00.667,724] <err> lte_lc: Could not send AT command, error: 65536
[00:00:00.667,755] <err> lte_lc: Failed to set system mode and mode preference, err -14
+CEREG: 2
+CEREG: 4
+CEREG: 2,"B984","00542616",9
+CSCON: 1
+CEREG: 2,"B984","00542616",9,0,11
+CSCON: 0
 

My overlay file is shown below.

&pinctrl {
        uart0_default: uart0_default {
                group1 {
                        psels = <NRF_PSEL(UART_TX, 0, 6)>, <NRF_PSEL(UART_RX, 0, 7)>;
                };
        };

        uart0_sleep: uart0_sleep {
                group1 {
                        psels = <NRF_PSEL(UART_TX, 0, 6)>, <NRF_PSEL(UART_RX, 0, 7)>;
                        low-power-enable;
                };
        };
};

&uart0 {
        status = "okay";
        current-speed = < 115200 >;
        /delete-property/ rts-pin;
        /delete-property/ cts-pin;
};

/* Enable uart1 for tracing. */

&uart1 {
   status = "okay";
   current-speed = <1000000>;
   pinctrl-0 = <&uart1_default>;
   pinctrl-1 = <&uart1_sleep>;
   pinctrl-names = "default", "sleep";
};

/ {
   chosen {
      nordic,modem-trace-uart = &uart1;
   };
};

I use UART0 for my serial terminal.

Would appreciate your pointers on this,

Thanks,

Rod 

  • Hi Rod,

    You might not have taken traces correctly or somehow trace file got corrupted. Can you try to do it again? Please have a look at instructions on how to capture modem trace in our Cellular IoT Fundamentals course. It should be possible to upload file in mtrace format.

    Best regards,
    Dejan

  • Hi Dejan,

    I started by trying this process using the nRF9169DK board

    I produced this trace file

    trace-2024-10-17T12-47-05.939Z.mtrace

    which opened automatically in Waveshark.

    I noticed that I was unable to subsequently open the same file in Waveshark but had to open the file that had been saved in Waveshark.

    nrf9160_WS.pcapng

    Anyway, this seems to work OK.

    I then tried this on my own board using the same process and this is where i see problems.

    Although I seem to be generating a .mtrace file, Waveshark reports no data.

    Im guessing I have something wrong with my UART set up?

    This is my overlay file 

    / {
       chosen {
          nordic,modem-trace-uart = &uart1;
       };
    };
    
    &uart0 {
    	status = "okay";
    	current-speed = < 115200 >;
    	pinctrl-0 = <&uart0_default>;
       	pinctrl-1 = <&uart0_sleep>;
       	pinctrl-names = "default", "sleep";
    	/delete-property/ rts-pin;
    	/delete-property/ cts-pin;
    };
    
    /* Enable uart1 for tracing. */
    
    
    &uart1 {
       	status = "okay";
       	current-speed = <1000000>;
       	pinctrl-0 = <&uart1_default_alt>;
       	pinctrl-1 = <&uart1_sleep_alt>;
       	pinctrl-names = "default", "sleep";
    	/delete-property/ rts-pin;
    	/delete-property/ cts-pin;
    };
    
    
    &pinctrl {
    	uart0_default: uart0_default {
    		group1 {
    			psels = <NRF_PSEL(UART_TX, 0, 6)>, <NRF_PSEL(UART_RX, 0, 7)>;
    		};
    	};
    
    	uart0_sleep: uart0_sleep {
    		group1 {
    			psels = <NRF_PSEL(UART_TX, 0, 6)>, <NRF_PSEL(UART_RX, 0, 7)>;
    			low-power-enable;
    		};
    	};
    };
    
    &pinctrl {
    	uart1_default_alt: uart1_default_alt {
    		group1 {
    			psels = <NRF_PSEL(UART_RX, 0, 14)>;
    			bias-pull-up;
    		};
    		group2 {
    			psels = <NRF_PSEL(UART_TX, 0, 13)>;
    		};
    	};
    
    	uart1_sleep_alt: uart1_sleep_alt {
    		group1 {
    			psels = <NRF_PSEL(UART_TX, 0, 14)>,
    				<NRF_PSEL(UART_RX, 0, 13)>;
    			low-power-enable;
    		};
    	};
    };
    
    


    Regards,

    Rod

  • Hi Rod,

    You could try to redirect your traces to UART0 and see if this has any effect. If you choose to do so, you need to replace instances of uart1 (as it is shown in the sending traces over UART section) with uart0. Then your terminal connection could go to uart1. If UART tracing is for some reason not possible or you have only one UART available on your custom board, you can try to do tracing with RTT

    Best regards,
    Dejan

Related