From f2c37a2bed5ddbf7ce4ced3e61798d51c91d8ed6 Mon Sep 17 00:00:00 2001 From: phelter Date: Thu, 23 Feb 2023 19:09:25 -0800 Subject: [PATCH] * #556 Initial Cmake Module definition. * Fixing CI builds, rely on pcap. (#556) * Updating tested configurations and minor clean-up of missing network interfaces (#555) * Further clean-up based on testing with build environment. (#555) * Using single definition for libraries everywhere. (#555) * Fixing A_CUSTOM_NETWORK_IF compile option. * Identifying and fixing compile issues. * Adding in additional warnings for GNU to ignore for now. * Fixing formatting issues with uncrustify. * More warnings for GNU used by CI/CD pipeline. * Assuming custom for build tests and using latest freertos-kernel code. Updated readme for how to consume at project level. * Fixing up issues identified in the PR. Making the build_test EXCLUDE_FROM_ALL so only compiled if requested. * Changing to support C89 instead of C99. Renaming tcp_tools to tcp_utilities to mimic the directory. * Using C90 ISO. Fixing compiler warnings. * Fixing non C90 compliant declaration after statement * Separating out CMakeLists so each port is independent. * Updating warning list in code. * Fixed formatting with uncrustify. * Fix failing tests * Fix failing unit-test * Fix a typo. --------- Co-authored-by: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> --- .github/workflows/ci.yml | 24 +- CMakeLists.txt | 236 ++++++++++++++++++ README.md | 35 ++- cmake_modules/FindPCAP.cmake | 75 ++++++ source/CMakeLists.txt | 93 +++++++ source/FreeRTOS_IP.c | 4 + source/FreeRTOS_Sockets.c | 4 + source/portable/CMakeLists.txt | 36 +++ .../NetworkInterface/ATSAM4E/CMakeLists.txt | 26 ++ .../NetworkInterface/ATSAME5x/CMakeLists.txt | 20 ++ .../portable/NetworkInterface/CMakeLists.txt | 54 ++++ .../NetworkInterface/DriverSAM/CMakeLists.txt | 22 ++ .../NetworkInterface/LPC17xx/CMakeLists.txt | 28 +++ .../NetworkInterface/LPC18xx/CMakeLists.txt | 28 +++ .../NetworkInterface/LPC54018/CMakeLists.txt | 28 +++ .../NetworkInterface/M487/CMakeLists.txt | 22 ++ .../MPS2_AN385/CMakeLists.txt | 29 +++ .../NetworkInterface/RX/CMakeLists.txt | 22 ++ .../NetworkInterface/SH2A/CMakeLists.txt | 25 ++ .../NetworkInterface/STM32Fxx/CMakeLists.txt | 25 ++ .../NetworkInterface/STM32Hxx/CMakeLists.txt | 23 ++ .../NetworkInterface/TM4C/CMakeLists.txt | 20 ++ .../ThirdParty/MSP432/CMakeLists.txt | 23 ++ .../NetworkInterface/WinPCap/CMakeLists.txt | 25 ++ .../NetworkInterface/Zynq/CMakeLists.txt | 73 ++++++ .../board_family/CMakeLists.txt | 20 ++ .../NetworkInterface/esp32/CMakeLists.txt | 28 +++ .../ksz8851snl/CMakeLists.txt | 23 ++ .../NetworkInterface/libslirp/CMakeLists.txt | 29 +++ .../NetworkInterface/linux/CMakeLists.txt | 39 +++ .../NetworkInterface/linux/NetworkInterface.c | 8 +- .../NetworkInterface/mw300_rd/CMakeLists.txt | 20 ++ .../NetworkInterface/pic32mzef/CMakeLists.txt | 23 ++ .../xilinx_ultrascale/CMakeLists.txt | 70 ++++++ test/CMakeLists.txt | 8 + test/build-combination/CMakeLists.txt | 144 +++++------ .../build-combination/Common/FreeRTOSConfig.h | 9 +- test/build-combination/Common/main.c | 58 +++-- .../DefaultConf/FreeRTOSIPConfig.h | 8 +- test/build-combination/README.md | 18 +- tools/CMakeLists.txt | 37 +++ 41 files changed, 1401 insertions(+), 141 deletions(-) create mode 100644 CMakeLists.txt create mode 100644 cmake_modules/FindPCAP.cmake create mode 100644 source/CMakeLists.txt create mode 100644 source/portable/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/ATSAM4E/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/ATSAME5x/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/DriverSAM/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/LPC17xx/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/LPC18xx/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/LPC54018/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/M487/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/MPS2_AN385/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/RX/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/SH2A/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/STM32Fxx/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/STM32Hxx/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/TM4C/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/ThirdParty/MSP432/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/WinPCap/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/Zynq/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/board_family/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/esp32/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/ksz8851snl/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/libslirp/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/linux/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/mw300_rd/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/pic32mzef/CMakeLists.txt create mode 100644 source/portable/NetworkInterface/xilinx_ultrascale/CMakeLists.txt create mode 100644 test/CMakeLists.txt create mode 100644 tools/CMakeLists.txt diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1b2c36c9f8..8d11d84409 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,7 +51,7 @@ jobs: - name: Clone This Repo uses: actions/checkout@v2 with: - path: ./tcp + path: ./tcp - name: Install spell run: | sudo apt-get install spell @@ -111,23 +111,23 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Update submodules - run: git submodule update --init --checkout + - name: Build Install Dependencies + run: | + sudo apt-get install -y libpcap-dev - name: Build checks (Enable all functionalities) run: | - cmake -S test/build-combination -B test/build-combination/build/ \ - -DTEST_CONFIGURATION=ENABLE_ALL - make -C test/build-combination/build/ + cmake -S . -B build -DFREERTOS_PLUS_TCP_TEST_CONFIGURATION=ENABLE_ALL + cmake --build build --target freertos_plus_tcp_build_test - name: Build checks (Disable all functionalities) run: | - cmake -S test/build-combination -B test/build-combination/build/ \ - -DTEST_CONFIGURATION=DISABLE_ALL - make -C test/build-combination/build/ + cmake -S . -B build -DFREERTOS_PLUS_TCP_TEST_CONFIGURATION=DISABLE_ALL + cmake --build build --target clean + cmake --build build --target freertos_plus_tcp_build_test - name: Build checks (Default configuration) run: | - cmake -S test/build-combination -B test/build-combination/build/ \ - -DTEST_CONFIGURATION=DEFAULT_CONF - make -C test/build-combination/build/ + cmake -S . -B build -DFREERTOS_PLUS_TCP_TEST_CONFIGURATION=DEFAULT_CONF + cmake --build build --target clean + cmake --build build --target freertos_plus_tcp_build_test complexity: runs-on: ubuntu-latest diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000000..71d0b56d0b --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,236 @@ + +cmake_minimum_required(VERSION 3.15) +cmake_policy(SET CMP0048 NEW) # project version +cmake_policy(SET CMP0076 NEW) # full paths + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake_modules") + +######################################################################## +# Project Details +project(FreeRTOS-Plus-TCP + VERSION 3.1.0 + DESCRIPTION "FreeRTOS TCP/UDP Network Layer" + HOMEPAGE_URL https://freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/index.html + LANGUAGES C) + +# Do not allow in-source build. +if( ${PROJECT_SOURCE_DIR} STREQUAL ${PROJECT_BINARY_DIR} ) +message( FATAL_ERROR "In-source build is not allowed. Please build in a separate directory, such as ${PROJECT_SOURCE_DIR}/build." ) +endif() + +# Options +option(FREERTOS_PLUS_TCP_BUILD_TEST "Build the test for FreeRTOS Plus TCP" OFF) + +# Configuration +# Override these at project level with: +# Optional: set(FREERTOS_PLUS_TCP_BUFFER_ALLOCATION "1" CACHE STRING "" FORCE) +# Optional: set(FREERTOS_PLUS_TCP_COMPILER "" CACHE STRING "" FORCE) +# Required: set(FREERTOS_PLUS_TCP_NETWORK_IF "POSIX" CACHE STRING "" FORCE) + +# Select the appropriate buffer allocaiton method. +# See: https://freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/Embedded_Ethernet_Buffer_Management.html +if (NOT FREERTOS_PLUS_TCP_BUFFER_ALLOCATION) + message(STATUS "Using default FREERTOS_PLUS_TCP_BUFFER_ALLOCATION = 2") + set(FREERTOS_PLUS_TCP_BUFFER_ALLOCATION "2" CACHE STRING "FreeRTOS buffer allocation model number. 1 .. 2.") +endif() + +# Select the Compiler - if left blank will detect using CMake +# Note relies on CMake to detect over any setting here. +# Valid options are: +# FREERTOS_PLUS_TCP_COMPILER | Detected | CMake +# ------------------------------------------------- +# CCS | No | ?TBD? +# GCC | Yes | GNU +# IAR | Yes | IAR +# Keil | Yes | ARMCC +# MSVC | Yes | MSVC # Note only for MinGW +# Renesas | No | ?TBD? +# Will always a attempt to detect and if detectable double checks that the compiler is set correctly. +set(FREERTOS_PLUS_TCP_COMPILER "" CACHE STRING "FreeRTOS Plus TCP Compiler Selection") + + +# Select the appropriate network interface +# This will fail the CMake preparation step if not set to one of those values. +set(FREERTOS_PLUS_TCP_NETWORK_IF "" CACHE STRING "FreeRTOS Plus TCP Network Interface selection") +set(FREERTOS_PLUS_TCP_NETWORK_IF_LIST + A_CUSTOM_NETWORK_IF + ATSAM43 ATSAME5x # AT + DRIVER_SAM + ESP32 + KSZ8851SNL + LPC17xx LPC18xx LPC54018 + M487 + MPS2_AN385 + MW300_RD + PIC32MZEF_ETH PIC32MZEF_WIFI + POSIX WIN_PCAP # Native Linux & Windows respectively + RX + SH2A + STM32FXX STM32HXX # ST Micro + MSP432 + TM4C + XILINX_ULTRASCALE ZYNQ # AMD/Xilinx +) +if(NOT FREERTOS_PLUS_TCP_NETWORK_IF) + # Attempt to detect the system. + if(UNIX) + message(STATUS "Detected UNIX/Posix system setting FREERTOS_PLUS_TCP_NETWORK_IF = POSIX") + set(FREERTOS_PLUS_TCP_NETWORK_IF POSIX) + elseif(MINGW) + message(STATUS "Detected Windows MinGW system setting FREERTOS_PLUS_TCP_NETWORK_IF = WIN_PCAP") + set(FREERTOS_PLUS_TCP_NETWORK_IF WIN_PCAP) + endif() +endif() + +if(NOT FREERTOS_PLUS_TCP_NETWORK_IF IN_LIST FREERTOS_PLUS_TCP_NETWORK_IF_LIST ) + message(FATAL_ERROR " FREERTOS_PLUS_TCP_NETWORK_IF is '${FREERTOS_PLUS_TCP_NETWORK_IF}'.\n" + " Please specify it from top-level CMake file (example):\n" + " set(FREERTOS_PLUS_TCP_NETWORK_IF POSIX CACHE STRING \"\")\n" + " or from CMake command line option:\n" + " -DFREERTOS_PLUS_TCP_NETWORK_IF=POSIX\n" + " \n" + " Available port options: (Tested means compiled with that variant)\n" + " A_CUSTOM_NETWORK_IF Target: User Defined\n" + " ATSAM4E Target: ATSAM4E Tested: TODO\n" + " ATSAME5x Target: ATSAME5x Tested: TODO\n" + " DRIVER_SAM Target: Driver SAM Tested: TODO\n" + " ESP32 Target: ESP-32 Tested: TODO\n" + " KSZ8851SNL Target: ksz8851snl Tested: TODO\n" + " POSIX Target: linux/Posix\n" + " LPC17xx Target: LPC17xx Tested: TODO\n" + " LPC18xx Target: LPC18xx Tested: TODO\n" + " LPC54018 Target: LPC54018 Tested: TODO\n" + " M487 Target: M487 Tested: TODO\n" + " MPS2_AN385 Target: MPS2_AN385 Tested: TODO\n" + " MW300_RD Target: mw300_rd Tested: TODO\n" + " PIC32MZEF_ETH Target: pic32mzef ethernet Tested: TODO\n" + " PIC32MZEF_WIFI Target: pic32mzef Wifi Tested: TODO\n" + " RX Target: RX Tested: TODO\n" + " SH2A Target: SH2A Tested: TODO\n" + " STM32FXX Target: STM32Fxx Tested: TODO\n" + " STM32HXX Target: STM32Hxx Tested: TODO\n" + " MSP432 Target: MSP432 Tested: TODO\n" + " TM4C Target: TM4C Tested: TODO\n" + " WIN_PCAP Target: Windows Tested: TODO\n" + " XILINX_ULTRASCALE Target: Xilinx Ultrascale Tested: TODO\n" + " ZYNQ Target: Xilinx Zynq") +elseif((FREERTOS_PORT STREQUAL "A_CUSTOM_PORT") AND (NOT TARGET freertos_kernel_port) ) + message(FATAL_ERROR " FREERTOS_PLUS_TCP_NETWORK_IF is set to A_CUSTOM_NETWORK_IF.\n" + " Please specify the custom network interface target with all necessary files.\n" + " For example, assuming a directory of:\n" + " FreeRTOSCustomNetworkInterface/\n" + " CMakeLists.txt\n" + " NetworkInterface.c\n\n" + " Where FreeRTOSCustomNetworkInterface/CMakeLists.txt is a modified version of:\n" + " add_library(freertos_plus_tcp_network_if STATIC)\n\n" + " target_sources(freertos_plus_tcp_network_if\n" + " PRIVATE\n" + " NetworkInterface.c)\n\n" + " target_include_directories(freertos_plus_tcp_network_if\n" + " PUBLIC\n" + " .)\n\n" + " taget_link_libraries(freertos_plus_tcp_network_if\n" + " PUBLIC\n" + " freertos_plus_tcp_port\n" + " freertos_plus_tcp_network_if_common\n" + " PRIVATE\n" + " freertos_kernel)") +endif() + +# There is also the need to add a target - typically an interface library that describes the +# Configuration for FreeRTOS-Kernel and FreeRTOS-Plus-TCP. +# This is called freertos_config +# If not defined will be default compile with one of the test build combinations AllEnable. + +# Select the appropriate Build Test configuration +# This is only used when freertos_config is not defined, otherwise the build test will be performed +# on the config defined in the freertos_config +set(FREERTOS_PLUS_TCP_TEST_CONFIGURATION "CUSTOM" CACHE STRING "FreeRTOS Plus TCP Build Test configuration") +set(FREERTOS_PLUS_TCP_TEST_CONFIGURATION_LIST + CUSTOM # Custom (external) configuration -eg from a top-level project + ENABLE_ALL # Enable all configuration settings + DISABLE_ALL # Disable all configuration settings + DEFAULT_CONF # Default (typical) configuration +) +if(NOT FREERTOS_PLUS_TCP_TEST_CONFIGURATION IN_LIST FREERTOS_PLUS_TCP_TEST_CONFIGURATION_LIST) + message(FATAL_ERROR "Invalid FREERTOS_PLUS_TCP_TEST_CONFIGURATION value '${FREERTOS_PLUS_TCP_TEST_CONFIGURATION}' should be one of: ${FREERTOS_PLUS_TCP_TEST_CONFIGURATION_LIST}") +else() + message(STATUS "Using FreeRTOS-Plus-TCP Test Configuration : ${FREERTOS_PLUS_TCP_TEST_CONFIGURATION}") + if (NOT FREERTOS_PLUS_TCP_TEST_CONFIGURATION STREQUAL "CUSTOM") + message(WARNING "FreeRTOS-Kernel configuration settings are configured by FreeRTOS-Plus-TCP") + endif() +endif() + +######################################################################## +# Requirements +set(CMAKE_C_STANDARD 90) # Note FreeRTOS-Kernel uses C99 constructs. +set(CMAKE_C_STANDARD_REQUIRED ON) + +######################################################################## +# Overall Compile Options +# Note the compile option strategy is to error on everything and then +# Per library opt-out of things that are warnings/errors. +# This ensures that no matter what strategy for compilation you take, the +# builds will still occur. +# +# Only tested with GNU and Clang. +# Other options are https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_ID.html#variable:CMAKE_%3CLANG%3E_COMPILER_ID +# Naming of compilers translation map: +# For the ?TBD? - Suggest trying GNU-based and adding the appropriate toolchain file. +# For Toolchain examples see _deps/cmake-src/toolchain/arm-none-eabil-gcc.toolchain.cmake +# +# FreeRTOS | CMake +# ------------------- +# CCS | ?TBD? +# GCC | GNU, Clang, *Clang Others? +# IAR | IAR +# Keil | ARMCC +# MSVC | MSVC # Note only for MinGW? +# Renesas | ?TBD? + +add_compile_options( + ### Gnu/Clang C Options + $<$:-fdiagnostics-color=always> + $<$:-fcolor-diagnostics> + + $<$:-Wall> + $<$:-Wextra> + $<$:-Wpedantic> + $<$:-Werror> + $<$:-Weverything> + + # TODO: Add in other Compilers here. +) + +######################################################################## +# External Dependencies +# Note: For backwards compatibility - still have .gitmodules defining submodules +# To support fetching content in a higher level project see +# README.md `Consume with CMake` +# This will allow you to upgrade submodules and have one common submodule for +# all your builds despite multiple submodules having different versions. +include(FetchContent) + +FetchContent_Declare( freertos_kernel + GIT_REPOSITORY https://github.com/phelter/FreeRTOS-Kernel.git #https://github.com/FreeRTOS/FreeRTOS-Kernel.git + GIT_TAG feature/fixing-clang-gnu-compiler-warnings #master +) + +FetchContent_Declare( cmock + GIT_REPOSITORY https://github.com/ThrowTheSwitch/CMock + GIT_TAG v2.5.3 +) + +add_subdirectory(source) +add_subdirectory(tools) +add_subdirectory(test) + +FetchContent_MakeAvailable(freertos_kernel cmock) + +# Note following are can be removed once FreeRTOS-Kernel v10.5.0 + fixes their issues. +# To ignore header specific issues - change all of the headers to SYSTEM +set(_freertos_kernel_targets freertos_kernel freertos_kernel_port) +# foreach (_target ${_freertos_kernel_targets} ) +# get_target_property( interface_directories ${_target} INTERFACE_INCLUDE_DIRECTORIES ) +# set_target_properties(${_target} PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${interface_directories}" ) +# endforeach() diff --git a/README.md b/README.md index f7ebd7a7f4..b38c902665 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,40 @@ Once python is downloaded and installed, you can verify the version from your te To run the script, you should switch to the FreeRTOS-Plus-TCP directory that was created using the [Cloning this repository](#cloning-this-repository) step above. And then run `python /GenerateOriginalFiles.py`. -## Cloning this repository +## To consume FreeRTOS+TCP + +### Consume with CMake +If using CMake, it is recommended to use this repository using FetchContent. +Add the following into your project's main or a subdirectory's `CMakeLists.txt`: + +- Define the source and version/tag you want to use: + +```cmake +FetchContent_Declare( freertos_plus_tcp + GIT_REPOSITORY https://github.com/FreeRTOS/FreeRTOS-Plus-TCP.git + GIT_TAG master #Note: Best practice to use specific git-hash or tagged version + GIT_SUBMODULES "" # Don't grab any submodules since not latest +) +``` + +- Configure the FreeRTOS-Kernel and make it available + - this particular example supports a native and cross-compiled build option. + +```cmake +set( FREERTOS_PLUS_FAT_DEV_SUPPORT OFF CACHE BOOL "" FORCE) +# Select the native compile PORT +set( FREERTOS_PLUS_FAT_PORT "POSIX" CACHE STRING "" FORCE) +# Select the cross-compile PORT +if (CMAKE_CROSSCOMPILING) + # Eg. Zynq 2019_3 version of port + set(FREERTOS_PLUS_FAT_PORT "ZYNQ_2019_3" CACHE STRING "" FORCE) +endif() + +FetchContent_MakeAvailable(freertos_plus_tcp) +``` + +### Consuming stand-alone + This repository uses [Git Submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules) to bring in dependent components. Note: If you download the ZIP file provided by GitHub UI, you will not get the contents of the submodules. (The ZIP file is also not a valid Git repository) diff --git a/cmake_modules/FindPCAP.cmake b/cmake_modules/FindPCAP.cmake new file mode 100644 index 0000000000..4f3c7b6412 --- /dev/null +++ b/cmake_modules/FindPCAP.cmake @@ -0,0 +1,75 @@ +# - Try to find libpcap include dirs and libraries +# +# Usage of this module as follows: +# +# find_package(PCAP) +# +# Variables used by this module, they can change the default behaviour and need +# to be set before calling find_package: +# +# PCAP_ROOT_DIR Set this variable to the root installation of +# libpcap if the module has problems finding the +# proper installation path. +# +# Variables defined by this module: +# +# PCAP_FOUND System has libpcap, include and library dirs found +# PCAP_INCLUDE_DIR The libpcap include directories. +# PCAP_LIBRARY The libpcap library (possibly includes a thread +# library e.g. required by pf_ring's libpcap) +# HAVE_PF_RING If a found version of libpcap supports PF_RING + +find_path(PCAP_ROOT_DIR + NAMES include/pcap.h +) + +find_path(PCAP_INCLUDE_DIR + NAMES pcap.h + HINTS ${PCAP_ROOT_DIR}/include +) + +find_library(PCAP_LIBRARY + NAMES pcap + HINTS ${PCAP_ROOT_DIR}/lib +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(PCAP DEFAULT_MSG + PCAP_LIBRARY + PCAP_INCLUDE_DIR +) + +include(CheckCSourceCompiles) +set(CMAKE_REQUIRED_LIBRARIES ${PCAP_LIBRARY}) +check_c_source_compiles("int main() { return 0; }" PCAP_LINKS_SOLO) +set(CMAKE_REQUIRED_LIBRARIES) + +# check if linking against libpcap also needs to link against a thread library +if (NOT PCAP_LINKS_SOLO) + find_package(Threads) + if (THREADS_FOUND) + set(CMAKE_REQUIRED_LIBRARIES ${PCAP_LIBRARY} ${CMAKE_THREAD_LIBS_INIT}) + check_c_source_compiles("int main() { return 0; }" PCAP_NEEDS_THREADS) + set(CMAKE_REQUIRED_LIBRARIES) + endif () + if (THREADS_FOUND AND PCAP_NEEDS_THREADS) + set(_tmp ${PCAP_LIBRARY} ${CMAKE_THREAD_LIBS_INIT}) + list(REMOVE_DUPLICATES _tmp) + set(PCAP_LIBRARY ${_tmp} + CACHE STRING "Libraries needed to link against libpcap" FORCE) + else () + message(FATAL_ERROR "Couldn't determine how to link against libpcap") + endif () +endif () + +include(CheckFunctionExists) +set(CMAKE_REQUIRED_LIBRARIES ${PCAP_LIBRARY}) +check_function_exists(pcap_get_pfring_id HAVE_PF_RING) +check_function_exists(pcap_dump_open_append HAVE_PCAP_DUMP_OPEN_APPEND) +set(CMAKE_REQUIRED_LIBRARIES) + +mark_as_advanced( + PCAP_ROOT_DIR + PCAP_INCLUDE_DIR + PCAP_LIBRARY +) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt new file mode 100644 index 0000000000..a990fe9478 --- /dev/null +++ b/source/CMakeLists.txt @@ -0,0 +1,93 @@ +add_library( freertos_plus_tcp STATIC ) + +target_sources( freertos_plus_tcp + PRIVATE + include/FreeRTOS_ARP.h + include/FreeRTOS_DHCP.h + include/FreeRTOS_DNS_Cache.h + include/FreeRTOS_DNS_Callback.h + include/FreeRTOS_DNS_Globals.h + include/FreeRTOS_DNS_Networking.h + include/FreeRTOS_DNS_Parser.h + include/FreeRTOS_DNS.h + include/FreeRTOS_errno_TCP.h + include/FreeRTOS_ICMP.h + include/FreeRTOS_IP_Private.h + include/FreeRTOS_IP_Timers.h + include/FreeRTOS_IP_Utils.h + include/FreeRTOS_IP.h + include/FreeRTOS_Sockets.h + include/FreeRTOS_Stream_Buffer.h + include/FreeRTOS_TCP_IP.h + include/FreeRTOS_TCP_Reception.h + include/FreeRTOS_TCP_State_Handling.h + include/FreeRTOS_TCP_Transmission.h + include/FreeRTOS_TCP_Utils.h + include/FreeRTOS_TCP_WIN.h + include/FreeRTOS_UDP_IP.h + include/FreeRTOSIPConfigDefaults.h + include/IPTraceMacroDefaults.h + include/NetworkBufferManagement.h + include/NetworkInterface.h + + FreeRTOS_ARP.c + FreeRTOS_DHCP.c + FreeRTOS_DNS_Cache.c + FreeRTOS_DNS_Callback.c + FreeRTOS_DNS_Networking.c + FreeRTOS_DNS_Parser.c + FreeRTOS_DNS.c + FreeRTOS_ICMP.c + FreeRTOS_IP_Timers.c + FreeRTOS_IP_Utils.c + FreeRTOS_IP.c + FreeRTOS_Sockets.c + FreeRTOS_Stream_Buffer.c + FreeRTOS_TCP_IP.c + FreeRTOS_TCP_Reception.c + FreeRTOS_TCP_State_Handling.c + FreeRTOS_TCP_Transmission.c + FreeRTOS_TCP_Utils.c + FreeRTOS_TCP_WIN.c + FreeRTOS_Tiny_TCP.c + FreeRTOS_UDP_IP.c +) + +# Note: Have to make system due to compiler warnings in header files. +target_include_directories( freertos_plus_tcp SYSTEM + PUBLIC + include +) + +#TODO(phelter): Investigate and fix in freertos_plus_tcp if not already fixed. +target_compile_options( freertos_plus_tcp + PRIVATE + $<$:-Wno-bad-function-cast> + $<$:-Wno-cast-qual> + $<$:-Wno-conditional-uninitialized> + $<$:-Wno-covered-switch-default> + $<$:-Wno-documentation> + $<$:-Wno-extra-semi-stmt> + $<$:-Wno-implicit-int-conversion> + $<$:-Wno-missing-noreturn> + $<$:-Wno-reserved-identifier> + $<$:-Wno-shorten-64-to-32> + $<$:-Wno-sign-conversion> + $<$:-Wno-unused-macros> + $<$:-Wno-unused-but-set-variable> + $<$:-Wno-unused-parameter> + $<$:-Wno-unused-variable> + $<$:-Wno-pedantic> +) + +target_link_libraries( freertos_plus_tcp + PUBLIC + freertos_config + freertos_plus_tcp_port # for pack_struct_start.h + PRIVATE + freertos_kernel + freertos_plus_tcp_network_if + freertos_plus_tcp_utilities +) + +add_subdirectory(portable) diff --git a/source/FreeRTOS_IP.c b/source/FreeRTOS_IP.c index 33eb2b67da..f6af451672 100644 --- a/source/FreeRTOS_IP.c +++ b/source/FreeRTOS_IP.c @@ -60,6 +60,10 @@ #include "FreeRTOS_Routing.h" #include "FreeRTOS_ND.h" +#if ( ipconfigUSE_TCP_MEM_STATS != 0 ) + #include "tcp_mem_stats.h" +#endif + /** @brief Time delay between repeated attempts to initialise the network hardware. */ #ifndef ipINITIALISATION_RETRY_DELAY #define ipINITIALISATION_RETRY_DELAY ( pdMS_TO_TICKS( 3000U ) ) diff --git a/source/FreeRTOS_Sockets.c b/source/FreeRTOS_Sockets.c index b76d6799f1..fd41f016aa 100644 --- a/source/FreeRTOS_Sockets.c +++ b/source/FreeRTOS_Sockets.c @@ -53,6 +53,10 @@ #include "NetworkBufferManagement.h" #include "FreeRTOS_Routing.h" +#if ( ipconfigUSE_TCP_MEM_STATS != 0 ) + #include "tcp_mem_stats.h" +#endif + /* The ItemValue of the sockets xBoundSocketListItem member holds the socket's * port number. */ /** @brief Set the port number for the socket in the xBoundSocketListItem. */ diff --git a/source/portable/CMakeLists.txt b/source/portable/CMakeLists.txt new file mode 100644 index 0000000000..c3aede2013 --- /dev/null +++ b/source/portable/CMakeLists.txt @@ -0,0 +1,36 @@ +add_library( freertos_plus_tcp_port STATIC ) + +target_sources( freertos_plus_tcp_port + PRIVATE + BufferManagement/BufferAllocation_${FREERTOS_PLUS_TCP_BUFFER_ALLOCATION}.c + # TODO: There's NetworkInterface/pic32mzef that has it's own BufferAllocation_2.c +) + +target_include_directories( freertos_plus_tcp_port + PUBLIC + # Using Cmake to detect except for unknown compilers. + $<$:${CMAKE_CURRENT_SOURCE_DIR}/Compiler/CCS> + $<$:${CMAKE_CURRENT_SOURCE_DIR}/Compiler/CCS> + $<$:${CMAKE_CURRENT_SOURCE_DIR}/Compiler/GCC> + $<$:${CMAKE_CURRENT_SOURCE_DIR}/Compiler/IAR> + $<$:${CMAKE_CURRENT_SOURCE_DIR}/Compiler/Keil> + $<$:${CMAKE_CURRENT_SOURCE_DIR}/Compiler/MSVC> + $<$:${CMAKE_CURRENT_SOURCE_DIR}/Compiler/Renesas> +) + +target_compile_options( freertos_plus_tcp_port + PRIVATE + $<$:-Wno-cast-align> + $<$:-Wno-extra-semi-stmt> + $<$:-Wno-pedantic> # Strange definition for STATIC_ASSERT +) + +target_link_libraries( freertos_plus_tcp_port + PRIVATE + freertos_kernel + freertos_plus_tcp + freertos_plus_tcp_network_if +) + +#------------------------------------------------------------------------------ +add_subdirectory(NetworkInterface) diff --git a/source/portable/NetworkInterface/ATSAM4E/CMakeLists.txt b/source/portable/NetworkInterface/ATSAM4E/CMakeLists.txt new file mode 100644 index 0000000000..22bacf3789 --- /dev/null +++ b/source/portable/NetworkInterface/ATSAM4E/CMakeLists.txt @@ -0,0 +1,26 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "ATSAM4E") ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + component/gmac.h + instance/gmac.h + ethernet_phy.c + ethernet_phy.h + gmac.c + gmac.h + NetworkInterface.c +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/ATSAME5x/CMakeLists.txt b/source/portable/NetworkInterface/ATSAME5x/CMakeLists.txt new file mode 100644 index 0000000000..7fe7b5dd01 --- /dev/null +++ b/source/portable/NetworkInterface/ATSAME5x/CMakeLists.txt @@ -0,0 +1,20 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "ATSAME5x") ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/CMakeLists.txt b/source/portable/NetworkInterface/CMakeLists.txt new file mode 100644 index 0000000000..dcf98604dd --- /dev/null +++ b/source/portable/NetworkInterface/CMakeLists.txt @@ -0,0 +1,54 @@ +add_library( freertos_plus_tcp_network_if_common STATIC ) + +target_sources( freertos_plus_tcp_network_if_common + PRIVATE + Common/phyHandling.c + include/phyHandling.h +) + +target_include_directories( freertos_plus_tcp_network_if_common + PUBLIC + include +) + +target_compile_options( freertos_plus_tcp_network_if_common + PRIVATE + $<$:-Wno-conditional-uninitialized> + $<$:-Wno-implicit-int-conversion> + $<$:-Wno-padded> + $<$:-Wno-uninitialized> + $<$:-Wno-unused-but-set-variable> + $<$:-Wno-unused-macros> +) + +target_link_libraries( freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) + +#------------------------------------------------------------------------------ +add_subdirectory(ATSAM4E) +add_subdirectory(ATSAME5x) +#add_subdirectory(board_family) - This is only an example. +add_subdirectory(DriverSAM) +add_subdirectory(esp32) +add_subdirectory(ksz8851snl) +add_subdirectory(libslirp) +add_subdirectory(linux) +add_subdirectory(LPC17xx) +add_subdirectory(LPC18xx) +add_subdirectory(LPC54018) +add_subdirectory(M487) +add_subdirectory(MPS2_AN385) +add_subdirectory(mw300_rd) +add_subdirectory(pic32mzef) +add_subdirectory(RX) +add_subdirectory(SH2A) +add_subdirectory(STM32Fxx) +add_subdirectory(STM32Hxx) +add_subdirectory(ThirdParty/MSP432) +add_subdirectory(TM4C) +add_subdirectory(WinPCap) +add_subdirectory(xilinx_ultrascale) +add_subdirectory(Zynq) diff --git a/source/portable/NetworkInterface/DriverSAM/CMakeLists.txt b/source/portable/NetworkInterface/DriverSAM/CMakeLists.txt new file mode 100644 index 0000000000..d142a9cd05 --- /dev/null +++ b/source/portable/NetworkInterface/DriverSAM/CMakeLists.txt @@ -0,0 +1,22 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "DRIVER_SAM") ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + gmac_SAM.c + gmac_SAM.h + NetworkInterface.c +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/LPC17xx/CMakeLists.txt b/source/portable/NetworkInterface/LPC17xx/CMakeLists.txt new file mode 100644 index 0000000000..1e6ca4f1b2 --- /dev/null +++ b/source/portable/NetworkInterface/LPC17xx/CMakeLists.txt @@ -0,0 +1,28 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "LPC17xx") ) + return() +endif() + +if(NOT TARGET lpc17xx_driver) + message(FATAL_ERROR "For FREERTOS_PLUS_TCP_NETWORK_IF=LPC17xx must have a target for the lpc17xx_driver") +endif() +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c +) + +target_link_libraries(freertos_plus_tcp_network_if + PRIVATE + lpc17xx_driver # TODO +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/LPC18xx/CMakeLists.txt b/source/portable/NetworkInterface/LPC18xx/CMakeLists.txt new file mode 100644 index 0000000000..480acf5725 --- /dev/null +++ b/source/portable/NetworkInterface/LPC18xx/CMakeLists.txt @@ -0,0 +1,28 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "LPC18xx") ) + return() +endif() + +if(NOT TARGET lpc17xx_driver) + message(FATAL_ERROR "For FREERTOS_PLUS_TCP_NETWORK_IF=LPC18xx must have a target for the lpc18xx_driver") +endif() +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c +) + +target_link_libraries(freertos_plus_tcp_network_if + PRIVATE + lpc18xx_driver # TODO +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/LPC54018/CMakeLists.txt b/source/portable/NetworkInterface/LPC54018/CMakeLists.txt new file mode 100644 index 0000000000..6d444220ed --- /dev/null +++ b/source/portable/NetworkInterface/LPC54018/CMakeLists.txt @@ -0,0 +1,28 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "LPC54018") ) + return() +endif() + +if(NOT TARGET fsl_enet_driver) + message(FATAL_ERROR "For FREERTOS_PLUS_TCP_NETWORK_IF=LPC54018 must have a target for the fsl_enet_driver") +endif() +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c +) + +target_link_libraries(freertos_plus_tcp_network_if + PRIVATE + lpc54018_driver # TODO +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/M487/CMakeLists.txt b/source/portable/NetworkInterface/M487/CMakeLists.txt new file mode 100644 index 0000000000..8400bc6bb8 --- /dev/null +++ b/source/portable/NetworkInterface/M487/CMakeLists.txt @@ -0,0 +1,22 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "M487") ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + m480_eth.c + m480_eth.h + NetworkInterface.c +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/MPS2_AN385/CMakeLists.txt b/source/portable/NetworkInterface/MPS2_AN385/CMakeLists.txt new file mode 100644 index 0000000000..231b4aaada --- /dev/null +++ b/source/portable/NetworkInterface/MPS2_AN385/CMakeLists.txt @@ -0,0 +1,29 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "MPS2_AN385") ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + ether_lan9118/SMM_MPS2.h + ether_lan9118/smsc9220_emac_config.h + ether_lan9118/smsc9220_eth_drv.c + ether_lan9118/smsc9220_eth_drv.h + NetworkInterface.c +) + +target_include_directories( freertos_plus_tcp_network_if + PRIVATE + ether_lan9118 +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/RX/CMakeLists.txt b/source/portable/NetworkInterface/RX/CMakeLists.txt new file mode 100644 index 0000000000..9fed7027f0 --- /dev/null +++ b/source/portable/NetworkInterface/RX/CMakeLists.txt @@ -0,0 +1,22 @@ +if (NOT ( (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "RX") ) ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +# TODO What about BufferAllocation_2.c here? +target_sources( freertos_plus_tcp_network_if + PRIVATE + ether_callback.c + NetworkInterface.c +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/SH2A/CMakeLists.txt b/source/portable/NetworkInterface/SH2A/CMakeLists.txt new file mode 100644 index 0000000000..54f704c0de --- /dev/null +++ b/source/portable/NetworkInterface/SH2A/CMakeLists.txt @@ -0,0 +1,25 @@ +if (NOT ( (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "SH2A") ) ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c +) + +# target_link_libraries( freertos_plus_tcp_network_if +# PRIVATE +# hwEthernetLib # Todo where is hwEthernet.h? +# ) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/STM32Fxx/CMakeLists.txt b/source/portable/NetworkInterface/STM32Fxx/CMakeLists.txt new file mode 100644 index 0000000000..cfe8f1c1f1 --- /dev/null +++ b/source/portable/NetworkInterface/STM32Fxx/CMakeLists.txt @@ -0,0 +1,25 @@ +if (NOT ( (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "STM32FXX") ) ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c + # stm32f2xx_hal_eth.h + # stm32f4xx_hal_eth.h + stm32f7xx_hal_eth.h #TODO: Only one of these ? + stm32fxx_hal_eth.c + stm32fxx_hal_eth.h +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/STM32Hxx/CMakeLists.txt b/source/portable/NetworkInterface/STM32Hxx/CMakeLists.txt new file mode 100644 index 0000000000..016f1b927c --- /dev/null +++ b/source/portable/NetworkInterface/STM32Hxx/CMakeLists.txt @@ -0,0 +1,23 @@ +if (NOT ( (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "STM32HXX") ) ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c + stm32h7xx_hal_eth.h + stm32hxx_hal_eth.c + stm32hxx_hal_eth.h +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/TM4C/CMakeLists.txt b/source/portable/NetworkInterface/TM4C/CMakeLists.txt new file mode 100644 index 0000000000..b019e71a4c --- /dev/null +++ b/source/portable/NetworkInterface/TM4C/CMakeLists.txt @@ -0,0 +1,20 @@ +if (NOT ( (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "TM4C") ) ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/ThirdParty/MSP432/CMakeLists.txt b/source/portable/NetworkInterface/ThirdParty/MSP432/CMakeLists.txt new file mode 100644 index 0000000000..fdbcc425b2 --- /dev/null +++ b/source/portable/NetworkInterface/ThirdParty/MSP432/CMakeLists.txt @@ -0,0 +1,23 @@ +if (NOT ( (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "MSP432") ) ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c + NetworkInterface.h + NetworkMiddleware.c + NetworkMiddleware.h +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/WinPCap/CMakeLists.txt b/source/portable/NetworkInterface/WinPCap/CMakeLists.txt new file mode 100644 index 0000000000..eb5f37573a --- /dev/null +++ b/source/portable/NetworkInterface/WinPCap/CMakeLists.txt @@ -0,0 +1,25 @@ +if (NOT ( (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "WIN_PCAP") ) ) + return() +endif() + +find_package(PCAP REQUIRED) + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + FaultInjection.c + NetworkInterface.c +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp + ${PCAP_LIBRARY} +) + diff --git a/source/portable/NetworkInterface/Zynq/CMakeLists.txt b/source/portable/NetworkInterface/Zynq/CMakeLists.txt new file mode 100644 index 0000000000..2f27c5125e --- /dev/null +++ b/source/portable/NetworkInterface/Zynq/CMakeLists.txt @@ -0,0 +1,73 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "ZYNQ") ) + return() +endif() + +if(NOT TARGET xil_bsp) + message(FATAL_ERROR "For FREERTOS_PLUS_TCP_NETWORK_IF=ZYNQ must have a target for the xil_bsp") +endif() + +# ZYNQ port shares uncached_memory.c and .h with FreeRTOS-Plus-FAT. +# Separating out so it can potentially be included there as well. +#------------------------------------------------------------------------------ +add_library(freertos_xil_uncached_memory STATIC) + +target_sources(freertos_xil_uncached_memory + PRIVATE + uncached_memory.c + uncached_memory.h +) + +target_include_directories(freertos_xil_uncached_memory + PUBLIC + . + PRIVATE + .. +) + +target_link_libraries(freertos_xil_uncached_memory + PRIVATE + freertos_kernel + freertos_plus_tcp + freertos_plus_tcp_network_if + xil_bsp +) + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) +set_property(TARGET freertos_plus_tcp_network_if PROPERTY C_STANDARD 99) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c + x_emacpsif_dma.c + x_emacpsif_hw.c + x_emacpsif_hw.h + x_emacpsif_physpeed.c + x_emacpsif.h + x_topology.h +) + +target_include_directories( freertos_plus_tcp_network_if + PRIVATE + .. +) + +target_compile_options( freertos_plus_tcp_network_if + PRIVATE + $<$:-Wno-cast-align> + $<$:-Wno-declaration-after-statement> + $<$:-Wno-padded> + $<$:-Wno-pedantic> + $<$:-Wno-unused-parameter> +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp + freertos_xil_uncached_memory + xil_bsp +) diff --git a/source/portable/NetworkInterface/board_family/CMakeLists.txt b/source/portable/NetworkInterface/board_family/CMakeLists.txt new file mode 100644 index 0000000000..03f46e4051 --- /dev/null +++ b/source/portable/NetworkInterface/board_family/CMakeLists.txt @@ -0,0 +1,20 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "") ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/esp32/CMakeLists.txt b/source/portable/NetworkInterface/esp32/CMakeLists.txt new file mode 100644 index 0000000000..899f711cca --- /dev/null +++ b/source/portable/NetworkInterface/esp32/CMakeLists.txt @@ -0,0 +1,28 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "ESP32") ) + return() +endif() + +if(NOT TARGET esp32_lib) + message(FATAL_ERROR "For FREERTOS_PLUS_TCP_NETWORK_IF=ESP32 must have a target for the esp32_lib") +endif() +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c +) + +target_link_libraries( freertos_plus_tcp_network_if + PRIVATE + esp32_lib # TODO +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/ksz8851snl/CMakeLists.txt b/source/portable/NetworkInterface/ksz8851snl/CMakeLists.txt new file mode 100644 index 0000000000..0ab28dfa81 --- /dev/null +++ b/source/portable/NetworkInterface/ksz8851snl/CMakeLists.txt @@ -0,0 +1,23 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "KSZ8851SNL") ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + ksz8851snl_reg.h + ksz8851snl.c + ksz8851snl.h + NetworkInterface.c +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/libslirp/CMakeLists.txt b/source/portable/NetworkInterface/libslirp/CMakeLists.txt new file mode 100644 index 0000000000..3c4a94dbf6 --- /dev/null +++ b/source/portable/NetworkInterface/libslirp/CMakeLists.txt @@ -0,0 +1,29 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "LIBSLIRP") ) + return() +endif() + +if(NOT TARGET slirp) + message(FATAL_ERROR "For FREERTOS_PLUS_TCP_NETWORK_IF=LIBSLIRP must have a target for the slirp") +endif() +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + MBuffNetifBackendLibslirp.c + MBuffNetworkInterface.c +) + +target_link_libraries(freertos_plus_tcp_network_if + PRIVATE + slirp # TODO +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/linux/CMakeLists.txt b/source/portable/NetworkInterface/linux/CMakeLists.txt new file mode 100644 index 0000000000..0b2e44cbd6 --- /dev/null +++ b/source/portable/NetworkInterface/linux/CMakeLists.txt @@ -0,0 +1,39 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "POSIX") ) + return() +endif() + +find_package(PCAP REQUIRED) +set(THREADS_PREFER_PTHREAD_FLAG TRUE) +find_package(Threads) + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c +) + +target_compile_options( freertos_plus_tcp_network_if + PRIVATE + $<$:-Wno-cast-align> + $<$:-Wno-declaration-after-statement> + $<$:-Wno-documentation> + $<$:-Wno-missing-noreturn> + $<$:-Wno-padded> + $<$:-Wno-shorten-64-to-32> + $<$:-Wno-undef> + $<$:-Wno-unused-macros> + $<$:-Wno-unused-parameter> +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp + ${PCAP_LIBRARY} + Threads::Threads +) diff --git a/source/portable/NetworkInterface/linux/NetworkInterface.c b/source/portable/NetworkInterface/linux/NetworkInterface.c index 8a19600893..bbe45b0aae 100644 --- a/source/portable/NetworkInterface/linux/NetworkInterface.c +++ b/source/portable/NetworkInterface/linux/NetworkInterface.c @@ -735,14 +735,14 @@ static void * prvLinuxPcapRecvThread( void * pvParam ) { int ret; - ( void ) pvParam; - /* Disable signals to this thread since this is a Linux pthread to be able to * printf and other blocking operations without being interrupted and put in * suspension mode by the linux port signals */ sigset_t set; + ( void ) pvParam; + sigfillset( &set ); pthread_sigmask( SIG_SETMASK, &set, NULL ); @@ -774,12 +774,12 @@ static void * prvLinuxPcapSendThread( void * pvParam ) uint8_t ucBuffer[ ipconfigNETWORK_MTU + ipSIZE_OF_ETH_HEADER ]; const time_t xMaxMSToWait = 1000; - ( void ) pvParam; - /* disable signals to avoid treating this thread as a FreeRTOS task and putting * it to sleep by the scheduler */ sigset_t set; + ( void ) pvParam; + sigfillset( &set ); pthread_sigmask( SIG_SETMASK, &set, NULL ); diff --git a/source/portable/NetworkInterface/mw300_rd/CMakeLists.txt b/source/portable/NetworkInterface/mw300_rd/CMakeLists.txt new file mode 100644 index 0000000000..974008c93e --- /dev/null +++ b/source/portable/NetworkInterface/mw300_rd/CMakeLists.txt @@ -0,0 +1,20 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "MW300_RD") ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/pic32mzef/CMakeLists.txt b/source/portable/NetworkInterface/pic32mzef/CMakeLists.txt new file mode 100644 index 0000000000..31f5ff6ea3 --- /dev/null +++ b/source/portable/NetworkInterface/pic32mzef/CMakeLists.txt @@ -0,0 +1,23 @@ +if (NOT ( (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "PIC32MZEF_ETH") OR + (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "PIC32MZEF_WIFI") ) ) + return() +endif() + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +# TODO What about BufferAllocation_2.c here? +target_sources( freertos_plus_tcp_network_if + PRIVATE + $<$:NetworkInterface_eth.c> + $<$:NetworkInterface_wifi.c> +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp +) diff --git a/source/portable/NetworkInterface/xilinx_ultrascale/CMakeLists.txt b/source/portable/NetworkInterface/xilinx_ultrascale/CMakeLists.txt new file mode 100644 index 0000000000..674a1dc506 --- /dev/null +++ b/source/portable/NetworkInterface/xilinx_ultrascale/CMakeLists.txt @@ -0,0 +1,70 @@ +if (NOT (FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "XILINX_ULTRASCALE") ) + return() +endif() + +if(NOT TARGET xil_bsp) + message(FATAL_ERROR "For FREERTOS_PLUS_TCP_NETWORK_IF=XILINX_ULTRASCALE must have a target for the xil_bsp") +endif() + +# XILINX_ULTRASCALE port shares uncached_memory.c and .h with FreeRTOS-Plus-FAT. +# Separating out so it can potentially be included there as well. +#------------------------------------------------------------------------------ +add_library(freertos_xil_uncached_memory STATIC) + +target_sources(freertos_xil_uncached_memory + PRIVATE + uncached_memory.c + uncached_memory.h +) + +target_include_directories(freertos_xil_uncached_memory + PUBLIC + . + PRIVATE + .. +) + +target_link_libraries(freertos_xil_uncached_memory + PRIVATE + freertos_kernel + freertos_plus_tcp + freertos_plus_tcp_network_if + xil_bsp +) + +#------------------------------------------------------------------------------ +add_library( freertos_plus_tcp_network_if STATIC ) + +target_sources( freertos_plus_tcp_network_if + PRIVATE + NetworkInterface.c + x_emacpsif_dma.c + x_emacpsif_hw.c + x_emacpsif_hw.h + x_emacpsif_physpeed.c + x_emacpsif.h + x_topology.h +) + +target_include_directories( freertos_plus_tcp_network_if + PRIVATE + .. +) + +target_compile_options( freertos_plus_tcp_network_if + PRIVATE + $<$:-Wno-cast-align> + $<$:-Wno-declaration-after-statement> + $<$:-Wno-padded> +) + +target_link_libraries( freertos_plus_tcp_network_if + PUBLIC + freertos_plus_tcp_port + freertos_plus_tcp_network_if_common + PRIVATE + freertos_kernel + freertos_plus_tcp + freertos_xil_uncached_memory + xil_bsp +) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000000..97d4459107 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,8 @@ +add_subdirectory(build-combination) + +if(FREERTOS_PLUS_TCP_BUILD_TEST) + add_subdirectory(cbmc) + add_subdirectory(Coverity) + add_subdirectory(unit-test) +endif() + diff --git a/test/build-combination/CMakeLists.txt b/test/build-combination/CMakeLists.txt index c695073309..9c77788cb3 100644 --- a/test/build-combination/CMakeLists.txt +++ b/test/build-combination/CMakeLists.txt @@ -1,89 +1,61 @@ -cmake_minimum_required ( VERSION 3.13.0 ) -project ( "FreeRTOS-Plus-TCP Build Combination" - VERSION 1.0.0 - LANGUAGES C ) - -# Allow the project to be organized into folders. -set_property( GLOBAL PROPERTY USE_FOLDERS ON ) - -# Use C90. -set( CMAKE_C_STANDARD 90 ) -set( CMAKE_C_STANDARD_REQUIRED ON ) - -# Do not allow in-source build. -if( ${PROJECT_SOURCE_DIR} STREQUAL ${PROJECT_BINARY_DIR} ) - message( FATAL_ERROR "In-source build is not allowed. Please build in a separate directory, such as ${PROJECT_SOURCE_DIR}/build." ) -endif() - -# Set global path variables. -get_filename_component(__MODULE_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}/../.." ABSOLUTE) -set(MODULE_ROOT_DIR ${__MODULE_ROOT_DIR} CACHE INTERNAL "FreeRTOS-Plus-TCP repository root.") - -# Configure options to always show in CMake GUI. -option( BUILD_CLONE_SUBMODULES - "Set this to ON to automatically clone any required Git submodules. When OFF, submodules must be manually cloned." - ON ) - - -option(TEST_CONFIGURATION "Configuration All Enable/Disable or default" ENABLE_ALL) - -message( STATUS "Argument: ${TEST_CONFIGURATION}") - -# Set output directories. -set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin ) -set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib ) -set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib ) - - -set( FREERTOS_KERNEL_DIR ${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel ) -set( TEST_DIR ${MODULE_ROOT_DIR}/test/build-combination ) - -include_directories( ${MODULE_ROOT_DIR}/source/include ) -include_directories( ${MODULE_ROOT_DIR}/source/portable/Compiler/MSVC ) -include_directories( ${FREERTOS_KERNEL_DIR}/include ) -# Add the correct portable directory to include search paths. -if (WIN32) - include_directories( ${FREERTOS_KERNEL_DIR}/portable/MSVC-MingW ) -else() - include_directories( ${FREERTOS_KERNEL_DIR}/portable/ThirdParty/GCC/Posix ) -endif() -include_directories( ${TEST_DIR}/Common ) - -if( ${TEST_CONFIGURATION} STREQUAL "ENABLE_ALL" ) - include_directories( ${TEST_DIR}/AllEnable ) -elseif( ${TEST_CONFIGURATION} STREQUAL "DISABLE_ALL" ) - include_directories( ${TEST_DIR}/AllDisable ) -else() - include_directories( ${TEST_DIR}/DefaultConf ) -endif() - -# Pick the correct kernel port files for the platform. -if (WIN32) - file(GLOB KERNEL_SOURCES "${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/*.c" - "${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/portable/MSVC-MingW/*.c") +add_library( freertos_plus_tcp_config_common INTERFACE ) +target_include_directories(freertos_plus_tcp_config_common INTERFACE Common ) + +# ------------------------------------------------------------------- +add_library( freertos_plus_tcp_config_all_disable INTERFACE) +target_include_directories(freertos_plus_tcp_config_all_disable INTERFACE AllDisable) +target_link_libraries(freertos_plus_tcp_config_all_disable INTERFACE freertos_plus_tcp_config_common) + +# ------------------------------------------------------------------- +add_library( freertos_plus_tcp_config_all_enable INTERFACE) +target_include_directories(freertos_plus_tcp_config_all_enable INTERFACE AllEnable) +target_link_libraries(freertos_plus_tcp_config_all_enable INTERFACE freertos_plus_tcp_config_common) + +# ------------------------------------------------------------------- +add_library( freertos_plus_tcp_config_default INTERFACE) +target_include_directories(freertos_plus_tcp_config_default INTERFACE DefaultConf) +target_link_libraries(freertos_plus_tcp_config_default INTERFACE freertos_plus_tcp_config_common) + +# ------------------------------------------------------------------- +# Configuration for FreeRTOS-Kernel +if(FREERTOS_PLUS_TCP_TEST_CONFIGURATION STREQUAL "CUSTOM" ) + # Check Config target is available. And then do nothing. + if(NOT TARGET freertos_config ) + message(FATAL_ERROR "FREERTOS_PLUS_TCP_TEST_CONFIGURATION = CUSTOM, but no freertos_config target defined.") + endif() +elseif(FREERTOS_PLUS_TCP_TEST_CONFIGURATION STREQUAL "DISABLE_ALL" ) + add_library( freertos_config ALIAS freertos_plus_tcp_config_all_disable) +elseif(FREERTOS_PLUS_TCP_TEST_CONFIGURATION STREQUAL "ENABLE_ALL" ) + add_library( freertos_config ALIAS freertos_plus_tcp_config_all_enable) else() - file(GLOB KERNEL_SOURCES "${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/*.c" - "${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/portable/ThirdParty/GCC/Posix/*.c" - "${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/portable/ThirdParty/GCC/Posix/utils/*.c") + add_library( freertos_config ALIAS freertos_plus_tcp_config_default) endif() -file(GLOB TCP_SOURCES "${MODULE_ROOT_DIR}/source/*.c" ) - -message(STATUS "${KERNEL_SOURCES}") -message(STATUS "${TCP_SOURCES}") - -add_executable(project ${KERNEL_SOURCES} - ${TCP_SOURCES} - ${FREERTOS_KERNEL_DIR}/portable/MemMang/heap_4.c - ${MODULE_ROOT_DIR}/source/portable/BufferManagement/BufferAllocation_2.c - ${TEST_DIR}/Common/main.c ) - -if (WIN32) - # Add preprocessor definitions to suppress warnings. - target_compile_definitions( project PRIVATE - _CRT_SECURE_NO_WARNINGS ) -else() - # Link pthread which is needed for POSIX port. - find_package( Threads REQUIRED ) - target_link_libraries( project Threads::Threads ) -endif() +add_executable(freertos_plus_tcp_build_test EXCLUDE_FROM_ALL) + +target_sources(freertos_plus_tcp_build_test + PRIVATE + Common/main.c +) + +target_compile_options(freertos_plus_tcp_build_test + PRIVATE + $<$:-Wno-cast-qual> + $<$:-Wno-format-nonliteral> + $<$:-Wno-implicit-function-declaration> + $<$:-Wno-missing-noreturn> + $<$:-Wno-missing-prototypes> + $<$:-Wno-missing-variable-declarations> + $<$:-Wno-reserved-identifier> + $<$:-Wno-shorten-64-to-32> + $<$:-Wno-sign-conversion> + $<$:-Wno-unused-parameter> + $<$:-Wno-unused-macros> + $<$:-Wno-unused-variable> +) + +target_link_libraries(freertos_plus_tcp_build_test + PRIVATE + freertos_plus_tcp + freertos_kernel +) diff --git a/test/build-combination/Common/FreeRTOSConfig.h b/test/build-combination/Common/FreeRTOSConfig.h index 7d5de97dc4..a7f7d86bad 100644 --- a/test/build-combination/Common/FreeRTOSConfig.h +++ b/test/build-combination/Common/FreeRTOSConfig.h @@ -114,18 +114,11 @@ * functions. */ #define configUSE_STATS_FORMATTING_FUNCTIONS 1 -/* Assert call defined for debug builds. */ -void vAssertCalled( const char * pcFile, - uint32_t ulLine ); - -#define configASSERT( x ) - /* The function that implements FreeRTOS printf style output, and the macro * that maps the configPRINTF() macros to that function. */ #define configPRINTF( X ) /* Non-format version thread-safe print. */ -extern void vLoggingPrint( const char * pcMessage ); #define configPRINT( X ) /* Non-format version thread-safe print. */ @@ -219,7 +212,7 @@ extern void vLoggingPrint( const char * pcMessage ); #define configPROFILING ( 0 ) /* Pseudo random number generator used by some tasks. */ -extern uint32_t ulRand(); +extern uint32_t ulRand( void ); #define configRAND32() ulRand() /* The platform that FreeRTOS is running on. */ diff --git a/test/build-combination/Common/main.c b/test/build-combination/Common/main.c index b6f7a31216..a414c89293 100644 --- a/test/build-combination/Common/main.c +++ b/test/build-combination/Common/main.c @@ -39,8 +39,17 @@ #include "FreeRTOS_Sockets.h" #include "FreeRTOS_DHCP.h" -#define mainHOST_NAME "Build Combination" +#include +#include +#define mainHOST_NAME "Build Combination" +#define mainDEVICE_NICK_NAME "Build_Combination" + +#if defined( _MSC_VER ) && ( _MSC_VER <= 1600 ) + #define local_stricmp _stricmp +#else + #define local_stricmp strcasecmp +#endif /*-----------------------------------------------------------*/ /* Notes if the trace is running or not. */ @@ -168,11 +177,11 @@ int main( void ) /* Determine if a name lookup is for this node. Two names are given * to this node: that returned by pcApplicationHostnameHook() and that set * by mainDEVICE_NICK_NAME. */ - if( _stricmp( pcName, pcApplicationHostnameHook() ) == 0 ) + if( local_stricmp( pcName, pcApplicationHostnameHook() ) == 0 ) { xReturn = pdPASS; } - else if( _stricmp( pcName, mainDEVICE_NICK_NAME ) == 0 ) + else if( local_stricmp( pcName, mainDEVICE_NICK_NAME ) == 0 ) { xReturn = pdPASS; } @@ -201,9 +210,8 @@ void vApplicationIdleHook( void ) /* Exit. Just a stub. */ } /*-----------------------------------------------------------*/ - void vAssertCalled( const char * pcFile, - uint32_t ulLine ) + unsigned long ulLine ) { const uint32_t ulLongSleep = 1000UL; volatile uint32_t ulBlockVariable = 0UL; @@ -223,6 +231,17 @@ void vAssertCalled( const char * pcFile, } /*-----------------------------------------------------------*/ +void vLoggingPrintf( const char * pcFormat, + ... ) +{ + va_list arg; + + va_start( arg, pcFormat ); + vprintf( pcFormat, arg ); + va_end( arg ); +} +/*-----------------------------------------------------------*/ + void getUserCmd( char * pucUserCmd ) { /* Provide a stub for this function. */ @@ -246,6 +265,8 @@ BaseType_t xApplicationGetRandomNumber( uint32_t * pulNumber ) return pdTRUE; } +/*-----------------------------------------------------------*/ + void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, StackType_t ** ppxIdleTaskStackBuffer, uint32_t * pulIdleTaskStackSize ) @@ -253,6 +274,19 @@ void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, /* Provide a stub for this function. */ } +/*-----------------------------------------------------------*/ + +void vApplicationTickHook( void ) +{ + /* Provide a stub for this function. */ +} + +/*-----------------------------------------------------------*/ + +void vApplicationDaemonTaskStartupHook( void ) +{ + /* Provide a stub for this function. */ +} /* * Callback that provides the inputs necessary to generate a randomized TCP @@ -285,20 +319,6 @@ void vApplicationMallocFailedHook( void ) /* Provide a stub for this function. */ } -BaseType_t xNetworkInterfaceOutput( NetworkInterface_t * pxInterface, - NetworkBufferDescriptor_t * const pxNetworkBuffer, - BaseType_t bReleaseAfterSend ) -{ - /* Provide a stub for this function. */ - return pdTRUE; -} - -BaseType_t xNetworkInterfaceInitialise( void ) -{ - /* Provide a stub for this function. */ - return pdTRUE; -} - struct xNetworkInterface * pxFillInterfaceDescriptor( BaseType_t xEMACIndex, struct xNetworkInterface * pxInterface ) { diff --git a/test/build-combination/DefaultConf/FreeRTOSIPConfig.h b/test/build-combination/DefaultConf/FreeRTOSIPConfig.h index c908f0fcd3..313c401e6e 100644 --- a/test/build-combination/DefaultConf/FreeRTOSIPConfig.h +++ b/test/build-combination/DefaultConf/FreeRTOSIPConfig.h @@ -38,6 +38,10 @@ /* It is not sensible for this macro to have a default value as it is hardware * dependent. */ -#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN +#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN -#endif +/* The windows simulator cannot really simulate MAC interrupts, and needs to + * block occasionally to allow other tasks to run. */ +#define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY ( 20 / portTICK_PERIOD_MS ) + +#endif /* ifndef FREERTOS_IP_CONFIG_H */ diff --git a/test/build-combination/README.md b/test/build-combination/README.md index 0bbcba87d3..8d7aca4957 100644 --- a/test/build-combination/README.md +++ b/test/build-combination/README.md @@ -9,20 +9,20 @@ All the CMake commands are to be run from the root of the repository. * Build checks (Enable all functionalities) ``` -cmake -S test/build-combination -B test/build-combination/build/ -DTEST_CONFIGURATION=ENABLE_ALL -make -C test/build-combination/build/ +cmake -S . -B build -DFREERTOS_PLUS_TCP_TEST_CONFIGURATION=ENABLE_ALL +cmake --build build --target freertos_plus_tcp_build_test ``` * Build checks (Disable all functionalities) ``` -cmake -S test/build-combination -B test/build-combination/build/ -DTEST_CONFIGURATION=DISABLE_ALL -make -C test/build-combination/build/ +cmake -S . -B build -DFREERTOS_PLUS_TCP_TEST_CONFIGURATION=DISABLE_ALL +cmake --build build --target freertos_plus_tcp_build_test ``` * Build checks (Default configuration) ``` -cmake -S test/build-combination -B test/build-combination/build/ -DTEST_CONFIGURATION=DEFAULT_CONF -make -C test/build-combination/build/ +cmake -S . -B build -DFREERTOS_PLUS_TCP_TEST_CONFIGURATION=DEFAULT_CONF +cmake --build build --target freertos_plus_tcp_build_test ``` ## Windows @@ -31,21 +31,21 @@ All the CMake commands are to be run from the root of the repository. * Build checks (Enable all functionalities) ``` -cmake -S test/build-combination -B test/build-combination/build/ -DTEST_CONFIGURATION=ENABLE_ALL -DCMAKE_GENERATOR_PLATFORM=Win32 +cmake -S . -B build -DFREERTOS_PLUS_TCP_TEST_CONFIGURATION=ENABLE_ALL -DCMAKE_GENERATOR_PLATFORM=Win32 ``` Open the generated Visual Studio Solution file `test\build-combination\build\FreeRTOS-Plus-TCP Build Combination.sln` in Visual Studio and click `Build --> Build Solution`. * Build checks (Disable all functionalities) ``` -cmake -S test/build-combination -B test/build-combination/build/ -DTEST_CONFIGURATION=ENABLE_ALL -DCMAKE_GENERATOR_PLATFORM=Win32 +cmake -S . -B build -DFREERTOS_PLUS_TCP_TEST_CONFIGURATION=ENABLE_ALL -DCMAKE_GENERATOR_PLATFORM=Win32 ``` Open the generated Visual Studio Solution file `test\build-combination\build\FreeRTOS-Plus-TCP Build Combination.sln` in Visual Studio and click `Build --> Build Solution`. * Build checks (Default configuration) ``` -cmake -S test/build-combination -B test/build-combination/build/ -DTEST_CONFIGURATION=ENABLE_ALL -DCMAKE_GENERATOR_PLATFORM=Win32 +cmake -S . -B build -DFREERTOS_PLUS_TCP_TEST_CONFIGURATION=ENABLE_ALL -DCMAKE_GENERATOR_PLATFORM=Win32 ``` Open the generated Visual Studio Solution file `test\build-combination\build\FreeRTOS-Plus-TCP Build Combination.sln` in Visual Studio and click `Build --> Build Solution`. diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt new file mode 100644 index 0000000000..dfbbdc5b8a --- /dev/null +++ b/tools/CMakeLists.txt @@ -0,0 +1,37 @@ +add_library( freertos_plus_tcp_utilities STATIC ) + +target_sources( freertos_plus_tcp_utilities + PRIVATE + tcp_utilities/include/tcp_dump_packets.h + tcp_utilities/include/tcp_mem_stats.h + tcp_utilities/include/tcp_netstat.h + + tcp_utilities/tcp_dump_packets.c + tcp_utilities/tcp_mem_stats.c + tcp_utilities/tcp_netstat.c +) + +# Note: Have to make system due to compiler warnings in header files. +target_include_directories( freertos_plus_tcp_utilities SYSTEM + PUBLIC + tcp_utilities/include +) + +#TODO(phelter): Investigate and fix in freertos_plus_tcp if not already fixed. +target_compile_options( freertos_plus_tcp_utilities + PRIVATE + $<$:-Wno-extra-semi-stmt> + $<$:-Wno-format> + $<$:-Wno-missing-variable-declarations> + $<$:-Wno-padded> + $<$:-Wno-unused-but-set-variable> + $<$:-Wno-unused-function> + $<$:-Wno-unused-macros> + $<$:-Wno-unused-variable> +) + +target_link_libraries( freertos_plus_tcp_utilities + PRIVATE + freertos_kernel + freertos_plus_tcp +)