Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into orgpal-mesh
  • Loading branch information
actions-user committed Oct 31, 2023
2 parents da0438b + 4fe58c7 commit 674bdda
Show file tree
Hide file tree
Showing 25 changed files with 662 additions and 97 deletions.
82 changes: 52 additions & 30 deletions CMake/Modules/FindNF_NativeAssemblies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,45 +9,52 @@
# and the namespace designation is 'System.Device.Gpio'
###########################################################################################

option(API_nanoFramework.Device.Can "option for nanoFramework.Device.Can")
option(API_nanoFramework.Device.OneWire "option for nanoFramework.Device.OneWire")
option(API_nanoFramework.Networking.Sntp "option for nanoFramework.Networking.Sntp")
option(API_nanoFramework.Runtime.Events "option for nanoFramework.Runtime.Events API")
option(API_nanoFramework.ResourceManager "option for nanoFramework.ResourceManager")
option(API_nanoFramework.System.Collections "option for nanoFramework.System.Collections")
option(API_nanoFramework.System.Text "option for nanoFramework.System.Text")
option(API_System.IO.FileSystem "option for System.IO.FileSystem")
option(API_System.Math "option for System.Math")
option(API_System.Net "option for System.Net")
option(API_System.Device.Adc "option for System.Device.Adc API")
option(API_System.Device.Dac "option for System.Device.Dac API")
option(API_System.Device.Gpio "option for System.Device.Gpio API")
option(API_System.Device.I2c "option for System.Device.I2c API")
option(API_System.Device.I2s "option for System.Device.I2s API")
option(API_System.Device.Pwm "option for System.Device.Pwm API")
option(API_System.IO.Ports "option for System.IO.Ports API")
option(API_System.Device.Spi "option for System.Device.Spi API")
option(API_System.Runtime.Serialization "option for System.Runtime.Serialization API")
option(API_Windows.Storage "option for Windows.Storage")
option(API_nanoFramework.Graphics "option for nanoFramework.Graphics")
option(API_nanoFramework.Device.Bluetooth "option for nanoFramework.Device.Bluetooth")
option(API_System.Device.UsbStream "option for System.Device.UsbStream API")
option(API_nanoFramework.Device.Can "option for nanoFramework.Device.Can")
option(API_nanoFramework.Device.OneWire "option for nanoFramework.Device.OneWire")
option(API_nanoFramework.Networking.Sntp "option for nanoFramework.Networking.Sntp")
option(API_nanoFramework.Runtime.Events "option for nanoFramework.Runtime.Events API")
option(API_nanoFramework.ResourceManager "option for nanoFramework.ResourceManager")
option(API_nanoFramework.System.Collections "option for nanoFramework.System.Collections")
option(API_nanoFramework.System.Text "option for nanoFramework.System.Text")
option(API_System.IO.FileSystem "option for System.IO.FileSystem")
option(API_System.Math "option for System.Math")
option(API_System.Net "option for System.Net")
option(API_System.Device.Adc "option for System.Device.Adc API")
option(API_System.Device.Dac "option for System.Device.Dac API")
option(API_System.Device.Gpio "option for System.Device.Gpio API")
option(API_System.Device.I2c "option for System.Device.I2c API")
option(API_System.Device.I2s "option for System.Device.I2s API")
option(API_System.Device.Pwm "option for System.Device.Pwm API")
option(API_System.IO.Ports "option for System.IO.Ports API")
option(API_System.Device.Spi "option for System.Device.Spi API")
option(API_System.Runtime.Serialization "option for System.Runtime.Serialization API")
option(API_Windows.Storage "option for Windows.Storage")
option(API_nanoFramework.Graphics "option for nanoFramework.Graphics")
option(API_nanoFramework.Device.Bluetooth "option for nanoFramework.Device.Bluetooth")
option(API_System.Device.UsbStream "option for System.Device.UsbStream API")
option(API_nanoFramework.System.IO.Hashing "option for nanoFramework.System.IO.Hashing API")
option(API_nanoFramework.System.Security.Cryptography "option for nanoFramework.System.Security.Cryptography API")

# Esp32 only
option(API_Hardware.Esp32 "option for Hardware.Esp32")
option(API_nanoFramework.Hardware.Esp32.Rmt "option for nanoFramework.Hardware.Esp32.Rmt")
option(API_Hardware.Esp32 "option for Hardware.Esp32")
option(API_nanoFramework.Hardware.Esp32.Rmt "option for nanoFramework.Hardware.Esp32.Rmt")


# Stm32 only
option(API_Hardware.Stm32 "option for Hardware.Stm32")
option(API_Hardware.Stm32 "option for Hardware.Stm32")

# TI CC13xxCC26xx
option(API_nanoFramework.TI.EasyLink "option for nanoFramework.TI.EasyLink API")
option(API_nanoFramework.Hardware.TI "option for nanoFramework.Hardware.TI API")
option(API_nanoFramework.TI.EasyLink "option for nanoFramework.TI.EasyLink API")
option(API_nanoFramework.Hardware.TI "option for nanoFramework.Hardware.TI API")

# Silabs Giant Gecko only
option(API_nanoFramework.GiantGecko.Adc "option for nanoFramework.GiantGecko.Adc")
option(API_Hardware.GiantGecko "option for Hardware.GiantGecko")
option(API_nanoFramework.GiantGecko.Adc "option for nanoFramework.GiantGecko.Adc")
option(API_Hardware.GiantGecko "option for Hardware.GiantGecko")

###################################
# add options for private APIs here

###################################

###################################
# add options for private APIs here
Expand Down Expand Up @@ -261,6 +268,21 @@ if(API_Hardware.GiantGecko)
PerformSettingsForApiEntry("nanoFramework.Hardware.GiantGecko")
endif()

# nanoFramework.System.IO.Hashing
if(API_nanoFramework.System.IO.Hashing)
##### API name here (doted name)
PerformSettingsForApiEntry("nanoFramework.System.IO.Hashing")
endif()

# nanoFramework.System.Security.Cryptography
if(API_nanoFramework.System.Security.Cryptography)
##### API name here (doted name)
PerformSettingsForApiEntry("nanoFramework.System.Security.Cryptography")

# enable adding Mbed TLS to the build
set(NF_REQUIRES_MBEDTLS TRUE CACHE BOOL "Enable Mbed TLS for nanoFramework.System.Security.Cryptography" FORCE)
endif()

# nanoFramework.Runtime.Events
if(API_nanoFramework.Runtime.Events)
##### API name here (doted name)
Expand Down
51 changes: 51 additions & 0 deletions CMake/Modules/FindnanoFramework.System.IO.Hashing.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#
# Copyright (c) .NET Foundation and Contributors
# See LICENSE file in the project root for full license information.
#

# native code directory
set(BASE_PATH_FOR_THIS_MODULE ${BASE_PATH_FOR_CLASS_LIBRARIES_MODULES}/nanoFramework.System.IO.Hashing)


# set include directories
list(APPEND nanoFramework.System.IO.Hashing_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/src/CLR/Core)
list(APPEND nanoFramework.System.IO.Hashing_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/src/CLR/Include)
list(APPEND nanoFramework.System.IO.Hashing_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/src/HAL/Include)
list(APPEND nanoFramework.System.IO.Hashing_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/src/PAL/Include)
list(APPEND nanoFramework.System.IO.Hashing_INCLUDE_DIRS ${BASE_PATH_FOR_THIS_MODULE})
list(APPEND nanoFramework.System.IO.Hashing_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/src/nanoFramework.System.IO.Hashing)

# source files
set(nanoFramework.System.IO.Hashing_SRCS

nf_sys_io_hashing.cpp


nf_sys_io_hashing_System_IO_Hashing_Crc32.cpp

)

foreach(SRC_FILE ${nanoFramework.System.IO.Hashing_SRCS})

set(nanoFramework.System.IO.Hashing_SRC_FILE SRC_FILE-NOTFOUND)

find_file(nanoFramework.System.IO.Hashing_SRC_FILE ${SRC_FILE}
PATHS
${BASE_PATH_FOR_THIS_MODULE}
${TARGET_BASE_LOCATION}
${PROJECT_SOURCE_DIR}/src/nanoFramework.System.IO.Hashing

CMAKE_FIND_ROOT_PATH_BOTH
)

if (BUILD_VERBOSE)
message("${SRC_FILE} >> ${nanoFramework.System.IO.Hashing_SRC_FILE}")
endif()

list(APPEND nanoFramework.System.IO.Hashing_SOURCES ${nanoFramework.System.IO.Hashing_SRC_FILE})

endforeach()

include(FindPackageHandleStandardArgs)

FIND_PACKAGE_HANDLE_STANDARD_ARGS(nanoFramework.System.IO.Hashing DEFAULT_MSG nanoFramework.System.IO.Hashing_INCLUDE_DIRS nanoFramework.System.IO.Hashing_SOURCES)
51 changes: 51 additions & 0 deletions CMake/Modules/FindnanoFramework.System.Security.Cryptography.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#
# Copyright (c) .NET Foundation and Contributors
# See LICENSE file in the project root for full license information.
#

# native code directory
set(BASE_PATH_FOR_THIS_MODULE ${BASE_PATH_FOR_CLASS_LIBRARIES_MODULES}/nanoFramework.System.Security.Cryptography)


# set include directories
list(APPEND nanoFramework.System.Security.Cryptography_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/src/CLR/Core)
list(APPEND nanoFramework.System.Security.Cryptography_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/src/CLR/Include)
list(APPEND nanoFramework.System.Security.Cryptography_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/src/HAL/Include)
list(APPEND nanoFramework.System.Security.Cryptography_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/src/PAL/Include)
list(APPEND nanoFramework.System.Security.Cryptography_INCLUDE_DIRS ${BASE_PATH_FOR_THIS_MODULE})
list(APPEND nanoFramework.System.Security.Cryptography_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/src/nanoFramework.System.Security.Cryptography)

# source files
set(nanoFramework.System.Security.Cryptography_SRCS

nf_sys_sec_cryptography.cpp


nf_sys_sec_cryptography_System_Security_Cryptography_HMACSHA256.cpp

)

foreach(SRC_FILE ${nanoFramework.System.Security.Cryptography_SRCS})

set(nanoFramework.System.Security.Cryptography_SRC_FILE SRC_FILE-NOTFOUND)

find_file(nanoFramework.System.Security.Cryptography_SRC_FILE ${SRC_FILE}
PATHS
${BASE_PATH_FOR_THIS_MODULE}
${TARGET_BASE_LOCATION}
${PROJECT_SOURCE_DIR}/src/nanoFramework.System.Security.Cryptography

CMAKE_FIND_ROOT_PATH_BOTH
)

if (BUILD_VERBOSE)
message("${SRC_FILE} >> ${nanoFramework.System.Security.Cryptography_SRC_FILE}")
endif()

list(APPEND nanoFramework.System.Security.Cryptography_SOURCES ${nanoFramework.System.Security.Cryptography_SRC_FILE})

endforeach()

include(FindPackageHandleStandardArgs)

FIND_PACKAGE_HANDLE_STANDARD_ARGS(nanoFramework.System.Security.Cryptography DEFAULT_MSG nanoFramework.System.Security.Cryptography_INCLUDE_DIRS nanoFramework.System.Security.Cryptography_SOURCES)
8 changes: 7 additions & 1 deletion CMake/binutils.ChibiOS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ macro(nf_add_platform_dependencies target)

endif()

if(API_nanoFramework.System.Security.Cryptography)
FetchContent_GetProperties(mbedtls)
endif()

nf_add_lib_native_assemblies(
EXTRA_INCLUDES
${CHIBIOS_INCLUDE_DIRS}
Expand All @@ -171,7 +175,9 @@ macro(nf_add_platform_dependencies target)
${SPIFFS_INCLUDE_DIRS}
${TARGET_CHIBIOS_COMMON_INCLUDE_DIRS}
${TARGET_CHIBIOS_NANOCLR_INCLUDE_DIRS}
${chibios_SOURCE_DIR}/os/hal/boards/${TARGET_BOARD})
${chibios_SOURCE_DIR}/os/hal/boards/${TARGET_BOARD}
${mbedtls_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/src/PAL/COM/sockets/ssl/MbedTLS)

add_dependencies(${target}.elf nano::NF_NativeAssemblies)

Expand Down
8 changes: 7 additions & 1 deletion CMake/binutils.FreeRTOS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ macro(nf_add_platform_dependencies target)

endif()

if(API_nanoFramework.System.Security.Cryptography)
FetchContent_GetProperties(mbedtls)
endif()

nf_add_lib_native_assemblies(
EXTRA_INCLUDES
${CMSIS_INCLUDE_DIRS}
Expand All @@ -137,7 +141,9 @@ macro(nf_add_platform_dependencies target)
${FATFS_INCLUDE_DIRS}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_SOURCE_DIR}/targets/FreeRTOS/NXP/_fatfs
${CMAKE_BINARY_DIR}/targets/${RTOS}/${TARGET_BOARD})
${CMAKE_BINARY_DIR}/targets/${RTOS}/${TARGET_BOARD}
${mbedtls_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/src/PAL/COM/sockets/ssl/MbedTLS)

add_dependencies(${target}.elf nano::NF_NativeAssemblies)

Expand Down
58 changes: 57 additions & 1 deletion CMake/binutils.common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -704,4 +704,60 @@ function(nf_check_path_limits)

endif()

endfunction()
endfunction()

function(nf_add_mbedtls_library)

# check if MBEDTLS_SOURCE was specified or if it's empty (default is empty)
set(NO_MBEDTLS_SOURCE TRUE)

if(MBEDTLS_SOURCE)
if(NOT ${MBEDTLS_SOURCE} STREQUAL "")
set(NO_MBEDTLS_SOURCE FALSE)
endif()
endif()

# set tag for currently supported version
# WHEN CHANGING THIS MAKE SURE TO UPDATE THE DEV CONTAINERS
set(MBEDTLS_GIT_TAG "mbedtls-2.28.5")

# set options for Mbed TLS
option(ENABLE_TESTING "no testing when building Mbed TLS." OFF)

if(NO_MBEDTLS_SOURCE)
# no Mbed TLS source specified, download it from it's repo
message(STATUS "MbedTLS ${MBEDTLS_GIT_TAG} from GitHub repo")

FetchContent_Declare(
mbedtls
GIT_REPOSITORY https://github.com/ARMmbed/mbedtls
GIT_TAG ${MBEDTLS_GIT_TAG}
)

else()
# MbedTLS source was specified

message(STATUS "MbedTLS ${MBEDTLS_GIT_TAG} (source from: ${MBEDTLS_SOURCE})")

FetchContent_Declare(
mbedtls
SOURCE_DIR ${MBEDTLS_SOURCE}
)

endif()

# Check if population has already been performed
FetchContent_GetProperties(mbedtls)
if(NOT mbedtls_POPULATED)
# Fetch the content using previously declared details
FetchContent_Populate(mbedtls)
endif()

# don't include tests or programs, only build libraries
set(ENABLE_TESTING CACHE BOOL OFF)
set(ENABLE_PROGRAMS CACHE BOOL OFF)

cmake_policy(SET CMP0048 NEW)
add_subdirectory(${mbedtls_SOURCE_DIR} mbedtls_build)

endfunction()
2 changes: 2 additions & 0 deletions CMake/xtensa-esp32.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
"API_System.Device.Wifi": "ON",
"API_System.IO.Ports": "ON",
"API_Hardware.Esp32": "ON",
"API_nanoFramework.System.IO.Hashing": "ON",
"API_nanoFramework.System.Security.Cryptography": "ON",
"API_nanoFramework.Hardware.Esp32.Rmt": "ON",
"API_nanoFramework.ResourceManager": "ON",
"API_nanoFramework.System.Collections": "ON",
Expand Down
2 changes: 2 additions & 0 deletions CMake/xtensa-esp32c3.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
"API_System.Device.Wifi": "ON",
"API_System.IO.Ports": "ON",
"API_Hardware.Esp32": "ON",
"API_nanoFramework.System.IO.Hashing": "ON",
"API_nanoFramework.System.Security.Cryptography": "ON",
"API_nanoFramework.Hardware.Esp32.Rmt": "OFF",
"API_nanoFramework.ResourceManager": "ON",
"API_nanoFramework.System.Collections": "ON",
Expand Down
2 changes: 2 additions & 0 deletions CMake/xtensa-esp32s2.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
"API_System.Device.Wifi": "ON",
"API_System.IO.Ports": "ON",
"API_Hardware.Esp32": "ON",
"API_nanoFramework.System.IO.Hashing": "ON",
"API_nanoFramework.System.Security.Cryptography": "ON",
"API_nanoFramework.Hardware.Esp32.Rmt": "ON",
"API_nanoFramework.ResourceManager": "ON",
"API_nanoFramework.System.Collections": "ON",
Expand Down
2 changes: 2 additions & 0 deletions CMake/xtensa-esp32s3.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
"API_System.Device.Wifi": "ON",
"API_System.IO.Ports": "ON",
"API_System.IO.FileSystem": "ON",
"API_nanoFramework.System.IO.Hashing": "ON",
"API_nanoFramework.System.Security.Cryptography": "ON",
"API_Hardware.Esp32": "ON",
"API_Windows.Storage": "ON",
"API_nanoFramework.Hardware.Esp32.Rmt": "ON",
Expand Down
30 changes: 30 additions & 0 deletions src/nanoFramework.System.IO.Hashing/nf_sys_io_hashing.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//

#include "nf_sys_io_hashing.h"

// clang-format off

static const CLR_RT_MethodHandler method_lookup[] =
{
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
Library_nf_sys_io_hashing_System_IO_Hashing_Crc32::ComputeHash___STATIC__U4__U4__SystemSpanByte,
};

const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_nanoFramework_System_IO_Hashing =
{
"nanoFramework.System.IO.Hashing",
0xEBD8ED20,
method_lookup,
{ 100, 0, 0, 1 }
};

// clang-format on
Loading

0 comments on commit 674bdda

Please sign in to comment.