mcumgr over openthread UDP Error 8

I'm trying to implement mcumgr over openthread UDP. to update firmware.

mcumgr echo works fine but when I try to list images the respond is Error 8.


prj.conf:

CONFIG_DK_LIBRARY=y

CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096

# 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_NCS_SAMPLES_DEFAULTS=y

CONFIG_NEWLIB_LIBC=y

# Enable floating point Hard ABI
CONFIG_FPU=y
CONFIG_FP_HARDABI=y

# Generic networking options
CONFIG_NETWORKING=y
CONFIG_NET_CONNECTION_MANAGER=y

# Kernel options
CONFIG_MAIN_STACK_SIZE=2048
CONFIG_INIT_STACKS=y

# Increase set for threads with meta-irq priority
CONFIG_NUM_METAIRQ_PRIORITIES=1

# Logging
CONFIG_NET_LOG=y
CONFIG_NET_STATISTICS=y

# Disable certain parts of Zephyr IPv6 stack
CONFIG_NET_IPV6_NBR_CACHE=n
CONFIG_NET_IPV6_MLD=n

# Stack sizes configuration
CONFIG_NET_TX_STACK_SIZE=1200
CONFIG_NET_RX_STACK_SIZE=1500


# L2 OpenThread enabling
CONFIG_NET_L2_OPENTHREAD=y
CONFIG_OPENTHREAD_DEBUG=y
CONFIG_OPENTHREAD_L2_DEBUG=y
CONFIG_OPENTHREAD_L2_LOG_LEVEL_INF=y


CONFIG_BOOTLOADER_MCUBOOT=y

#RTT seiral
CONFIG_UART_CONSOLE=n
CONFIG_RTT_CONSOLE=y
CONFIG_USE_SEGGER_RTT=y


# Enable flash operations.
CONFIG_FLASH=y

# Required by the `taskstat` command.
CONFIG_THREAD_MONITOR=y

# Support for taskstat command
CONFIG_OS_MGMT_TASKSTAT=y

# Enable statistics and statistic names.
CONFIG_STATS=y
CONFIG_STATS_NAMES=y

# Enable most core commands.
CONFIG_MCUMGR_CMD_IMG_MGMT=y
CONFIG_MCUMGR_CMD_STAT_MGMT=y

# Enable the shell mcumgr transport.
CONFIG_MCUMGR_SMP_SHELL=y
# mcumgr-cli application doesn't accepts log in the channel it uses
CONFIG_SHELL_LOG_BACKEND=n
I'm using nrf52840 with nrf connect SDK 2.2.0.
+ is this the right implementation of DFU using openthread? 
 
  • Hi, 

    Not sure how you set SMP over UPD in the application, but you could refer to and test the SMP Server Sample and build with the overlay-udp.conf. 

    Regards,
    Amanda H.

  • Hello Amanda,

    I followed the instruction on the SMP Server Sample, I just integrated OpenThread with the sample.

    Instructions like echo and stat are working but anything related to the image will give me error 8.

    I looked for the meaning of error 8 and it seems to mean that the command is not supported. not sure if thats the case or if something is wrong with my code

     

    #include <zephyr/kernel.h>
    #include <zephyr/stats/stats.h>
    #define LOG_LEVEL LOG_LEVEL_DBG
    #include <zephyr/logging/log.h>
    LOG_MODULE_REGISTER(smp_sample);
    #include <zephyr/net/openthread.h>
    #include <zephyr/net/socket.h>
    #include <openthread/thread.h>
    #include <stdio.h>
    
    #include <zephyr/mgmt/mcumgr/smp_udp.h>
    #include <zephyr/net/net_mgmt.h>
    #include <zephyr/net/net_event.h>
    #include <zephyr/net/net_conn_mgr.h>
    
    #include "os_mgmt/os_mgmt.h"
    
    #ifdef CONFIG_MCUMGR_CMD_FS_MGMT
    #include <zephyr/device.h>
    #include <zephyr/fs/fs.h>
    #include "fs_mgmt/fs_mgmt.h"
    #include <zephyr/fs/littlefs.h>
    #endif
    #ifdef CONFIG_MCUMGR_CMD_OS_MGMT
    #include "os_mgmt/os_mgmt.h"
    #endif
    #ifdef CONFIG_MCUMGR_CMD_IMG_MGMT
    #include "img_mgmt/img_mgmt.h"
    #endif
    #ifdef CONFIG_MCUMGR_CMD_STAT_MGMT
    #include "stat_mgmt/stat_mgmt.h"
    #endif
    #ifdef CONFIG_MCUMGR_CMD_SHELL_MGMT
    #include "shell_mgmt/shell_mgmt.h"
    #endif
    
    
    
    #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!");
    
    }
    

  • Before integrating, do you test  SMP Server Sample with overlay-udp.conf? Do you get any errors?

    -Amanda H

  • I just tried the SMP sample with connection over ethernet it seems to be working fine unlike with openthread

  • Do you add the configs in this overlay-udp.conf into your project config?
    This similar case might help, but it needs to increase CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE. 

    -Amanda H. 

Related