4.9.0 with shell via telnetd (SOLVED)

Gene Smith gds at chartertn.net
Mon Sep 29 20:14:24 UTC 2008


Alan,

Thanks for the code. To get a simple telnetd/pty to work in 4.9 I had to 
add/remove a few new things to my Init() marked below with + and - 
compared to 4.8. The key seems to be adding "NEEDS_LIBBLOCK" (link 
errors without) and reserving the dummy slot in the Device_drivers[] 
array for later addition of pty driver (PTY_DRIVER_TABLE_ENTRY causes 
link error to pty routines). So now I can telnet in again. Thanks for 
the pointers!
-gene

#include <bsp.h>
#include <rtems/pty.h>

#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 20
#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM

#define CONFIGURE_EXECUTIVE_RAM_SIZE (512*1024)
#define CONFIGURE_MAXIMUM_SEMAPHORES 20
#define CONFIGURE_MAXIMUM_TASKS      20

#define CONFIGURE_MICROSECONDS_PER_TICK 10000

#define CONFIGURE_INIT_TASK_STACK_SIZE (10*1024)
#define CONFIGURE_INIT_TASK_PRIORITY   120
#define CONFIGURE_INIT_TASK_INITIAL_MODES (RTEMS_PREEMPT | \
                                            RTEMS_NO_TIMESLICE | \
                                            RTEMS_NO_ASR | \
                                            RTEMS_INTERRUPT_LEVEL(0))
#define CONFIGURE_MAXIMUM_POSIX_TIMERS 5  /* tbd gds: XXX */
#define CONFIGURE_MAXIMUM_TIMERS 5
+#define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK   /* for telnet shell */


-/*#define CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE*/

#ifndef CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE
	#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
	#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+	#define CONFIGURE_APPLICATION_NEEDS_NULL_DRIVER	 /* pty here! */
#else
	rtems_driver_address_table Device_drivers[] = {
	    CONSOLE_DRIVER_TABLE_ENTRY,
	    CLOCK_DRIVER_TABLE_ENTRY,
	    PTY_DRIVER_TABLE_ENTRY  /* link fails */
	};
#endif
#define CONFIGURE_MAXIMUM_PTYS 2

#define CONFIGURE_INIT

rtems_task Init (rtems_task_argument argument);

#include <rtems/confdefs.h>

+/* needed for pty/telnetd? */
+#define CONFIGURE_SHELL_COMMANDS_INIT
+#define CONFIGURE_SHELL_COMMANDS_ALL
+#include <rtems/shellconfig.h>


#include <stdio.h>
#include <stdlib.h>
#include <rtems/rtems_bsdnet.h>
#include "networkconfig.h"
#include <rtems/telnetd.h>


void rtemsShell( char *pty_name, void *cmd_arg)
{
     rtems_shell_main_loop( NULL );
}
#define SHELL_ENTRY rtemsShell

/*
  * RTEMS Startup Task
  */
rtems_task
Init (rtems_task_argument ignored)
{
     rtems_bsdnet_initialize_network ();
     rtems_bsdnet_show_inet_routes ();
-    /*rtems_telnetd_initialize(); ---- harder with 4.9 */

+    /*
      * Starting the telnetd server
      */
+    printf("Starting the telnetd Server.\n");
+    rtems_telnetd_initialize(
         SHELL_ENTRY,               /* "shell" function */
         NULL,                      /* no context necessary for echoShell */
         FALSE,                     /* spawn a new thread */
         RTEMS_MINIMUM_STACK_SIZE * 20,  /* shell needs a large stack */
         1,                         /* priority .. we feel important 
today */
         0                          /* do not ask for password */
         );
<snip>
} /* END Init() */



Alan Cudmore wrote:
> This is what I use for telnetd and the shell in 4.9:
> 
>   void rtemsShell(
>     char *pty_name,
>     void *cmd_arg
>   )
>   {
>     rtems_shell_main_loop( NULL ); 
>   }
> 
>   #define SHELL_ENTRY rtemsShell
> 
> 
>    /*
>    ** Starting the telnetd server
>    */
>    printf("Starting the telnetd Server.\n");
>      rtems_telnetd_initialize(
>        SHELL_ENTRY,               /* "shell" function */
>        NULL,                      /* no context necessary for echoShell */
>        FALSE,                     /* spawn a new thread */
>        RTEMS_MINIMUM_STACK_SIZE * 20,  /* shell needs a large stack */
>        1,                         /* priority .. we feel important today */
>        0                          /* do not ask for password */
>       ); 
> 
> 
> Alan
> 
> 
> 
> On Sep 28, 2008, at 11:21 PM, Gene Smith wrote:
> 
>> The shell with telnetd in 4.8 works find. Just have to intialize telnetd
>> in Init() and it goes.
>>
>> However, with 4.9 the new improved shell has a documentation hole
>> regarding telnet. The shell manual says it easy to attach the shell to a
>> serial port or telnetd. However, how to do it with telnetd (a socket)
>> says TBD.
>>
>> Can someone list the steps needed to get telnetd running with the shell
>> in 4.9.0 ?
>>
>> Thanks,
>> -gene
>>
>> _______________________________________________
>> rtems-users mailing list
>> rtems-users at rtems.com 
>> <mailto:rtems-users at rtems.com>
>> http://rtems.rtems.org/mailman/listinfo/rtems-users
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> rtems-users mailing list
> rtems-users at rtems.com
> http://rtems.rtems.org/mailman/listinfo/rtems-users




More information about the users mailing list