Arm Mbed OS support forum

How to use mbedtls with NUCLEO_L031K6?

Hello, I attempt to add the library via mbed add <git url> but receive a number of errors when I mbed compile that are not easy to fix.

 #error "The NET and TIMING modules are not available for mbed OS - please use the network and timing functions provided by mbed OS"

How am I supposed to use it?

Hello,

Nucleo L031K6 is low memory target, because of that it is not supported in MbedOS6+ and with MbedOS lower than 6 it was probably supported only with bare metal profile or Mbed2 = no network connectivity.

BR, Jan

Thanks, I do remember reading that. But I am not trying to use it with network connectivity. I just need mbedtls for the hashing functions so that I can authenticate to a secure I2C device.

Ah, ok.

So you need something like mbed-os-example-tls from TLS - APIs | Mbed OS 5 Documentation right?

So you will need to add to mbed_app.json something like this

{
"requires": ["bare-metal","mbedtls"]
}

I am not sure if this will be enough but the compiler will tell you what will be necessary to add from another mbed_lib.json files, I think. You must to try.

BR, Jan

That has helped but has not completely solved the issue. I tried variations of “mbedtls” in the modules line but thought it was not working as the examples I found used nonexistent headers. I am now able to import mbedtls/sha1.h and define a structure of type mbedtls_sha1_context however the supporting functions are not linked in.

/main.cc:90: undefined reference to `mbedtls_sha1_init'
collect2: error: ld returned 1 exit status

From:

mbedtls_sha1_context dg;
mbedtls_sha1_init(&dg);

I can’t find any more guidance in getting it working via the modules system. I see bits and pieces of answers to other similar questions (usually about getting the networking or PKA code working) that solve the issue by putting mbedtls into the project directory and compiling it there. As far as I can tell this is not the intended method, and in my case it leads to a lot of compilation errors that I don’t think I should spend time fixing just yet.