Update code to v1.0.14 (10)

This commit is contained in:
Caten
2024-02-29 19:35:00 +08:00
parent c2ee3b694c
commit a956d26f6d
3188 changed files with 2317293 additions and 146 deletions

View File

@@ -0,0 +1,3 @@
# Ignore output directories
/out/
/install/

View File

@@ -0,0 +1,59 @@
# CMakeList.txt
#
# Copyright (C) 2006-2022 wolfSSL Inc.
#
# This file is part of wolfSSL. (formerly known as CyaSSL)
#
# Usage:
# In MSVS 2019 with Azure Sphere plugin installed choose option
# "Open Local Folder" and browse to wolfssl-root/IDE/MSVS-2019-AZSPHERE"
# highlight wolfssl_new_azsphere and select "Open"
#
# To build:
# go to MSVS menu option "Build" and select "Build All"
#
# See https://docs.microsoft.com/en-us/azure-sphere/install/overview for how
# to get started with an Azure sphere device. Once you have completed the step
# to build/flash and run the Blinky example you will be ready to build/flash
# and run this example!
cmake_minimum_required (VERSION 3.4.1)
project (wolfssl_new_azsphere C)
azsphere_configure_tools(TOOLS_REVISION "22.02")
azsphere_configure_api(TARGET_API_SET "12")
# add wolfSSL preprocessor directives
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS -Wno-conversion -Wno-sign-conversion")
# add a shared object for SSL/TLS and CRYPTO
set( SSL_SRC_DIR "../../../src" )
set( CRYPTO_SRC_DIR "../../../wolfcrypt/src" )
set( INCLUDE_DIR "../../.." )
aux_source_directory( ${SSL_SRC_DIR} SSL_SOURCES )
list( REMOVE_ITEM SSL_SOURCES ../../../src/bio.c )
list( REMOVE_ITEM SSL_SOURCES ../../../src/conf.c )
list( REMOVE_ITEM SSL_SOURCES ../../../src/x509.c )
list( REMOVE_ITEM SSL_SOURCES ../../../src/x509_str.c )
list( REMOVE_ITEM SSL_SOURCES ../../../src/pk.c )
list( REMOVE_ITEM SSL_SOURCES ../../../src/ssl_misc.c )
aux_source_directory( ${CRYPTO_SRC_DIR} CRYPTO_SOURCES )
list( REMOVE_ITEM CRYPTO_SOURCES ../../../wolfcrypt/src/evp.c )
list( REMOVE_ITEM CRYPTO_SOURCES ../../../wolfcrypt/src/misc.c )
add_library( wolfssl STATIC ${SSL_SOURCES} ${CRYPTO_SOURCES} )
# Create executable that uses library
set( SERVER_APP_DIR "../server" )
set( CLIENT_APP_DIR "../client" )
set( USER_SETTINGS_DIR ".." )
set( APP_INCLUDE_DIRS ${SERVER_APP_DIR} ${CLIENT_APP_DIR} ${USER_SETTINGS_DIR} )
add_executable (${PROJECT_NAME} main.c ${SERVER_APP_DIR}/server.c ${CLIENT_APP_DIR}/client.c )
target_link_libraries (${PROJECT_NAME} applibs pthread gcc_s c wolfssl)
include_directories( ${INCLUDE_DIR} ${APP_INCLUDE_DIRS})
# azsphere_target_hardware_definition(${PROJECT_NAME} TARGET_DIRECTORY "HardwareDefinitions/mt3620_rdb" TARGET_DEFINITION "template_appliance.json")
azsphere_target_hardware_definition(${PROJECT_NAME} TARGET_DIRECTORY "HardwareDefinitions/seeed_mt3620_mdb" TARGET_DEFINITION "template_appliance.json")
azsphere_target_add_image_package(${PROJECT_NAME})

View File

@@ -0,0 +1,47 @@
{
"environments": [
{
"environment": "AzureSphere"
}
],
"configurations": [
{
"name": "ARM-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [
"AzureSphere"
],
"buildRoot": "${projectDir}\\out\\${name}",
"installRoot": "${projectDir}\\out\\${name}",
"cmakeToolchain": "${env.AzureSphereDefaultSDKDir}CMakeFiles\\AzureSphereToolchain.cmake",
"buildCommandArgs": "-v",
"ctestCommandArgs": "",
"variables": [
{
"name": "AZURE_SPHERE_TARGET_API_SET",
"value": "latest-lts"
}
]
},
{
"name": "ARM-Release",
"generator": "Ninja",
"configurationType": "Release",
"inheritEnvironments": [
"AzureSphere"
],
"buildRoot": "${projectDir}\\out\\${name}",
"installRoot": "${projectDir}\\out\\${name}",
"cmakeToolchain": "${env.AzureSphereDefaultSDKDir}CMakeFiles\\AzureSphereToolchain.cmake",
"buildCommandArgs": "-v",
"ctestCommandArgs": "",
"variables": [
{
"name": "AZURE_SPHERE_TARGET_API_SET",
"value": "latest-lts"
}
]
}
]
}

View File

@@ -0,0 +1,36 @@
/* template_appliance.h
*
* Copyright (C) 2006-2022 wolfSSL Inc.
*
* This file is part of wolfSSL.
*
* wolfSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
/* This file maps the Avnet MT3620 Starter Kit (SK)
* to the 'template appliance' abstraction used by the templates.
* Some peripherals are on-board, while other peripherals must be
* attached externally (conditionally).
* See https://aka.ms/AzureSphereHardwareDefinitions for more
* information on how to use hardware abstractions .
*/
#pragma once
#include "avnet_mt3620_sk.h"
/* MT3620 SK: wolfssl azsphere CI app */
#define WOLF_AZSPHERE AVNET_MT3620_SK_USER_LED_RED

View File

@@ -0,0 +1,41 @@
{
"Metadata": {
"Type": "Azure Sphere Hardware Definition",
"Version": 1
},
"Description":
{
"Name": "Template hardware abstraction for Avnet MT3620 SK",
"MainCoreHeaderFileTopContent": [
"/* Copyright (C) 2006-2022 wolfSSL Inc.",
" * This file is part of wolfSSL.",
" *",
" * wolfSSL is free software; you can redistribute it and/or modify",
" * it under the terms of the GNU General Public License as published by",
" * the Free Software Foundation; either version 2 of the License, or",
" * (at your option) any later version.",
" *",
" * wolfSSL is distributed in the hope that it will be useful,",
" * but WITHOUT ANY WARRANTY; without even the implied warranty of",
" * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the",
" * GNU General Public License for more details.",
" *",
" * You should have received a copy of the GNU General Public License",
" * along with this program; if not, write to the Free Software",
" * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA",
" */",
"/* This file maps the Avnet MT3620 Starter Kit (SK)",
" * to the 'template appliance' abstraction used by the templates.",
" * Some peripherals are on-board, while other peripherals must be",
" * attached externally (conditionally).",
" * See https://aka.ms/AzureSphereHardwareDefinitions for more",
" * information on how to use hardware abstractions .",
" */"
]
},
"Imports" : [ {"Path": "avnet_mt3620_sk.json"} ],
"Peripherals": [
{"Name": "WOLF_AZSPHERE", "Type": "Gpio", "Mapping": "AVNET_MT3620_SK_USER_LED_RED", "Comment": "MT3620 SK: User LED."}
]
}

View File

@@ -0,0 +1,32 @@
/* Copyright (C) 2006-2022 wolfSSL Inc.
* This file is part of wolfSSL.
*
* wolfSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
/* This file maps the MT3620 reference development board (RDB)
* to the 'template appliance' abstraction used by the templates.
* Some peripherals are on-board, while other peripherals must be
* attached externally (conditionally).
* See https://aka.ms/AzureSphereHardwareDefinitions for more
* information on how to use hardware abstractions .
*/
#pragma once
#include "mt3620_rdb.h"
/* MT3620 SK: wolfssl azsphere CI app */
#define WOLF_AZSPHERE MT3620_RDB_LED1_RED

View File

@@ -0,0 +1,41 @@
{
"Metadata": {
"Type": "Azure Sphere Hardware Definition",
"Version": 1
},
"Description":
{
"Name": "Template hardware abstraction for MT3620 RDB",
"MainCoreHeaderFileTopContent": [
"/* Copyright (C) 2006-2022 wolfSSL Inc.",
" * This file is part of wolfSSL.",
" *",
" * wolfSSL is free software; you can redistribute it and/or modify",
" * it under the terms of the GNU General Public License as published by",
" * the Free Software Foundation; either version 2 of the License, or",
" * (at your option) any later version.",
" *",
" * wolfSSL is distributed in the hope that it will be useful,",
" * but WITHOUT ANY WARRANTY; without even the implied warranty of",
" * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the",
" * GNU General Public License for more details.",
" *",
" * You should have received a copy of the GNU General Public License",
" * along with this program; if not, write to the Free Software",
" * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA",
" */",
"/* This file maps the MT3620 reference development board (RDB)",
" * to the 'template appliance' abstraction used by the templates.",
" * Some peripherals are on-board, while other peripherals must be",
" * attached externally (conditionally).",
" * See https://aka.ms/AzureSphereHardwareDefinitions for more",
" * information on how to use hardware abstractions .",
" */"
]
},
"Imports" : [ {"Path": "mt3620_rdb.json"} ],
"Peripherals": [
{"Name": "WOLF_AZSPHERE", "Type": "Gpio", "Mapping": "MT3620_RDB_LED1_RED", "Comment": "MT3620 RDB: LED 1 (red channel)"}
]
}

View File

@@ -0,0 +1,35 @@
/* template_appliance.h
*
* Copyright (C) 2006-2022 wolfSSL Inc.
*
* This file is part of wolfSSL.
*
* wolfSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
/* This file maps the Seeed MT3620 Mini Development Board (MDB)
* to the 'template appliance' abstraction used by the templates.
* Some peripherals are on-board, while other peripherals must be
* attached externally (conditionally).
* See https://aka.ms/AzureSphereHardwareDefinitions for more
* information on how to use hardware abstractions .
*/
#pragma once
#include "seeed_mt3620_mdb.h"
/* MT3620 SK: wolfssl azsphere CI app */
#define WOLF_AZSPHERE SEEED_MT3620_MDB_USER_LED

View File

@@ -0,0 +1,41 @@
{
"Metadata": {
"Type": "Azure Sphere Hardware Definition",
"Version": 1
},
"Description":
{
"Name": "Template hardware abstraction for Seeed MT3620 MDB",
"MainCoreHeaderFileTopContent": [
"/* Copyright (C) 2006-2022 wolfSSL Inc.",
" * This file is part of wolfSSL.",
" *",
" * wolfSSL is free software; you can redistribute it and/or modify",
" * it under the terms of the GNU General Public License as published by",
" * the Free Software Foundation; either version 2 of the License, or",
" * (at your option) any later version.",
" *",
" * wolfSSL is distributed in the hope that it will be useful,",
" * but WITHOUT ANY WARRANTY; without even the implied warranty of",
" * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the",
" * GNU General Public License for more details.",
" *",
" * You should have received a copy of the GNU General Public License",
" * along with this program; if not, write to the Free Software",
" * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA",
" */",
"/* This file maps the Seeed MT3620 Mini Development Board (MDB)",
" * to the 'template appliance' abstraction used by the templates.",
" * Some peripherals are on-board, while other peripherals must be",
" * attached externally (conditionally).",
" * See https://aka.ms/AzureSphereHardwareDefinitions for more",
" * information on how to use hardware abstractions .",
" */"
]
},
"Imports" : [ {"Path": "seeed_mt3620_mdb.json"} ],
"Peripherals": [
{"Name": "WOLF_AZSPHERE", "Type": "Gpio", "Mapping": "SEEED_MT3620_MDB_USER_LED", "Comment": "MT3620 MDB: User LED."}
]
}

View File

@@ -0,0 +1,12 @@
{
"SchemaVersion": 1,
"Name": "wolfssl_new_azsphere",
"ComponentId": "959b4478-a9a3-440a-b1e7-9bb0b1f1d357",
"EntryPoint": "/bin/app",
"CmdArgs": [],
"Capabilities": {
"Gpio": [ "$WOLF_AZSPHERE" ],
"AllowedApplicationConnections": []
},
"ApplicationType": "Default"
}

View File

@@ -0,0 +1,25 @@
#pragma once
/// <summary>
/// This identifier should be defined before including any of the networking-related header files.
/// It indicates which version of the Wi-Fi data structures the application uses.
/// </summary>
#define NETWORKING_STRUCTS_VERSION 1
/// <summary>
/// This identifier must be defined before including any of the Wi-Fi related header files.
/// It indicates which version of the Wi-Fi data structures the application uses.
/// </summary>
#define WIFICONFIG_STRUCTS_VERSION 1
/// <summary>
/// This identifier must be defined before including any of the UART-related header files.
/// It indicates which version of the UART data structures the application uses.
/// </summary>
#define UART_STRUCTS_VERSION 1
/// <summary>
/// This identifier must be defined before including any of the SPI-related header files.
/// It indicates which version of the SPI data structures the application uses.
/// </summary>
#define SPI_STRUCTS_VERSION 1

View File

@@ -0,0 +1,14 @@
{
"version": "0.2.1",
"configurations": [
{
"type": "azurespheredbg",
"name": "wolfssl_new_azsphere (HLCore)",
"project": "CMakeLists.txt",
"workingDirectory": "${workspaceRoot}",
"applicationPath": "${debugInfo.target}",
"imagePath": "${debugInfo.targetImage}",
"partnerComponents": []
}
]
}

View File

@@ -0,0 +1,92 @@
/* main.c
*
* Copyright (C) 2006-2022 wolfSSL Inc.
*
* This file is part of wolfSSL.
*
* wolfSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
#include <stdbool.h>
#include <errno.h>
#include <string.h>
#include <time.h>
#include <applibs/log.h>
#include <applibs/gpio.h>
#include <wolfssl/wolfcrypt/settings.h>
#ifndef WOLFSSL_USER_SETTINGS
#error "user_settings.h not included"
#endif
#include <server.h>
#include <client.h>
/*
* The following #include imports a "template appliance" definition. This app
* comes with multiple implementations of the template appliance, each in a
* separate directory, which allow the code to run unchanged on different
* hardware.
*
* By default, this app targets hardware that follows the MT3620-mini Reference
* Development Board (MDB) specification, such as the MT3620-mini Dev Kit from
* Seeed Studio.
*
* To target different hardware, you'll need to update CMakeLists.txt.
* For example, to target the Avnet MT3620 Starter Kit, make this update:
* azsphere_target_hardware_definition(${PROJECT_NAME}
* TARGET_DIRECTORY "HardwareDefinitions/avnet_mt3620_sk"
* TARGET_DEFINITION "template_appliance.json")
*
* See https://aka.ms/AzureSphereHardwareDefinitions for more details.
*/
#include <hw/template_appliance.h>
typedef enum {
ExitCode_Success = 0,
ExitCode_Main_Led = 1
} ExitCode;
int main(void)
{
Log_Debug(
"\nVisit https://github.com/Azure/azure-sphere-samples for other"
" examples.\n");
int ret;
int fd = GPIO_OpenAsOutput(WOLF_AZSPHERE, GPIO_OutputMode_PushPull, GPIO_Value_High);
if (fd < 0) {
Log_Debug(
"Error opening GPIO: %s (%d). Check that app_manifest.json includes"
" the GPIO used.\n",
strerror(errno), errno);
return ExitCode_Main_Led;
}
const struct timespec sleepTime = {.tv_sec = 1, .tv_nsec = 0};
printf("Launching the server...\n");
ret = azsphere_server_app();
printf("ret azsphere_server_app = %d\n", ret);
/* if server exists continually blink the red LED indicating server needs
* to be rebooted */
while (true) {
GPIO_SetValue(fd, GPIO_Value_Low);
nanosleep(&sleepTime, NULL);
GPIO_SetValue(fd, GPIO_Value_High);
nanosleep(&sleepTime, NULL);
}
}