1258945Sroberto<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2258945Sroberto 3258945Sroberto<html> 4258945Sroberto 5258945Sroberto <head> 6258945Sroberto <meta http-equiv="content-type" content="text/html;charset=iso-8859-1"> 7258945Sroberto <meta name="generator" content="HTML Tidy, see www.w3.org"> 8258945Sroberto <title>vxWorks Port of NTP</title> 9258945Sroberto <link href="../scripts/style.css" type="text/css" rel="stylesheet"> 10258945Sroberto </head> 11258945Sroberto<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 12258945Sroberto 13258945Sroberto <body link="#00008B" vlink="#8B0000"> 14258945Sroberto <h4>VxWorks port of NTP</h4> 15275970Scy<p>Last update: 16275970Scy <!-- #BeginDate format:En2m -->21-Oct-2010 23:44<!-- #EndDate --> 17275970Scy UTC</p> 18258945Sroberto <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> 19258945Sroberto <h4>Configuration issues</h4> 20258945Sroberto <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> 21258945Sroberto <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> 22258945Sroberto <p><blink>WARNING: Check you are not overwriting files, before entering the following: there should be no conflict, but check first...</blink></p> 23258945Sroberto <pre> 24258945Sroberto export CC="cc386 -nostdlib -m486 -DCPU=I80486 -I/usr/wind/target/h" 25258945Sroberto export RANLIB=ranlib386 26258945Sroberto export AR=ar386 27258945Sroberto export VX_KERNEL=/usr/wind/target/config/ims_std_bsp/vxWorks<br> 28258945Sroberto 29258945Sroberto cd /usr/wind/target/sys 30258945Sroberto ln -s ../signal.h 31258945Sroberto ln -s ../time.h 32258945Sroberto ln -s socket.h sockio.h 33258945Sroberto ln -s ../selectLib.h select.h 34258945Sroberto ln -s ../timers.h 35258945Sroberto touch file.h param.h resource.h utsname.h var.h ../netdb.h ../a.out.h ../termios.h 36258945Sroberto echo " ******ADD #include \"sys/times.h\" to sys/time.h " 37258945Sroberto </pre> 38258945Sroberto 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: 39258945Sroberto 40258945Sroberto <pre> sed -e 's%main.*()%vxmain()%' configure > configure.vxnew 41258945Sroberto mv configure.vxnew configure 42258945Sroberto chmod 755 configure 43258945Sroberto </pre> 44258945Sroberto <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 "-lm".</p> 45258945Sroberto <p>>You are now ready to compile 46258945Sroberto <p>The ./configure.in file needed to be altered to allow for a host-target configuration to take place.</p> 47258945Sroberto <ul> 48258945Sroberto <li>The define SYS_VXWORKS was added to the compilation flags. 49258945Sroberto <li>Little endianess is set if the target is of type iX86. 50258945Sroberto <li>The size of char, integer, long values are all set. If Wind River ever changes these values they will need to be updated. 51258945Sroberto <li>clock_settime() is defined to be used for setting the clock. 52258945Sroberto <li>The Linking flags have -r added to allow for relinking into the vxWorks kernel 53258945Sroberto </ul> 54258945Sroberto <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> 55258945Sroberto <ul> 56258945Sroberto <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. 57258945Sroberto <li>POSIX timers have been added. 58258945Sroberto <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. 59258945Sroberto </ul> 60258945Sroberto <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> 61258945Sroberto <h4>Compilation issues</h4> 62258945Sroberto <p>You will need autoconf and automake ... available free from the gnu archives worldwide.</p> 63258945Sroberto <p>The variable <tt>arch</tt> is the target architecture (e.g. i486)</p> 64258945Sroberto <pre> 65258945Sroberto mkdir A.vxworks) 66258945Sroberto cd A.vxworks 67258945Sroberto ../configure --target=arch-wrs-vxworks 68258945Sroberto make 69258945Sroberto </pre> 70258945Sroberto <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> 71258945Sroberto <h4>Running the software</h4> 72258945Sroberto <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> 73258945Sroberto <pre> 74258945Sroberto ld < ntpdate/ntpdate 75258945Sroberto ld < ntpd/ntpd 76258945Sroberto ld < ntptrace/ntptrace 77258945Sroberto ld < ntpq/ntpq 78258945Sroberto ld < ntpdc/ntpdc 79258945Sroberto ntpdate ("-b", "192.168.0.245") 80258945Sroberto sp(ntpd, "-c", "/export/home/casey/ntp/ntp.conf") 81258945Sroberto ntpdc("-c", "monlist", "192.168.0.244") 82258945Sroberto ntpq("-c", "peers", "192.168.0.244") 83258945Sroberto ntptrace("192.168.0.244") 84258945Sroberto </pre> 85258945Sroberto <p>Casey Crellin, casey@csc.co.za</p> 86258945Sroberto </body> 87258945Sroberto 88275970Scy</html> 89