This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SMP over UDP not working after update to v1.6.0 in NCS

Hello,

Im using SMP over UDP (OpenThread) and after updating to v1.6.0 in NCS, sending most commands with `mcumgr-cli` makes the device restart with:

E: ***** MPU FAULT *****
E:   Stacking error (context area might be not valid)
E:   Data Access Violation
E:   MMFAR Address: 0x20016018
E: r0/a1:  0xaaaaaaaa  r1/a2:  0xaaaaaaaa  r2/a3:  0xaaaaaaaa
E: r3/a4:  0xaaaaaaaa r12/ip:  0xaaaaaaaa r14/lr:  0xaaaaaaaa
E:  xpsr:  0x61000000
E: s[ 0]:  0x00000000  s[ 1]:  0x00000000  s[ 2]:  0x00000000  s[ 3]:  0x00000000
E: s[ 4]:  0x00000000  s[ 5]:  0x00000000  s[ 6]:  0x00000000  s[ 7]:  0x00000000
E: s[ 8]:  0x00000000  s[ 9]:  0x00000000  s[10]:  0x00000000  s[11]:  0x00000000
E: s[12]:  0x00000000  s[13]:  0x00000000  s[14]:  0x00000000  s[15]:  0x00000000
E: fpscr:  0xaaaaaaaa
E: Faulting instruction address (r15/pc): 0x00029708
E: >>> ZEPHYR FATAL ERROR 2: Stack overflow on CPU 0
E: Current thread: 0x20002c08 (sysworkq)


This happens for most commands, including `echo`, `image upload`, `image confirm`, etc

It works perfectly fine up until `v1.5.1`.

Is this a known issue?


Thank you

Parents
  • Hello, 

    Are you able to provide more details? Is this a custom application? I will need to forward to our OpenThread team.

    Kind regards,
    Øyvind

  • I made a very simple application that starts the smp udp service to test what I've just reported (attached).

    #include <zephyr.h>
    #include <logging/log.h>
    #include <net/openthread.h>
    #include <net/socket.h>
    #include <openthread/thread.h>
    #include <stdio.h>
    
    #include <mgmt/mcumgr/smp_udp.h>
    #include <net/net_mgmt.h>
    #include <net/net_event.h>
    #include <net/net_conn_mgr.h>
    
    #include "os_mgmt/os_mgmt.h"
    
    LOG_MODULE_REGISTER(main, CONFIG_MAIN_LOG_LEVEL);
    
    #define EVENT_MASK (NET_EVENT_L4_CONNECTED | NET_EVENT_L4_DISCONNECTED)
    
    static struct net_mgmt_event_callback mgmt_cb;
    
    static void event_handler(struct net_mgmt_event_callback *cb,
    			  uint32_t mgmt_event, struct net_if *iface)
    {
    	if ((mgmt_event & EVENT_MASK) != mgmt_event) {
    		return;
    	}
    
    	if (mgmt_event == NET_EVENT_L4_CONNECTED) {
    		LOG_INF("Network connected");
    
    		if (smp_udp_open() < 0) {
    			LOG_ERR("could not open smp udp");
    		}
    
    		return;
    	}
    
    	if (mgmt_event == NET_EVENT_L4_DISCONNECTED) {
    		LOG_INF("Network disconnected");
    		smp_udp_close();
    		return;
    	}
    }
    
    
    void get_ieee_eui64(uint8_t *ieee_eui64)
    {
    	uint64_t factory_address;
    	uint32_t index = 0;
    	// By default, the device uses Nordic Semiconductor's MA-L (fa-ce-36). It can be modified by overwriting
    	const uint32_t nordic_oui = 0xf4ce36;
    
    	// Set the MAC Address Block Larger (MA-L) formerly called OUI.
    	ieee_eui64[index++] = (nordic_oui >> 16) & 0xff;
    	ieee_eui64[index++] = (nordic_oui >> 8) & 0xff;
    	ieee_eui64[index++] = nordic_oui & 0xff;
    
    	// Use device identifier assigned during the production.
    	factory_address = (uint64_t)NRF_FICR->DEVICEID[0] << 32;
    	factory_address |= NRF_FICR->DEVICEID[1];
    	memcpy(ieee_eui64 + index, &factory_address, sizeof(factory_address) - index);
    }
    
    void get_macaddress(uint8_t *macaddr)
    {
    	uint8_t eui64[8];
    	get_ieee_eui64(eui64);
    	// get the last 6 bytes, ignoring the first two bytes of Nordic Semiconductor's MA-L
    	memcpy(macaddr, &eui64[2], 6);
    }
    
    void insert_ip_addr(){
    	// add manual ip, CUSTOM PREFIX + macaddress
    	uint8_t macaddr[6];
    	char manual_ip[46];
    	
    	get_macaddress(macaddr);
    
    	sprintf(manual_ip, "fdaa:bb:1::%02x%02x:%02x%02x:%02x%02x",
    		macaddr[0], macaddr[1], macaddr[2], macaddr[3],
    		macaddr[4], macaddr[5]);
    	
    	LOG_INF("Adding manual ip: %s", manual_ip);
    
    	otNetifAddress aAddress;
    
    	otIp6AddressFromString(manual_ip, &aAddress.mAddress);
    	aAddress.mPrefixLength  = 64;
    	aAddress.mPreferred     = true;
    	aAddress.mValid         = true;
    	aAddress.mAddressOrigin = OT_ADDRESS_ORIGIN_MANUAL;
    	otIp6AddUnicastAddress(openthread_get_default_context()->instance, &aAddress);
    }
    
    void main(void)
    {
    	insert_ip_addr();
    
    	// init SMP
    	os_mgmt_register_group();
    
    	// init SMP UDP
    	LOG_INF("STARTING SMP UDP");
    	net_mgmt_init_event_callback(&mgmt_cb, event_handler, EVENT_MASK);
    	net_mgmt_add_event_callback(&mgmt_cb);
    	net_conn_mgr_resend_status();
    
    	LOG_INF("SMP: build time: " __DATE__ " " __TIME__);
    
    	LOG_INF("Device fully initialized!");
    
    }
    


    # nRF board library
    CONFIG_DK_LIBRARY=y
    
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
    
    # Network settings
    CONFIG_NETWORKING=y
    CONFIG_NET_SOCKETS=y
    CONFIG_NET_SOCKETS_POLL_MAX=4
    CONFIG_NET_SOCKETS_POSIX_NAMES=y
    CONFIG_NET_CONNECTION_MANAGER=y
    CONFIG_NET_BUF_USER_DATA_SIZE=24
    CONFIG_NET_CONFIG_SETTINGS=y
    # Network shell
    CONFIG_NET_SHELL=y
    CONFIG_SHELL_ARGC_MAX=26
    CONFIG_SHELL_CMD_BUFF_SIZE=416
    
    ## SMP
    # Enable mcumgr.
    CONFIG_MCUMGR=y
    
    CONFIG_MCUMGR_CMD_OS_MGMT=y
    CONFIG_MCUMGR_BUF_COUNT=6
    
    # Enable the UDP mcumgr transports.
    CONFIG_MCUMGR_SMP_UDP=y
    CONFIG_MCUMGR_SMP_UDP_IPV6=y
    
    
    # OpenThread
    CONFIG_OPENTHREAD_NETWORK_NAME="OpenThread"
    CONFIG_OPENTHREAD_CHANNEL=11
    CONFIG_OPENTHREAD_DHCP6_CLIENT=y
    CONFIG_OPENTHREAD_SLAAC=y
    CONFIG_OPENTHREAD_PANID=43981
    CONFIG_OPENTHREAD_XPANID="de:ad:00:be:ef:00:ca:fe"
    CONFIG_OPENTHREAD_MASTERKEY="00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff"
    # CONFIG_OPENTHREAD_MANUAL_START is not set
    
    

Reply
  • I made a very simple application that starts the smp udp service to test what I've just reported (attached).

    #include <zephyr.h>
    #include <logging/log.h>
    #include <net/openthread.h>
    #include <net/socket.h>
    #include <openthread/thread.h>
    #include <stdio.h>
    
    #include <mgmt/mcumgr/smp_udp.h>
    #include <net/net_mgmt.h>
    #include <net/net_event.h>
    #include <net/net_conn_mgr.h>
    
    #include "os_mgmt/os_mgmt.h"
    
    LOG_MODULE_REGISTER(main, CONFIG_MAIN_LOG_LEVEL);
    
    #define EVENT_MASK (NET_EVENT_L4_CONNECTED | NET_EVENT_L4_DISCONNECTED)
    
    static struct net_mgmt_event_callback mgmt_cb;
    
    static void event_handler(struct net_mgmt_event_callback *cb,
    			  uint32_t mgmt_event, struct net_if *iface)
    {
    	if ((mgmt_event & EVENT_MASK) != mgmt_event) {
    		return;
    	}
    
    	if (mgmt_event == NET_EVENT_L4_CONNECTED) {
    		LOG_INF("Network connected");
    
    		if (smp_udp_open() < 0) {
    			LOG_ERR("could not open smp udp");
    		}
    
    		return;
    	}
    
    	if (mgmt_event == NET_EVENT_L4_DISCONNECTED) {
    		LOG_INF("Network disconnected");
    		smp_udp_close();
    		return;
    	}
    }
    
    
    void get_ieee_eui64(uint8_t *ieee_eui64)
    {
    	uint64_t factory_address;
    	uint32_t index = 0;
    	// By default, the device uses Nordic Semiconductor's MA-L (fa-ce-36). It can be modified by overwriting
    	const uint32_t nordic_oui = 0xf4ce36;
    
    	// Set the MAC Address Block Larger (MA-L) formerly called OUI.
    	ieee_eui64[index++] = (nordic_oui >> 16) & 0xff;
    	ieee_eui64[index++] = (nordic_oui >> 8) & 0xff;
    	ieee_eui64[index++] = nordic_oui & 0xff;
    
    	// Use device identifier assigned during the production.
    	factory_address = (uint64_t)NRF_FICR->DEVICEID[0] << 32;
    	factory_address |= NRF_FICR->DEVICEID[1];
    	memcpy(ieee_eui64 + index, &factory_address, sizeof(factory_address) - index);
    }
    
    void get_macaddress(uint8_t *macaddr)
    {
    	uint8_t eui64[8];
    	get_ieee_eui64(eui64);
    	// get the last 6 bytes, ignoring the first two bytes of Nordic Semiconductor's MA-L
    	memcpy(macaddr, &eui64[2], 6);
    }
    
    void insert_ip_addr(){
    	// add manual ip, CUSTOM PREFIX + macaddress
    	uint8_t macaddr[6];
    	char manual_ip[46];
    	
    	get_macaddress(macaddr);
    
    	sprintf(manual_ip, "fdaa:bb:1::%02x%02x:%02x%02x:%02x%02x",
    		macaddr[0], macaddr[1], macaddr[2], macaddr[3],
    		macaddr[4], macaddr[5]);
    	
    	LOG_INF("Adding manual ip: %s", manual_ip);
    
    	otNetifAddress aAddress;
    
    	otIp6AddressFromString(manual_ip, &aAddress.mAddress);
    	aAddress.mPrefixLength  = 64;
    	aAddress.mPreferred     = true;
    	aAddress.mValid         = true;
    	aAddress.mAddressOrigin = OT_ADDRESS_ORIGIN_MANUAL;
    	otIp6AddUnicastAddress(openthread_get_default_context()->instance, &aAddress);
    }
    
    void main(void)
    {
    	insert_ip_addr();
    
    	// init SMP
    	os_mgmt_register_group();
    
    	// init SMP UDP
    	LOG_INF("STARTING SMP UDP");
    	net_mgmt_init_event_callback(&mgmt_cb, event_handler, EVENT_MASK);
    	net_mgmt_add_event_callback(&mgmt_cb);
    	net_conn_mgr_resend_status();
    
    	LOG_INF("SMP: build time: " __DATE__ " " __TIME__);
    
    	LOG_INF("Device fully initialized!");
    
    }
    


    # nRF board library
    CONFIG_DK_LIBRARY=y
    
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
    
    # Network settings
    CONFIG_NETWORKING=y
    CONFIG_NET_SOCKETS=y
    CONFIG_NET_SOCKETS_POLL_MAX=4
    CONFIG_NET_SOCKETS_POSIX_NAMES=y
    CONFIG_NET_CONNECTION_MANAGER=y
    CONFIG_NET_BUF_USER_DATA_SIZE=24
    CONFIG_NET_CONFIG_SETTINGS=y
    # Network shell
    CONFIG_NET_SHELL=y
    CONFIG_SHELL_ARGC_MAX=26
    CONFIG_SHELL_CMD_BUFF_SIZE=416
    
    ## SMP
    # Enable mcumgr.
    CONFIG_MCUMGR=y
    
    CONFIG_MCUMGR_CMD_OS_MGMT=y
    CONFIG_MCUMGR_BUF_COUNT=6
    
    # Enable the UDP mcumgr transports.
    CONFIG_MCUMGR_SMP_UDP=y
    CONFIG_MCUMGR_SMP_UDP_IPV6=y
    
    
    # OpenThread
    CONFIG_OPENTHREAD_NETWORK_NAME="OpenThread"
    CONFIG_OPENTHREAD_CHANNEL=11
    CONFIG_OPENTHREAD_DHCP6_CLIENT=y
    CONFIG_OPENTHREAD_SLAAC=y
    CONFIG_OPENTHREAD_PANID=43981
    CONFIG_OPENTHREAD_XPANID="de:ad:00:be:ef:00:ca:fe"
    CONFIG_OPENTHREAD_MASTERKEY="00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff"
    # CONFIG_OPENTHREAD_MANUAL_START is not set
    
    

Children
Related