4.9.0 with shell via telnetd - new telnetd issue?
Robert S. Grimes
rsg at alum.mit.edu
Thu Dec 18 23:11:02 UTC 2008
Gene Smith wrote:
> 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
>>
All,
Okay, I got it working, following Alan's example, plus "LD_LIBS +=
-ltelnetd", plus this:
+/* needed for pty/telnetd? */
+#define CONFIGURE_SHELL_COMMANDS_INIT
+#define CONFIGURE_SHELL_COMMANDS_ALL
+#include <rtems/shellconfig.h>
as noted by Gene. I didn't have to make the other changes, Gene, but then again, I had some things already - like NEEDS_LIBBLOCK.
However, when I say ugly, this is what I see.
Welcome to rtems-4.9.0(PowerPC/Generic (no FPU)/virtex)
COPYRIGHT (c) 1989-2008.
On-Line Applications Research Corporation (OAR).
Login into RTEMS
login: rrtteemmss
Password:
RTEMS SHELL (Ver.1.0-FRC):. Sep 26 2008. 'help' to list commands.
[/] $
Note the login response - what I typed was this "rtems<cr>", where "<cr>" is the enter key. While it at first glance looked like local echo is on, notice that I only hit the enter key _once_, yet the shell has seen two; the second is consumed by the Password prompt. So what gives? Seems like something with telnetd - how do I fix this? I'm sure it is something trivial, yet rather important...
Thanks,
-Bob
More information about the users
mailing list