Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FreeRTOS-Plus-TCP port #239

Merged
merged 41 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
3d954cd
FreeRTOS-Plus-TCP port: system and UDP unicast
bjsowa Aug 12, 2023
2d9ed40
Fix clock_elapsed_s method
bjsowa Aug 13, 2023
d3e8cc1
Avoid double free
bjsowa Aug 14, 2023
f949eb3
Add TCP transport
bjsowa Aug 14, 2023
8e2d99d
Fix build when only TCP is enabled
bjsowa Aug 14, 2023
ba1c4c0
Initial FreeRTOS-Plus-TCP example
bjsowa Aug 25, 2023
d502492
Initial CI workflow
bjsowa Aug 25, 2023
c8c8b3d
Fix newline character in printf
bjsowa Aug 28, 2023
b86ce98
Fix network driver checksum options
bjsowa Aug 28, 2023
46bde55
Fix printf newline
bjsowa Aug 28, 2023
6314ac9
Make vAppTask static
bjsowa Aug 28, 2023
649fed5
Resolve MAC address of gateway before running Zenoh app
bjsowa Aug 28, 2023
c7cb1ef
Set zenoh debug level
bjsowa Aug 28, 2023
9965500
Increase socket timeout
bjsowa Aug 28, 2023
98be97f
Fix segfault when failed to create endpoint
bjsowa Aug 28, 2023
28fe14f
Fix warning about overflow in int conversion when using 64-bit system
bjsowa Aug 28, 2023
1390425
Use ai_family returned by getaddrinfo
bjsowa Aug 28, 2023
933324f
Fix tcp and udp read methods
bjsowa Aug 28, 2023
8633333
Retain original contributor in z_pub example
bjsowa Aug 28, 2023
1c0d0b3
Add z_scout example
bjsowa Aug 28, 2023
663724b
Base the z_pub example on unix example
bjsowa Aug 28, 2023
fe5d30e
Add more examples
bjsowa Aug 28, 2023
1581f37
Change FreeRTOS-Plus-TCP repository
bjsowa Aug 29, 2023
66e5d1c
Fix building in Release mode
bjsowa Aug 29, 2023
7fc8da0
Multi-threading initial
bjsowa Aug 29, 2023
841924c
Mark UDP Multicast as unsupported
bjsowa Aug 29, 2023
8148874
Fix _z_task_free
bjsowa Aug 29, 2023
070b5a6
Use multi-threading in examples
bjsowa Aug 29, 2023
daa800d
Add sleep to z_sub example
bjsowa Aug 29, 2023
424421d
Allow passing task attributes to read and lease tasks
bjsowa Aug 29, 2023
62556f9
Use static tasks in z_pub example
bjsowa Aug 29, 2023
a364a6e
Remove redundant print
bjsowa Aug 29, 2023
683a4d8
Add more examples
bjsowa Aug 29, 2023
5d92775
Change char* to const char*
bjsowa Aug 30, 2023
63c089b
Update license headers
bjsowa Aug 30, 2023
2291ddd
Update README
bjsowa Aug 30, 2023
a547d02
Merge branch 'master' into freertos
bjsowa Sep 21, 2023
4e81de9
Fix config keys
bjsowa Sep 21, 2023
d6d757f
Fix fprintzid
bjsowa Sep 21, 2023
376ed99
Ignore freertos_plus_tcp port sources when using PlatformIO
bjsowa Sep 21, 2023
7f9c2cf
Merge remote-tracking branch 'zenoh/master' into freertos
bjsowa Oct 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/freertos_plus_tcp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#
# Copyright (c) 2023 ZettaScale Technology
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
# which is available at https://www.apache.org/licenses/LICENSE-2.0.
#
# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
#
# Contributors:
# Błażej Sowa, <[email protected]>
#
name: freertos_plus_tcp

on:
push:
branches: [ '**' ]
pull_request:
branches: [ '**' ]

jobs:
build:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v2
- uses: jwlawson/[email protected]
- name: Install requirements
run: |
sudo apt update
sudo apt install -y ninja-build libslirp-dev
- name: Build examples
run: |
cd examples/freertos_plus_tcp
cmake -Bbuild -G"Ninja Multi-Config"
cmake --build ./build --config Debug
cmake --build ./build --config Release
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ include(GNUInstallDirs)
option(BUILD_SHARED_LIBS "Build shared libraries if ON, otherwise build static libraries" ON)
option(ZENOH_DEBUG "Use this to set the ZENOH_DEBUG variable." 0)
option(WITH_ZEPHYR "Build for Zephyr RTOS" OFF)
option(WITH_FREERTOS_PLUS_TCP "Build for FreeRTOS RTOS and FreeRTOS-Plus-TCP network stack" OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "")
if(CMAKE_EXPORT_COMPILE_COMMANDS)
set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES
Expand Down Expand Up @@ -91,6 +92,8 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "Windows")
elseif(CMAKE_SYSTEM_NAME MATCHES "Generic")
if(WITH_ZEPHYR)
add_definition(ZENOH_ZEPHYR)
elseif(WITH_FREERTOS_PLUS_TCP)
add_definition(ZENOH_FREERTOS_PLUS_TCP)
endif()
else()
message(FATAL_ERROR "zenoh-pico is not yet available on ${CMAKE_SYSTEM_NAME} platform")
Expand All @@ -104,6 +107,7 @@ message(STATUS "Building in ${CMAKE_BUILD_TYPE} mode")
message(STATUS "Build shared library: ${BUILD_SHARED_LIBS}")
message(STATUS "Zenoh Level Log: ${ZENOH_DEBUG}")
message(STATUS "Build for Zephyr RTOS: ${WITH_ZEPHYR}")
message(STATUS "Build for FreeRTOS-Plus-TCP: ${WITH_FREERTOS_PLUS_TCP}")
message(STATUS "Configuring for ${CMAKE_SYSTEM_NAME}")

if(SKBUILD)
Expand Down Expand Up @@ -163,6 +167,9 @@ file(GLOB_RECURSE Sources
if(WITH_ZEPHYR)
file (GLOB Sources_Zephyr "src/system/zephyr/*.c")
list(APPEND Sources ${Sources_Zephyr})
elseif(WITH_FREERTOS_PLUS_TCP)
file (GLOB Sources_Freertos_Plus_TCP "src/system/freertos_plus_tcp/*.c")
list(APPEND Sources ${Sources_Freertos_Plus_TCP})
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "Darwin" OR CMAKE_SYSTEM_NAME MATCHES "BSD" OR POSIX_COMPATIBLE)
file (GLOB Sources_Unix "src/system/unix/*.c")
list(APPEND Sources ${Sources_Unix})
Expand Down
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,17 @@ It is fully compatible with its main [Rust Zenoh implementation](https://github.

Currently, zenoh-pico provides support for the following (RT)OSs and protocols:

| **(RT)OS** | **Transport Layer** | **Network Layer** | **Data Link Layer** |
|:---------------:|:--------------------------------:|:-------------------:|:--------------------------------------------------:|
| **Unix** | UDP (unicast and multicast), TCP | IPv4, IPv6, 6LoWPAN | WiFi, Ethernet, Thread |
| **Windows** | UDP (unicast and multicast), TCP | IPv4, IPv6 | WiFi, Ethernet |
| **Zephyr** | UDP (unicast and multicast), TCP | IPv4, IPv6, 6LoWPAN | WiFi, Ethernet, Thread, Serial |
| **Arduino** | UDP (unicast and multicast), TCP | IPv4, IPv6 | WiFi, Ethernet, Bluetooth (Serial profile), Serial |
| **ESP-IDF** | UDP (unicast and multicast), TCP | IPv4, IPv6 | WiFi, Ethernet, Serial |
| **MbedOS** | UDP (unicast and multicast), TCP | IPv4, IPv6 | WiFi, Ethernet, Serial |
| **OpenCR** | UDP (unicast and multicast), TCP | IPv4 | WiFi |
| **Emscripten** | Websocket | IPv4, IPv6 | WiFi, Ethernet |
| **(RT)OS** | **Transport Layer** | **Network Layer** | **Data Link Layer** |
|:---------------------:|:--------------------------------:|:-------------------:|:--------------------------------------------------:|
| **Unix** | UDP (unicast and multicast), TCP | IPv4, IPv6, 6LoWPAN | WiFi, Ethernet, Thread |
| **Windows** | UDP (unicast and multicast), TCP | IPv4, IPv6 | WiFi, Ethernet |
| **Zephyr** | UDP (unicast and multicast), TCP | IPv4, IPv6, 6LoWPAN | WiFi, Ethernet, Thread, Serial |
| **Arduino** | UDP (unicast and multicast), TCP | IPv4, IPv6 | WiFi, Ethernet, Bluetooth (Serial profile), Serial |
| **ESP-IDF** | UDP (unicast and multicast), TCP | IPv4, IPv6 | WiFi, Ethernet, Serial |
| **MbedOS** | UDP (unicast and multicast), TCP | IPv4, IPv6 | WiFi, Ethernet, Serial |
| **OpenCR** | UDP (unicast and multicast), TCP | IPv4 | WiFi |
| **Emscripten** | Websocket | IPv4, IPv6 | WiFi, Ethernet |
| **FreeRTOS-Plus-TCP** | UDP (unicast), TCP | IPv4 | Ethernet |

Check the website [zenoh.io](http://zenoh.io) and the [roadmap](https://github.com/eclipse-zenoh/roadmap) for more detailed information.

Expand Down
98 changes: 98 additions & 0 deletions examples/freertos_plus_tcp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#
# Copyright (c) 2023 Fictionlab sp. z o.o.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
# which is available at https://www.apache.org/licenses/LICENSE-2.0.
#
# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
#
# Contributors:
# Błażej Sowa, <[email protected]>

cmake_minimum_required(VERSION 3.20)
project(zenohpico_freertos_plus_tcp_examples)

set(CMAKE_SYSTEM_NAME "Generic")
set(CMAKE_C_STANDARD 11)

include(../../cmake/helpers.cmake)
set_default_build_type(Release)

find_package(PkgConfig REQUIRED)
pkg_check_modules(SLIRP REQUIRED slirp)

add_library(slirp INTERFACE)
target_link_libraries(slirp INTERFACE ${SLIRP_LINK_LIBRARIES})
target_include_directories(slirp INTERFACE ${SLIRP_INCLUDE_DIRS})
target_compile_options(slirp INTERFACE -Wno-error)

include(FetchContent)

FetchContent_Declare(freertos_kernel
GIT_REPOSITORY "https://github.com/FreeRTOS/FreeRTOS-Kernel.git"
GIT_TAG "V10.6.1"
)

FetchContent_Declare(freertos_plus_tcp
GIT_REPOSITORY "https://github.com/FreeRTOS/FreeRTOS-Plus-TCP.git"
GIT_TAG "34148c3"
GIT_SUBMODULES ""
)

add_library(freertos_config INTERFACE)
target_include_directories(freertos_config SYSTEM INTERFACE include)
target_compile_options(freertos_config INTERFACE -Wno-error)

set(FREERTOS_HEAP "3" CACHE STRING "" FORCE)
set(FREERTOS_PORT "GCC_POSIX" CACHE STRING "" FORCE)
set(FREERTOS_PLUS_TCP_NETWORK_IF "LIBSLIRP" CACHE STRING "" FORCE)
set(FREERTOS_PLUS_TCP_BUFFER_ALLOCATION "2" CACHE STRING "" FORCE)

FetchContent_MakeAvailable(freertos_kernel freertos_plus_tcp)

set(BUILD_SHARED_LIBS OFF)
set(WITH_FREERTOS_PLUS_TCP ON)
set(ZENOH_DEBUG 3)
configure_include_project(ZENOHPICO zenohpico zenohpico "../.." zenohpico "https://github.com/eclipse-zenoh/zenoh-pico" "")

target_link_libraries(zenohpico
freertos_kernel
freertos_plus_tcp
)
target_compile_definitions(zenohpico
PUBLIC
Z_FEATURE_MULTI_THREAD=1
Z_FEATURE_LINK_TCP=1
Z_FEATURE_SCOUTING_UDP=1
Z_FEATURE_LINK_UDP_UNICAST=1
Z_FEATURE_LINK_UDP_MULTICAST=0
Z_CONFIG_SOCKET_TIMEOUT=1000
)

add_library(main OBJECT main.c)
target_link_libraries(main
freertos_kernel
freertos_plus_tcp
)

function(add_example name)
add_executable(${name} ${name}.c)
target_link_libraries(${name}
main
freertos_kernel
freertos_plus_tcp
zenohpico
)
endfunction()

add_example(z_get)
add_example(z_pub_st)
add_example(z_pub)
add_example(z_pull)
add_example(z_put)
add_example(z_queryable)
add_example(z_scout)
add_example(z_sub_st)
add_example(z_sub)
64 changes: 64 additions & 0 deletions examples/freertos_plus_tcp/include/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//
// Copyright (c) 2023 Fictionlab sp. z o.o.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License 2.0 which is available at
// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
//
// Contributors:
// Błażej Sowa, <[email protected]>

#ifndef FREERTOS_CONFIG_H
#define FREERTOS_CONFIG_H

#include "bits/pthread_stack_min.h"

/* Core options */
#define configUSE_PREEMPTION 1
#define configTICK_RATE_HZ ((TickType_t)1000)
#define configMAX_PRIORITIES (56)
#define configMINIMAL_STACK_SIZE ((uint16_t) PTHREAD_STACK_MIN)
#define configMAX_TASK_NAME_LEN (16)
#define configUSE_16_BIT_TICKS 0
#define configQUEUE_REGISTRY_SIZE 0
#define configTASK_NOTIFICATION_ARRAY_ENTRIES 1
#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0

/* Hook function related definitions. */
#define configUSE_IDLE_HOOK 0
#define configUSE_TICK_HOOK 0
#define configUSE_MALLOC_FAILED_HOOK 0
#define configUSE_DAEMON_TASK_STARTUP_HOOK 0
#define configUSE_SB_COMPLETED_CALLBACK 0

/* Enable/Disable features */
#define configSUPPORT_STATIC_ALLOCATION 1
#define configSUPPORT_DYNAMIC_ALLOCATION 1
#define configUSE_MUTEXES 1
#define configUSE_RECURSIVE_MUTEXES 1
#define configUSE_COUNTING_SEMAPHORES 1
#define configUSE_CO_ROUTINES 0
#define configUSE_TIMERS 0
#define configUSE_TRACE_FACILITY 0
#define configUSE_QUEUE_SETS 0
#define configUSE_NEWLIB_REENTRANT 0

/* Set the API functions which should be included */
#define INCLUDE_vTaskPrioritySet 1
#define INCLUDE_uxTaskPriorityGet 1
#define INCLUDE_vTaskDelete 1
#define INCLUDE_vTaskCleanUpResources 0
#define INCLUDE_vTaskSuspend 1
#define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1
#define INCLUDE_xTaskGetSchedulerState 1
#define INCLUDE_xTimerPendFunctionCall 1
#define INCLUDE_xQueueGetMutexHolder 1
#define INCLUDE_uxTaskGetStackHighWaterMark 1
#define INCLUDE_eTaskGetState 1
#define INCLUDE_xTimerPendFunctionCall 0

#endif /* FREERTOS_CONFIG_H */
54 changes: 54 additions & 0 deletions examples/freertos_plus_tcp/include/FreeRTOSIPConfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//
// Copyright (c) 2023 Fictionlab sp. z o.o.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License 2.0 which is available at
// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
//
// Contributors:
// Błażej Sowa, <[email protected]>

#ifndef FREERTOS_IP_CONFIG_H
#define FREERTOS_IP_CONFIG_H

// Driver specific
#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN
#define ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES 1
#define ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM 0
#define ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM 1
#define ipconfigZERO_COPY_RX_DRIVER 1
#define ipconfigZERO_COPY_TX_DRIVER 1
#define ipconfigUSE_LINKED_RX_MESSAGES 1
#define ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS 60

// Enable/Disable features
#define ipconfigUSE_IPv4 1
#define ipconfigUSE_IPv6 1
#define ipconfigUSE_DHCP 1
#define ipconfigUSE_DHCPv6 0
#define ipconfigUSE_RA 0
#define ipconfigUSE_DNS 1
#define ipconfigUSE_TCP 1
#define ipconfigUSE_ARP_REMOVE_ENTRY 0
#define ipconfigUSE_ARP_REVERSED_LOOKUP 0
#define ipconfigSUPPORT_SELECT_FUNCTION 0
#define ipconfigSUPPORT_OUTGOING_PINGS 0
#define ipconfigUSE_NETWORK_EVENT_HOOK 1
#define ipconfigUSE_DHCP_HOOK 0

// DHCP
#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD (pdMS_TO_TICKS(1000U))
#define ipconfigDHCP_REGISTER_HOSTNAME 1

#define ipconfigIP_TASK_PRIORITY (configMAX_PRIORITIES - 2)
#define ipconfigIP_TASK_STACK_SIZE_WORDS (configMINIMAL_STACK_SIZE * 5)

// Set ipconfigBUFFER_PADDING on 64-bit platforms
#if INTPTR_MAX == INT64_MAX
#define ipconfigBUFFER_PADDING 14U
#endif

#endif /* FREERTOS_IP_CONFIG_H */
Loading
Loading