Mbed TLS is now part of TrustedFirmware.org.

How can I use mbed TLS library in my ARM project in Keil IDE?


Dec 23, 2016 08:39
lulala

I want to do an RSA encryption/decryption using my AT91SAM7S256 ARM MCU. After googling I found mbed TLS library. I download it on my Windows and extracted it in the directory of my project.

I was created the project using Keil IDE as below:

Project >> New mVision Project Assigning a name to the project Choosing "AT91SAM7S256" under Atmel MCUs Accepting the following suggestion: Alt text After that, in the following tab, I added the path of mbed TLS extracted directory to the Include Path of Keil(Path of header files, I think):

Project >> Option for Target "MyProjectName" >> C\C++

As the last step I did a right click on the project name in the right sidebar and using Add files to group AGroupName I added rsa.h and rsa.c of mbed TLS files to my project. I added a file named main.c that I myself was created it already with the simplest content:

<code>#include "rsa.h"

int main(){ return 0; }</code> Here are the pictures of above steps: Alt text Alt text Finally I tried to build this project from Project >> Build all target files, but I faced the following error : <code>Build target 'Target 1' assembling SAM7.s... compiling rsa.c... mbedtls-2.0.0\library\rsa.c(30): error: #5: cannot open source input file "mbedtls/config.h": No such file or directory compiling main.c... main.c(1): error: #5: cannot open source input file "rsa.h": No such file or directory Target not created <</quote>></code> Well, I added config.h to the group just like rsa.c and rsa.h and replaced "mbedtls/config.h" with "config.h" in the rsa.c file and that error removed. but another similar error appeared. Well I added about 10 files and edit the content as described but I still faced similar error.

I want to ask if is this the correct way? Am I should manually add all the files one by one? Or there is a better and efficient way? As the contents of mbed TLS library shows(make, makeinstall and so on) and as the extension of downloaded file shows(".tgz"), it is written for linux platform. Does that mean I can't use it in windows? As a starter, witch one is better for the above described project? Keil vs IAR IDE? Windows vs Linux platforms? Note that this is the first step of project, I think I must add other algorithms also.

Thanks in advance.

 
Dec 28, 2016 11:26
Andres Amaya Garcia

Hi,

There are many questions in the original post, so I will answer them separately:

  • As the contents of mbed TLS library shows(make, makeinstall and so on) and as the extension of downloaded file shows(".tgz"), it is written for linux platform. Does that mean I can't use it in windows?

As indicated in the mbed TLS's README, the supported build systems are Make, CMake and Visual Studio. This does not imply that the software cannot be used with any other build systems or toolchains, but it is the user's task to introduce the necessary changes to ensure that the library works as expected. mbed TLS is distributed from the official website as tar files compressed with Gzip, hence the extension .tgz. However, these files are not specific to Linux and this does not imply that they cannot be used in other platforms.

  • As a starter, witch one is better for the above described project? Keil vs IAR IDE? Windows vs Linux platforms?

mbed TLS is designed to be portable and is written to work with many different compilers and development environments, and compiles with uVision and IAR compilers. The best environment for your use will depend on your specific needs.

For more information regarding the supported platforms, compilers and build systems, please refer to this README.

  • I want to ask if is this the correct way? Am I should manually add all the files one by one? Or there is a better and efficient way?

Please note that we do not provide Keil uVision IDE project files as part of mbed TLS. It seems that an mbed TLS port for the Keil uVision and the AT91SAM7S256 is being attempted. It also seems that only a subset of the functionality offered by mbed TLS is required (e.g. RSA). I would recommend to configure mbed TLS by using the configuration file at include/mbedtls/config.h instead of manually trying to add/remove files and then trying to fix the dependencies. The following knowledgebase articles provide useful information on creating ports to new platforms and configuring mbed TLS:

I hope this information is helpful.

Kind regards, Andres AG, mbed TLS Team Member