xref: /freebsd/contrib/ntp/html/hints/vxworks.html (revision 2b15cb3d0922bd70ea592f0da9b4a5b167f4d53f)
1*2b15cb3dSCy Schubert<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2*2b15cb3dSCy Schubert
3*2b15cb3dSCy Schubert<html>
4*2b15cb3dSCy Schubert
5*2b15cb3dSCy Schubert	<head>
6*2b15cb3dSCy Schubert		<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
7*2b15cb3dSCy Schubert		<meta name="generator" content="HTML Tidy, see www.w3.org">
8*2b15cb3dSCy Schubert        <title>vxWorks Port of NTP</title>
9*2b15cb3dSCy Schubert		<link href="../scripts/style.css" type="text/css" rel="stylesheet">
10*2b15cb3dSCy Schubert	</head>
11*2b15cb3dSCy Schubert<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
12*2b15cb3dSCy Schubert
13*2b15cb3dSCy Schubert    <body link="#00008B" vlink="#8B0000">
14*2b15cb3dSCy Schubert        <h4>VxWorks port of NTP</h4>
15*2b15cb3dSCy Schubert<p>Last update:
16*2b15cb3dSCy Schubert  <!-- #BeginDate format:En2m -->21-Oct-2010  23:44<!-- #EndDate -->
17*2b15cb3dSCy Schubert  UTC</p>
18*2b15cb3dSCy Schubert        <p>Creating a port for vxWorks posed some problems. This port may help as a starting point for similar ports to real-time OS's and other embeddable kernels, particularly where <tt>main()</tt> is not allowed, and where the configure scripts need to be altered.</p>
19*2b15cb3dSCy Schubert        <h4>Configuration issues</h4>
20*2b15cb3dSCy Schubert        <p>I decided to do as little invasive surgery as possible on the NTP code, so I brought the vxWorks header tree in line with the standard Unix tree. The following changes were needed, as a side effect these changes will allow for easy porting of other autoconfigure enabled code.</p>
21*2b15cb3dSCy Schubert        <p>Where I have 386 you will need to put in your target type. The vxWorks tree entry point is <tt>/usr/wind</tt>. If these are the same for your system, you should be able to cut and paste the changes.</p>
22*2b15cb3dSCy Schubert        <p><blink>WARNING: Check you are not overwriting files, before entering the following: there should be no conflict, but check first...</blink></p>
23*2b15cb3dSCy Schubert		<pre>
24*2b15cb3dSCy Schubert            export CC=&quot;cc386 -nostdlib -m486 -DCPU=I80486 -I/usr/wind/target/h&quot;
25*2b15cb3dSCy Schubert            export RANLIB=ranlib386
26*2b15cb3dSCy Schubert            export AR=ar386
27*2b15cb3dSCy Schubert            export VX_KERNEL=/usr/wind/target/config/ims_std_bsp/vxWorks<br>
28*2b15cb3dSCy Schubert
29*2b15cb3dSCy Schubert            cd /usr/wind/target/sys
30*2b15cb3dSCy Schubert            ln -s ../signal.h
31*2b15cb3dSCy Schubert            ln -s ../time.h
32*2b15cb3dSCy Schubert            ln -s socket.h sockio.h
33*2b15cb3dSCy Schubert            ln -s ../selectLib.h select.h
34*2b15cb3dSCy Schubert            ln -s ../timers.h
35*2b15cb3dSCy Schubert            touch file.h param.h resource.h utsname.h var.h ../netdb.h ../a.out.h ../termios.h
36*2b15cb3dSCy Schubert         echo &quot; ******ADD #include \&quot;sys/times.h\&quot; to sys/time.h &quot;
37*2b15cb3dSCy Schubert            </pre>
38*2b15cb3dSCy Schubert		The configure script must be changed in the following way to get the linking tests to work, once in the correct directory issue the following commands:
39*2b15cb3dSCy Schubert
40*2b15cb3dSCy Schubert		<pre>      sed -e 's%main.*()%vxmain()%' configure &gt; configure.vxnew
41*2b15cb3dSCy Schubert            mv configure.vxnew configure
42*2b15cb3dSCy Schubert            chmod 755 configure
43*2b15cb3dSCy Schubert      </pre>
44*2b15cb3dSCy Schubert		<p></p>The new version 4 of NTP requires some maths functions so it links in the maths library (-lm) in the <tt>./ntpd/Makefile.am</tt> file change the line <tt>ntpd_LDADD = $(LDADD) -lm</tt> by removing the &quot;-lm&quot;.</p>
45*2b15cb3dSCy Schubert		 <p>>You are now ready to compile
46*2b15cb3dSCy Schubert		<p>The ./configure.in file needed to be altered to allow for a host-target configuration to take place.</p>
47*2b15cb3dSCy Schubert		<ul>
48*2b15cb3dSCy Schubert            <li>The define SYS_VXWORKS was added to the compilation flags.
49*2b15cb3dSCy Schubert            <li>Little endianess is set if the target is of type iX86.
50*2b15cb3dSCy Schubert            <li>The size of char, integer, long values are all set. If Wind River ever changes these values they will need to be updated.
51*2b15cb3dSCy Schubert            <li>clock_settime() is defined to be used for setting the clock.
52*2b15cb3dSCy Schubert            <li>The Linking flags have -r added to allow for relinking into the vxWorks kernel
53*2b15cb3dSCy Schubert        </ul>
54*2b15cb3dSCy Schubert        <p>Unfortunately I have had to make use of the <tt>./include/ntp_machine.h</tt> file to add in the checks that would have been checked at linking stage by <tt>autoconf</tt>, a better method should be devised.</p>
55*2b15cb3dSCy Schubert        <ul>
56*2b15cb3dSCy Schubert            <li>There is now a <tt>NO_MAIN_ALLOWED</tt> define that simulates command line args, this allows the use of the normal startup sysntax.
57*2b15cb3dSCy Schubert            <li>POSIX timers have been added.
58*2b15cb3dSCy Schubert            <li>Structures normally found in <tt>netdb.h</tt> have been added with, the corresponding code is in <tt>./libntp/machines.c</tt>. Where possible the defines for these have been kept non-vxWorks specific.
59*2b15cb3dSCy Schubert        </ul>
60*2b15cb3dSCy Schubert        <p>Unfortunately there are still quite a few <tt>SYS_VXWORKS</tt> type defines in the source, but I have eliminated as many as possible. You have the choice of using the <tt>usrtime.a</tt> library avaliable from the vxworks archives or forgoing <tt>adjtime()</tt> and using the <tt>clock_[get|set]time()</tt>. The <tt>./include/ntp_machine.h</tt> file clearly marks how to do this.</p>
61*2b15cb3dSCy Schubert        <h4>Compilation issues</h4>
62*2b15cb3dSCy Schubert        <p>You will need autoconf and automake ... available free from the gnu archives worldwide.</p>
63*2b15cb3dSCy Schubert        <p>The variable <tt>arch</tt> is the target architecture (e.g. i486)</p>
64*2b15cb3dSCy Schubert        <pre>
65*2b15cb3dSCy Schubert            mkdir A.vxworks)
66*2b15cb3dSCy Schubert            cd A.vxworks
67*2b15cb3dSCy Schubert            ../configure --target=arch-wrs-vxworks
68*2b15cb3dSCy Schubert            make
69*2b15cb3dSCy Schubert       </pre>
70*2b15cb3dSCy Schubert        <p>Options I normally use are the <tt>--disable-all-clocks --enable-LOCAL-CLOCK</tt> flags. The program should proceed to compile without problem. The daemon ntpd, ntpdate, ntptrace, ntpdc, ntpq programs and of course the libraries are all fully ported. The other utilities are not, but they should be easy to port.</p>
71*2b15cb3dSCy Schubert        <h4>Running the software</h4>
72*2b15cb3dSCy Schubert        <p>Load in the various files, call them in the normal vxWorks function type manner. Here are some examples. Refer to the man pages for further information.</p>
73*2b15cb3dSCy Schubert        <pre>
74*2b15cb3dSCy Schubert            ld &lt; ntpdate/ntpdate
75*2b15cb3dSCy Schubert            ld &lt; ntpd/ntpd
76*2b15cb3dSCy Schubert            ld &lt; ntptrace/ntptrace
77*2b15cb3dSCy Schubert            ld &lt; ntpq/ntpq
78*2b15cb3dSCy Schubert            ld &lt; ntpdc/ntpdc
79*2b15cb3dSCy Schubert            ntpdate (&quot;-b&quot;, &quot;192.168.0.245&quot;)
80*2b15cb3dSCy Schubert            sp(ntpd, &quot;-c&quot;, &quot;/export/home/casey/ntp/ntp.conf&quot;)
81*2b15cb3dSCy Schubert            ntpdc(&quot;-c&quot;, &quot;monlist&quot;, &quot;192.168.0.244&quot;)
82*2b15cb3dSCy Schubert            ntpq(&quot;-c&quot;, &quot;peers&quot;, &quot;192.168.0.244&quot;)
83*2b15cb3dSCy Schubert            ntptrace(&quot;192.168.0.244&quot;)
84*2b15cb3dSCy Schubert        </pre>
85*2b15cb3dSCy Schubert        <p>Casey Crellin, casey@csc.co.za</p>
86*2b15cb3dSCy Schubert    </body>
87*2b15cb3dSCy Schubert
88*2b15cb3dSCy Schubert</html>
89