-
Notifications
You must be signed in to change notification settings - Fork 15
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
Add support for FreeRTOS TCP/IP stack #9
Add support for FreeRTOS TCP/IP stack #9
Conversation
4b2f7d0
to
c17bd9b
Compare
c17bd9b
to
767e6de
Compare
@@ -62,7 +62,7 @@ extern uint32_t SystemCoreClock; | |||
#define configTICK_RATE_HZ ( ( uint32_t ) 100 ) /* Scheduler polling rate of 1000 Hz */ | |||
|
|||
#define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) xTimeInMs ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you defining these? These are already defined in projdefs.h.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added description about FVP behaviour and the justification for setting configTICK_RATE_HZ
to 100
and the custom definition of pdMS_TO_TICKS
.
@@ -62,7 +62,7 @@ extern uint32_t SystemCoreClock; | |||
#define configTICK_RATE_HZ ( ( uint32_t ) 100 ) /* Scheduler polling rate of 1000 Hz */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment does not match the actual value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe let's just specify the unit in the comment so we never need to update this again should the value change.
OR just delete the comment since the macro already has the unit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added description about FVP behaviour and the justification for setting configTICK_RATE_HZ
to 100
and the custom definition of pdMS_TO_TICKS
.
#if ( ipconfigHAS_DEBUG_PRINTF == 1 ) | ||
#include <stdio.h> | ||
#define FreeRTOS_debug_printf( X ) \ | ||
printf( "%p->%s %d: ", \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why both prrintf and vLoggingPrintf?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was copied from one of the examples. Removed additional printf
.
* messages. */ | ||
#define ipconfigHAS_PRINTF 1 | ||
#if ( ipconfigHAS_PRINTF == 1 ) | ||
#include <stdio.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this include needed here? Should this not be in the implementation file of vLoggingPrintf?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. This is a typo. #include <stdio.h>
removed.
*/ | ||
#define ipconfigIPv4_BACKWARD_COMPATIBLE 0 | ||
|
||
#define portINLINE __inline |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be part of portmacro.h, if not already there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not needed. Removed.
* | ||
* @param[out] pNetworkContext The output parameter to return the created network context. | ||
* @param[in] pServerInfo Server connection info. | ||
* @param[in] pTLSParams socket configs for the connection. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Params sendTimeoutMs and recvTimeoutMs not documented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function header updated.
* over the network. | ||
* | ||
* @param[in] pNetworkContext The network context created using Secure Sockets API. | ||
* @param[in] pBuffer Buffer containing the bytes to send over the network stack. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @param[in] pBuffer Buffer containing the bytes to send over the network stack. | |
* @param[in] pMessage Buffer containing the bytes to send over the network stack. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function header updated.
/* Set socket receive timeout. */ | ||
/* transportTimeout = pdMS_TO_TICKS( recvTimeoutMs ); */ | ||
/* / * Setting the receive block time cannot fail. * / */ | ||
/* ( void ) FreeRTOS_setsockopt( pNetworkContext->socket, */ | ||
/* 0, */ | ||
/* FREERTOS_SO_RCVTIMEO, */ | ||
/* &transportTimeout, */ | ||
/* sizeof( TickType_t ) ); */ | ||
|
||
/* / * Set socket send timeout. * / */ | ||
/* transportTimeout = pdMS_TO_TICKS( sendTimeoutMs ); */ | ||
/* / * Setting the send block time cannot fail. * / */ | ||
/* ( void ) FreeRTOS_setsockopt( pNetworkContext->socket, */ | ||
/* 0, */ | ||
/* FREERTOS_SO_SNDTIMEO, */ | ||
/* &transportTimeout, */ | ||
/* sizeof( TickType_t ) ); */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we remove this commented code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. We need this to set the send/receive timeout on the socket. Code retained.
uint32_t ulDestinationAddress, | ||
uint16_t usDestinationPort ) | ||
{ | ||
psa_status_t xPsaStatus = PSA_ERROR_PROGRAMMER_ERROR; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding the following to avoid unused variable warning -
( void ) ulSourceAddress;
( void ) usSourcePort;
( void ) ulDestinationAddress;
( void ) usDestinationPort;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
manifest.yml
Outdated
version: "3d5ee0e821cab38cb6e6265fcf1ce7552a54519d" | ||
repository: | ||
type: "git" | ||
url: "https://github.com/urutva/FreeRTOS-Plus-TCP.git" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be updated to https://github.com/FreeRTOS/FreeRTOS-Plus-TCP.git
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if I am missing something but I cannot see it changed.
It is still pointing to the fork.
Here is my current URL: https://github.com/FreeRTOS/iot-reference-arm-corstone3xx/pull/9/files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please feel free to resolve this. I do not have a resolve button.
Projects/blinky/CMakeLists.txt
Outdated
@@ -47,6 +47,8 @@ else() | |||
add_compile_options(-O1) | |||
endif() | |||
|
|||
set(NETWORK_COMPONENT "IOT-VSOCKET") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blinky does not need networking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please feel free to resolve this. I do not have a resolve button.
# Select the components required by the application | ||
set(NETWORK_COMPONENT "IOT-VSOCKET") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Select the components required by the application | |
set(NETWORK_COMPONENT "IOT-VSOCKET") | |
set(CONNECTIVITY_STACK "IOT_VSOCKET" CACHE STRING "Choose the connectivity stack to use") | |
set_property(CACHE CONNECTIVITY_STACK PROPERTY STRINGS "IOT_VSOCKET") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NETWORK_COMPONENT
changed to CONNECTIVITY_STACK
.
May be I'm missing something, what is the need to set a property on the variable which isn't used by the build system. If the intention was to describe the possible values, I've added them to the description string in the variable definition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is so if a UI is used for CMake, the possible values will be selectable.
At the moment the connectivity stack is only selectable by changing the CMakeLists.txt. Perhaps also add an optional argument for the build shell script?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently there is no plan to support CMake UI in FRI.
Providing an option to select a network in the build script is useful, however, I cannot think of an use case where developers would like to switch network stack during each build. Hence, hard-coding it in CMake code is a better approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please feel free to resolve this. I do not have a resolve button.
@@ -15,6 +15,8 @@ add_library(iot-vsocket STATIC | |||
transport_tls_iot_socket.c | |||
) | |||
|
|||
add_library(network-component ALIAS iot-vsocket) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add_library(network-component ALIAS iot-vsocket) | |
add_library(connectivity-stack ALIAS iot-vsocket) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please feel free to resolve this. I do not have a resolve button.
# Select the components required by the application | ||
set(NETWORK_COMPONENT "IOT-VSOCKET") | ||
set(NETWORK_COMPONENT "FREERTOS-TCP-IP") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Select the components required by the application | |
set(NETWORK_COMPONENT "IOT-VSOCKET") | |
set(NETWORK_COMPONENT "FREERTOS-TCP-IP") | |
set(CONNECTIVITY_STACK "FREERTOS_PLUS_TCP" CACHE STRING "Choose the connectivity stack to use") | |
set_property(CACHE CONNECTIVITY_STACK PROPERTY STRINGS "FREERTOS_PLUS_TCP" "IOT_VSOCKET") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NETWORK_COMPONENT changed to CONNECTIVITY_STACK.
May be I'm missing something, what is the need to set a property on the variable which isn't used by the build system. If the intention was to describe the possible values, I've added them to the description string in the variable definition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is so if a UI is used for CMake, the possible values will be selectable.
At the moment the connectivity stack is only selectable by changing the CMakeLists.txt. Perhaps also add an optional argument for the build shell script?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as #9 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please feel free to resolve this. I do not have a resolve button.
Middleware/FreeRTOS/CMakeLists.txt
Outdated
@@ -3,3 +3,6 @@ | |||
# SPDX-License-Identifier: MIT | |||
|
|||
add_subdirectory(kernel) | |||
if (${NETWORK_COMPONENT} STREQUAL "FREERTOS-TCP-IP") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (${NETWORK_COMPONENT} STREQUAL "FREERTOS-TCP-IP") | |
if(CONNECTIVITY_STACK STREQUAL "FREERTOS_PLUS_TCP") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please feel free to resolve this. I do not have a resolve button.
app-config | ||
app-logging | ||
event-helper | ||
PUBLIC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason for having this PUBLIC
?
Is it worth explaining with a comment or in the PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It turns out that the dependency on connectivity-stack
need not be public. Changed the dependency to PRIVATE
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please feel free to resolve this. I do not have a resolve button.
Instead of directly using malloc, use FreeRTOS provided malloc API. Signed-off-by: Devaraj Ranganna <devaraj.ranganna@arm.com>
FreeRTOS TCP/IP stack recommends `heap_4` and `BufferAllocation_2`. https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/tree/V4.0.0-appsec#note Since FreeRTOS manages the heap, set Mbed TLS memory APIs to use FreeRTOS heap APIs (mbedtls_platform_set_calloc_free). In addition, reduce allocated heap size from `0x000b0000` to `0x00000400`, since FreeRTOS manages heap when `heap_4` configuration is selected. Ideally, heap size should be 0, however, GNU expects linker symbol `end` to be available. Hence, set it to `0x400`. Also, set the FreeRTOS config `configAPPLICATION_ALLOCATED_HEAP` to 0, indicating FreeRTOS allocates the heap based on `configTOTAL_HEAP_SIZE` (720896 bytes). Signed-off-by: Devaraj Ranganna <devaraj.ranganna@arm.com>
The socket creation is part of `Middleware/ARM/IoT_VSocket-lib/AVH/interface/vsocket/iot_socket.c` and hence `socket_startup.c` is redundant. In addition, `socket_startup()` always returns 0. Signed-off-by: Devaraj Ranganna <devaraj.ranganna@arm.com>
The system event helper library provides system event management, so that the tasks can wait on the required system event to happen. Signed-off-by: Devaraj Ranganna <devaraj.ranganna@arm.com>
Add a CMake variable `CONNECTIVITY_STACK`, so that the application can select a network stack from the supported network stacks. Signed-off-by: Devaraj Ranganna <devaraj.ranganna@arm.com>
Since we are integrating latest version of FreeRTOS TCP/IP stack which relies on FreeRTOS kernel, ensure that we are using the latest released version of FreeRTOS kernel which is `V10.6.1`. In addtion, fix a typo and remove unused macro from `FreeRTOSConfig.h`. Signed-off-by: Devaraj Ranganna <devaraj.ranganna@arm.com>
767e6de
to
b9b82d7
Compare
Signed-off-by: Devaraj Ranganna <devaraj.ranganna@arm.com>
Added support for FreeRTOS TCP/IP stack and made it the default choice of network stack. Signed-off-by: Devaraj Ranganna <devaraj.ranganna@arm.com>
Added support for choosing either ecosystem FVP or Arm virtual hardware FVP running in the AMI to the `run.sh` script. The ecosystem FVP is used by default. Signed-off-by: Devaraj Ranganna <devaraj.ranganna@arm.com>
With the addition of support for FreeRTOS TCP/IP stack, in addition to Arm Virtual Hardware using Amazon Machine Images, Arm FRI can now run ecosystem FVPs. Signed-off-by: Devaraj Ranganna <devaraj.ranganna@arm.com>
Signed-off-by: Devaraj Ranganna <devaraj.ranganna@arm.com>
Signed-off-by: Devaraj Ranganna <devaraj.ranganna@arm.com>
Provide justification for setting `configTICK_RATE_HZ` to `100` to simulate scheduler polling rate of `1000 Hz` or 1 tick per second. Signed-off-by: Devaraj Ranganna <devaraj.ranganna@arm.com>
b9b82d7
to
6463898
Compare
@@ -9,7 +9,7 @@ | |||
*/ | |||
|
|||
__STACK_SIZE = 0x00002800; | |||
__HEAP_SIZE = 0x000b0000; | |||
__HEAP_SIZE = 0x00000400; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the linker scripts and FreeRTOSConfig.h
are used by the two applications, is it also necessary to modify Blinky to use Heap 4 instead of Heap 3?
Can we move the heap selection to https://github.com/FreeRTOS/iot-reference-arm-corstone3xx/blob/main/Middleware/FreeRTOS/CMakeLists.txt
so it applies to all applications using the FRI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion. Let's handle that as part of another PR to improve blinky example.
Add support for FreeRTOS TCP/IP stack
Description
This PR adds support for FreeRTOS TCP/IP stack and makes it the default network stack for the FRI.
Test Steps
Tested AWS IoT core end to end connectivity and OTA job.
Checklist:
Related Issue
Depends on FreeRTOS/FreeRTOS-Plus-TCP#1009
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.