2011/01/28

ntpclient on Trident pnx84xx

0. Prepare trident build environment
# cd /PATH/TO/TRIDENT/SRC
# source pnx8400_MP_env.sh


1. Download latest ntpclient source codes from official website.



# wget http://doolittle.icarus.com/ntpclient/ntpclient_2010_365.tar.gz
# tar -zxvf ntpclient_2010_365.tar.gz
# cd ntpclient-2010

2. Modify the Makefile for Trident pnx84xx.

# vi Makefile

# A long time ago, far, far away, under Solaris, you needed to
#    CFLAGS += -xO2 -Xc
#    LDLIBS += -lnsl -lsocket
# To cross-compile
CC = arm-linux-gcc
CFLAGS += --sysroot=$(_TMSYSROOT)
LDFLAGS+= --sysroot=$(_TMSYSROOT)

# To check for lint
#    CFLAGS += -Wpointer-arith -Wcast-align -Wcast-qual -Wshadow -Wundef \
#     -Waggregate-return -Wnested-externs -Winline -Wwrite-strings -Wstrict-prototypes

# This is old-school networking code, making the traditional cast between
# struct sockaddr* and struct sockaddr_in*.  Thus a modern gcc needs:
CFLAGS += -fno-strict-aliasing

CFLAGS += -std=c89
CFLAGS += -W -Wall
CFLAGS += -O2
# CFLAGS += -DPRECISION_SIOCGSTAMP
CFLAGS += -DENABLE_DEBUG
CFLAGS += -DENABLE_REPLAY
# CFLAGS += -DUSE_OBSOLETE_GETTIMEOFDAY

LDFLAGS += -lrt

all: ntpclient

test: ntpclient
        ./ntpclient -d -r <test.dat

ntpclient: ntpclient.o phaselock.o

ntpclient.o phaselock.o: ntpclient.h

adjtimex: adjtimex.o

clean:
        rm -f ntpclient adjtimex *.o

# make
arm-linux-gcc --sysroot=/usr/local/apollo/SRC/open_source_archive/linux/toolchains/gnu_cortex-a9_tools -fno-strict-aliasing -std=c89 -W -Wall -O2 -DENABLE_DEBUG -DENABLE_REPLAY   -c -o ntpclient.o ntpclient.c
arm-linux-gcc --sysroot=/usr/local/apollo/SRC/open_source_archive/linux/toolchains/gnu_cortex-a9_tools -fno-strict-aliasing -std=c89 -W -Wall -O2 -DENABLE_DEBUG -DENABLE_REPLAY   -c -o phaselock.o phaselock.c
arm-linux-gcc --sysroot=/usr/local/apollo/SRC/open_source_archive/linux/toolchains/gnu_cortex-a9_tools -lrt  ntpclient.o phaselock.o   -o ntpclient
/usr/local/apollo/SRC/open_source_archive/linux/toolchains/gnu_cortex-a9_tools/lib/libpthread.so.0: warning: the use of `mktemp' is dangerous, better use `mkstemp'

# file ntpclient
ntpclient: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), not stripped

DONE !

PS.
In case you have to use some earlier version, you may have below issue.

ntpclient.o: In function `set_freq':
ntpclient.c:(.text+0x18): undefined reference to `__adjtimex'
ntpclient.o: In function `main':
ntpclient.c:(.text+0xc58): undefined reference to `__adjtimex'
collect2: ld returned 1 exit status
make: *** [ntpclient] Error 1

Try to replace __adjtimex by adjtimex in ntpclient.c

-----

沒有留言: