Compiling mbedTLS for PIC32MX processor with XC32 compiler of Microchip Technology

I would really appeciate if someone could explain me the steps to compile mbedTLS for a PIC32MX processor using the Microchip Technolgy’s XC32 compiler, because I was not able to do it.
I’m using Windows 10.

What I tried so far:
(0) Installed CMake (cmake-gui) 3.16.2
(1) Downloaded mbedtls-2.16.3-apache (on 31-december-2019) and extracted it to C:\source
(2) Went to folder \configs, selected file config-mini-tls1_1.h, did a copy of it, renamed it to config.h, copied it to folder \include\mbedtls replacing the existing file.
(3) Opened CMD/prompt, and did on it:
(3.a) mkdir C:\compiled then cd C:\compiled
(3.b) SET CC=C:\Program Files (x86)\Microchip\xc32\v1.43\bin (XC32 compiler folder)
(3.c) cmake c:\source

It does not compile correctly, and Im not figuring out what’s happening.
Please, could you help me?

Regards, and happy new year.


Hi @abomin3v3l
Thank you for your question!

Note that CC is the compiler itself, and not the folder of the toolchain.
You should set CC to be the compiler itself.
please try the following for step 3.b:

SET CC=C:\Program Files (x86)\Microchip\xc32\v1.43\bin\xc32-gcc.exe

Regards,
Mbed TLS Support
Ron

1 Like

Hi. I changed according, and now I’m getting another error.

Regards,
Jeferson

Hi Jeferson,
The failure states that:

It fails with the following output:
    Change Dir: C;/compiled/CMakFiles/CMakeTmp

I believe this is related to windows path vs. Linux path, and the failure is because the path is separated with /.
Please try to run in cygwin for example, and not windows command prompt
Regards,
Ron

1 Like

Hi.
I have used Cygwin.
I did copied XC32 compiler folder “v1.43” to C:

Hi @abomin3v3l
Please try the following command:

CC=/cygdrive/c/1.43/bin/x32-gcc.exe cmake /cygdrive/c/source

Regards
Ron

1 Like

I tried:

cd C:/compiled
CC=/cygdrive/c/v1.43/bin/x32-gcc.exe
cmake /cygdrive/c/source

And got this:

01

The source code is really at C:\source

Hi @abomin3v3l
Please check where the source code is in cygwin.

/cygdrive/c/source should point to C:\source, but it is case sensitive, perhaps that’s the reason.
Regards

1 Like

Thanks for helping me.
I don’t know how to go ahead at this point.
Check that:

01

Hi @abomin3v3l
Thanks for the input
To be honest, this is strange.

Please try building from the source directory:

cd c:\source
CC=/cygdrive/c/v1.43/bin/x32-gcc.exe cmake .
make

Regards

1 Like

Hi @roneld01
I did not understood about what you have typed, is this correct?
01

What more I can try?
Regards.

HI Jeferson,
Yes, this is correct.
cmake only generates the makefiles with relevant toolchain, etc…
After that, to build, you will need to run make

1 Like

03

Please also check that, I deleted c:\compiled folder and tried to create the folder again with cygwin, but the folder is not present on c:\

02

Hi Jeferson,
For some reason, the cmake didn’t recognize you setting the toolchain, and it tried using c1 as a compiler.

maybe cmake CC=/cygdrive/c/v1.43/bin/x32-gcc.exe . will work?

Please also check that, I deleted c:\compiled folder and tried to create the folder again with cygwin, but the folder is not present on c:\

That’s because you didn’t create c:\compiled
You have created a folder named c:compiled in your user folder. cygwin work swith Linux style paths. You should create the folder /cygdrive/c/source`. ( Maybe mkdir c:\source would also work)
Regards

1 Like

@roneld01
I think I need to know exactly what I need to type on cygwin, because I’m really not familiar with command line, cygwin etc.

for example, I would appreciate if you can send me in this format:

TRY1
command1
command2
commandN

TRY2
command1
command2
commandN

and I would copy and paste your commands exactly as you sent, on cygwin, and tell you the results.

Also, this was the folder that was created when I typed in “mkdir c:\compiled” on cygwin

aaa

Thanks very much.

Hi @abomin3v3l
Please try the following:

cd /cygdrive/c/source
rm CmakeCache.txt
rm -r CMakeFiles/
CC=/cygdrive/c/v1.43/bin/x32-gcc.exe cmake  .
make

Regards

1 Like

Note that removing the CMakeFiles flder should be done as admin, so perhaps you should delete it through your windows file browser

1 Like

I always run cygwin as admin.

Result:

Hi Jefereson,
Do you still have c:\1.43\bin\x32-gcc.exe ?

Could you try in cygwin the following:

cd /cygdrive/c/v1.43/bin/
ls -l
cd /cygdrive/c/
ls -l
cd /cygdrive/c/v1.43/
ls -l

Regards

1 Like

C:\v1.43\bin does exist:

cd /cygdrive/c/v1.43/bin/
ls -l

cd /cygdrive/c/
ls -l

cd /cygdrive/c/v1.43/
ls -l
04