source: rtems-docs/user/migration/v4_11-to-v5.rst @ 4726207

5
Last change on this file since 4726207 was 4726207, checked in by Chris Johns <chrisj@…>, on 03/12/20 at 07:04:25

user: Add a migration chapter

This is a start with the hope we collect useful pieces to aid porting.
Please add to this.

Closes #3895

  • Property mode set to 100644
File size: 2.7 KB
Line 
1.. SPDX-License-Identifier: CC-BY-SA-4.0
2
3.. Copyright (C) 2020 Chris Johns
4
5.. _Migration_4_11_to_5:
6
7RTEMS 4.11 to RTEMS 5
8=====================
9
10This section provides helpful information when migrating from RTEMS 4.11 to
11RTEMS 5.
12
13Configuration
14-------------
15
16A number of configurations macros have moved as a result of internal changes in
17RTEMS. Some of these will produce a warning indicating the new configuration
18setings you need to define. If you need to run an application on RTEMS 4.11 and
19RTEMS 5 the following code exmaple shows how to conditionally define the
20settings. The example is:
21
22.. code-block:: c
23
24    #include <rtems.h>
25
26    #if __RTEMS_MAJOR__ < 5
27     #define CONFIGURE_MAXIMUM_FIFOS 10
28     #define CONFIGURE_MAXIMUM_PIPES 10
29    #else
30     #define CONFIGURE_IMFS_ENABLE_MKFIFO
31    #endif
32
33    #define MAX_FILE_DESCRIPTORS 200
34    #if __RTEMS_MAJOR__ < 5
35     #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS MAX_FILE_DESCRIPTORS
36    #else
37     #define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS       MAX_FILE_DESCRIPTORS
38    #endif
39
40Networking
41----------
42
43The following code samples provides a simple way to initialise and start
44networking with the BSD Library's (``libbsd``) networking stack. The simplest
45method to configure the networking stack is to provide a :file:`/etc/rc,conf`
46file on your target. If your target has no non-volatile media for a file system
47create the :file:`rc.conf` file each time your application starts.
48
49The :file:`rc.conf` support in ``libbsd`` provides a number of needed support
50settings. We recommend you search for FreeBSD and ``rc.conf`` to view the
51available online documentation that FreeBSD provides.
52
53In this example the network interface is ``cgem0``, replace with your
54interface name.
55
56.. code-block:: c
57
58    static const char* rc_conf =
59      "# /etc/rc.conf\n" \
60      "hostname=\"rtems5-libbsd\"\n" \
61      "ifconfig_cgem0=\"inet 10.1.2.3 netmask 255.255.255.0 rxcsum txcsum\"\n" \
62      "ifconfig_cgem0_alias0=\"ether 00:80:81:82:83:84\"\n" \
63      "defaultrouter=\"10.1.2.1\"\n" \
64      "telnetd_enable=\"YES\"\n";
65
66    void start_network(void)
67    {
68      FILE *rc;
69      int   r;
70
71      /*
72       * Initialise libbsd.
73       */
74      rtems_bsd_initialize();
75
76      /*
77       * Create the /etc/rc,conf, assume /etc exists.
78       */
79      rc = fopen("/etc/rc.conf", "w");
80      if (rc_conf == NULL) {
81        printf("error: cannot create /etc/rc.conf\n");
82        exit(1);
83      }
84
85      fprintf(rc, rc_conf);
86      fclose(rc);
87
88      /*
89       * Arguments are timeout and trace
90       */
91      r = rtems_bsd_run_etc_rc_conf(30, false);
92      if (r < 0) {
93        printf("error: loading /etc/rc.conf failed: %s\n",strerror(errno));
94        exit(1);
95      }
96    }
Note: See TracBrowser for help on using the repository browser.