Problems related to nrf5340 brighton/off

Hello.
We are testing nrf5340 - nrf7002 using the example of blpovisioning.
I try to put on/off function using button, but if I reset pcb and turn on, it will connect to wifi and tcp server normally, but if I turn on -> off -> an error occurred in bt hci.
I looked it up
devzone.nordicsemi.com/.../473790
github.com/.../files
It's related, so I modified the nrf53_support.c file and built it

[00:00:17.729,492] <inf> Provisioning: Configuring server address...
[00:00:17.729,797] <inf> Provisioning: Attempting to create socket...
[00:00:17.730,285] <inf> Provisioning: Attempting to connect to server...
[00:00:17.731,048] <err> net_arp: Gateway not set for iface 0x20002718
[00:00:18.425,598] <err> net_arp: Gateway not set for iface 0x20002718
[00:00:19.119,750] <err> net_arp: Gateway not set for iface 0x20002718
[00:00:19.813,903] <err> net_arp: Gateway not set for iface 0x20002718
[00:00:20.508,056] <err> net_arp: Gateway not set for iface 0x20002718

This error is occurring.

Is there any additional data to refer to??

The sdk you are using is v2.8.0

Parents
  • Hi

    So the error you're looking for here seems to come from the arp.c file in ...\v2.9.0\zephyr\subsys\net\l2\ethernet\arp.c In the net_pkt() function it seems to check if the destination IP is specified, and returns the "Gateway not set for iface" error if it is not specified.

    struct net_pkt *net_arp_prepare(struct net_pkt *pkt,
    				struct in_addr *request_ip,
    				struct in_addr *current_ip)
    {
    	bool is_ipv4_ll_used = false;
    	struct arp_entry *entry;
    	struct in_addr *addr;
    
    	if (!pkt || !pkt->buffer) {
    		return NULL;
    	}
    
    	if (net_pkt_ipv4_acd(pkt)) {
    		return arp_prepare(net_pkt_iface(pkt), request_ip, NULL,
    				   pkt, current_ip);
    	}
    
    	if (IS_ENABLED(CONFIG_NET_IPV4_AUTO)) {
    		is_ipv4_ll_used = net_ipv4_is_ll_addr((struct in_addr *)
    						&NET_IPV4_HDR(pkt)->src) ||
    				  net_ipv4_is_ll_addr((struct in_addr *)
    						&NET_IPV4_HDR(pkt)->dst);
    	}
    
    	/* Is the destination in the local network, if not route via
    	 * the gateway address.
    	 */
    	if (!current_ip && !is_ipv4_ll_used &&
    	    !net_if_ipv4_addr_mask_cmp(net_pkt_iface(pkt), request_ip)) {
    		struct net_if_ipv4 *ipv4 = net_pkt_iface(pkt)->config.ip.ipv4;
    
    		if (ipv4) {
    			addr = &ipv4->gw;
    			if (net_ipv4_is_addr_unspecified(addr)) {
    				NET_ERR("Gateway not set for iface %p",
    					net_pkt_iface(pkt));
    
    				return NULL;
    			}
    		} else {
    			addr = request_ip;
    		}
    	} else {
    		addr = request_ip;
    	}
    
    	k_mutex_lock(&arp_mutex, K_FOREVER);
    
    	/* If the destination address is already known, we do not need
    	 * to send any ARP packet.
    	 */
    	entry = arp_entry_find_move_first(net_pkt_iface(pkt), addr);
    	if (!entry) {
    		struct net_pkt *req;
    
    		entry = arp_entry_find_pending(net_pkt_iface(pkt), addr);
    		if (!entry) {
    			/* No pending, let's try to get a new entry */
    			entry = arp_entry_get_free();
    			if (!entry) {
    				/* Then let's take one from table? */
    				entry = arp_entry_get_last_from_table();
    			}
    		} else {
    			/* There is a pending ARP request already, check if this packet is already
    			 * in the pending list and if so, resend the request, otherwise just
    			 * append the packet to the request fifo list.
    			 */
    			if (k_queue_unique_append(&entry->pending_queue._queue,
    						  net_pkt_ref(pkt))) {
    				NET_DBG("Pending ARP request for %s, queuing pkt %p",
    					net_sprint_ipv4_addr(addr), pkt);
    				k_mutex_unlock(&arp_mutex);
    				return NULL;
    			}
    
    			entry = NULL;
    		}
    
    		req = arp_prepare(net_pkt_iface(pkt), addr, entry, pkt,
    				  current_ip);
    
    		if (!entry) {
    			/* We cannot send the packet, the ARP cache is full
    			 * or there is already a pending query to this IP
    			 * address, so this packet must be discarded.
    			 */
    			NET_DBG("Resending ARP %p", req);
    		}
    
    		if (!req && entry) {
    			/* Add the arp entry back to arp_free_entries, to avoid the
    			 * arp entry is leak due to ARP packet allocated failed.
    			 */
    			sys_slist_prepend(&arp_free_entries, &entry->node);
    		}
    
    		k_mutex_unlock(&arp_mutex);
    		return req;
    	}
    
    	k_mutex_unlock(&arp_mutex);
    
    	net_pkt_lladdr_src(pkt)->addr =
    		(uint8_t *)net_if_get_link_addr(entry->iface)->addr;
    	net_pkt_lladdr_src(pkt)->len = sizeof(struct net_eth_addr);
    
    	net_pkt_lladdr_dst(pkt)->addr = (uint8_t *)&entry->eth;
    	net_pkt_lladdr_dst(pkt)->len = sizeof(struct net_eth_addr);
    
    	NET_DBG("ARP using ll %s for IP %s",
    		net_sprint_ll_addr(net_pkt_lladdr_dst(pkt)->addr,
    				   sizeof(struct net_eth_addr)),
    		net_sprint_ipv4_addr(&NET_IPV4_HDR(pkt)->dst));
    
    	return pkt;
    }

    I added a snippet from  NCS 2.9.0 here. How do you set the IP address in your application exactly?

    Best regards,

    Simon

Reply
  • Hi

    So the error you're looking for here seems to come from the arp.c file in ...\v2.9.0\zephyr\subsys\net\l2\ethernet\arp.c In the net_pkt() function it seems to check if the destination IP is specified, and returns the "Gateway not set for iface" error if it is not specified.

    struct net_pkt *net_arp_prepare(struct net_pkt *pkt,
    				struct in_addr *request_ip,
    				struct in_addr *current_ip)
    {
    	bool is_ipv4_ll_used = false;
    	struct arp_entry *entry;
    	struct in_addr *addr;
    
    	if (!pkt || !pkt->buffer) {
    		return NULL;
    	}
    
    	if (net_pkt_ipv4_acd(pkt)) {
    		return arp_prepare(net_pkt_iface(pkt), request_ip, NULL,
    				   pkt, current_ip);
    	}
    
    	if (IS_ENABLED(CONFIG_NET_IPV4_AUTO)) {
    		is_ipv4_ll_used = net_ipv4_is_ll_addr((struct in_addr *)
    						&NET_IPV4_HDR(pkt)->src) ||
    				  net_ipv4_is_ll_addr((struct in_addr *)
    						&NET_IPV4_HDR(pkt)->dst);
    	}
    
    	/* Is the destination in the local network, if not route via
    	 * the gateway address.
    	 */
    	if (!current_ip && !is_ipv4_ll_used &&
    	    !net_if_ipv4_addr_mask_cmp(net_pkt_iface(pkt), request_ip)) {
    		struct net_if_ipv4 *ipv4 = net_pkt_iface(pkt)->config.ip.ipv4;
    
    		if (ipv4) {
    			addr = &ipv4->gw;
    			if (net_ipv4_is_addr_unspecified(addr)) {
    				NET_ERR("Gateway not set for iface %p",
    					net_pkt_iface(pkt));
    
    				return NULL;
    			}
    		} else {
    			addr = request_ip;
    		}
    	} else {
    		addr = request_ip;
    	}
    
    	k_mutex_lock(&arp_mutex, K_FOREVER);
    
    	/* If the destination address is already known, we do not need
    	 * to send any ARP packet.
    	 */
    	entry = arp_entry_find_move_first(net_pkt_iface(pkt), addr);
    	if (!entry) {
    		struct net_pkt *req;
    
    		entry = arp_entry_find_pending(net_pkt_iface(pkt), addr);
    		if (!entry) {
    			/* No pending, let's try to get a new entry */
    			entry = arp_entry_get_free();
    			if (!entry) {
    				/* Then let's take one from table? */
    				entry = arp_entry_get_last_from_table();
    			}
    		} else {
    			/* There is a pending ARP request already, check if this packet is already
    			 * in the pending list and if so, resend the request, otherwise just
    			 * append the packet to the request fifo list.
    			 */
    			if (k_queue_unique_append(&entry->pending_queue._queue,
    						  net_pkt_ref(pkt))) {
    				NET_DBG("Pending ARP request for %s, queuing pkt %p",
    					net_sprint_ipv4_addr(addr), pkt);
    				k_mutex_unlock(&arp_mutex);
    				return NULL;
    			}
    
    			entry = NULL;
    		}
    
    		req = arp_prepare(net_pkt_iface(pkt), addr, entry, pkt,
    				  current_ip);
    
    		if (!entry) {
    			/* We cannot send the packet, the ARP cache is full
    			 * or there is already a pending query to this IP
    			 * address, so this packet must be discarded.
    			 */
    			NET_DBG("Resending ARP %p", req);
    		}
    
    		if (!req && entry) {
    			/* Add the arp entry back to arp_free_entries, to avoid the
    			 * arp entry is leak due to ARP packet allocated failed.
    			 */
    			sys_slist_prepend(&arp_free_entries, &entry->node);
    		}
    
    		k_mutex_unlock(&arp_mutex);
    		return req;
    	}
    
    	k_mutex_unlock(&arp_mutex);
    
    	net_pkt_lladdr_src(pkt)->addr =
    		(uint8_t *)net_if_get_link_addr(entry->iface)->addr;
    	net_pkt_lladdr_src(pkt)->len = sizeof(struct net_eth_addr);
    
    	net_pkt_lladdr_dst(pkt)->addr = (uint8_t *)&entry->eth;
    	net_pkt_lladdr_dst(pkt)->len = sizeof(struct net_eth_addr);
    
    	NET_DBG("ARP using ll %s for IP %s",
    		net_sprint_ll_addr(net_pkt_lladdr_dst(pkt)->addr,
    				   sizeof(struct net_eth_addr)),
    		net_sprint_ipv4_addr(&NET_IPV4_HDR(pkt)->dst));
    
    	return pkt;
    }

    I added a snippet from  NCS 2.9.0 here. How do you set the IP address in your application exactly?

    Best regards,

    Simon

Children
No Data
Related