diff --git a/.github/README.md b/.github/README.md new file mode 100644 index 00000000..7cdf21c0 --- /dev/null +++ b/.github/README.md @@ -0,0 +1,16 @@ +# Evaluation version + +This repository contains an evaluation version of **P-Net**, a P-Net stack +for Profinet Device implementations. It is especially well suited for +embedded systems where resources are limited and efficiency is crucial. +It is written in C and can be run on an RTOS such as rt-kernel, FreeRTOS, +or on Linux. + +It does not contain any ports and cannot be built without adding additional sources. + +See [readme](../README.md) for more information on the complete version of the stack and the [releases](https://github.com/rtlabs-com/p-net/releases) for binary downloads for common targets. + +This version of P-Net can be used for evaluation purposes +only. Contact if you intend to use this stack in a +product or if you need assistance during evaluation. The commercial +version of this stack is supplied with full sources. diff --git a/requirements.jenkins.in b/requirements.jenkins.in new file mode 100644 index 00000000..106d9758 --- /dev/null +++ b/requirements.jenkins.in @@ -0,0 +1,2 @@ +gcovr +-r doc/requirements.txt diff --git a/requirements.jenkins.txt b/requirements.jenkins.txt new file mode 100644 index 00000000..808e56f9 --- /dev/null +++ b/requirements.jenkins.txt @@ -0,0 +1,144 @@ +# This file was autogenerated by uv via the following command: +# uv pip compile requirements.jenkins.in -o requirements.jenkins.txt +accessible-pygments==0.0.4 + # via pydata-sphinx-theme +alabaster==0.7.16 + # via sphinx +babel==2.14.0 + # via + # pydata-sphinx-theme + # sphinx +beautifulsoup4==4.12.3 + # via pydata-sphinx-theme +breathe==4.34.0 +certifi==2024.2.2 + # via requests +chardet==5.2.0 + # via reportlab +charset-normalizer==3.3.2 + # via requests +codespell==2.2.2 +colorlog==6.8.2 + # via gcovr +commonmark==0.9.1 + # via recommonmark +docutils==0.17.1 + # via + # breathe + # myst-parser + # pydata-sphinx-theme + # recommonmark + # rst2pdf + # sphinx + # sphinx-jinja +gcovr==7.2 +graphviz==0.20.1 +idna==3.7 + # via requests +imagesize==1.4.1 + # via sphinx +importlib-metadata==7.1.0 + # via rst2pdf +jinja2==3.1.3 + # via + # gcovr + # myst-parser + # rst2pdf + # sphinx + # sphinx-jinja +lxml==5.2.1 + # via gcovr +markdown-it-py==2.2.0 + # via + # mdit-py-plugins + # myst-parser +markupsafe==2.1.5 + # via jinja2 +mdit-py-plugins==0.3.5 + # via myst-parser +mdurl==0.1.2 + # via markdown-it-py +myst-parser==0.18.1 +packaging==24.0 + # via + # pydata-sphinx-theme + # rst2pdf + # sphinx +pillow==10.3.0 + # via reportlab +pydata-sphinx-theme==0.15.2 + # via sphinx-book-theme +pyenchant==3.2.2 + # via sphinxcontrib-spelling +pygments==2.17.2 + # via + # accessible-pygments + # gcovr + # pydata-sphinx-theme + # rst2pdf + # rstcloth + # sphinx +pyyaml==6.0.1 + # via + # myst-parser + # rst2pdf + # rstcloth + # sphinxcontrib-kroki +recommonmark==0.7.1 +reportlab==4.2.0 + # via rst2pdf +requests==2.31.0 + # via + # sphinx + # sphinxcontrib-kroki +rst2pdf==0.99 +rstcloth==0.5.3 +smartypants==2.0.1 + # via rst2pdf +snowballstemmer==2.2.0 + # via sphinx +soupsieve==2.5 + # via beautifulsoup4 +sphinx==5.3.0 + # via + # breathe + # myst-parser + # pydata-sphinx-theme + # recommonmark + # rstcloth + # sphinx-book-theme + # sphinx-copybutton + # sphinx-jinja + # sphinxcontrib-kroki + # sphinxcontrib-programoutput + # sphinxcontrib-spelling +sphinx-book-theme==1.0.1 +sphinx-copybutton==0.5.1 +sphinx-jinja==2.0.2 +sphinxcontrib-applehelp==1.0.8 + # via sphinx +sphinxcontrib-devhelp==1.0.6 + # via sphinx +sphinxcontrib-htmlhelp==2.0.5 + # via sphinx +sphinxcontrib-jsmath==1.0.1 + # via sphinx +sphinxcontrib-kroki==1.3.0 +sphinxcontrib-programoutput==0.17 +sphinxcontrib-qthelp==1.0.7 + # via sphinx +sphinxcontrib-serializinghtml==1.1.10 + # via sphinx +sphinxcontrib-spelling==8.0.0 +tabulate==0.8.10 + # via rstcloth +tomli==2.0.1 + # via gcovr +typing-extensions==4.11.0 + # via + # myst-parser + # pydata-sphinx-theme +urllib3==2.2.1 + # via requests +zipp==3.18.1 + # via importlib-metadata diff --git a/src/device/pf_cmina.c b/src/device/pf_cmina.c index b287a4b9..38851134 100644 --- a/src/device/pf_cmina.c +++ b/src/device/pf_cmina.c @@ -318,6 +318,15 @@ int pf_cmina_set_default_cfg (pnet_t * net, uint16_t reset_mode) 0, sizeof (net->cmina_nonvolatile_dcp_ase.station_name)); + /* Reset network interface */ + pnal_set_ip_suite ( + net->pf_interface.main_port.name, + &net->cmina_nonvolatile_dcp_ase.full_ip_suite.ip_suite.ip_addr, + &net->cmina_nonvolatile_dcp_ase.full_ip_suite.ip_suite.ip_mask, + &net->cmina_nonvolatile_dcp_ase.full_ip_suite.ip_suite.ip_gateway, + net->cmina_nonvolatile_dcp_ase.station_name, + true); + pf_file_clear (p_file_directory, PF_FILENAME_IP); pf_file_clear (p_file_directory, PF_FILENAME_DIAGNOSTICS); #if PNET_OPTION_SNMP diff --git a/src/drivers/drivers.cmake b/src/drivers/drivers.cmake new file mode 100644 index 00000000..846431fe --- /dev/null +++ b/src/drivers/drivers.cmake @@ -0,0 +1,17 @@ +#******************************************************************** +# _ _ _ +# _ __ | |_ _ | | __ _ | |__ ___ +# | '__|| __|(_)| | / _` || '_ \ / __| +# | | | |_ _ | || (_| || |_) |\__ \ +# |_| \__|(_)|_| \__,_||_.__/ |___/ +# +# www.rt-labs.com +# Copyright 2018 rt-labs AB, Sweden. +# +# This software is dual-licensed under GPLv3 and a commercial +# license. See the file LICENSE.md distributed with this software for +# full license information. +#*******************************************************************/ +if (PNET_OPTION_DRIVER_ENABLE) + include( src/drivers/lan9662/driver.cmake ) +endif() diff --git a/src/drivers/lan9662/add_mera_lib.cmake b/src/drivers/lan9662/add_mera_lib.cmake new file mode 100644 index 00000000..005825ab --- /dev/null +++ b/src/drivers/lan9662/add_mera_lib.cmake @@ -0,0 +1,42 @@ +#******************************************************************** +# _ _ _ +# _ __ | |_ _ | | __ _ | |__ ___ +# | '__|| __|(_)| | / _` || '_ \ / __| +# | | | |_ _ | || (_| || |_) |\__ \ +# |_| \__|(_)|_| \__,_||_.__/ |___/ +# +# www.rt-labs.com +# Copyright 2020 rt-labs AB, Sweden. +# +# This software is licensed under the terms of the BSD 3-clause +# license. See the file LICENSE distributed with this software for +# full license information. +#*******************************************************************/ + + +cmake_minimum_required(VERSION 3.14) + +# Attempt to find externally built mera library +find_package(mera QUIET) + +if (NOT mera_FOUND) + # Download and build mera locally as a static library + # Todo: this is a private repo. Switch to public repo before release + message(STATUS "Fetch mera from github") + include(FetchContent) + FetchContent_Declare( + mera + GIT_REPOSITORY https://github.com/microchip-ung/rtlabs-mera + GIT_TAG b9d43d5 + ) + + FetchContent_GetProperties(mera) + if(NOT mera_POPULATED) + FetchContent_Populate(mera) + set(BUILD_SHARED_LIBS_OLD ${BUILD_SHARED_LIBS}) + set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "" FORCE) + add_subdirectory(${mera_SOURCE_DIR} ${mera_BINARY_DIR} EXCLUDE_FROM_ALL) + set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_OLD} CACHE BOOL "" FORCE) + endif() + +endif() diff --git a/src/drivers/lan9662/driver.cmake b/src/drivers/lan9662/driver.cmake new file mode 100644 index 00000000..6d5b6ede --- /dev/null +++ b/src/drivers/lan9662/driver.cmake @@ -0,0 +1,154 @@ +#******************************************************************** +# _ _ _ +# _ __ | |_ _ | | __ _ | |__ ___ +# | '__|| __|(_)| | / _` || '_ \ / __| +# | | | |_ _ | || (_| || |_) |\__ \ +# |_| \__|(_)|_| \__,_||_.__/ |___/ +# +# www.rt-labs.com +# Copyright 2018 rt-labs AB, Sweden. +# +# This software is dual-licensed under GPLv3 and a commercial +# license. See the file LICENSE.md distributed with this software for +# full license information. +#*******************************************************************/ + +cmake_dependent_option ( + PNET_OPTION_DRIVER_LAN9662 + "Enable LAN9662 HW Offload driver" OFF + "PNET_OPTION_DRIVER_ENABLE" OFF ) + +if (PNET_OPTION_DRIVER_LAN9662) + +option(PNET_OPTION_LAN9662_SHOW_RTE_INFO "Show RTE config log message" OFF) +set(PNET_LAN9662_MAX_FRAMES 2 CACHE STRING "Max active CPM and PPM instances") +set(PNET_LAN9662_MAX_IDS 16 CACHE STRING "Max subslots for a frame") + +set(PNET_LAN9662_VCAM_BASE 2 CACHE STRING "LAN9662 VCAP base index") +set(PNET_LAN9662_RTP_BASE 4 CACHE STRING "LAN9662 RTP base index") +set(PNET_LAN9662_WAL_BASE 6 CACHE STRING "LAN9662 write action list base index") +set(PNET_LAN9662_RAL_BASE 8 CACHE STRING "LAN9662 read action list base index") + +message(STATUS "LAN9662 pnet_driver_options.h configuration") +configure_file ( + src/drivers/lan9662/pnet_driver_options.h.in + include/pnet_driver_options.h +) + +message(STATUS "Add LAN9662 targets and configurations") + +if(TARGET mera) + message(STATUS "LAN9662 mera lib found") + get_target_property(MERA_INCLUDES mera INCLUDE_DIRECTORIES) +else() + message(STATUS "LAN9662 mera lib not found - fetch repo") + include(src/drivers/lan9662/add_mera_lib.cmake) + get_target_property(MERA_INCLUDES mera INCLUDE_DIRECTORIES) +endif() + +add_executable(pn_lan9662 "") +add_executable(pn_shm_tool "") + +set_target_properties (pn_lan9662 pn_shm_tool + PROPERTIES + C_STANDARD 99 + ) + +add_subdirectory (samples/pn_dev_lan9662) +add_subdirectory (samples/pn_shm_tool) + +target_sources(profinet + PRIVATE + ${PROFINET_SOURCE_DIR}/src/drivers/lan9662/src/pf_cpm_driver_lan9662.c + ${PROFINET_SOURCE_DIR}/src/drivers/lan9662/src/pf_lan9662_mera.c + ${PROFINET_SOURCE_DIR}/src/drivers/lan9662/src/pf_mera_trace.c + ${PROFINET_SOURCE_DIR}/src/drivers/lan9662/src/pf_mera_trace.c + ${PROFINET_SOURCE_DIR}/src/drivers/lan9662/src/pf_rte_uio.c + ${PROFINET_SOURCE_DIR}/src/drivers/lan9662/src/pf_sram_uio.c + ${PROFINET_SOURCE_DIR}/src/drivers/lan9662/src/pf_ppm_driver_lan9662.c + ) + +target_include_directories(profinet + PRIVATE + src/drivers/lan9662 + src/drivers/lan9662/include + ${MERA_INCLUDES} + ) + +target_link_libraries(profinet + PUBLIC + mera + ) + +install ( + TARGETS mera + EXPORT ProfinetConfig + DESTINATION lib + ) + +target_include_directories(pn_dev + PRIVATE + src/drivers/lan9662 + src/drivers/lan9662/include + ) + +target_include_directories(pn_lan9662 + PRIVATE + samples/pn_dev_lan9662 + src/drivers/lan9662 + src/drivers/lan9662/include + src/ports/linux + ) + +target_sources(pn_lan9662 + PRIVATE + samples/pn_dev_lan9662/sampleapp_common.c + samples/pn_dev_lan9662/app_utils.c + samples/pn_dev_lan9662/app_log.c + samples/pn_dev_lan9662/app_gsdml.c + samples/pn_dev_lan9662/app_data.c + samples/pn_dev_lan9662/app_shm.c + src/ports/linux/sampleapp_main.c + ) + +target_compile_options(pn_lan9662 + PRIVATE + ${APP_COMPILER_FLAGS} + ) + +target_link_options(pn_lan9662 + PRIVATE + -Wl,--gc-sections + ) + +target_sources(pn_shm_tool + PRIVATE + samples/pn_shm_tool/pn_shm_tool.c + ) + +target_compile_options(pn_shm_tool + PRIVATE + ${APP_COMPILER_FLAGS} + ) + +target_link_options(pn_shm_tool + PRIVATE + -Wl,--gc-sections + ) + +target_link_libraries (pn_shm_tool PUBLIC rt pthread) + +file(COPY + src/drivers/lan9662/include/driver_config.h + src/drivers/lan9662/include/pnet_lan9662_api.h + DESTINATION include + ) + +file(COPY + src/ports/linux/set_network_parameters + src/drivers/lan9662/set_profinet_leds + DESTINATION + ${PROFINET_BINARY_DIR}/ + ) + +endif() \ No newline at end of file diff --git a/test/test_dcp.cpp b/test/test_dcp.cpp index 2119c4b8..841094a0 100644 --- a/test/test_dcp.cpp +++ b/test/test_dcp.cpp @@ -228,7 +228,7 @@ TEST_F (DcpTest, DcpRunTest) EXPECT_EQ ( mock_os_data.eth_send_count, 9 + (PNET_MAX_PHYSICAL_PORTS - 1) * 4); - EXPECT_EQ (mock_os_data.set_ip_suite_count, 2); + EXPECT_EQ (mock_os_data.set_ip_suite_count, 3); EXPECT_EQ (appdata.call_counters.led_on_calls, 3); EXPECT_EQ (appdata.call_counters.led_off_calls, 4);