Weird problem with CONFIG_NETINIT_THREAD
Hi all, I am programming a custom board which has Ethernet, but does not have UART or USB connections, so I need to access NSH via Telnet. The board is configured to use DHCP client. I am using latest master: commit # c6c0baa233594dd8e5319a82a6708121e8e94349 in incubator-nuttx tree. The weird problem is: When CONFIG_NETINIT_THREAD is disabled, it works: The board boots, I can telnet into NSH running on it. When CONFIG_NETINIT_THREAD is enabled, the board seems to never request a DHCP lease. As it has no (known, to me) IP address, I cannot telnet into it. I'm having a little trouble debugging this because, e.g., when I set a breakpoint at netinit_thread(), it never seems to be hit. I have single-stepped through netinit_bringup(). It calls pthread_create() to start netinit_thread() and that call returns OK, but I cannot seem to debug netinit_thread() itself. For completeness, my defconfig: [[[ # # This file is autogenerated: PLEASE DO NOT EDIT IT. # # You can use "make menuconfig" to make any modifications to the installed .config file. # You can then do "make savedefconfig" to generate a new defconfig file that includes your # modifications. # # CONFIG_ARCH_LEDS is not set # CONFIG_DEV_CONSOLE is not set # CONFIG_DISABLE_OS_API is not set # CONFIG_FS_LARGEFILE is not set # CONFIG_SERIAL is not set CONFIG_ARCH="arm" CONFIG_ARCH_BOARD="TmGw" CONFIG_ARCH_BOARD_TMGW=y CONFIG_ARCH_CHIP="tiva" CONFIG_ARCH_CHIP_TIVA=y CONFIG_ARCH_CHIP_TM4C129=y CONFIG_ARCH_CHIP_TM4C129ENCZAD=y CONFIG_ARCH_CHIP_TM4C=y CONFIG_ARCH_HIPRI_INTERRUPT=y CONFIG_ARCH_RAMVECTORS=y CONFIG_ARCH_STACKDUMP=y CONFIG_ARMV7M_LIBM=y CONFIG_ARMV7M_MEMCPY=y CONFIG_BOARD_LATE_INITIALIZE=y CONFIG_BOARD_LOOPSPERMSEC=11401 CONFIG_BUILTIN=y CONFIG_DEBUG_ERROR=y CONFIG_DEBUG_FEATURES=y CONFIG_DEBUG_INFO=y CONFIG_DEBUG_SYMBOLS=y CONFIG_DEBUG_WARN=y CONFIG_FS_PROCFS=y CONFIG_INIT_ENTRYPOINT="nsh_main" CONFIG_LIBC_FLOATINGPOINT=y CONFIG_LIBM=y CONFIG_MM_CIRCBUF=y CONFIG_NET=y CONFIG_NETDB_DNSCLIENT=y CONFIG_NETINIT_DHCPC=y CONFIG_NETUTILS_DHCPC_HOST_NAME="nuttx-tmgw" CONFIG_NETUTILS_NETCAT=y CONFIG_NETUTILS_TELNETD=y CONFIG_NET_ARP_IPIN=y CONFIG_NET_ARP_SEND=y CONFIG_NET_BROADCAST=y CONFIG_NET_ETH_PKTSIZE=1518 CONFIG_NET_ICMP=y CONFIG_NET_ICMP_SOCKET=y CONFIG_NET_ROUTE=y CONFIG_NET_STATISTICS=y CONFIG_NET_TCP=y CONFIG_NET_TCPBACKLOG=y CONFIG_NET_TCP_WRITE_BUFFERS=y CONFIG_NET_UDP=y CONFIG_NET_UDP_CHECKSUMS=y CONFIG_NET_UDP_NOTIFIER=y CONFIG_NET_UDP_WRITE_BUFFERS=y CONFIG_NSH_BUILTIN_APPS=y CONFIG_PREALLOC_MQ_MSGS=4 CONFIG_PREALLOC_TIMERS=4 CONFIG_PRIORITY_INHERITANCE=y CONFIG_RAM_SIZE=262144 CONFIG_RAM_START=0x2000 CONFIG_RAW_BINARY=y CONFIG_RR_INTERVAL=200 CONFIG_SCHED_HPWORK=y CONFIG_SCHED_LPWORK=y CONFIG_SCHED_WAITPID=y CONFIG_START_YEAR=2015 CONFIG_SYSTEM_DHCPC_RENEW=y CONFIG_SYSTEM_NSH=y CONFIG_SYSTEM_PING=y CONFIG_TIVA_BOARDMAC=y CONFIG_TIVA_ETHERNET=y CONFIG_USERLED=y CONFIG_USERLED_LOWER=y ]]] Any thoughts are greatly appreciated. Cheers, Nathan
Re: Weird problem with CONFIG_NETINIT_THREAD
Sounds like nothing is calling netinit_bringup(). Normally this is part of the console initialization: nsh_altconsole.c: netinit_bringup(); nsh_consolemain.c: netinit_bringup(); nsh_telnetd.c: netinit_bringup(); nsh_usbconsole.c: netinit_bringup(); So perhaps it is not called in this configuration? netinit_bringup() starts the monitor thread that brings up the network, including the DHCP interactions. Is the netinit pthread running? There are lots of other possibilities: Does the driver have a MAC address? On 6/26/2022 11:14 AM, Nathan Hartman wrote: Hi all, I am programming a custom board which has Ethernet, but does not have UART or USB connections, so I need to access NSH via Telnet. The board is configured to use DHCP client. I am using latest master: commit # c6c0baa233594dd8e5319a82a6708121e8e94349 in incubator-nuttx tree. The weird problem is: When CONFIG_NETINIT_THREAD is disabled, it works: The board boots, I can telnet into NSH running on it. When CONFIG_NETINIT_THREAD is enabled, the board seems to never request a DHCP lease. As it has no (known, to me) IP address, I cannot telnet into it. I'm having a little trouble debugging this because, e.g., when I set a breakpoint at netinit_thread(), it never seems to be hit. I have single-stepped through netinit_bringup(). It calls pthread_create() to start netinit_thread() and that call returns OK, but I cannot seem to debug netinit_thread() itself. For completeness, my defconfig: [[[ # # This file is autogenerated: PLEASE DO NOT EDIT IT. # # You can use "make menuconfig" to make any modifications to the installed .config file. # You can then do "make savedefconfig" to generate a new defconfig file that includes your # modifications. # # CONFIG_ARCH_LEDS is not set # CONFIG_DEV_CONSOLE is not set # CONFIG_DISABLE_OS_API is not set # CONFIG_FS_LARGEFILE is not set # CONFIG_SERIAL is not set CONFIG_ARCH="arm" CONFIG_ARCH_BOARD="TmGw" CONFIG_ARCH_BOARD_TMGW=y CONFIG_ARCH_CHIP="tiva" CONFIG_ARCH_CHIP_TIVA=y CONFIG_ARCH_CHIP_TM4C129=y CONFIG_ARCH_CHIP_TM4C129ENCZAD=y CONFIG_ARCH_CHIP_TM4C=y CONFIG_ARCH_HIPRI_INTERRUPT=y CONFIG_ARCH_RAMVECTORS=y CONFIG_ARCH_STACKDUMP=y CONFIG_ARMV7M_LIBM=y CONFIG_ARMV7M_MEMCPY=y CONFIG_BOARD_LATE_INITIALIZE=y CONFIG_BOARD_LOOPSPERMSEC=11401 CONFIG_BUILTIN=y CONFIG_DEBUG_ERROR=y CONFIG_DEBUG_FEATURES=y CONFIG_DEBUG_INFO=y CONFIG_DEBUG_SYMBOLS=y CONFIG_DEBUG_WARN=y CONFIG_FS_PROCFS=y CONFIG_INIT_ENTRYPOINT="nsh_main" CONFIG_LIBC_FLOATINGPOINT=y CONFIG_LIBM=y CONFIG_MM_CIRCBUF=y CONFIG_NET=y CONFIG_NETDB_DNSCLIENT=y CONFIG_NETINIT_DHCPC=y CONFIG_NETUTILS_DHCPC_HOST_NAME="nuttx-tmgw" CONFIG_NETUTILS_NETCAT=y CONFIG_NETUTILS_TELNETD=y CONFIG_NET_ARP_IPIN=y CONFIG_NET_ARP_SEND=y CONFIG_NET_BROADCAST=y CONFIG_NET_ETH_PKTSIZE=1518 CONFIG_NET_ICMP=y CONFIG_NET_ICMP_SOCKET=y CONFIG_NET_ROUTE=y CONFIG_NET_STATISTICS=y CONFIG_NET_TCP=y CONFIG_NET_TCPBACKLOG=y CONFIG_NET_TCP_WRITE_BUFFERS=y CONFIG_NET_UDP=y CONFIG_NET_UDP_CHECKSUMS=y CONFIG_NET_UDP_NOTIFIER=y CONFIG_NET_UDP_WRITE_BUFFERS=y CONFIG_NSH_BUILTIN_APPS=y CONFIG_PREALLOC_MQ_MSGS=4 CONFIG_PREALLOC_TIMERS=4 CONFIG_PRIORITY_INHERITANCE=y CONFIG_RAM_SIZE=262144 CONFIG_RAM_START=0x2000 CONFIG_RAW_BINARY=y CONFIG_RR_INTERVAL=200 CONFIG_SCHED_HPWORK=y CONFIG_SCHED_LPWORK=y CONFIG_SCHED_WAITPID=y CONFIG_START_YEAR=2015 CONFIG_SYSTEM_DHCPC_RENEW=y CONFIG_SYSTEM_NSH=y CONFIG_SYSTEM_PING=y CONFIG_TIVA_BOARDMAC=y CONFIG_TIVA_ETHERNET=y CONFIG_USERLED=y CONFIG_USERLED_LOWER=y ]]] Any thoughts are greatly appreciated. Cheers, Nathan
Re: Weird problem with CONFIG_NETINIT_THREAD
On Sun, Jun 26, 2022 at 1:25 PM Gregory Nutt wrote: > > Sounds like nothing is calling netinit_bringup(). Normally this is part > of the console initialization: > > nsh_altconsole.c: netinit_bringup(); > nsh_consolemain.c: netinit_bringup(); > nsh_telnetd.c: netinit_bringup(); > nsh_usbconsole.c: netinit_bringup(); > > So perhaps it is not called in this configuration? > > netinit_bringup() starts the monitor thread that brings up the network, > including the DHCP interactions. Is the netinit pthread running? > > There are lots of other possibilities: Does the driver have a MAC address? Thanks for the reply. Update: I now believe CONFIG_NETINIT_THREAD_PRIORITY was too low. By default it is set to 80. In the debugger, in netinit_bringup(), I manually bumped sparam.sched_priority all the way up to 250 and now the network configuration seems to run. I tried such a high value just for testing but I think it should be lower than that for real usage. I wonder what task with a priority higher than 80 was preventing netinit_thread() from running? Seems like a deadlock situation where something else is waiting for the network to come up, but it doesn't because netinit_thread() never gets a chance to run. This also explains why I had trouble hitting a breakpoint in netinit_thread(). There was nothing wrong with the debugger; rather that function never got a chance to run due to priorities... Thoughts? Cheers, Nathan