[PATCH rtems-lwip v1 7/8] lwip.py: Add NTP library build

Kinsey Moore kinsey.moore at oarcorp.com
Tue Aug 23 19:47:40 UTC 2022


---
 lwip.py                     | 24 ++++++++++
 ntp-file-import.yaml        | 92 +++++++++++++++++++++++++++++++++++++
 rtemslwip/zynqmp/lwipopts.h | 19 +++++++-
 3 files changed, 134 insertions(+), 1 deletion(-)
 create mode 100644 ntp-file-import.yaml

diff --git a/lwip.py b/lwip.py
index 627d88c..2eccb0b 100644
--- a/lwip.py
+++ b/lwip.py
@@ -60,9 +60,13 @@ xilinx_aarch64_driver_source = [
 
 def build(bld):
     source_files = []
+    ntp_source_files = []
+    ntp_incl = ''
     common_includes = './lwip/src/include ./uLan/ports/os/rtems ./rtemslwip/include '
     driver_source = []
     drv_incl = ' '
+    bsd_compat_sources = ["rtemslwip/bsd_compat/netdb.c", "rtemslwip/bsd_compat/ifaddrs.c", "rtemslwip/bsd_compat/rtems-kernel-program.c"]
+    bsd_compat_incl = './rtemslwip/bsd_compat_include '
 
     arch_lib_path = rtems.arch_bsp_lib_path(bld.env.RTEMS_VERSION,
                                             bld.env.RTEMS_ARCH_BSP)
@@ -77,6 +81,13 @@ def build(bld):
     source_files.append('./rtemslwip/common/rtems_lwip_io.c')
     source_files.append('./rtemslwip/common/network_compat.c')
 
+    with open('ntp-file-import.yaml', 'r') as cf:
+        files = yaml.full_load(cf.read())
+        for f in files['source-files-to-import']:
+            ntp_source_files.append(os.path.join('./sebhbsd', f))
+        for f in files['header-paths-to-import']:
+            ntp_incl += os.path.join('./sebhbsd', f) + ' '
+
     def walk_sources(path):
         sources = []
         for root, dirs, files in os.walk(path):
@@ -139,6 +150,19 @@ def build(bld):
         use=['lwip_obj', 'driver_obj'])
     bld.install_files("${PREFIX}/" + arch_lib_path, ["liblwip.a"])
 
+    bld(features ='c',
+        target='ntp_obj',
+        cflags='-g -Wall -O0 -DHAVE_CONFIG_H=1',
+        includes=ntp_incl + drv_incl + bsd_compat_incl + common_includes,
+        source=ntp_source_files + bsd_compat_sources,
+        )
+
+    bld(features='c cstlib',
+        target = 'ntp',
+        cflags='-g -Wall -O0 -DHAVE_CONFIG_H=1',
+        use=['ntp_obj'])
+    bld.install_files("${PREFIX}/" + arch_lib_path, ["libntp.a"])
+
     def install_headers(root_path):
         for root, dirs, files in os.walk(root_path):
             for name in files:
diff --git a/ntp-file-import.yaml b/ntp-file-import.yaml
new file mode 100644
index 0000000..5e4e8a4
--- /dev/null
+++ b/ntp-file-import.yaml
@@ -0,0 +1,92 @@
+header-paths-to-import:
+    - freebsd/contrib/ntp/include
+    - freebsd/contrib/ntp/lib/isc/include
+    - freebsd/contrib/ntp/lib/isc/pthreads/include
+    - freebsd/contrib/ntp/lib/isc/unix/include
+    - freebsd/contrib/ntp/sntp/libopts
+    - rtemsbsd/include
+source-files-to-import:
+    - freebsd/contrib/ntp/lib/isc/assertions.c
+    - freebsd/contrib/ntp/lib/isc/error.c
+    - freebsd/contrib/ntp/lib/isc/hmacsha.c
+    - freebsd/contrib/ntp/lib/isc/iterated_hash.c
+    - freebsd/contrib/ntp/lib/isc/lib.c
+    - freebsd/contrib/ntp/lib/isc/log.c
+    - freebsd/contrib/ntp/lib/isc/netaddr.c
+    - freebsd/contrib/ntp/lib/isc/nls/msgcat.c
+    - freebsd/contrib/ntp/lib/isc/pthreads/mutex.c
+    - freebsd/contrib/ntp/lib/isc/result.c
+    - freebsd/contrib/ntp/lib/isc/sha1.c
+    - freebsd/contrib/ntp/lib/isc/sockaddr.c
+    - freebsd/contrib/ntp/lib/isc/unix/dir.c
+    - freebsd/contrib/ntp/lib/isc/unix/errno2result.c
+    - freebsd/contrib/ntp/lib/isc/unix/file.c
+    - freebsd/contrib/ntp/lib/isc/unix/interfaceiter.c
+    - freebsd/contrib/ntp/lib/isc/unix/net.c
+    - freebsd/contrib/ntp/lib/isc/unix/stdio.c
+    - freebsd/contrib/ntp/lib/isc/unix/strerror.c
+    - freebsd/contrib/ntp/lib/isc/unix/time.c
+    - freebsd/contrib/ntp/libntp/a_md5encrypt.c
+    - freebsd/contrib/ntp/libntp/atoint.c
+    - freebsd/contrib/ntp/libntp/authkeys.c
+    - freebsd/contrib/ntp/libntp/authreadkeys.c
+    - freebsd/contrib/ntp/libntp/decodenetnum.c
+    - freebsd/contrib/ntp/libntp/dolfptoa.c
+    - freebsd/contrib/ntp/libntp/emalloc.c
+    - freebsd/contrib/ntp/libntp/findconfig.c
+    - freebsd/contrib/ntp/libntp/humandate.c
+    - freebsd/contrib/ntp/libntp/is_ip_address.c
+    - freebsd/contrib/ntp/libntp/lib_strbuf.c
+    - freebsd/contrib/ntp/libntp/modetoa.c
+    - freebsd/contrib/ntp/libntp/msyslog.c
+    - freebsd/contrib/ntp/libntp/netof.c
+    - freebsd/contrib/ntp/libntp/ntp_calendar.c
+    - freebsd/contrib/ntp/libntp/ntp_intres.c
+    - freebsd/contrib/ntp/libntp/ntp_libopts.c
+    - freebsd/contrib/ntp/libntp/ntp_random.c
+    - freebsd/contrib/ntp/libntp/ntp_rfc2553.c
+    - freebsd/contrib/ntp/libntp/ntp_worker.c
+    - freebsd/contrib/ntp/libntp/numtoa.c
+    - freebsd/contrib/ntp/libntp/recvbuff.c
+    - freebsd/contrib/ntp/libntp/refidsmear.c
+    - freebsd/contrib/ntp/libntp/refnumtoa.c
+    - freebsd/contrib/ntp/libntp/socket.c
+    - freebsd/contrib/ntp/libntp/socktoa.c
+    - freebsd/contrib/ntp/libntp/statestr.c
+    - freebsd/contrib/ntp/libntp/systime.c
+    - freebsd/contrib/ntp/libntp/vint64ops.c
+    - freebsd/contrib/ntp/libntp/work_fork.c
+    - freebsd/contrib/ntp/libntp/work_thread.c
+    - freebsd/contrib/ntp/libntp/xsbprintf.c
+    - freebsd/contrib/ntp/ntpd/cmd_args.c
+    - freebsd/contrib/ntp/ntpdc/ntpdc_ops.c
+    - freebsd/contrib/ntp/ntpd/ntp_config.c
+    - freebsd/contrib/ntp/ntpd/ntp_control.c
+    - freebsd/contrib/ntp/ntpd/ntp_crypto.c
+    - freebsd/contrib/ntp/ntpd/ntpd.c
+    - freebsd/contrib/ntp/ntpd/ntpd-opts.c
+    - freebsd/contrib/ntp/ntpd/ntp_filegen.c
+    - freebsd/contrib/ntp/ntpd/ntp_io.c
+    - freebsd/contrib/ntp/ntpd/ntp_leapsec.c
+    - freebsd/contrib/ntp/ntpd/ntp_loopfilter.c
+    - freebsd/contrib/ntp/ntpd/ntp_monitor.c
+    - freebsd/contrib/ntp/ntpd/ntp_parser.c
+    - freebsd/contrib/ntp/ntpd/ntp_peer.c
+    - freebsd/contrib/ntp/ntpd/ntp_proto.c
+    - freebsd/contrib/ntp/ntpd/ntp_refclock.c
+    - freebsd/contrib/ntp/ntpd/ntp_request.c
+    - freebsd/contrib/ntp/ntpd/ntp_restrict.c
+    - freebsd/contrib/ntp/ntpd/ntp_scanner.c
+    - freebsd/contrib/ntp/ntpd/ntp_signd.c
+    - freebsd/contrib/ntp/ntpd/ntpsim.c
+    - freebsd/contrib/ntp/ntpd/ntp_timer.c
+    - freebsd/contrib/ntp/ntpd/ntp_util.c
+    - freebsd/contrib/ntp/ntpd/rc_cmdlength.c
+    - freebsd/contrib/ntp/ntpd/version.c
+    - freebsd/contrib/ntp/sntp/libopts/libopts.c
+    - freebsd/contrib/ntp/libntp/clocktypes.c
+    - freebsd/contrib/ntp/lib/isc/tsmemcmp.c
+    - freebsd/contrib/ntp/libntp/machines.c
+    - freebsd/contrib/ntp/libntp/prettydate.c
+    - rtemsbsd/rtems/rtems-program.c
+    - rtemsbsd/rtems/rtems-program-socket.c
diff --git a/rtemslwip/zynqmp/lwipopts.h b/rtemslwip/zynqmp/lwipopts.h
index 2d358a3..ec5d70f 100644
--- a/rtemslwip/zynqmp/lwipopts.h
+++ b/rtemslwip/zynqmp/lwipopts.h
@@ -31,6 +31,7 @@
 
 #define NO_SYS 0
 #define LWIP_SOCKET                     1
+#define SO_REUSE 1
 #define LWIP_COMPAT_SOCKETS 1
 #define LWIP_NETCONN 1
 
@@ -48,7 +49,8 @@
 #define MEM_ALIGNMENT           64
 #define MEM_SIZE                2 * 1024 * 1024
 #define MEMP_NUM_PBUF           32
-#define MEMP_NUM_UDP_PCB        4
+#define MEMP_NUM_NETCONN        16
+#define MEMP_NUM_UDP_PCB        16
 #define MEMP_NUM_TCP_PCB        32
 #define MEMP_NUM_TCP_PCB_LISTEN 8
 #define MEMP_NUM_TCP_SEG        256
@@ -114,10 +116,25 @@
 #define CONFIG_LINKSPEED_AUTODETECT 1
 #define TCPIP_MBOX_SIZE                 20
 #define DEFAULT_TCP_RECVMBOX_SIZE       20
+#define DEFAULT_UDP_RECVMBOX_SIZE       20
 #define DEFAULT_ACCEPTMBOX_SIZE         5
 
 #define tskIDLE_PRIORITY RTEMS_MAXIMUM_PRIORITY
 #define portTICK_RATE_MS ( rtems_clock_get_ticks_per_second() * 1000 )
 #define vTaskDelay( x ) sys_arch_delay( x )
 
+#if 0
+#define LWIP_DEBUG
+#define DNS_DEBUG LWIP_DBG_ON
+#define DHCP_DEBUG LWIP_DBG_ON
+#define TCP_DEBUG LWIP_DBG_ON
+#define TCP_INPUT_DEBUG LWIP_DBG_ON
+#define UDP_DEBUG LWIP_DBG_ON
+#define IP_DEBUG LWIP_DBG_ON
+#define NETIF_DEBUG LWIP_DBG_ON
+#define SOCKETS_DEBUG LWIP_DBG_ON
+#define MEMP_DEBUG LWIP_DBG_ON
+#define TCPIP_DEBUG LWIP_DBG_ON
+#endif
+
 #endif /* __LWIPOPTS_H__ */
-- 
2.30.2



More information about the devel mailing list