November 27, 2026

Kyu - Telnet -- a diversion

Having done nothing at all with Kyu and networking for about 10 months, I got the idea that it would be very handy to have a telnet server running as part of Kyu. I will be working with Kyu on an H3 board (OrangePi) since that is stable and well tested.

TFTP

This is another diversion along the way. I need to start a TFTP server running on my linux host to aid and abet Kyu.
su
dnf install tftp-server -y
systemctl start tftp.service
systemctl enable tftp.service
firewall-cmd --add-service=tftp --permanent
firewall-cmd --reload
firewall-cmd --list-services
dhcpv6-client ftp http mdns nut samba ssh tftp
It turns out this was already up and running. I have issues on the Kyu side.

Nothing works!

The immortal words of a fellow I used to work with. I try running a TCP echo test and get a data abort in Kyu with traceback. The traceback would be much more informative if the symbol table was loaded. This was the reason for needlessly reinstalling and restarting the TFTP server. Kyu simply says:
TFTP server not listening
fetched symbol table: 0 bytes
The system does respond to ping, so things are not entirely broken. I use the "n" menu in Kyu to perform network tests. I find that DHCP, BOOTP, and TFTP all work when launched from the test menu. Why is TFTP failing when called from the regular bootup sequence?

I add an entry to the "n" menu to call shell_init() which is what attempts to fetch the symbol table. If I do a "n 4" first to test DHCP (which works), then do a "n 8" to fetch the symbol table, it works.

Now, with the symbol table loaded, I try "t 4" to try launching the TCP echo server. I get:

Called from sem_block+24 -- 40015044
Called from user_lock+2c -- 40028f30
Called from tcp_bind+14 -- 400372a0
Called from echo_thread+18 -- 4003830c
Called from thr_exit -- 400137f0
The call to "thr_exit" at the bottom of the stack is normal. Every thread is set up so that if it returns, it will return to thr_exit(). Here we see the call to tcp_bind failing as it tries to acquire the "user_lock".

The problem is a configuration error. I see this in kyu.h

// #define WANT_TCP_XINU
// #define WANT_TCP_BSD
// #define WANT_TCP_KYU
#define WANT_TCP_NONE
I am pretty sure that I disabled all TCP when I was compiling and linking Kyu to see what the "small footprint" size would be without TCP. Just fiddling this parameter does not change the linked size. The Makefile also needs to be changed, otherwise the TCP routines get linked in, but never called.

Recompiling with WANT_TCP_BSD gets things working. It might be good to put some basic sanity checks in the top level routines like tcp_bind, tcp_accept, and tcp_connect to display a polite error message if TCP is not configured.

With my first cut at a telnet server running, the thread list looks like this:

  Thread:       name (  &tp   )    state     sem       pc       sp     pri
  Thread:    blinker (400aaf2c)  REPEAT I          40014998 40580000   10
  Thread:      shell (400ab864)   READY I          400056bc 4056c000   11
  Thread:     net-in (400ab4b4)     SEM I  net-inq 40014994 40574000   20
  Thread:    net-out (400ab3c8)     SEM J net-outq 400144f4 40576000   21
  Thread:  net-timer (400ab2dc)  REPEAT I          40014998 40578000   22
  Thread:  tcp-input (400ab68c)     SEM J  tcp-inq 400144f4 40570000   24
* Thread:  tcp-timer (400ab5a0)   READY I          40014998 40572000   25
  Thread: telnet-server (400ab1f0)     SEM I   socket 40014994 4057a000   27
  Thread:       idle (400ab778)   READY C          400149f0 4056e000 1234
And regular telnet connects to it. It is just an echo server at this stage. It does get typed characters one at a time. At least it did during initial testing, but when I add the code to process the IAC info, I get line by line (which is nicer perhaps).


Have any comments? Questions? Drop me a line!

Tom's electronics pages / tom@mmto.org