Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions .github/.cSpellWords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,20 @@ ecdh
ECDH
ECKEY
fsanitize
FVPs
havege
hkdf
HKDF
IDAQAB
indet
inkey
iotdeviceadvisor
istty
JITP
JITR
Jytl
NBNS
LLMNR
mcuboot
MCUBOOT
mbed
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@
[submodule "Middleware/Unity"]
path = Middleware/Unity
url = https://github.com/ThrowTheSwitch/Unity.git
[submodule "Middleware/FreeRTOS/FreeRTOS-Plus-TCP-lib/FreeRTOS-Plus-TCP"]
path = Middleware/FreeRTOS/FreeRTOS-Plus-TCP-lib/FreeRTOS-Plus-TCP
url = https://github.com/FreeRTOS/FreeRTOS-Plus-TCP.git
2 changes: 1 addition & 1 deletion Bsp/an552_ns.ld
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

__STACK_SIZE = 0x00002800;
__HEAP_SIZE = 0x000b0000;
__HEAP_SIZE = 0x00000400;
Copy link
Contributor

@hugueskamba hugueskamba Oct 12, 2023

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?

Copy link
Contributor Author

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.


MEMORY
{
Expand Down
31 changes: 23 additions & 8 deletions Config/freertos-config/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,37 @@ extern uint32_t SystemCoreClock;
/* Memory allocation related definitions. */
#define configSUPPORT_STATIC_ALLOCATION 1
#define configSUPPORT_DYNAMIC_ALLOCATION 1
#define configTOTAL_HEAP_SIZE 512000 /* should be enough */
#define configAPPLICATION_ALLOCATED_HEAP 1
#define configTOTAL_HEAP_SIZE 720896
#define configAPPLICATION_ALLOCATED_HEAP 0

#define configENABLE_MVE 0
#define configENABLE_FPU 1
#define configENABLE_MPU 0
#define configENABLE_TRUSTZONE 0
#define configRUN_FREERTOS_SECURE_ONLY 0

/* somehow 100 tick per second gives similar timing (~85%) as 1000 did on the FPGA, so with this 1 ms to 1 tick can be */
/* kept... */
#define configTICK_RATE_HZ ( ( uint32_t ) 100 ) /* Scheduler polling rate of 1000 Hz */

/* From the "Fast Models Reference Guide" (https://developer.arm.com/documentation/100964/1123/About-the-models),
* "Programmer's View (PV) models of processors and devices work at a level
* where functional behavior is equivalent to what a programmer would see using
* the hardware.
*
* They sacrifice timing accuracy to achieve fast simulation execution speeds:
* you can use the PV models for confirming software functionality, but you
* must not rely on the accuracy of cycle counts, low-level component
* interactions, or other hardware-specific behavior."
*
* As described above, FVPs sacrifice timing accuracy to achieve fast
* simulation execution speeds. Therefore, we need this work around of setting
* `configTICK_RATE_HZ` to `100` to simulate scheduler polling rate of
* `1000 Hz` or 1 tick per second.
*
* In addition, the macro `pdMS_TO_TICKS` is defined here to match the 1 tick
* per second instead of using the macro defined in
* `FreeRTOS-kernel/include/projdefs.h`
*/
#define configTICK_RATE_HZ ( ( uint32_t ) 100 )
#define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) xTimeInMs )
Copy link
Member

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.

Copy link
Contributor Author

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.

#define TICKS_TO_pdMS( xTics ) ( ( uint32_t ) xTics )
#define TICKS_TO_pdMS( xTicks ) ( ( uint32_t ) xTicks )

#define configMINIMAL_STACK_SIZE 4096
#define configUSE_16_BIT_TICKS 0
Expand All @@ -72,7 +88,6 @@ extern uint32_t SystemCoreClock;
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
#define configUSE_TICKLESS_IDLE 0
#define configCPU_CLOCK_HZ ( ( unsigned long ) SystemCoreClock )
#define configMS_TO_RTOS_TICK( ms ) ( ms ) /* Tick rate is 1000 Hz, so 1 tick is 1 ms */
#define configMAX_PRIORITIES 56
#define configMAX_TASK_NAME_LEN 16
#define configIDLE_SHOULD_YIELD 1
Expand Down
316 changes: 316 additions & 0 deletions Config/freertos-config/FreeRTOSIPConfig.h

Large diffs are not rendered by default.

48 changes: 48 additions & 0 deletions Docs/Prerequisites.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Prerequisites

## Setting up the platforms

This reference integration supports both [Arm ecosystem FVPs](https://developer.arm.com/downloads/-/arm-ecosystem-fvps)
and Arm Virtual Hardware using [Amazon Machine Images](#setting-up-arm-virtual-hardware-using-amazon-machine-images).

The Corstone-300 ecosystem FVP is aligned with the Arm MPS3 development
platform. It is based on the Cortex-M55 processor and offers a choice of the
Ethos-U55 and Ethos-U65 processors. This FVP is provided free of charge for the
limited development and validation of open-source software on the Corstone-300
platform while Arm Virtual Hardware is recommended for commercial software.
Follow the [link](https://developer.arm.com/downloads/-/arm-ecosystem-fvps) for
more information.

### Setting up Arm ecosystem FVPs

* Download the Corstone-300 FVP from [here](https://developer.arm.com/downloads/-/arm-ecosystem-fvps)
* Run the following commands to install the Corstone-300 FVP and add FVP path
to `PATH` variable.
```bash
mkdir FVP_Corstone_SSE-300_11.22_20
tar -xzf <download location>/FVP_Corstone_SSE-300_11.22_20_Linux64.tgz -C FVP_Corstone_SSE-300_11.22_20
cd FVP_Corstone_SSE-300_11.22_20
./FVP_Corstone_SSE-300.sh
echo PATH=\"<FVP installation path>/FVP_Corstone_SSE-300/models/Linux64_GCC-9.3:\$PATH\" >> ~/.bashrc
source ~/.bashrc
```

### Setting up Arm Virtual Hardware using Amazon Machine Images

Follow the instructions described in [Launch Arm Virtual Hardware Instance](setting-up-arm-virtual-hardware.md)
to setup your development environment.

If you have successfully followed the instructions, then you should have a
console (either AWS-Web-Console or Local-Console) to an Arm Virtual Hardware
Instance. From now on, any command-line commands described in this document
must be run on the console connected to the Arm Virtual Hardware Instance.

**Note**
The run example script `Tools/scripts/run.sh` assumes ecosystem FVP by default.
If you are using Arm virtual hardware using Amazon machine images then an
additional argument `--fvp_type vht` must be passed to the run example script.

## Setting up development environment

Follow the instructions described in [Setting Up your Development Environment](development-environment.md)
to setup your development environment.
16 changes: 3 additions & 13 deletions Docs/aws-iot-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,10 @@ non-secure (FreeRTOS kernel and the application) images are singed separately,
MCUBoot verifies that both image signatures are valid before booting. If either
of the verification fails, then MCUBoot stops the booting process.

## Setting up Arm Virtual Hardware using Amazon Machine Images
## Prerequisites

Follow the instructions described in [Launch Arm Virtual Hardware Instance](setting-up-arm-virtual-hardware.md)
to setup your development environment.

If you have successfully followed the instructions, then you should have a
console (either AWS-Web-Console or Local-Console) to an Arm Virtual Hardware
Instance. From now on, any command-line commands described in this document
must be run on the console connected to the Arm Virtual Hardware Instance.

## Setting up development environment

Follow the instructions described in [Setting Up your Development Environment](development-environment.md)
to setup your development environment.
Follow the instructions described in [Prerequisites](Prerequisites.md) and
ensure that all the prerequisites are met before continuing.

## Setting up AWS connectivity

Expand Down
16 changes: 3 additions & 13 deletions Docs/blinky.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,10 @@ on the secure-side and prints it on the console. In addition, to simulate LED
blinking, `LED On` and `LED off` are printed onto the console at regular
intervals.

## Setting up Arm Virtual Hardware using Amazon Machine Images
## Prerequisites

Follow the instructions described in [Launch Arm Virtual Hardware Instance](setting-up-arm-virtual-hardware.md)
to setup your development environment.

If you have successfully followed the instructions, then you should have a
console (either AWS-Web-Console or Local-Console) to Arm Virtual Hardware
Instance. From now on, any command-line commands described in this document
must be run on the console connected to Arm Virtual Hardware Instance.

## Setting up development environment

Follow the instructions described in [Setting Up your Development Environment](development-environment.md)
to setup your development environment.
Follow the instructions described in [Prerequisites](Prerequisites.md) and
ensure that all the prerequisites are met before continuing.

## Building the application

Expand Down
2 changes: 1 addition & 1 deletion Docs/development-environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ argument, you should run:
git submodule update --init --recursive
```

## Prerequisites
## Build requirements

* Ubuntu 20.04 or higher. Please note that the following instructions are
validated on Ubuntu 20.04.
Expand Down
8 changes: 6 additions & 2 deletions Middleware/ARM/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@

add_subdirectory(TF-M)
add_subdirectory(mbedtls-lib)
add_subdirectory(IoT_Socket-lib)
add_subdirectory(IoT_VSocket-lib)
if (DEFINED CONNECTIVITY_STACK)
if (${CONNECTIVITY_STACK} STREQUAL "IOT_VSOCKET")
add_subdirectory(IoT_Socket-lib)
add_subdirectory(IoT_VSocket-lib)
endif()
endif()
add_subdirectory(freertos-pkcs11-psa-lib)
add_subdirectory(freertos-ota-pal-psa-lib)
4 changes: 3 additions & 1 deletion Middleware/ARM/IoT_VSocket-lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ execute_process(COMMAND git am --abort

add_library(iot-vsocket STATIC
AVH/interface/vsocket/iot_socket.c
socket_startup.c
network_startup.c
transport_tls_iot_socket.c
)

add_library(connectivity-stack ALIAS iot-vsocket)

target_include_directories(iot-vsocket
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
Expand All @@ -25,6 +26,7 @@ target_include_directories(iot-vsocket
target_link_libraries(iot-vsocket
PUBLIC
iot-socket-api
event-helper
freertos_kernel
fri-bsp
awsIoT
Expand Down
25 changes: 22 additions & 3 deletions Middleware/ARM/IoT_VSocket-lib/network_startup.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,27 @@

#include <stdint.h>

extern int32_t socket_startup (void);
#include "FreeRTOS.h"
#include "event_helper.h"

int32_t network_startup (void) {
return socket_startup();
int32_t network_startup( void )
{
EventBits_t uxBits;

/* The iot-vsocket implementation utilizes the underlying host network
* stack for network operation. It is assumed that the host network is
* already operational by the time the application runs. */
uxBits = xEventGroupSetBits( xSystemEvents, EVENT_MASK_NETWORK_UP );

if( !( uxBits & EVENT_MASK_NETWORK_UP ) )
{
/* During this stage of application intialisation, there are no other
* tasks active except logging task. Hence the value returned by
* xEventGroupSetBits must have EVENT_MASK_NETWORK_UP bit set. If not,
* something went wrong during initialisation. Trigger an assert to
* catch this. */
configASSERT( 0 );
}

return 0;
}
11 changes: 0 additions & 11 deletions Middleware/ARM/IoT_VSocket-lib/socket_startup.c

This file was deleted.

20 changes: 11 additions & 9 deletions Middleware/ARM/IoT_VSocket-lib/transport_interface_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ typedef enum TransportStatus
TRANSPORT_STATUS_DNS_FAILURE, /**< Resolving hostname of the server failed. */
TRANSPORT_STATUS_SOCKET_CREATE_FAILURE, /**< Underlying socket creation failed. */
TRANSPORT_STATUS_CONNECT_FAILURE, /**< Initial connection to the server failed. */
TRANSPORT_STATUS_TLS_FAILURE, /**< TLS Handshake for the secure connection failed. */
TRANSPORT_STATUS_TLS_FAILURE, /**< TLS Handshake for the secure connection failed. */
TRANSPORT_STATUS_SOCKET_CLOSE_FAILURE /**< Failed to close the underlying socket. */
} TransportStatus_t;

Expand Down Expand Up @@ -118,16 +118,18 @@ typedef struct TLSParams
* @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.
* @param[in] sendTimeoutMs socket send timeout.
* @param[in] recvTimeoutMs socket receive timeout.
*
* @return #TRANSPORT_STATUS_SUCCESS on success;
* #TRANSPORT_STATUS_INVALID_PARAMETER, #TRANSPORT_STATUS_INSUFFICIENT_MEMORY,
* #TRANSPORT_STATUS_CREDENTIALS_INVALID, #TRANSPORT_STATUS_INTERNAL_ERROR,
* #TRANSPORT_STATUS_DNS_FAILURE, #TRANSPORT_STATUS_CONNECT_FAILURE on failure.
*/
TransportStatus_t Transport_Connect( NetworkContext_t * pNetworkContext,
const ServerInfo_t * pServerInfo,
const TLSParams_t * pTLSParams,
uint32_t sendTimeoutMs,
const ServerInfo_t * pServerInfo,
const TLSParams_t * pTLSParams,
uint32_t sendTimeoutMs,
uint32_t recvTimeoutMs );

/**
Expand Down Expand Up @@ -157,8 +159,8 @@ TransportStatus_t Transport_Disconnect( NetworkContext_t * pNetworkContext );
* negative value on error.
*/
int32_t Transport_Recv( NetworkContext_t * pNetworkContext,
void * pBuffer,
size_t bytesToRecv );
void * pBuffer,
size_t bytesToRecv );

/**
* @brief Sends data over an established TLS session using the Secure Sockets API.
Expand All @@ -167,13 +169,13 @@ int32_t Transport_Recv( NetworkContext_t * pNetworkContext,
* 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.
* @param[in] pMessage A message to be sent over the network stack.
* @param[in] bytesToSend Number of bytes to send over the network.
*
* @return Number of bytes sent if successful; negative value on error.
*/
int32_t Transport_Send( NetworkContext_t * pNetworkContext,
const void * pMessage,
size_t bytesToSend );
const void * pMessage,
size_t bytesToSend );

#endif /* TRANSPORT_INTERFACE_API_H */
6 changes: 6 additions & 0 deletions Middleware/FreeRTOS/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@
# SPDX-License-Identifier: MIT

add_subdirectory(kernel)

if (DEFINED CONNECTIVITY_STACK)
if (${CONNECTIVITY_STACK} STREQUAL "FREERTOS_TCP_IP")
add_subdirectory(FreeRTOS-Plus-TCP-lib)
endif()
endif()
33 changes: 33 additions & 0 deletions Middleware/FreeRTOS/FreeRTOS-Plus-TCP-lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2023 Arm Limited and/or its affiliates
# <[email protected]>
# SPDX-License-Identifier: MIT

set(FREERTOS_PLUS_TCP_NETWORK_IF "MPS3_AN552" CACHE STRING "FreeRTOS Plus TCP Network Interface selection")

set(FREERTOS_PLUS_TCP_BUFFER_ALLOCATION "2" CACHE STRING "FreeRTOS buffer allocation model number. 1 .. 2.")

add_subdirectory(FreeRTOS-Plus-TCP/source)
add_subdirectory(FreeRTOS-Plus-TCP/tools)

add_library(connectivity-stack ALIAS freertos_plus_tcp)

target_sources( freertos_plus_tcp
PRIVATE
src/network_startup.c
src/transport_mbedtls.c
)

target_include_directories( freertos_plus_tcp SYSTEM
PUBLIC
src
)

target_link_libraries(freertos_plus_tcp
PRIVATE
app-logging
freertos_kernel
fri-bsp
awsIoT
mbedtls-helpers
event-helper
)
Submodule FreeRTOS-Plus-TCP added at 3d5ee0
Loading