1 | .. SPDX-License-Identifier: CC-BY-SA-4.0 |
---|
2 | |
---|
3 | .. Copyright (C) 2020 Chris Johns |
---|
4 | |
---|
5 | .. _Migration_4_11_to_5: |
---|
6 | |
---|
7 | RTEMS 4.11 to RTEMS 5 |
---|
8 | ===================== |
---|
9 | |
---|
10 | This section provides helpful information when migrating from RTEMS 4.11 to |
---|
11 | RTEMS 5. |
---|
12 | |
---|
13 | Configuration |
---|
14 | ------------- |
---|
15 | |
---|
16 | A number of configurations macros have moved as a result of internal changes in |
---|
17 | RTEMS. Some of these will produce a warning indicating the new configuration |
---|
18 | setings you need to define. If you need to run an application on RTEMS 4.11 and |
---|
19 | RTEMS 5 the following code exmaple shows how to conditionally define the |
---|
20 | settings. 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 | |
---|
40 | Networking |
---|
41 | ---------- |
---|
42 | |
---|
43 | The following code samples provides a simple way to initialise and start |
---|
44 | networking with the BSD Library's (``libbsd``) networking stack. The simplest |
---|
45 | method to configure the networking stack is to provide a :file:`/etc/rc,conf` |
---|
46 | file on your target. If your target has no non-volatile media for a file system |
---|
47 | create the :file:`rc.conf` file each time your application starts. |
---|
48 | |
---|
49 | The :file:`rc.conf` support in ``libbsd`` provides a number of needed support |
---|
50 | settings. We recommend you search for FreeBSD and ``rc.conf`` to view the |
---|
51 | available online documentation that FreeBSD provides. |
---|
52 | |
---|
53 | In this example the network interface is ``cgem0``, replace with your |
---|
54 | interface 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 | } |
---|