Not able to communicate with the Bootloader while using Serial recovery example on Custom board

Hi,

I've integrated the nRF52840 SoC with my custom board(IMX6-ULL). I want to implement the serial recovery method for DFU mentioned in this GitHub project created by one of the Nordic Members which I got from another  DevZone post.

https://github.com/hellesvik-nordic/samples_for_nrf_connect_sdk/tree/main/bootloader_samples/serial_recovery/mcuboot_serial_recovery_uart

I'm able to implement both button-based and timing-based methods mentioned in the above link on the nRF52840DK without any problems. But while implementing the same on my board with a custom UART overlay, I'm unable to use mcumgr as it is giving an NMP timeout.

My board doesn't have a button for triggering recovery mode, so I tried the wait method and I can see that the Bootloader is waiting for 5 seconds(Specified wait time) before loading the application as expected. But this step not working

Any suggestions?

Thanks.

  • Hello,

    Have you tried disabling the Mass storage?

    Could you share  your connstring and type  in the mcumgr script ?And are you getting any error logs while doing this?

    Kind Regards,

    Abhijith

  • Hi,

    Yes, I disabled the Mass Storage Mode. This is my connection profile

    root@12050445:/real# ./mcumgr conn show
    Connection profiles: 
      acm0: type=serial, connstring='dev=/dev/ttymxc6,baud=115200,mtu=512'
    

    And this is the detailed error I'm getting while attaching the log-level flag for mcumgr

    root@12050445:/real# ./mcumgr -l debug -c acm0 image list
    DEBU[2023-03-11 13:44:33.457] Using connection profile: name=acm0 type=serial connstring=dev=/dev/ttymxc6,baud=115200,mtu=512 
    DEBU[2023-03-11 13:44:33.46] {add-nmp-listener} [serial_sesn.go:213] seq=66 
    DEBU[2023-03-11 13:44:33.463] Encoded &{NmpBase:{hdr:{Op:0 Flags:0 Len:0 Group:1 Seq:66 Id:0}}} to:
    00000000  a0                                                |.| 
    DEBU[2023-03-11 13:44:33.466] Encoded:
    00000000  00 00 00 01 00 01 42 00  a0                       |......B..| 
    DEBU[2023-03-11 13:44:33.468] Tx NMP request: 00000000  00 00 00 01 00 01 42 00  a0                       |......B..| 
    DEBU[2023-03-11 13:44:33.469] Base64 encoding request:
    00000000  00 00 00 01 00 01 42 00  a0                       |......B..| 
    DEBU[2023-03-11 13:44:33.47] Tx serial
    00000000  06 09                                             |..| 
    DEBU[2023-03-11 13:44:33.471] Tx serial
    00000000  41 41 73 41 41 41 41 42  41 41 46 43 41 4b 44 31  |AAsAAAABAAFCAKD1|
    00000010  4d 77 3d 3d                                       |Mw==| 
    DEBU[2023-03-11 13:44:33.472] Tx serial
    00000000  0a                                                |.| 
    DEBU[2023-03-11 13:44:43.478] {remove-nmp-listener} [serial_sesn.go:213] seq=66 
    DEBU[2023-03-11 13:44:43.481] goroutine 1 [running]:
    mynewt.apache.org/newt/util.NewNewtError(0x430596, 0xb, 0xb)
    	/home/rently/go/pkg/mod/mynewt.apache.org/[email protected]/util/util.go:77 +0xa4
    mynewt.apache.org/newt/util.ChildNewtError(0x4bf640, 0x200f8f8, 0x206aea0)
    	/home/rently/go/pkg/mod/mynewt.apache.org/[email protected]/util/util.go:103 +0x74
    mynewt.apache.org/newtmgr/newtmgr/cli.imageStateListCmd(0x207f040, 0x20c8520, 0x0, 0x4)
    	/home/rently/go/pkg/mod/mynewt.apache.org/[email protected]/newtmgr/cli/image.go:103 +0x168
    github.com/spf13/cobra.(*Command).execute(0x207f040, 0x20c8440, 0x4, 0x4, 0x207f040, 0x20c8440)
    	/home/rently/go/pkg/mod/github.com/spf13/[email protected]/command.go:830 +0x1f4
    github.com/spf13/cobra.(*Command).ExecuteC(0x207e640, 0x451d00, 0x2016940, 0x0)
    	/home/rently/go/pkg/mod/github.com/spf13/[email protected]/command.go:914 +0x238
    github.com/spf13/cobra.(*Command).Execute(...)
    	/home/rently/go/pkg/mod/github.com/spf13/[email protected]/command.go:864
    main.main()
    	/home/rently/mynewt-mcumgr-cli/mcumgr/mcumgr.go:94 +0xd8
    
    goroutine 7 [syscall]:
    os/signal.signal_recv(0x0)
    	/usr/local/go/src/runtime/sigqueue.go:168 +0x158
    os/signal.loop()
    	/usr/local/go/src/os/signal/signal_unix.go:23 +0x14
    created by os/signal.Notify.func1.1
    	/usr/local/go/src/os/signal/signal.go:151 +0x34
    
    goroutine 9 [chan receive]:
    main.main.func1(0x2016940)
    	/home/rently/mynewt-mcumgr-cli/mcumgr/mcumgr.go:82 +0x34
    created by main.main
    	/home/rently/mynewt-mcumgr-cli/mcumgr/mcumgr.go:80 +0xd0
    
    goroutine 10 [syscall]:
    syscall.Syscall(0x3, 0x7, 0x20fc02d, 0xfd3, 0xdc250, 0x66cd7350, 0x72)
    	/usr/local/go/src/syscall/asm_linux_arm.s:14 +0x8
    syscall.read(0x7, 0x20fc02d, 0xfd3, 0xfd3, 0x0, 0x0, 0x0)
    	/usr/local/go/src/syscall/zsyscall_linux_arm.go:686 +0x40
    syscall.Read(...)
    	/usr/local/go/src/syscall/syscall_unix.go:187
    internal/poll.ignoringEINTRIO(...)
    	/usr/local/go/src/internal/poll/fd_unix.go:581
    internal/poll.(*FD).Read(0x2016fc0, 0x20fc02d, 0xfd3, 0xfd3, 0x0, 0x0, 0x0)
    	/usr/local/go/src/internal/poll/fd_unix.go:162 +0x118
    os.(*File).read(...)
    	/usr/local/go/src/os/file_posix.go:31
    os.(*File).Read(0x200f768, 0x20fc02d, 0xfd3, 0xfd3, 0x1000, 0xa, 0xffffffff)
    	/usr/local/go/src/os/file.go:117 +0x5c
    github.com/tarm/serial.(*Port).Read(0x200f770, 0x20fc02d, 0xfd3, 0xfd3, 0x0, 0x0, 0x0)
    	/home/rently/go/pkg/mod/github.com/tarm/[email protected]/serial_linux.go:138 +0x38
    bufio.(*Scanner).Scan(0x20176c0, 0x0)
    	/usr/local/go/src/bufio/scan.go:214 +0x88
    mynewt.apache.org/newtmgr/nmxact/nmserial.(*SerialXport).Rx(0x2016f80, 0x20176c0, 0x0, 0x0, 0x0, 0x0)
    	/home/rently/go/pkg/mod/mynewt.apache.org/[email protected]/nmxact/nmserial/serial_xport.go:304 +0xec
    mynewt.apache.org/newtmgr/nmxact/nmserial.(*SerialXport).Start.func1(0x2016f80)
    	/home/rently/go/pkg/mod/mynewt.apache.org/[email protected]/nmxact/nmserial/serial_xport.go:135 +0xd4
    created by mynewt.apache.org/newtmgr/nmxact/nmserial.(*SerialXport).Start
    	/home/rently/go/pkg/mod/mynewt.apache.org/[email protected]/nmxact/nmserial/serial_xport.go:127 +0xf8
    
    goroutine 11 [select]:
    mynewt.apache.org/newtmgr/nmxact/nmserial.(*SerialSesn).Open.func1(0x206aea0)
    	/home/rently/go/pkg/mod/mynewt.apache.org/[email protected]/nmxact/nmserial/serial_sesn.go:101 +0xbc
    created by mynewt.apache.org/newtmgr/nmxact/nmserial.(*SerialSesn).Open
    	/home/rently/go/pkg/mod/mynewt.apache.org/[email protected]/nmxact/nmserial/serial_sesn.go:97 +0x1cc 
    Error: NMP timeout
    

    To add more context, when I flash the SMP_SVR example (from samples) the same mcumgr commands work (with the same port)  and I'm able to send mcumgr commands without a timeout; only with this serial recovery method, I get this timeout(loading from the bootloader).

    I added a custom board overlay to the above project. Other than that, I haven't made any changes.

    My custom overlay is,

    &uart0 {
    	current-speed = <115200>;
    	status = "okay";
    };
    
    
    
    / {
    	chosen {
    		zephyr,console = &uart0;
    		zephyr,shell-uart = &uart0;
    		zephyr,uart-mcumgr = &uart0;
    		zephyr,bt-mon-uart = &uart1;
    		zephyr,bt-c2h-uart = &uart1;
    		zephyr,ot-uart = &uart0;
    	};
    };
    
    &pinctrl {
    	uart0_default: uart0_default {
    		group1 {
    			psels = <NRF_PSEL(UART_TX, 0, 29)>,
    					<NRF_PSEL(UART_RTS, 1, 13)>;
    		};
    		group2 {
    			psels = <NRF_PSEL(UART_RX, 0, 31)>,
    					<NRF_PSEL(UART_CTS, 1, 15)>;
    			bias-pull-up;
    		};
    	};
    
    	uart0_sleep: uart0_sleep {
    		group1 {
    			psels = <NRF_PSEL(UART_TX, 0, 29)>,
    				<NRF_PSEL(UART_RTS, 1, 13)>,
    				<NRF_PSEL(UART_RX, 0, 31)>,
    				<NRF_PSEL(UART_CTS, 1, 15)>;
    			low-power-enable;
    		};
    	};
    
    	uart1_me: uart1_me {
    		group1 {
    			psels = <NRF_PSEL(UART_TX, 0, 9)>;
    		};
    		group2 {
    			psels = <NRF_PSEL(UART_RX, 0, 10)>;
    			bias-pull-up;
    		};
    	};
    
    	uart1_sleep_me: uart1_sleep_me {
    		group1 {
    			psels = <NRF_PSEL(UART_TX, 0, 9)>,
    				<NRF_PSEL(UART_RX, 0, 10)>;
    			low-power-enable;
    		};
    	};
    };
    
    &uart1 {
    	status = "okay";
    	current-speed = < 0x1c200 >;
    	pinctrl-0 = < &uart1_me >;
    	pinctrl-1 = < &uart1_sleep_me >;
    	pinctrl-names = "default", "sleep";
    };

    mcuboot.conf

    CONFIG_SIZE_OPTIMIZATIONS=y
    CONFIG_SINGLE_APPLICATION_SLOT=y
    
    # Enable MCUboot Serial Recovery
    CONFIG_MCUBOOT_SERIAL=y
    CONFIG_UART_CONSOLE=n
    
    CONFIG_MCUBOOT_INDICATION_LED=y
    
    CONFIG_BOOT_SERIAL_WAIT_FOR_DFU=y
    CONFIG_BOOT_SERIAL_WAIT_FOR_DFU_TIMEOUT=5000

    Thanks.

  • Hello,

    Sorry for the long response time I took here. I am still looking into this. I tried to build the same sample in NCS V2.2.0 and I am getting some issue and I have contacted my colleague (author of repository) about this.

    Have you included CONFIG_MCUMGR_SMP_UART=y config in your file? And which SDK version are you trying with?

    Kind Regards,

    Abhijith

  • Hi,

    I resolved the issue and it's working after putting the custom UART overlay file into the mcuboot.

    Thanks.

  • Hello,

    Glad to hear that you resolved the  issue and thank you for updating this here.

    Kind Regards,

    Abhijith

Related