Closed locnnil closed 1 year ago
Figure out that the problem was in my environment variables. I Solve my problem using *CMake instead of Make for me works with these steps:
toolchain-arm-none-eabi.cmake
toolchain file with the content:set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_SYSTEM_VERSION 1)
# this info holds the location of installation
set(CMAKE_STAGING_PREFIX /tmp/mbedTLS)
set(CMAKE_C_COMPILER /usr/bin/arm-none-eabi-gcc)
set(CMAKE_CXX_COMPILER /usr/bin/arm-none-eabi-g++)
set(CMAKE_MAKE_PROGRAM=/usr/bin/make)
set(CMAKE_C_FLAGS="-mcpu=cortex-m0plus -mthumb -O2")
set(CMAKE_CXX_FLAGS="-mcpu=cortex-m0plus -mthumb -O2")
set(CMAKE_EXE_LINKER_FLAGS " --specs=nosys.specs")
set(CMAKE_STRIP /usr/bin/arm-none-eabi-strip)
set(CMAKE_FIND_ROOT_PATH /usr/arm-none-eabi)
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)
toolchain-arm-none-eabi.cmake
file in a folder and from that same folder I ran:# Download the `.tar.gz` of MbedTLS
wget https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v3.2.1.tar.gz
# unzip
tar zxf v3.2.1.tar.gz
# Configure to crypto_baremetal
mbedtls-3.2.1/scripts/config.py -w mbedtls-3.2.1/include/mbedtls/mbedtls_config.h crypto_baremetal
# Folder to build
mkdir mbedtls
# Go inside build folder
pushd mbedtls
# Configuring (necessary force that compiler works to CMake)
cmake -DCMAKE_C_COMPILER_WORKS=1 \
-DCMAKE_BUILD_TYPE=Release -DUSE_SHARED_MBEDTLS_LIBRARY=OFF \
-DUSE_STATIC_MBEDTLS_LIBRARY=ON \
-DENABLE_PROGRAMS=OFF -DENABLE_TESTING=OFF \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_TOOLCHAIN_FILE=../toolchain-arm-none-eabi.cmake ../mbedtls-3.2.1
# Compiling and installing
make all install
# Free diretory stack
popd
Then inside the folder /tmp/mbedTLS
I have:
cd /tmp/mbedTLS
tree
.
├── cmake
│ ├── MbedTLSConfig.cmake
│ ├── MbedTLSConfigVersion.cmake
│ ├── MbedTLSTargets.cmake
│ └── MbedTLSTargets-release.cmake
├── include
│ ├── mbedtls
│ │ ├── aes.h
│ │ ├── aria.h
│ │ ├── asn1.h
│ │ ├── asn1write.h
│ │ ├── base64.h
│ │ ├── bignum.h
│ │ ├── build_info.h
│ │ ├── camellia.h
│ │ ├── ccm.h
│ │ ├── chacha20.h
│ │ ├── chachapoly.h
│ │ ├── check_config.h
│ │ ├── cipher.h
│ │ ├── cmac.h
│ │ ├── compat-2.x.h
│ │ ├── config_psa.h
│ │ ├── constant_time.h
│ │ ├── ctr_drbg.h
│ │ ├── debug.h
│ │ ├── des.h
│ │ ├── dhm.h
│ │ ├── ecdh.h
│ │ ├── ecdsa.h
│ │ ├── ecjpake.h
│ │ ├── ecp.h
│ │ ├── entropy.h
│ │ ├── error.h
│ │ ├── gcm.h
│ │ ├── hkdf.h
│ │ ├── hmac_drbg.h
│ │ ├── mbedtls_config.h
│ │ ├── md5.h
│ │ ├── md.h
│ │ ├── memory_buffer_alloc.h
│ │ ├── net_sockets.h
│ │ ├── nist_kw.h
│ │ ├── oid.h
│ │ ├── pem.h
│ │ ├── pkcs12.h
│ │ ├── pkcs5.h
│ │ ├── pk.h
│ │ ├── platform.h
│ │ ├── platform_time.h
│ │ ├── platform_util.h
│ │ ├── poly1305.h
│ │ ├── private_access.h
│ │ ├── psa_util.h
│ │ ├── ripemd160.h
│ │ ├── rsa.h
│ │ ├── sha1.h
│ │ ├── sha256.h
│ │ ├── sha512.h
│ │ ├── ssl_cache.h
│ │ ├── ssl_ciphersuites.h
│ │ ├── ssl_cookie.h
│ │ ├── ssl.h
│ │ ├── ssl_ticket.h
│ │ ├── threading.h
│ │ ├── timing.h
│ │ ├── version.h
│ │ ├── x509_crl.h
│ │ ├── x509_crt.h
│ │ ├── x509_csr.h
│ │ └── x509.h
│ └── psa
│ ├── crypto_builtin_composites.h
│ ├── crypto_builtin_primitives.h
│ ├── crypto_compat.h
│ ├── crypto_config.h
│ ├── crypto_driver_common.h
│ ├── crypto_driver_contexts_composites.h
│ ├── crypto_driver_contexts_primitives.h
│ ├── crypto_extra.h
│ ├── crypto.h
│ ├── crypto_platform.h
│ ├── crypto_se_driver.h
│ ├── crypto_sizes.h
│ ├── crypto_struct.h
│ ├── crypto_types.h
│ └── crypto_values.h
└── lib
├── libmbedcrypto.a
├── libmbedtls.a
└── libmbedx509.a
I hope this comment could help others with the same problem as I did! =)
Summary
I’m trying to compile the mbedTLS library to use with RP2040 microcontroler (in a .a library file), to use in with CMake pico-sdk of Raspberry Pi Pico board, but I’m getting an linker error.
System information
Mbed TLS version (number or commit id): 1a100b69a4132 (branch development) Operating system and version: Pop!_OS 22.04 LTS x86_64 Configuration (if not default, please attach
mbedtls_config.h
): crypto_baremetal Compiler and options (if you used a pre-built binary, please indicate how you obtained it): arm-none-eabi-gcc (15:10.3-2021.07-4) 10.3.1 20210621 Additional environment information: Compilling for RP2040 MCU, using compiler flags and env variables:Expected behavior
The compilation of MbedTLS library for baremetal_crypto configuration. (A
.a
library file)Actual behavior
The error:
Steps to reproduce
In a linux-based environment (more specificaly in a Ubuntu based Environment):
Additional information
I followed the instructions of README.md did I miss something? Already try to compile in my Raspberry Pi Zero W (using the OS: Raspbian GNU/Linux 11 (bullseye) armv6l) and I get the same result (The same errors).