warmcat / libwebsockets

canonical libwebsockets.org networking library
https://libwebsockets.org
Other
4.79k stars 1.49k forks source link

Looking for an libwebsockets porting for freertos, Did libwebsockets need port for FreeRTOS #2025

Closed ghost closed 4 years ago

ghost commented 4 years ago

Hi All. I have arrived to run PPPoS (SYS_NO = 0 <=> OS FreeRTOS) via my LTE modem SARA-R412M using ATMEL SAM4E16E board. LwIP "TCP/IP Stack" has been integrated based on PPPoS protocol as Link layer for our modem.

Now i’m looking to use libwebsockets running in FreeRTOS I have not arrived to use libwebsockets with FreeRTOS ? Did libwebsockets need port for FreeRTOS Someone have suggestion about how to libwebsockets used with FreeRTOS ?

lws-team commented 4 years ago

It already works fine on FreeRTOS + lwip, although you might need some meddling at the edges depending on your exact SDK.

For example, here it is building on a Mediatek arm device

https://libwebsockets.org/sai/index.html?task=b3d20beefd2ec9e3b7f28b5e8e8fc4b227539648a6cd2f40b0f6c61fbac6a99c

You can see from the build logs the main point is

cmake .. -DCMAKE_INSTALL_PREFIX:PATH=/tmp -DCMAKE_TOOLCHAIN_FILE=../contrib/cross-linkit.cmake -DLWS_PLAT_FREERTOS=1 -DLWS_WITH_ZLIB=0 -DLWS_WITHOUT_EXTENSIONS=1 -DLWS_WITH_ZIP_FOPS=0 -DLWS_WITH_HTTP_STREAM_COMPRESSION=0 -DLWS_WITH_MBEDTLS=1 -DLWS_WITH_FILE_OPS=0

Make a version of the provided toolchain file that points to your toolchain an cross-built staging

ghost commented 4 years ago

Hi All, Thank you for your reply. I need to compile libwebsockets using cross-arm-none-eabi. I have created "contrib/cross-arm-none-eabi.cmake" file also i have modified the set(CROSS_PATH /usr/local/arm-none-eabi) to path of the cross compiler i'm using for ATMEL SAM16E16E.

#
# CMake Toolchain file for crosscompiling on ARM.
#
# This can be used when running cmake in the following way:
#  cd build/
#  cmake .. -DCMAKE_TOOLCHAIN_FILE=../contrib/cross-arm-none-eabi.cmake
#

set(CROSS_PATH /usr/local/arm-none-eabi)

# Target operating system name.
set(CMAKE_SYSTEM_NAME Linux)

# Name of C compiler.
set(CMAKE_C_COMPILER "${CROSS_PATH}/bin/arm-none-eabi-gcc")
set(CMAKE_CXX_COMPILER "${CROSS_PATH}/bin/arm-none-eabi-g++")

#
# Different build system distros set release optimization level to different
# things according to their local policy, eg, Fedora is -O2 and Ubuntu is -O3
# here.  Actually the build system's local policy is completely unrelated to
# our desire for cross-build release optimization policy for code built to run
# on a completely different target than the build system itself.
#
# Since this goes last on the compiler commandline we have to override it to a
# sane value for cross-build here.  Notice some gcc versions enable broken
# optimizations with -O3.
#
if (CMAKE_BUILD_TYPE MATCHES RELEASE OR CMAKE_BUILD_TYPE MATCHES Release OR CMAKE_BUILD_TYPE MATCHES release)
    set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2")
    set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
endif()

# Where to look for the target environment. (More paths can be added here)
set(CMAKE_FIND_ROOT_PATH "${CROSS_PATH}")

# Adjust the default behavior of the FIND_XXX() commands:
# search programs in the host environment only.
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)

# Search headers and libraries in the target environment only.
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

I got this log error:

said@said build % cmake .. -DCMAKE_INSTALL_PREFIX:PATH=/tmp -DCMAKE_TOOLCHAIN_FILE=../contrib/cross-arm-none-eabi.cmake -DLWS_PLAT_FREERTOS=1 -DLWS_WITH_ZLIB=0 -DLWS_WITHOUT_EXTENSIONS=1 -DLWS_WITH_ZIP_FOPS=0 -DLWS_WITH_HTTP_STREAM_COMPRESSION=0 -DLWS_WITH_MBEDTLS=1 -DLWS_WITH_FILE_OPS=0
-- The C compiler identification is GNU 9.2.1
-- Checking whether C compiler has -isysroot
-- Checking whether C compiler has -isysroot - yes
-- Checking whether C compiler supports OSX deployment target flag
-- Checking whether C compiler supports OSX deployment target flag - no
-- Check for working C compiler: /usr/local/arm-none-eabi/bin/arm-none-eabi-gcc-9.2.1
-- Check for working C compiler: /usr/local/arm-none-eabi/bin/arm-none-eabi-gcc-9.2.1 - broken
CMake Error at /usr/local/Cellar/cmake/3.17.3/share/cmake/Modules/CMakeTestCCompiler.cmake:60 (message):
  The C compiler

    "/usr/local/arm-none-eabi/bin/arm-none-eabi-gcc-9.2.1"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /Users/said/libwebsockets/build/CMakeFiles/CMakeTmp

    Run Build Command(s):/usr/local/bin/ninja cmTC_4a592 && [1/2] Building C object CMakeFiles/cmTC_4a592.dir/testCCompiler.c.o
    [2/2] Linking C executable cmTC_4a592
    FAILED: cmTC_4a592 
    : && /usr/local/arm-none-eabi/bin/arm-none-eabi-gcc-9.2.1 -I/usr/local/opt/openssl/include/ -I/usr/local/include -I/usr/local/opt/expat/include -I /usr/local/include/openssl  -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names -L/usr/local/opt/openssl/lib -L/usr/local/lib -L/usr/local/opt/expat/lib CMakeFiles/cmTC_4a592.dir/testCCompiler.c.o  -o cmTC_4a592   && :
    /usr/local/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: warning: cannot find entry symbol arch_paths_first; defaulting to 0000000000008018
    /usr/local/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /usr/local/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/lib/libc.a(lib_a-exit.o): in function `exit':
    exit.c:(.text.exit+0x2c): undefined reference to `_exit'
    collect2: error: ld returned 1 exit status
    ninja: build stopped: subcommand failed.

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:66 (project)

-- Configuring incomplete, errors occurred!
See also "/Users/said/libwebsockets/build/CMakeFiles/CMakeOutput.log".
See also "/Users/said/libwebsockets/build/CMakeFiles/CMakeError.log".
lws-team commented 4 years ago

Hm there are two problems there.... one is the cross toolchain should look like this for atmel toolchain installed in /opt/arm-none-eabi (wise to not put it in /usr)

# if your sdk lives somewhere else, this is the only place that should need changing
set(CROSS_BASE /opt/arm-none-eabi)
set(CROSS_PATH ${CROSS_BASE}/bin/arm-none-eabi)

#
# Target operating system name.
set(CMAKE_SYSTEM_NAME Generic)

# Name of C compiler.
set(CMAKE_C_COMPILER "${CROSS_PATH}-gcc")

#
# cmake believes we should link a NOP test program OK, but since we're
# baremetal, that's not true in our case.  It tries to build this test
# with the cross compiler, but with no args on it, and it fails.
# So disable this test for this toolchain (we'll find out soon enough
# if we actually can't compile anything)

set(CMAKE_C_COMPILER_WORKS 1)
set(CMAKE_CXX_COMPILER_WORKS 1)

That will get you through cmake

$ cmake .. .. -DCMAKE_INSTALL_PREFIX:PATH=/tmp -DCMAKE_TOOLCHAIN_FILE=../contrib/cross-atmel.cmake -DLWS_PLAT_FREERTOS=1 -DLWS_WITH_ZLIB=0 -DLWS_WITHOUT_EXTENSIONS=1 -DLWS_WITH_ZIP_FOPS=0 -DLWS_WITH_HTTP_STREAM_COMPRESSION=0 -DLWS_WITH_MBEDTLS=1 -DLWS_WITH_FILE_OPS=0
-- The C compiler identification is GNU 6.3.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- No LWS_WITH_DIR or LWS_WITH_LEJP_CONF
LWS_WITH_DIR OFF
-- Found Git: /usr/bin/git (found version "2.26.2") 
Git commit hash: v4.1.0-rc2-21-g70c2afbe
-- CMAKE_TOOLCHAIN_FILE='/tmp/libwebsockets/contrib/cross-atmel.cmake'
-- Performing Test LWS_HAVE_inline
-- Performing Test LWS_HAVE_inline - Success
-- Performing Test LWS_HAVE___inline__
-- Performing Test LWS_HAVE___inline__ - Success
-- Performing Test LWS_HAVE___inline
-- Performing Test LWS_HAVE___inline - Success
-- Performing Test LWS_HAVE_MALLOC_TRIM
-- Performing Test LWS_HAVE_MALLOC_TRIM - Failed
-- Performing Test LWS_HAVE_MALLOC_USABLE_SIZE
-- Performing Test LWS_HAVE_MALLOC_USABLE_SIZE - Success
-- Looking for fork
-- Looking for fork - not found
-- Looking for getenv
-- Looking for getenv - found
-- Looking for memset
-- Looking for memset - found
-- Looking for socket
-- Looking for socket - not found
-- Looking for strerror
-- Looking for strerror - found
-- Looking for vfork
-- Looking for vfork - not found
-- Looking for execvpe
-- Looking for execvpe - not found
-- Looking for snprintf
-- Looking for snprintf - not found
-- Looking for _snprintf
-- Looking for _snprintf - not found
-- Looking for _vsnprintf
-- Looking for _vsnprintf - not found
-- Looking for getloadavg
-- Looking for getloadavg - not found
-- Looking for atoll
-- Looking for atoll - found
-- Looking for _atoi64
-- Looking for _atoi64 - not found
-- Looking for _stat32i64
-- Looking for _stat32i64 - not found
-- Looking for clock_gettime
-- Looking for clock_gettime - not found
-- Looking for in6addr.h
-- Looking for in6addr.h - not found
-- Looking for memory.h
-- Looking for memory.h - found
-- Looking for netinet/in.h
-- Looking for netinet/in.h - not found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stdlib.h
-- Looking for stdlib.h - found
-- Looking for strings.h
-- Looking for strings.h - found
-- Looking for string.h
-- Looking for string.h - found
-- Looking for sys/prctl.h
-- Looking for sys/prctl.h - not found
-- Looking for sys/socket.h
-- Looking for sys/socket.h - not found
-- Looking for sys/sockio.h
-- Looking for sys/sockio.h - not found
-- Looking for sys/stat.h
-- Looking for sys/stat.h - found
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Looking for vfork.h
-- Looking for vfork.h - not found
-- Looking for sys/capability.h
-- Looking for sys/capability.h - not found
-- Looking for malloc.h
-- Looking for malloc.h - found
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for inttypes.h
-- Looking for inttypes.h - found
-- Looking for cap_set_flag in cap
-- Looking for cap_set_flag in cap - not found
-- Looking for 3 include files stdlib.h, ..., string.h
-- Looking for 3 include files stdlib.h, ..., string.h - found
-- Performing Test LWS_HAS_INTPTR_T
-- Performing Test LWS_HAS_INTPTR_T - Success
-- Performing Test LWS_HAS_GETOPT_LONG
-- Performing Test LWS_HAS_GETOPT_LONG - Failed
-- Performing Test LWS_HAVE_VISIBILITY
-- Performing Test LWS_HAVE_VISIBILITY - Success
-- Performing Test LWS_GCC_HAS_IGNORED_QUALIFIERS
-- Performing Test LWS_GCC_HAS_IGNORED_QUALIFIERS - Success
-- Performing Test LWS_GCC_HAS_TYPE_LIMITS
-- Performing Test LWS_GCC_HAS_TYPE_LIMITS - Success
-- Performing Test LWS_HAVE_PIPE2
-- Performing Test LWS_HAVE_PIPE2 - Failed
-- Performing Test LWS_HAVE_TCP_USER_TIMEOUT
-- Performing Test LWS_HAVE_TCP_USER_TIMEOUT - Failed
-- Performing Test LWS_HAVE_MBEDTLS_NET_SOCKETS
-- Performing Test LWS_HAVE_MBEDTLS_NET_SOCKETS - Failed
Compiling with SSL support
-- Looking for SSL_CTX_set1_param
-- Looking for SSL_CTX_set1_param - not found
-- Looking for SSL_set_info_callback
-- Looking for SSL_set_info_callback - not found
-- Looking for X509_VERIFY_PARAM_set1_host
-- Looking for X509_VERIFY_PARAM_set1_host - not found
-- Looking for RSA_set0_key
-- Looking for RSA_set0_key - not found
-- Looking for X509_get_key_usage
-- Looking for X509_get_key_usage - not found
-- Looking for EVP_PKEY_new_raw_private_key
-- Looking for EVP_PKEY_new_raw_private_key - not found
-- Looking for SSL_CTX_get0_certificate
-- Looking for SSL_CTX_get0_certificate - not found
-- Looking for SSL_get0_alpn_selected
-- Looking for SSL_get0_alpn_selected - not found
-- Looking for SSL_set_alpn_protos
-- Looking for SSL_set_alpn_protos - not found
-- Looking for EVP_aes_128_cfb8
-- Looking for EVP_aes_128_cfb8 - not found
-- Looking for EVP_aes_128_cfb128
-- Looking for EVP_aes_128_cfb128 - not found
-- Looking for EVP_aes_192_cfb8
-- Looking for EVP_aes_192_cfb8 - not found
-- Looking for EVP_aes_192_cfb128
-- Looking for EVP_aes_192_cfb128 - not found
-- Looking for EVP_aes_256_cfb8
-- Looking for EVP_aes_256_cfb8 - not found
-- Looking for EVP_aes_256_cfb128
-- Looking for EVP_aes_256_cfb128 - not found
-- Looking for EVP_aes_128_xts
-- Looking for EVP_aes_128_xts - not found
-- Looking for RSA_verify_pss_mgf1
-- Looking for RSA_verify_pss_mgf1 - not found
-- Looking for HMAC_CTX_new
-- Looking for HMAC_CTX_new - not found
-- Looking for SSL_CTX_set_ciphersuites
-- Looking for SSL_CTX_set_ciphersuites - not found
-- Looking for EVP_PKEY_new_raw_private_key
-- Looking for EVP_PKEY_new_raw_private_key - not found
Searching for OpenSSL executable and dlls
 GENCERTS = 1
Generating SSL Certificates for the test-server...
Generating a RSA private key
.............+++++
......+++++
writing new private key to '/tmp/libwebsockets/build/libwebsockets-test-server.key.pem'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:State or Province Name (full name) []:Locality Name (eg, city) [Default City]:Organization Name (eg, company) [Default Company Ltd]:Organizational Unit Name (eg, section) []:Common Name (eg, your name or your server's hostname) []:Email Address []:SUCCESSFULLY generated SSL certificate
DIR /tmp/libwebsockets/build CMP /tmp/libwebsockets/cmake
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/libwebsockets/build
$

However the toolchain by itself does not include any, eg, lwip pieces. You will need to get what's generally called "an SDK" from Atmel that has lwip and mbedtls or whatever other "middleware" is needed to actually build an image. And you'll need to look at, eg, ./contrib/cross-linkit.cmake to see how to tell it where your other library pieces are.

ghost commented 4 years ago

😊 thank @lws-team . I have my own modular structure integrated "Atmel Advanced Software Framework (ASF)" + "LwIP" + "FreeRTOS". I need now to added "LWS" as a top layer. I know that libwebsocket based on cmake tools but for me for compilation i use make with a config.mk . code structure The make file is too long if you want i can share it with you below.

config.mk file:

#Root path
PRJ_PATH = .

# CPU Architecture
ARCH = cortex-m4

#Target part
PART = sam4e16e

# Application name
TARGET_FLASH = flash.elf
TARGET_SRAM = flash.elf

# List of include files
INC_PATH = \
                         inc/ \
                    config/ \
                    asf/ \
                    asf/common/ \
                    asf/common/boards/ \
                    asf/common/services/ \
                    asf/common/services/clock/ \
                    asf/common/services/clock/sam4e/ \
                    asf/common/services/gpio/ \
                    asf/common/services/gpio/sam_gpio/ \
                    asf/common/services/ioport/ \
                    asf/common/services/ioport/sam/ \
                    asf/common/services/sleepmgr/ \
                    asf/common/services/sleepmgr/sam/ \
                    asf/common/services/usb/ \
                    asf/common/services/usb/class/ \
                    asf/common/services/usb/class/cdc/ \
                    asf/common/services/usb/class/cdc/device/ \
                    asf/common/services/usb/udc/ \
                    asf/common/utils/stdio/stdio_usb/ \
                    asf/common/services/delay/ \
                    asf/common/utils/ \
                    asf/common/utils/interrupt/ \
                    asf/sam/ \
                    asf/sam/boards/ \
                    asf/sam/boards/sam4e_ek/ \
                    asf/sam/drivers/ \
                    asf/sam/drivers/matrix/ \
                    asf/sam/drivers/pio/ \
                    asf/sam/drivers/pmc/ \
                    asf/sam/drivers/rstc/ \
                    asf/sam/drivers/rstc/example1/ \
                    asf/sam/drivers/uart/ \
                    asf/sam/drivers/udp/ \
                    asf/sam/drivers/usart/ \
                    asf/sam/utils/ \
                    asf/sam/utils/cmsis/ \
                    asf/sam/utils/cmsis/sam4e/ \
                    asf/sam/utils/cmsis/sam4e/include/ \
                    asf/sam/utils/cmsis/sam4e/include/component/ \
                    asf/sam/utils/cmsis/sam4e/include/instance/ \
                    asf/sam/utils/cmsis/sam4e/include/pio/ \
                    asf/sam/utils/cmsis/sam4e/source/ \
                    asf/sam/utils/cmsis/sam4e/source/templates/ \
                    asf/sam/utils/cmsis/sam4e/source/templates/gcc/ \
                    asf/sam/utils/fpu/ \
                    asf/sam/utils/header_files/ \
                    asf/sam/utils/linker_scripts/ \
                    asf/sam/utils/linker_scripts/sam4e/ \
                    asf/sam/utils/linker_scripts/sam4e/sam4e16/ \
                    asf/sam/utils/linker_scripts/sam4e/sam4e16/gcc/ \
                    asf/sam/utils/make/ \
                    asf/sam/utils/preprocessor/ \
                    asf/sam/utils/syscalls/ \
                    asf/sam/utils/syscalls/gcc/ \
                    asf/thirdparty/ \
                    asf/thirdparty/CMSIS/ \
                    asf/thirdparty/CMSIS/Include/ \
                    asf/thirdparty/CMSIS/Lib/ \
                    asf/thirdparty/CMSIS/Lib/GCC/ \
                    config/ \
                    freertos/ \
                    freertos/freertos-10.3.1/ \
                    freertos/freertos-10.3.1/source/ \
                    freertos/freertos-10.3.1/source/include/ \
                    freertos/freertos-10.3.1/source/portable/ \
                    freertos/freertos-10.3.1/source/portable/gcc/ \
                    freertos/freertos-10.3.1/source/portable/gcc/arm_cm4f/ \
                    freertos/freertos-10.3.1/source/portable/memmang/ \
                    lwip/ \
                    lwip/lwip-port \
                    lwip/lwip-port/sam \
                    lwip/lwip-port/sam/include \
                    lwip/lwip-port/sam/include/arch \
                    lwip/lwip-port/sam/netif \
                    lwip/lwip/ \
                    lwip/lwip/src/ \
                    lwip/lwip/src/api/ \
                    lwip/lwip/src/core/ \
                    lwip/lwip/src/core/ipv4/ \
                    lwip/lwip/src/core/ipv6/ \
                    lwip/lwip/src/include/ \
                    lwip/lwip/src/include/compat/ \
                    lwip/lwip/src/include/compat/posix/ \
                    lwip/lwip/src/include/compat/posix/arpa/ \
                    lwip/lwip/src/include/compat/posix/net/ \
                    lwip/lwip/src/include/compat/posix/sys/ \
                    lwip/lwip/src/include/compat/stdc/ \
                    lwip/lwip/src/include/lwip/ \
                    lwip/lwip/src/include/lwip/apps/ \
                    lwip/lwip/src/include/lwip/priv/ \
                    lwip/lwip/src/include/lwip/prot/ \
                    lwip/lwip/src/include/netif/ \
                    lwip/lwip/src/include/netif/ppp/ \
                    lwip/lwip/src/include/netif/ppp/polarssl/ \
                    lwip/lwip/src/netif/ \
                    lwip/lwip/src/netif/ppp/ \
                    lwip/lwip/src/netif/ppp/polarssl/ \
                    src/httpclient/ \

# List of source files
CSRCS = \
                        src/main.c \
                        src/task_ppp.c \
                        src/trace.c \
                        src/task_tcp.c \
                        asf/common/services/clock/sam4e/sysclk.c \
                        asf/common/services/sleepmgr/sam/sleepmgr.c \
                        asf/common/services/usb/class/cdc/device/udi_cdc.c \
                        asf/common/services/usb/class/cdc/device/udi_cdc_desc.c \
                        asf/common/services/usb/udc/udc.c \
                        asf/common/utils/stdio/stdio_usb/stdio_usb.c \
                        asf/common/utils/interrupt/interrupt_sam_nvic.c \
                        asf/sam/boards/sam4e_ek/init.c \
                        asf/sam/drivers/matrix/matrix.c \
                        asf/sam/drivers/pmc/pmc.c \
                        asf/sam/drivers/pmc/sleep.c \
                        asf/sam/drivers/uart/uart.c \
                        asf/sam/drivers/udp/udp_device.c \
                        asf/sam/drivers/usart/usart.c \
                        asf/sam/drivers/pio/pio.c \
                        asf/sam/drivers/pio/pio_handler.c \
                        asf/sam/drivers/rstc/rstc.c \
                        asf/sam/utils/cmsis/sam4e/source/templates/exceptions.c \
                        asf/sam/utils/cmsis/sam4e/source/templates/gcc/startup_sam4e.c \
                        asf/sam/utils/cmsis/sam4e/source/templates/system_sam4e.c \
                        asf/sam/utils/syscalls/gcc/syscalls.c \
                        freertos/freertos-10.3.1/source/croutine.c \
                        freertos/freertos-10.3.1/source/event_groups.c \
                        freertos/freertos-10.3.1/source/list.c \
                        freertos/freertos-10.3.1/source/portable/gcc/arm_cm4f/port.c \
                        freertos/freertos-10.3.1/source/portable/memmang/heap_4.c \
                        freertos/freertos-10.3.1/source/queue.c \
                        freertos/freertos-10.3.1/source/stream_buffer.c \
                        freertos/freertos-10.3.1/source/tasks.c \
                        freertos/freertos-10.3.1/source/timers.c \
                        lwip/lwip-port/sam/sys_arch.c \
                        lwip/lwip/src/api/api_lib.c \
                        lwip/lwip/src/api/api_msg.c \
                        lwip/lwip/src/api/err.c \
                        lwip/lwip/src/api/if_api.c \
                        lwip/lwip/src/api/netbuf.c \
                        lwip/lwip/src/api/netdb.c \
                        lwip/lwip/src/api/netifapi.c \
                        lwip/lwip/src/api/sockets.c \
                        lwip/lwip/src/api/tcpip.c \
                        lwip/lwip/src/core/altcp.c \
                        lwip/lwip/src/core/altcp_alloc.c \
                        lwip/lwip/src/core/altcp_tcp.c \
                        lwip/lwip/src/core/def.c \
                        lwip/lwip/src/core/dns.c \
                        lwip/lwip/src/core/inet_chksum.c \
                        lwip/lwip/src/core/init.c \
                        lwip/lwip/src/core/ip.c \
                        lwip/lwip/src/core/ipv4/acd.c \
                        lwip/lwip/src/core/ipv4/autoip.c \
                        lwip/lwip/src/core/ipv4/dhcp.c \
                        lwip/lwip/src/core/ipv4/etharp.c \
                        lwip/lwip/src/core/ipv4/icmp.c \
                        lwip/lwip/src/core/ipv4/igmp.c \
                        lwip/lwip/src/core/ipv4/ip4.c \
                        lwip/lwip/src/core/ipv4/ip4_addr.c \
                        lwip/lwip/src/core/ipv4/ip4_frag.c \
                        lwip/lwip/src/core/ipv6/dhcp6.c \
                        lwip/lwip/src/core/ipv6/ethip6.c \
                        lwip/lwip/src/core/ipv6/icmp6.c \
                        lwip/lwip/src/core/ipv6/inet6.c \
                        lwip/lwip/src/core/ipv6/ip6.c \
                        lwip/lwip/src/core/ipv6/ip6_addr.c \
                        lwip/lwip/src/core/ipv6/ip6_frag.c \
                        lwip/lwip/src/core/ipv6/mld6.c \
                        lwip/lwip/src/core/ipv6/nd6.c \
                        lwip/lwip/src/core/mem.c \
                        lwip/lwip/src/core/memp.c \
                        lwip/lwip/src/core/netif.c \
                        lwip/lwip/src/core/pbuf.c \
                        lwip/lwip/src/core/raw.c \
                        lwip/lwip/src/core/stats.c \
                        lwip/lwip/src/core/sys.c \
                        lwip/lwip/src/core/tcp.c \
                        lwip/lwip/src/core/tcp_in.c \
                        lwip/lwip/src/core/tcp_out.c \
                        lwip/lwip/src/core/timeouts.c \
                        lwip/lwip/src/core/udp.c \
                        lwip/lwip/src/netif/bridgeif.c \
                        lwip/lwip/src/netif/bridgeif_fdb.c \
                        lwip/lwip/src/netif/ethernet.c \
                        lwip/lwip/src/netif/lowpan6.c \
                        lwip/lwip/src/netif/lowpan6_ble.c \
                        lwip/lwip/src/netif/lowpan6_common.c \
                        lwip/lwip/src/netif/ppp/auth.c \
                        lwip/lwip/src/netif/ppp/ccp.c \
                        lwip/lwip/src/netif/ppp/chap-md5.c \
                        lwip/lwip/src/netif/ppp/chap-new.c \
                        lwip/lwip/src/netif/ppp/chap_ms.c \
                        lwip/lwip/src/netif/ppp/demand.c \
                        lwip/lwip/src/netif/ppp/eap.c \
                        lwip/lwip/src/netif/ppp/ecp.c \
                        lwip/lwip/src/netif/ppp/eui64.c \
                        lwip/lwip/src/netif/ppp/fsm.c \
                        lwip/lwip/src/netif/ppp/ipcp.c \
                        lwip/lwip/src/netif/ppp/ipv6cp.c \
                        lwip/lwip/src/netif/ppp/lcp.c \
                        lwip/lwip/src/netif/ppp/magic.c \
                        lwip/lwip/src/netif/ppp/mppe.c \
                        lwip/lwip/src/netif/ppp/multilink.c \
                        lwip/lwip/src/netif/ppp/polarssl/arc4.c \
                        lwip/lwip/src/netif/ppp/polarssl/des.c \
                        lwip/lwip/src/netif/ppp/polarssl/md4.c \
                        lwip/lwip/src/netif/ppp/polarssl/md5.c \
                        lwip/lwip/src/netif/ppp/polarssl/sha1.c \
                        lwip/lwip/src/netif/ppp/ppp.c \
                        lwip/lwip/src/netif/ppp/pppapi.c \
                        lwip/lwip/src/netif/ppp/pppcrypt.c \
                        lwip/lwip/src/netif/ppp/pppoe.c \
                        lwip/lwip/src/netif/ppp/pppol2tp.c \
                        lwip/lwip/src/netif/ppp/pppos.c \
                        lwip/lwip/src/netif/ppp/upap.c \
                        lwip/lwip/src/netif/ppp/utils.c \
                        lwip/lwip/src/netif/ppp/vj.c \
                        lwip/lwip/src/netif/slipif.c \
                        lwip/lwip/src/netif/zepif.c \
                        src/httpclient/httpclient.c \

# List of assembly source files
ASSRCS = \

# Additional search paths for libs
LIB_PATH = \
                asf/thirdparty/CMSIS/Lib/GCC

# List of libs to use during linking
LIBS = \
             arm_cortexM4lf_math_softfp \
             m
# Path relative to root directory pointing to a linker script
LINKER_SCRIPT_FLASH = scripts/flash.ld
LINKER_SCRIPT_SRAM = scripts/sram.ld

# Path relative to root directory pointing to a debug script
DEBUG_SCRIPT_FLASH = scripts/flash.gdb
DEBUG_SCRIPT_SRAM = scripts/sram.gdb

# Project type parameters
PROJECT_TYPE = all

# Additional options for debugging
DBFLAGS = \

# Application optimization used during compilation and linking
OPTIMIZATION = -O1

# Extra flags to use when archiving
ARFLAGS = \

# Extra flags to use when assembling
asfLAGS = \
                    -mfloat-abi=softfp                                                                                                                                                              \
                    -mfpu=fpv4-sp-d16

# Extra flags to use when compiling
CFLAGS = \
                 -mfloat-abi=softfp                                                                                                                                                                 \
                 -mfpu=fpv4-sp-d16

# Extra flags to use when preprocessing
CPPFLAGS = \
                     -D ARM_MATH_CM4=true                                                                                                                                                       \
                     -D BOARD=SAM4E_EK                                                                                                                                                              \
                     -D __SAM4E16E__                                                                                                                                                                    \
                     -D printf=iprintf                                                                                                                                                              \
                     -D scanf=iscanf                                                                                                                                                                    

# Extra flags to when linking
LDFLAGS = \

# Pre- and post-build commands
PREBUILD_CMD = \

POSTBUILD_CMD = \

Makefile adapted to our structure(Original source ref from (asf): /usr/local/xdk-asf-3.47.0/sam/utils/make/Makefile.sam.in):

# MAKEFILE_PATH = /usr/local/xdk-asf-3.47.0/sam/utils/make/Makefile.sam.in
# include ${MAKEFILE_PATH}

# List of available make goals:
#
# all                     Default target, builds the project
# clean                   Clean up the project
# rebuild                 Rebuild the project
# debug_flash             Builds the project and debug in flash
# debug_sram              Builds the project and debug in sram
#
# doc                     Build the documentation
# cleandoc                Clean up the documentation
# rebuilddoc              Rebuild the documentation
#

# Include the config.mk file from the current working path, e.g., where the
# user called make.
include config.mk

# Tool to use to generate documentation from the source code
DOCGEN          ?= doxygen

# Look for source files relative to the top-level source directory
VPATH           := $(PRJ_PATH)

# Output target file
project_type    := $(PROJECT_TYPE)

# Output target file
ifeq ($(project_type),flash)
target          := $(TARGET_FLASH)
linker_script   := $(PRJ_PATH)/$(LINKER_SCRIPT_FLASH)
debug_script    := $(PRJ_PATH)/$(DEBUG_SCRIPT_FLASH)
else
target          := $(TARGET_SRAM)
linker_script   := $(PRJ_PATH)/$(LINKER_SCRIPT_SRAM)
debug_script    := $(PRJ_PATH)/$(DEBUG_SCRIPT_SRAM)
endif

# Output project name (target name minus suffix)
project         := $(basename $(target))

# Output target file (typically ELF or static library)
ifeq ($(suffix $(target)),.a)
target_type     := lib
else
ifeq ($(suffix $(target)),.elf)
target_type     := elf
else
$(error "Target type $(target_type) is not supported")
endif
endif

# Allow override of operating system detection. The user can add OS=Linux or
# OS=Windows on the command line to explicit set the host OS.
#
# This allows to work around broken uname utility on certain systems.
ifdef OS
  ifeq ($(strip $(OS)), Linux)
    os_type     := Linux
  endif
  ifeq ($(strip $(OS)), Windows)
    os_type     := windows32_64
  endif
endif

os_type         ?= $(strip $(shell uname))

ifeq ($(os_type),windows32)
os              := Windows
else
ifeq ($(os_type),windows64)
os              := Windows
else
ifeq ($(os_type),windows32_64)
os              ?= Windows
else
ifeq ($(os_type),)
os              := Windows
else
# Default to Linux style operating system. Both Cygwin and mingw are fully
# compatible (for this Makefile) with Linux.
os              := Linux
endif
endif
endif
endif

# Output documentation directory and configuration file.
docdir          := ../doxygen/html
doccfg          := ../doxygen/doxyfile.doxygen

CROSS           ?= arm-none-eabi-
AR              := $(CROSS)ar
AS              := $(CROSS)as
CC              := $(CROSS)gcc
CPP             := $(CROSS)gcc -E
CXX             := $(CROSS)g++
LD              := $(CROSS)g++
NM              := $(CROSS)nm
OBJCOPY         := $(CROSS)objcopy
OBJDUMP         := $(CROSS)objdump
SIZE            := $(CROSS)size
GDB             := $(CROSS)gdb

RM              := rm
ifeq ($(os),Windows)
RMDIR           := rmdir /S /Q
else
RMDIR           := rmdir -p --ignore-fail-on-non-empty
endif

# On Windows, we need to override the shell to force the use of cmd.exe
ifeq ($(os),Windows)
SHELL           := cmd
endif

# Strings for beautifying output
MSG_CLEAN_FILES         = "RM      *.o *.d"
MSG_CLEAN_DIRS          = "RMDIR   $(strip $(clean-dirs))"
MSG_CLEAN_DOC           = "RMDIR   $(docdir)"
MSG_MKDIR               = "MKDIR   $(dir $@)"

MSG_INFO                = "INFO    "
MSG_PREBUILD            = "PREBUILD  $(PREBUILD_CMD)"
MSG_POSTBUILD           = "POSTBUILD $(POSTBUILD_CMD)"

MSG_ARCHIVING           = "AR      $@"
MSG_ASSEMBLING          = "AS      $@"
MSG_BINARY_IMAGE        = "OBJCOPY $@"
MSG_COMPILING           = "CC      $@"
MSG_COMPILING_CXX       = "CXX     $@"
MSG_EXTENDED_LISTING    = "OBJDUMP $@"
MSG_IHEX_IMAGE          = "OBJCOPY $@"
MSG_LINKING             = "LN      $@"
MSG_PREPROCESSING       = "CPP     $@"
MSG_SIZE                = "SIZE    $@"
MSG_SYMBOL_TABLE        = "NM      $@"

MSG_GENERATING_DOC      = "DOXYGEN $(docdir)"

# Don't use make's built-in rules and variables
MAKEFLAGS       += -rR

# Don't print 'Entering directory ...'
MAKEFLAGS       += --no-print-directory

# Function for reversing the order of a list
reverse = $(if $(1),$(call reverse,$(wordlist 2,$(words $(1)),$(1)))) $(firstword $(1))

# Hide command output by default, but allow the user to override this
# by adding V=1 on the command line.
#
# This is inspired by the Kbuild system used by the Linux kernel.
ifdef V
  ifeq ("$(origin V)", "command line")
    VERBOSE = $(V)
  endif
endif
ifndef VERBOSE
  VERBOSE = 0
endif

ifeq ($(VERBOSE), 1)
  Q =
else
  Q = @
endif

arflags-gnu-y           := $(ARFLAGS)
asflags-gnu-y           := $(ASFLAGS)
cflags-gnu-y            := $(CFLAGS)
cxxflags-gnu-y          := $(CXXFLAGS)
cppflags-gnu-y          := $(CPPFLAGS)
cpuflags-gnu-y          :=
dbgflags-gnu-y          := $(DBGFLAGS)
libflags-gnu-y          := $(foreach LIB,$(LIBS),-l$(LIB))
ldflags-gnu-y           := $(LDFLAGS)
flashflags-gnu-y        :=
clean-files             :=
clean-dirs              :=

clean-files             += $(wildcard $(target) $(project).map)
clean-files             += $(wildcard $(project).hex $(project).bin)
clean-files             += $(wildcard $(project).lss $(project).sym)
clean-files             += $(wildcard $(build))

# Use pipes instead of temporary files for communication between processes
cflags-gnu-y    += -pipe
asflags-gnu-y   += -pipe
ldflags-gnu-y   += -pipe

# Archiver flags.
arflags-gnu-y   += rcs

# Always enable warnings. And be very careful about implicit
# declarations.
cflags-gnu-y    += -Wall -Wstrict-prototypes -Wmissing-prototypes
cflags-gnu-y    += -Werror-implicit-function-declaration
cxxflags-gnu-y  += -Wall
# IAR doesn't allow arithmetic on void pointers, so warn about that.
cflags-gnu-y    += -Wpointer-arith
cxxflags-gnu-y  += -Wpointer-arith

# Preprocessor flags.
cppflags-gnu-y  += $(foreach INC,$(addprefix $(PRJ_PATH)/,$(INC_PATH)),-I$(INC))
asflags-gnu-y   += $(foreach INC,$(addprefix $(PRJ_PATH)/,$(INC_PATH)),'-Wa,-I$(INC)')

# CPU specific flags.
cpuflags-gnu-y  += -mcpu=$(ARCH) -mthumb -D=__$(PART)__

# Dependency file flags.
depflags        = -MD -MP -MQ $@

# Debug specific flags.
ifdef BUILD_DEBUG_LEVEL
dbgflags-gnu-y  += -g$(BUILD_DEBUG_LEVEL)
else
dbgflags-gnu-y  += -g3
endif

# Optimization specific flags.
ifdef BUILD_OPTIMIZATION
optflags-gnu-y  = -O$(BUILD_OPTIMIZATION)
else
optflags-gnu-y  = $(OPTIMIZATION)
endif

# Always preprocess assembler files.
asflags-gnu-y   += -x assembler-with-cpp
# Compile C files using the GNU99 standard.
cflags-gnu-y    += -std=gnu99
# Compile C++ files using the GNU++98 standard.
cxxflags-gnu-y  += -std=gnu++98

# Don't use strict aliasing (very common in embedded applications).
cflags-gnu-y    += -fno-strict-aliasing
cxxflags-gnu-y  += -fno-strict-aliasing

# Separate each function and data into its own separate section to allow
# garbage collection of unused sections.
cflags-gnu-y    += -ffunction-sections -fdata-sections
cxxflags-gnu-y  += -ffunction-sections -fdata-sections

# Various cflags.
cflags-gnu-y += -Wchar-subscripts -Wcomment -Wformat=2 -Wimplicit-int
cflags-gnu-y += -Wmain -Wparentheses
cflags-gnu-y += -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs -Wunused
cflags-gnu-y += -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef
cflags-gnu-y += -Wshadow -Wbad-function-cast -Wwrite-strings
cflags-gnu-y += -Wsign-compare -Waggregate-return
cflags-gnu-y += -Wmissing-declarations
cflags-gnu-y += -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations
cflags-gnu-y += -Wpacked -Wredundant-decls -Wnested-externs -Winline -Wlong-long
cflags-gnu-y += -Wunreachable-code
cflags-gnu-y += -Wcast-align
cflags-gnu-y += --param max-inline-insns-single=500

# Garbage collect unreferred sections when linking.
ldflags-gnu-y   += -Wl,--gc-sections

# Use the linker script if provided by the project.
ifneq ($(strip $(linker_script)),)
ldflags-gnu-y   += -Wl,-T $(linker_script)
endif

# Output a link map file and a cross reference table
ldflags-gnu-y   += -Wl,-Map=$(project).map,--cref

# Add library search paths relative to the top level directory.
ldflags-gnu-y   += $(foreach _LIB_PATH,$(addprefix $(PRJ_PATH)/,$(LIB_PATH)),-L$(_LIB_PATH))

a_flags  = $(cpuflags-gnu-y) $(depflags) $(cppflags-gnu-y) $(asflags-gnu-y) -D__ASSEMBLY__
c_flags  = $(cpuflags-gnu-y) $(dbgflags-gnu-y) $(depflags) $(optflags-gnu-y) $(cppflags-gnu-y) $(cflags-gnu-y)
cxx_flags= $(cpuflags-gnu-y) $(dbgflags-gnu-y) $(depflags) $(optflags-gnu-y) $(cppflags-gnu-y) $(cxxflags-gnu-y)
l_flags  = -Wl,--entry=Reset_Handler -Wl,--cref $(cpuflags-gnu-y) $(optflags-gnu-y) $(ldflags-gnu-y)
ar_flags = $(arflags-gnu-y)

# Source files list and part informations must already be included before
# running this makefile

# If a custom build directory is specified, use it -- force trailing / in directory name.
ifdef BUILD_DIR
    build-dir       := $(dir $(BUILD_DIR))$(if $(notdir $(BUILD_DIR)),$(notdir $(BUILD_DIR))/)
else
    build-dir        =
endif

# Create object files list from source files list.
obj-y                   := $(addprefix $(build-dir), $(addsuffix .o,$(basename $(CSRCS) $(ASSRCS))))
# Create dependency files list from source files list.
dep-files               := $(wildcard $(foreach f,$(obj-y),$(basename $(f)).d))

clean-files             += $(wildcard $(obj-y))
clean-files             += $(dep-files)

clean-dirs              += $(call reverse,$(sort $(wildcard $(dir $(obj-y)))))

# Default target.
.PHONY: all
ifeq ($(project_type),all)
all:
    $(MAKE) all PROJECT_TYPE=flash
    $(MAKE) all PROJECT_TYPE=sram
else
ifeq ($(target_type),lib)
all: $(target) $(project).lss $(project).sym
else
ifeq ($(target_type),elf)
all: prebuild $(target) $(project).lss $(project).sym $(project).hex $(project).bin postbuild
endif
endif
endif

prebuild:
ifneq ($(strip $(PREBUILD_CMD)),)
    @echo $(MSG_PREBUILD)
    $(Q)$(PREBUILD_CMD)
endif

postbuild:
ifneq ($(strip $(POSTBUILD_CMD)),)
    @echo $(MSG_POSTBUILD)
    $(Q)$(POSTBUILD_CMD)
endif

# Clean up the project.
.PHONY: clean
clean:
    @$(if $(strip $(clean-files)),echo $(MSG_CLEAN_FILES))
    $(if $(strip $(clean-files)),$(Q)$(RM) $(clean-files),)
    @$(if $(strip $(clean-dirs)),echo $(MSG_CLEAN_DIRS))
# Remove created directories, and make sure we only remove existing
# directories, since recursive rmdir might help us a bit on the way.
ifeq ($(os),Windows)
    $(Q)$(if $(strip $(clean-dirs)),                        \
            $(RMDIR) $(strip $(subst /,\,$(clean-dirs))))
else
    $(Q)$(if $(strip $(clean-dirs)),                        \
        for directory in $(strip $(clean-dirs)); do     \
            if [ -d "$$directory" ]; then           \
                $(RMDIR) $$directory;           \
            fi                                      \
        done                                            \
    )
endif

# Rebuild the project.
.PHONY: rebuild
rebuild: clean all

# Debug the project in flash.
.PHONY: debug_flash
debug_flash: all
    $(GDB) -x "$(PRJ_PATH)/$(DEBUG_SCRIPT_FLASH)" -ex "reset" -readnow -se $(TARGET_FLASH)

# Debug the project in sram.
.PHONY: debug_sram
debug_sram: all
    $(GDB) -x "$(PRJ_PATH)/$(DEBUG_SCRIPT_SRAM)" -ex "reset" -readnow -se $(TARGET_SRAM)

.PHONY: objfiles
objfiles: $(obj-y)

# Create object files from C source files.
$(build-dir)%.o: %.c $(MAKEFILE_PATH) config.mk
    $(Q)test -d $(dir $@) || echo $(MSG_MKDIR)
ifeq ($(os),Windows)
    $(Q)test -d $(patsubst %/,%,$(dir $@)) || mkdir $(subst /,\,$(dir $@))
else
    $(Q)test -d $(dir $@) || mkdir -p $(dir $@)
endif
    @echo $(MSG_COMPILING)
    $(Q)$(CC) $(c_flags) -c $< -o $@

# Create object files from C++ source files.
$(build-dir)%.o: %.cpp $(MAKEFILE_PATH) config.mk
    $(Q)test -d $(dir $@) || echo $(MSG_MKDIR)
ifeq ($(os),Windows)
    $(Q)test -d $(patsubst %/,%,$(dir $@)) || mkdir $(subst /,\,$(dir $@))
else
    $(Q)test -d $(dir $@) || mkdir -p $(dir $@)
endif
    @echo $(MSG_COMPILING_CXX)
    $(Q)$(CXX) $(cxx_flags) -c $< -o $@

# Preprocess and assemble: create object files from assembler source files.
$(build-dir)%.o: %.S $(MAKEFILE_PATH) config.mk
    $(Q)test -d $(dir $@) || echo $(MSG_MKDIR)
ifeq ($(os),Windows)
    $(Q)test -d $(patsubst %/,%,$(dir $@)) || mkdir $(subst /,\,$(dir $@))
else
    $(Q)test -d $(dir $@) || mkdir -p $(dir $@)
endif
    @echo $(MSG_ASSEMBLING)
    $(Q)$(CC) $(a_flags) -c $< -o $@

# Include all dependency files to add depedency to all header files in use.
include $(dep-files)

ifeq ($(target_type),lib)
# Archive object files into an archive
$(target): $(MAKEFILE_PATH) config.mk $(obj-y)
    @echo $(MSG_ARCHIVING)
    $(Q)$(AR) $(ar_flags) $@ $(obj-y)
    @echo $(MSG_SIZE)
    $(Q)$(SIZE) -Bxt $@
else
ifeq ($(target_type),elf)
# Link the object files into an ELF file. Also make sure the target is rebuilt
# if the common Makefile.sam.in or project config.mk is changed.
$(target): $(linker_script) $(MAKEFILE_PATH) config.mk $(obj-y)
    @echo $(MSG_LINKING)
    $(Q)$(LD) $(l_flags) $(obj-y) $(libflags-gnu-y) -o $@
    @echo $(MSG_SIZE)
    $(Q)$(SIZE) -Ax $@
    $(Q)$(SIZE) -Bx $@
endif
endif

# Create extended function listing from target output file.
%.lss: $(target)
    @echo $(MSG_EXTENDED_LISTING)
    $(Q)$(OBJDUMP) -h -S $< > $@

# Create symbol table from target output file.
%.sym: $(target)
    @echo $(MSG_SYMBOL_TABLE)
    $(Q)$(NM) -n $< > $@

# Create Intel HEX image from ELF output file.
%.hex: $(target)
    @echo $(MSG_IHEX_IMAGE)
    $(Q)$(OBJCOPY) -O ihex $(flashflags-gnu-y)  $< $@

# Create binary image from ELF output file.
%.bin: $(target)
    @echo $(MSG_BINARY_IMAGE)
    $(Q)$(OBJCOPY) -O binary $< $@

# Provide information about the detected host operating system.
.SECONDARY: info-os
info-os:
    @echo $(MSG_INFO)$(os) build host detected

# Build Doxygen generated documentation.
.PHONY: doc
doc:
    @echo $(MSG_GENERATING_DOC)
    $(Q)cd $(dir $(doccfg)) && $(DOCGEN) $(notdir $(doccfg))

# Clean Doxygen generated documentation.
.PHONY: cleandoc
cleandoc:
    @$(if $(wildcard $(docdir)),echo $(MSG_CLEAN_DOC))
    $(Q)$(if $(wildcard $(docdir)),$(RM) --recursive $(docdir))

# Rebuild the Doxygen generated documentation.
.PHONY: rebuilddoc
rebuilddoc: cleandoc doc
lws-team commented 4 years ago

Well, this is getting away from any lws issue.

I need now to added "LWS" as a top layer.

Although lws might be the top level of your software stack actually you do not have to take that approach about the build.

You can build lws on one side, just show it where the lwip + freertos headers it should refer to are living, and let it produce an incomplete libwebsockets.a standalone.

Afterwards you can just add the libwebsockets.a to your existing SDK link and add code using its apis there. This approach lets you leverage the lws cmake build cleanly without having to integrate "the rest of the world" into it.

lws-team commented 4 years ago

I pushed a patch on master which adds a ./contrib/cross-atmel.cmake that builds here if you place the toolchain and xdk download (== "ASF3") into /opt. Study the toolchain file to see where they go and how to modify them. That can build with the example cmake line shown in the toolchain file to produce a libwebsockets.a, untested since I don't have a devkit.

But the xdk has only the very old (and unmaintained) polarssl, lws doesn't support it. It supports the successor, mbedtls, you'll have to integrate that yourself. On ESP32, it's very possible to produce a sub-1MB image with lws, assets and mbedtls, I assume it'll be the same here.

ghost commented 4 years ago

@lws-team Thank you soo much. I will do my best to test it.

ghost commented 4 years ago

Hi @lws-team. I have added to ./contrib/cross-atmel.cmake file asf path, freertos path and lwip path. (in my case i use lwip-2.0.1 not old lwip in asf, freertos-10.3.1).

lws-team commented 4 years ago

My advice is don't change stuff around until you reproduce it building as I provided it.

I'm not Atmel, I'm not involved in your project, I have some interest to see it can build at all, which it does, but I have no interest beyond that.

ghost commented 4 years ago

Hi @lws-team . Okay. IT WORKS YEAH. I have added mbedtls, lwip-2.2.0, freertos-10.3.0 used in my project to /opt/xdk-asf-3.48.0/ in order to use by lws. Then it works fine. I have arrived to generate libwebsockets.a for atmel after i have folowed your recommendations.

I will see how can i use it in my project. [100%] Linking C static library libwebsockets.a [100%] Built target websockets said@said build % Thank you 🙏 😊

lws-team commented 4 years ago

Great... actually using lws on freertos should be no different than using it on linux or whatever... the idea is you can write things once for all platforms... there are some optional things like secure streams and smd enabled in this example but you can see how it is done for esp32 on esp-idf / freertos

https://libwebsockets.org/git/libwebsockets/tree/minimal-examples/embedded/esp32/esp-wrover-kit/main/lws-minimal-esp32.c#n213

ghost commented 4 years ago

The libwebsocket.a imported to my project as lib works. but i need to test ws-client. I have tried the client sample "lws-minimal-ws-client-binance" (because i need my board as simple ws-client), then i got this error

make      
/Applications/Xcode.app/Contents/Developer/usr/bin/make all PROJECT_TYPE=flash
CC      src/main.o
In file included from ./lws/include/libwebsockets.h:267,
                 from src/main.c:13:
./mbedtls/include/mbedtls/entropy.h:127:5: error: unknown type name 'mbedtls_sha256_context'
  127 |     mbedtls_sha256_context  accumulator;
      |     ^~~~~~~~~~~~~~~~~~~~~~
lws-team commented 4 years ago

Binance example has a lot of baggage unrelated to simple ws-client... like needing zlib for extensions... minimal-ws-client will be simpler.

You need to gain some debugging skills rather than ask me every time, because now the main part of this is your code and build arrangements, not any lws issue.

Eg doesn't that try to include its own dependent headers? Why would that be broken on your build arrangements

https://github.com/ARMmbed/mbedtls/blob/development/include/mbedtls/entropy.h#L37

ghost commented 4 years ago

Okay thank you. I try to test lws for atmel sam4e with minimal-ws-client. I think, just question: lws need integration of atmel configuration /lws-freertos.h, lws_config.h) ? because after genartion of libwebsockets.s and adding (include and lib generated )to my project i got some errors with i see i found esp32 dependencies.

undef MBEDTLS_CONFIG_FILE

// #define MBEDTLS_CONFIG_FILE <mbedtls/esp_config.h>

define MBEDTLS_CONFIG_FILE <mbedtls/config.h>

when i replace #include<mbedtls/lws_config.h> by #include<mbedtls/config.h>. i got another error:./lws/include/libwebsockets/lws-freertos.h:62:10: fatal error: freertos/FreeRTOS.h: No such file or directory    62 | #include <freertos/FreeRTOS.h> when i see the lws-freertos.h file i see esp32 configuration and headers i'm looking for atmel_config.h