How to print to a telnet terminal in AVH?

Hello!
I am running a FreeRTOS TCP Echo Server example on a Arm Virtual Hardware target. The echo part works perfectly, however, I would like to print out the amount of ticks it took to run the client echo from xTaskGetTickCount() in the telnet terminal that the virtual target is hosted on but the printf() does not seem to print anything in my case when the echo is done.

Here is the code for the FreeRTOS TCP Server part:

static void
tcpecho_thread(void *arg)
{
  struct netconn *conn, *newconn;
  err_t err;
  LWIP_UNUSED_ARG(arg);

  /* Create a new connection identifier. */
  /* Bind connection to well known port number 7. */
#if LWIP_IPV6
  conn = netconn_new(NETCONN_TCP_IPV6);
  netconn_bind(conn, IP6_ADDR_ANY, 7);
#else /* LWIP_IPV6 */
  conn = netconn_new(NETCONN_TCP);
  netconn_bind(conn, IP_ADDR_ANY, 7);
#endif /* LWIP_IPV6 */
  LWIP_ERROR("tcpecho: invalid conn", (conn != NULL), return;);

  /* Tell connection to go into listening mode. */
  netconn_listen(conn);

  while (1) {
    
		long start = xTaskGetTickCount();
    /* Grab new connection. */
    err = netconn_accept(conn, &newconn);
    /*printf("accepted new connection %p\n", newconn);*/
    /* Process the new connection. */
    if (err == ERR_OK) {
      struct netbuf *buf;
      void *data;
      u16_t len;

      while ((err = netconn_recv(newconn, &buf)) == ERR_OK) {
        /*printf("Recved\n");*/
        do {
             netbuf_data(buf, &data, &len);
             err = netconn_write(newconn, data, len, NETCONN_COPY);
#if 0
            if (err != ERR_OK) {
              printf("tcpecho: netconn_write: error \"%s\"\n", lwip_strerr(err));
            }
#endif
        } while (netbuf_next(buf) >= 0);
        netbuf_delete(buf);
      }
      /*printf("Got EOF, looping\n");*/
      /* Close connection and discard connection identifier. */
      netconn_close(newconn);
      netconn_delete(newconn);
			
			long stop = xTaskGetTickCount(); //test get tick counter
			long time= start- stop;
      PRINTF("%d The number of ticks is ",time );
    }
  }
}

Whenever I run the TCP Server code on the virtual target the telnet terminal seem to appear frozen but I’m not quite sure if that is the case or it is just not receiving any outputs. The Client part is ran on the Ubuntu Host as a python script.

I’m not familiar with your setup so can’t offer specific advice, but my first suggestion is to ensure printf() works as expected outside of a FreeRTOS application, so from main().

I’m sorry if the explanation was a bit confusing. Basically I have a virtual host machine which is ran on Ubuntu that i SSH into twice and in one of the terminals I run the code mentioned above but targeted towards a virtual Cortex-M4 processor that listens to the ports 5000-5002, I’ll try to insert a picture.
tcp

After running the server code, I then run a client python script in the second terminal that sends some random strings and wait for it to echo back. My goal here is too print out the number of ticks this echo took in the server terminal (as seen in the picture) and not in the client terminal, I hope that makes it a bit more clear. I have been able to accomplish this on my local PC through an IDE but for some reason it’s not printing out to the telnet terminal on the virtual machine.

From the information I’ve gathered it seems like I have to do some sort of retargeting and make the stdout to go through USART instead. I’ve tried following this example without much success
(I/O Retargeting: Retarget Input and Output via UART). I found this example from ARM themselves and they were able to use printf() to print directly to the telnet terminal by retargeting. (AVH-GetStarted/main.c at main · ARM-software/AVH-GetStarted · GitHub). I’ve included my project below if there is possibly someone that could help me out. The project can be found in tcpecho\boards\frdmk64f\lwip_examples\lwip_tcpecho\freertos\mdk. The printf() are located in lwip/contrib/apps/tcpecho on lines 62-94.

Hi @mdang. It seems to me this is more about how to configure AVH to output to proper destinations. Can you try reaching out to AVH forum? I think they will be able to better help you with this issue.