libdatachannel icon indicating copy to clipboard operation
libdatachannel copied to clipboard

how to use this library on a MCU

Open sm-oralnum opened this issue 2 years ago • 6 comments

Hello, i wanted to know if we can use this library on a nxp MCU (MIMXRT1170) ? We are developing a video stream application in real time with embedded c.

Best regards,

Safouane.Maaloul

sm-oralnum avatar May 23 '22 15:05 sm-oralnum

If there is a toolchain to compile C++17 programs for your MCU, then you can use the library. Otherwise, it might not be possible.

paullouisageneau avatar May 24 '22 18:05 paullouisageneau

Yes, there is a toolchain to compile C++17 programs on the MCU. Do i need to modify the cMakeLists.txt to compile for Arm® Cortex®-M7 core at 1 GHz to have a lib that i can use on the MCU ?

Best regards,

Safouane.Maaloul

sm-oralnum avatar Jun 03 '22 11:06 sm-oralnum

What kind of OS runs on your device? libdatachannel requires a POSIX-compatible system like Linux or FreeBSD (it uses the Berkeley sockets API, for instance).

If it is POSIX-compatible, it should build as it is, you only need a build of OpenSSL for the same architecture if you don't already have one.

paullouisageneau avatar Jun 03 '22 21:06 paullouisageneau

And the dependencies like usrsctp. When we are doing the cross compile for the mcu (arm) for the library libdatachannel, do we have to cross compile for thesedependencies too ? Or do we have to fine packages or libraries that are on the MCU and can replace these dependencies ?

sm-oralnum avatar Jul 04 '22 15:07 sm-oralnum

You should cross-compile them too, CMake should take care of that automatically. They should compile fine for arm.

paullouisageneau avatar Jul 04 '22 21:07 paullouisageneau

i have an error : CMake Error at deps/usrsctp/CMakeLists.txt:132 (message): usrsctp.h not found My toolchain.cmake file is

set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_SIZEOF_VOID_P 0)
set(CMAKE_C_COMPILER_WORKS 1)
set(CMAKE_CXX_COMPILER_WORKS 1)
set(CMAKE_C_COMPILER_FORCED TRUE)
set(CMAKE_CXX_COMPILER_FORCED TRUE)
#set(CMAKE_CXX_STANDARD 20)
# set(CMAKE_CXX_STANDARD 11)
# set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Without that flag CMake is not able to pass test compilation check
#set(CMAKE_TRY_COMPILE_TARGET_TYPE   "STATIC_LIBRARY")
set(TOOLCHAIN_EXT   .exe)
#set(BAREMETAL_ARM_TOOLCHAIN_PATH   "${CMAKE_CURRENT_SOURCE_DIR}/gcc-arm-none-eabi-10-2020-q4-major/bin/")
#set(BAREMETAL_ARM_TOOLCHAIN_PATH   "${CMAKE_CURRENT_SOURCE_DIR}/../../gcc-arm-none-eabi-10.3-2021.10/bin/")
#set(BAREMETAL_ARM_TOOLCHAIN_PATH   "//wsl.localhost/Ubuntu/usr/bin/")
#set(BAREMETAL_ARM_TOOLCHAIN_PATH   "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../usr/bin/")
#set(BAREMETAL_ARM_TOOLCHAIN_PATH   "/usr/bin/")

# TOOLCHAIN_DIR AND NANO LIBRARY
SET(TOOLCHAIN_DIR $ENV{ARMGCC_DIR})
STRING(REGEX REPLACE "\\\\" "/" TOOLCHAIN_DIR "${TOOLCHAIN_DIR}")

IF(NOT TOOLCHAIN_DIR)
    MESSAGE(FATAL_ERROR "***Please set ARMGCC_DIR in envionment variables***")
ENDIF()

MESSAGE(STATUS "TOOLCHAIN_DIR: " ${TOOLCHAIN_DIR})

# TARGET_TRIPLET
SET(TARGET_TRIPLET "arm-none-eabi")

SET(TOOLCHAIN_BIN_DIR ${TOOLCHAIN_DIR}/bin)
SET(TOOLCHAIN_INC_DIR ${TOOLCHAIN_DIR}/${TARGET_TRIPLET}/include)
SET(TOOLCHAIN_LIB_DIR ${TOOLCHAIN_DIR}/${TARGET_TRIPLET}/lib)

set(CMAKE_AR                        ${TOOLCHAIN_BIN_DIR}/${TARGET_TRIPLET}-ar${TOOLCHAIN_EXT})
set(CMAKE_ASM_COMPILER              ${TOOLCHAIN_BIN_DIR}/${TARGET_TRIPLET}-gcc${TOOLCHAIN_EXT} CACHE INTERNAL "C Compiler")
set(CMAKE_C_COMPILER                ${TOOLCHAIN_BIN_DIR}/${TARGET_TRIPLET}-gcc${TOOLCHAIN_EXT} CACHE INTERNAL "C++ Compiler")
set(CMAKE_CXX_COMPILER              ${TOOLCHAIN_BIN_DIR}/${TARGET_TRIPLET}-g++${TOOLCHAIN_EXT} CACHE INTERNAL "ASM Compiler")
set(CMAKE_LINKER                    ${TOOLCHAIN_BIN_DIR}/${TARGET_TRIPLET}-ld${TOOLCHAIN_EXT})
set(CMAKE_OBJCOPY                   ${TOOLCHAIN_BIN_DIR}/${TARGET_TRIPLET}-objcopy CACHE INTERNAL "objcopy tool")
SET(CMAKE_OBJDUMP                   ${TOOLCHAIN_BIN_DIR}/${TARGET_TRIPLET}-objdump CACHE INTERNAL "objdump tool")
set(CMAKE_RANLIB                    ${TOOLCHAIN_BIN_DIR}/${TARGET_TRIPLET}-ranlib CACHE INTERNAL "ranlib tool")
set(CMAKE_SIZE                      ${TOOLCHAIN_BIN_DIR}/${TARGET_TRIPLET}-size$ CACHE INTERNAL "size tool")
set(CMAKE_STRIP                     ${TOOLCHAIN_BIN_DIR}/${TARGET_TRIPLET}-strip CACHE INTERNAL "strip tool")
#set(CMAKE_STRIP                     ${BAREMETAL_ARM_TOOLCHAIN_PATH}${TOOLCHAIN_DIR}-strip${CMAKE_EXECUTABLE_SUFFIX} CACHE INTERNAL "")


#set(CMAKE_C_FLAGS                   "--sysroot -Wno-psabi --specs=nosys.specs -fdata-sections -nostartfiles -nostdlib -ffunction-sections -W" CACHE INTERNAL "")
#set(CMAKE_C_FLAGS  "-std=c99 -pedantic -Wall -Wextra -Wfloat-equal -Wshadow -Wpointer-arith -Wunreachable-code -Winit-self -Wno-unused-function -Wno-unused-parameter -Wno-unreachable-code -Werror -Wno-dev" CACHE INTERNAL "")
# set(CMAKE_C_FLAGS  "" CACHE INTERNAL "")
# set(CMAKE_CXX_FLAGS                 "${CMAKE_C_FLAGS} -fno-exceptions" CACHE INTERNAL "")

# set(CMAKE_C_FLAGS                   "${APP_C_FLAGS} -Wno-psabi --specs=nosys.specs -fdata-sections -ffunction-sections -Wl,--gc-sections" CACHE INTERNAL "")
# set(CMAKE_CXX_FLAGS                 "${APP_CXX_FLAGS} ${CMAKE_C_FLAGS} -fno-exceptions" CACHE INTERNAL "")


# set(CMAKE_C_FLAGS_DEBUG             "-Os -g" CACHE INTERNAL "")
# set(CMAKE_C_FLAGS_RELEASE           "-Os -DNDEBUG" CACHE INTERNAL "")
# set(CMAKE_CXX_FLAGS_DEBUG           "${CMAKE_C_FLAGS_DEBUG}" CACHE INTERNAL "")
# set(CMAKE_CXX_FLAGS_RELEASE         "${CMAKE_C_FLAGS_RELEASE}" CACHE INTERNAL "")


SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -g -std=gnu++11" CACHE INTERNAL "c compiler flags debug")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g -std=gnu++11" CACHE INTERNAL "cxx compiler flags debug")
SET(CMAKE_ASM_FLAGS_DEBUG "${CMAKE_ASM_FLAGS_DEBUG} -g" CACHE INTERNAL "asm compiler flags debug")
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG}" CACHE INTERNAL "linker flags debug")

SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 " CACHE INTERNAL "c compiler flags release")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 " CACHE INTERNAL "cxx compiler flags release")
SET(CMAKE_ASM_FLAGS_RELEASE "${CMAKE_ASM_FLAGS_RELEASE}" CACHE INTERNAL "asm compiler flags release")
SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}" CACHE INTERNAL "linker flags release")

SET(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN_DIR}/${TARGET_TRIPLET} ${EXTRA_FIND_PATH})
# search for programs in the build host directories
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
# for libraries and headers in the target directories
set(CMAKE_THREAD_LIBS_INIT "-lpthread")
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(CMAKE_USE_WIN32_THREADS_INIT 0)
set(CMAKE_USE_PTHREADS_INIT 1)
set(THREADS_PREFER_PTHREAD_FLAG ON)
set(CMAKE_FIND_LIBRARY_PREFIXES lib )
set(CMAKE_FIND_LIBRARY_SUFFIXES .a )
set(CMAKE_FIND_LIBRARY_SUFFIXES .h )
MESSAGE(STATUS "BUILD_TYPE: " ${CMAKE_BUILD_TYPE})
#SET(CMAKE_FIND_ROOT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/gcc-arm-none-eabi-10.3-2021.10/arm-none-eabi/include")
#message("${CMAKE_CURRENT_SOURCE_DIR}")
#target_include_directories(test PRIVATE"${CMAKE_CURRENT_SOURCE_DIR}/gcc-arm-none-eabi-10.3-2021.10/arm-none-eabi/include")

Can you help me please ?

sm-oralnum avatar Jul 25 '22 13:07 sm-oralnum