I have an issue where the Beagle connect Freedom cannot receive incoming UDP packets with zephyr code.
I was struggling with this initially, but then it mysteriously started working even though I’m sure I didnt change anything that should have affected this. But great anyway. So I continued working on other parts of the code, unrelated to networking. All went well for several days across multiple power downs and reflashes. Then, again for no reason I could see, it stopped receiving again. Even reverting to old code that I knew had worked no longer did. I’ve been hammering on this for ages but I just cant get it to work. Sending works fine. It responds to pings from another machine, and I very occasionally see a message in tio advising of a dropped subg packet, however I would see these occasionally when it was working. I’ve also tried with a second, brand new device with the same result - nothing received.
To test this further, I downloaded a udp receiver sample from here https://beej.us/guide/bgnet/examples/listener.c (a rather excellent networking guide) and got the exact same results.
At this point I assume the bug is either in the bcf zephyr driver, zephyr itself, or my prj.conf file. Hopefully it’s in my prj.conf file - it appears to be almost impossible to find out what is needed here and what should be avoided.
On the other hand, maybe the bcf just needs to be set up in a rather non standard manner.
To test this - download the beej sample mentioned earlier, along with the corresponding ‘talker’ app, then replace the #includes at the head of the file with this:
#if __ZEPHYR__ #include <zephyr/kernel.h> #else #include <unistd.h> #include <stdlib.h> #endif #include <stdint.h> #include <stdio.h> #include <string.h> #include <strings.h> #if __ZEPHYR__ #include <zephyr/net/net_ip.h> #include <zephyr/net/socket.h> #include <zephyr/net/net_core.h> #include <zephyr/device.h> #include <zephyr/drivers/uart.h> #else #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <linux/in6.h> #include <netdb.h> #include <fcntl.h> #endif #if __ZEPHYR__ #define LOG_LEVEL LOG_LEVEL_INF #include <zephyr/logging/log.h> LOG_MODULE_REGISTER(network_test); #endif
You may also need to adjust the ‘main’ declaration and it’s return statements.
Now the file can be complied and flashed to the bcf, or compiled and run on the linux desktop.
compile and run the ‘talker’ app to send it messages.
My proj.conf file is as follows:
# Base board features CONFIG_SERIAL=y # Generic networking options CONFIG_NETWORKING=y CONFIG_NET_UDP=y CONFIG_NET_TCP=y CONFIG_NET_IPV6=y CONFIG_NET_IPV4=y CONFIG_NET_SOCKETS=y CONFIG_NET_SOCKETS_POSIX_NAMES=y CONFIG_NET_SOCKETS_POLL_MAX=8 CONFIG_NET_CONFIG_AUTO_INIT=y CONFIG_NET_CONNECTION_MANAGER=y # Kernel options CONFIG_NEWLIB_LIBC=y # Logging CONFIG_LOG=y CONFIG_NET_STATISTICS=y CONFIG_NET_ICMPV6_LOG_LEVEL_DBG=y CONFIG_NET_IPV6_MLD=y CONFIG_IEEE802154=y CONFIG_NET_L2_IEEE802154=y CONFIG_NET_L2_IEEE802154_LOG_LEVEL_INF=y CONFIG_NET_CONFIG_IEEE802154_CHANNEL=1 CONFIG_NET_CONFIG_IEEE802154_PAN_ID=0xabcd CONFIG_NET_CONFIG_IEEE802154_RADIO_TX_POWER=20 CONFIG_IEEE802154_CC13XX_CC26XX=n CONFIG_IEEE802154_CC13XX_CC26XX_SUB_GHZ=y CONFIG_IEEE802154_CC13XX_CC26XX_SUB_GHZ_NUM_RX_BUF=6 # Network buffers CONFIG_NET_PKT_RX_COUNT=8 CONFIG_NET_BUF_RX_COUNT=64 CONFIG_NET_PKT_TX_COUNT=20 CONFIG_NET_BUF_TX_COUNT=50 CONFIG_NET_CONTEXT_NET_PKT_POOL=y # IP address options CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3 CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=4 CONFIG_NET_IF_MAX_IPV6_COUNT=2 CONFIG_NET_MAX_CONN=8 CONFIG_NET_MAX_CONTEXTS=10 # Network application options and configuration CONFIG_NET_CONFIG_SETTINGS=y CONFIG_NET_CONFIG_NEED_IPV6=y CONFIG_NET_CONFIG_NEED_IPV4=n CONFIG_NET_CONFIG_MY_IPV6_ADDR="2001:db8::1" CONFIG_NET_CONFIG_PEER_IPV6_ADDR="2001:db8::2"
Extensive monkying with these config options hasnt helped, but I really didnt know what I was doing here.
I’ll test this further using TCP code, but I really need to use UDP multicasting.