RTEMS Network Adapter Porting - network shell command introduction and enable

The network adapter driver part is not included in RTEMS for BBB board BSP. And TCP / IP protocol stack is not enabled by default.
So to transplant the entire network to bbb board, the first thing to do is to enable tcp / ip protocol stack. And then enable these network commands.


Step 1: Enable the tcp / ip protocol stack:

When compile RTEMS source code, the network stack is disable by default. So how to enable TCP/IP stack:

We can read the RTEMS source code configure file:


  1. Optional Features:  
  2.   --disable-option-checking  ignore unrecognized --enable/--with options  
  3.   --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)  
  4.   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]  
  5.   --enable-maintainer-mode  
  6.                           enable make rules and dependencies not useful (and  
  7.                           sometimes confusing) to the casual installer  
  8.   --enable-multiprocessing  
  9.                           enable multiprocessing interface; the  
  10.                           multiprocessing interface is a communication  
  11.                           interface between different RTEMS instances and  
  12.                           allows synchronization of objects via message  
  13.                           passing  
  14.   --enable-posix          enable posix interface  
  15.   --enable-networking     enable TCP/IP stack  
  16.   --enable-cxx            enable C++ support  
  17.   --enable-tests          enable tests (default:samples)  
  18.   --enable-rtems-debug    enable RTEMS_DEBUG  
  19.   --enable-rtemsbsp="bsp1 bsp2 .."  
  20.                           BSPs to include in build  
  21.   --enable-multilib       build many library versions (default=no)  
  22.   --enable-paravirt       enable support for paravirtualization (default=no)  
  23.   --enable-drvmgr         enable Driver Manager at Startup  
  24.   --enable-docs           enable building documentation (default:disabled)  


So when compiling the code, add the --enable networking --enable posix after the configure.




Step 2: Enable the network-related shell command:

RTEMS shell command contain network-related commands such as ping, ifconfig, netstats, etc.
So when you enter the system shell, enter help all, there will be enabled shell command, which can not find the ping , Ifconfig and so on. In the source code, you can search these network command source and implementation, as shown below:



So how to enable the network command is the key issue, the first thing to be clear is that the implementation of the command is related to the driver, but the command is independent of the Internet driver.

download the shell of the document at the official website, which describes the network is like this:

  1. The command set available to the application is user configurable. It is configured using a  
  2. mechanism similar to the confdefs.h mechanism used to specify application configuration.  
  3. In the simplest caseif the user wishes to configure a command set with all commands avail-  
  4. able that are neither filesystem management (e.g. mounting, formating, etc.) or network  
  5. related, then the following is all that is required:  
  6. #define CONFIGURE_SHELL_COMMANDS_INIT  
  7. #define CONFIGURE_SHELL_COMMANDS_ALL  
  8. #include <rtems/shellconfig.h>  
  9. In a slightly more complex example, if the user wishes to include all networking commands  
  10. as well as support for mounting MS-DOS and NFS filesystems, then the following is all that  
  11. is required:  
  12. #define CONFIGURE_SHELL_COMMANDS_INIT  
  13. #define CONFIGURE_SHELL_COMMANDS_ALL  
  14. #define CONFIGURE_SHELL_MOUNT_MSDOS  
  15. #define CONFIGURE_SHELL_MOUNT_NFS  
  16.   
  17. #include <rtems/shellconfig.h>  

This means that if you want to implement the network command to define these four variables, and to include the shellconfig.h header file, but did not specify which should be placed in the file.

The next section gives answers to these questions:

This means that if the user wants to configure the command, define the corresponding command.

See here is more clear, that is to say if you want to configure the ping command, it is necessary in the configuration file, defined as follows:

#define CONFIGURE_SHELL_COMMAND_PING

In other words, in the rki folder, include the following command in the include header file, rtems_config.h:

#define CONFIGURE_SHELL_COMMANDS_INIT
#define CONFIGURE_SHELL_COMMANDS_ALL
#define CONFIGURE_SHELL_MOUNT_RFS
#define CONFIGURE_SHELL_MOUNT_MSDOS
#define CONFIGURE_SHELL_MOUNT_NFS //c add
#define CONFIGURE_SHELL_COMMAND_IFCONFIG
#define CONFIGURE_SHELL_COMMAND_ROUTE
#define CONFIGURE_SHELL_COMMAND_PING
#define CONFIGURE_SHELL_COMMAND_NETSTATS

#include <rtems/shellconfig.h>



The following posted my own rtems_config.h file content:


  1. /* 
  2. ** rtems_config.h 
  3. ** 
  4. **  Author:  Alan Cudmore 
  5. ** 
  6. **  This contains the configuration settings for an RTEMS Application 
  7. ** 
  8. */  
  9.   
  10. /* 
  11. ** RTEMS Includes 
  12. */  
  13. #include <rtems.h>  
  14.   
  15. #include <bsp.h>  
  16.   
  17. #ifdef RKI_INCLUDE_MONITOR  
  18.    #include <rtems/monitor.h>  
  19. #endif  
  20.   
  21. #ifdef RKI_INCLUDE_TARFS  
  22.    #include <rtems/untar.h>  
  23. #endif  
  24.   
  25. #include <rtems/mkrootfs.h>  
  26.   
  27.   
  28. /* 
  29. ** RTEMS OS Configuration defintions 
  30. */  
  31. #define TASK_INTLEVEL 0  
  32. #define CONFIGURE_INIT  
  33. #define CONFIGURE_INIT_TASK_ATTRIBUTES  (RTEMS_FLOATING_POINT | RTEMS_PREEMPT | RTEMS_NO_TIMESLICE | RTEMS_ASR | RTEMS_INTERRUPT_LEVEL(TASK_INTLEVEL))  
  34. #define CONFIGURE_INIT_TASK_STACK_SIZE  (32*1024)  
  35. #define CONFIGURE_INIT_TASK_PRIORITY    120  
  36.   
  37. #define CONFIGURE_MAXIMUM_TASKS                       128  
  38. #define CONFIGURE_MAXIMUM_TIMERS                        5  
  39. #define CONFIGURE_MAXIMUM_SEMAPHORES                  512  
  40. #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES              128  
  41.   
  42. /* POSIX Keys are needed for the Shell */  
  43. #define CONFIGURE_MAXIMUM_POSIX_KEYS                   32  
  44. #define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS        64  
  45.   
  46. #define CONFIGURE_MAXIMUM_PARTITIONS                   2  
  47.   
  48. #define CONFIGURE_EXECUTIVE_RAM_SIZE    ( 1024 * 1024 )  
  49.   
  50. #define CONFIGURE_RTEMS_INIT_TASKS_TABLE  
  51. #define CONFIGURE_MAXIMUM_DRIVERS                     10  
  52. #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER  
  53. #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER  
  54.   
  55. #define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM  
  56. #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS     200  
  57. #define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK  
  58. #define CONFIGURE_SWAPOUT_TASK_PRIORITY               10  
  59.   
  60.   
  61.   
  62. #define CONFIGURE_SHELL_COMMANDS_INIT  
  63. #define CONFIGURE_SHELL_COMMANDS_ALL  
  64. #define CONFIGURE_SHELL_MOUNT_RFS  
  65. #define CONFIGURE_SHELL_MOUNT_MSDOS  
  66. #define CONFIGURE_SHELL_MOUNT_NFS //c add  
  67. #define CONFIGURE_SHELL_COMMAND_IFCONFIG  
  68. #define CONFIGURE_SHELL_COMMAND_ROUTE  
  69. #define CONFIGURE_SHELL_COMMAND_PING  
  70. #define CONFIGURE_SHELL_COMMAND_NETSTATS  
  71.   
  72. #include <rtems/shellconfig.h>  
  73.   
  74. #define CONFIGURE_MICROSECONDS_PER_TICK              10000  
  75.   
  76. #define CONFIGURE_STACK_CHECKER_ENABLED  
  77.   
  78. #define CONFIGURE_MAXIMUM_USER_EXTENSIONS     1  
  79.   
  80.   
  81. /* 
  82. ** Filesystems needed 
  83. */  
  84. /* IMFS and RFS will always be used */  
  85. #define CONFIGURE_FILESYSTEM_IMFS  
  86. #define CONFIGURE_FILESYSTEM_RFS  
  87. #define CONFIGURE_FILESYSTEM_TFTPFS  
  88. #define CONFIGURE_FILESYSTEM_MSDOS  
  89.   
  90. /* 
  91. ** Init task prototype 
  92. */  
  93. rtems_task Init (rtems_task_argument argument);  
  94.   
  95. /* 
  96. ** This include file must be AFTER the 
  97. ** configuration data. 
  98. */  
  99. #include <rtems/confdefs.h>  


The command working as follow:








评论

此博客中的热门博文

RTEMS-libbsd generates drive device firmware

RTEMS Network Transplantation - rtems system initialization process analysis

Add wpa_supplicant_fork command on RTEMS-libbsd