cancel
Showing results for 
Search instead for 
Did you mean: 

Title: Integrating cJSON, mbedTLS, lwIP, and FatFS into an STM32U5 project

srikanthpalvai
Associate III

I'm working on a project with an STM32U5 device (NUCLEO-U5A5ZJ-Q) and I need to integrate cJSON, mbedTLS, lwIP, and FatFS to load and flash a configuration file cacert.pemonto the STM32 device. However, when I searched for mbedtls and lwip in the middleware and software packages, I couldn't find them.

Can anyone provide suggestions or guidance on how to integrate mbedtls, lwIP, and FatFS into my STM32 project? Additionally, I'm curious if there's a cJSON library available for STM32.


https://github.com/STMicroelectronics/STM32CubeU5/tree/main/Projects/NUCLEO-U5A5ZJ-Q
https://github.com/STMicroelectronics/STM32CubeU5/tree/main/Middlewares/Third_Party


https://github.com/STMicroelectronics/STM32CubeH7
https://github.com/STMicroelectronics/STM32CubeH7/tree/master/Middlewares/Third_Party


I've noticed that the STM32H7 series has middleware third-party tools like lwIP and mbedTLS available, but these are not included in the STM32U5 series. Is there a specific reason why these middleware components are absent in the STM32U5 series compared to the H7 series?

Thank you in advance for your help!

1 ACCEPTED SOLUTION

Accepted Solutions

@srikanthpalvai did you not see what @STea wrote:

 

@STea wrote:

Hello @srikanthpalvai ,

Can you please input your new queries in a new thread for better visibility and we can proceed by closing this one .

BR


https://community.st.com/t5/stm32-mcus-embedded-software/title-integrating-cjson-mbedtls-lwip-and-fatfs-into-an-stm32u5/m-p/650011/highlight/true#M46183

 

View solution in original post

12 REPLIES 12
STea
ST Employee

Hello @srikanthpalvai ,

In fact MbedTLS is well supported in the STM32U5 series and it's part of the TFM solution implementation as you can find in the TFM project under TFM_SBSFU_Boot alt_xx.c files which leverage the wrapper layer of MbedTLS to be HW accelerated which are part of The PSA cryptography API that provides access to a set of cryptographic primitives .MbedTLS can be found under STM32CubeU5/Middlewares/Third_Party/mbed-crypto at main · STMicroelectronics/STM32CubeU5 (github.com).

Regarding the support for  lwIP it is not supported for the U5 series instead you can replace it by the NetXduo from AzureRTOS you can find some examples of Netxduo Under STM32CubeU5/Projects/B-U585I-IOT02A/Applications/NetXDuo at main · STMicroelectronics/STM32CubeU5 (github.com)

FatFS is replaced by Azure FileX you can find a n example on it's implementation under STM32CubeU5/Projects/B-U585I-IOT02A/Applications/FileX at main · STMicroelectronics/STM32CubeU5 (github.com).

in the U5 series the Middleware Package is centered on the Azure middleware ecosystem you can read more about it in the Azure official documentation .

BR

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Thanks for the quick response  @STea 
 STM32CubeU5/Middlewares/Third_Party/mbed-crypto at main · STMicroelectronics/STM32CubeU5 (github.com).
Would it be sufficient to copy the mbed-crypto directory directly into my project, or are there additional steps I need to follow for proper integration?

 STM32CubeU5/Projects/B-U585I-IOT02A/Applications/NetXDuo at main · STMicroelectronics/STM32CubeU5 (github.com)
https://github.com/STMicroelectronics/STM32CubeU5/tree/main/Middlewares/ST/netxduo

How can I integrate the NetXDuo TCP/IP stack into my project after establishing a PPP communication link with the SIM7600 module?


STM32CubeU5/Projects/B-U585I-IOT02A/Applications/FileX at main · STMicroelectronics/STM32CubeU5 (github.com).
Here the example is to create the STM.TXT in the run-time 
/* Create a file called STM32.TXT in the root directory. */
nor_ospi_status = fx_file_create(&nor_ospi_flash_disk, "STM32.TXT");

But I have my pre-configured config.ini file and cacert.pem files for mbedlts communication. 
How can inject them into the stm32 target? Could you please share an example of it?

 Is there any cJSON library available for STM32?


@srikanthpalvai wrote:

 Is there any cJSON library available for STM32?


Why would it be in any way specific to STM32 ?

Surely, it's just about parsing text - which isn't going to rely on anything STM32-specific?

You can simply dump the source into your project:

AndrewNeil_0-1709819029556.png

https://github.com/DaveGamble/cJSON 

Thanks @Andrew Neil

srikanthpalvai_0-1709855309006.png

After enabling the core, Netxduo is getting enabled bu why do I enable threadX first?

srikanthpalvai_1-1709855384698.png



I found crypto here but it's not the mbed-crypto 

srikanthpalvai_2-1709855515574.png

@STea Could you please give me some inputs to my reply's

@STea Kindly Remainder 

Hello @srikanthpalvai ,

First of all sorry for the delay.

answering your requests now :

  • "After enabling the core, Netxduo is getting enabled bu why do I enable threadX first?"

 NetX Duo assumes the existence of ThreadX and depends on its thread execution, suspension, periodic timers, and mutual exclusion facilities. you can get more indepth details on this in this link .

  • "i found crypto here but it's not the mbed-crypto" 

NetX Duo Crypto Module is a lightweight cryptographic library that is designed specifically for use with NetX Duo TCP/IP networking stack. It provides a set of cryptographic functions that are optimized for use in embedded systems with limited resources. The NetX Duo Crypto Module supports a range of cryptographic algorithms, including AES, DES, SHA-1, SHA-256, and HMAC.

MbedTLS is not integrated by default in CubeMX so you need to add it to your project manually .

this can be done by adding the source file needed to your project as well as the necessary includes or you can build a static version of the Mbedtls library and use it with static link.

see the following link for more details

 Porting Mbed TLS to a new environment or OS — Mbed TLS documentation (mbed-tls.readthedocs.io)

Compile Mbed TLS to a static library in Eclipse CDT — Mbed TLS documentation (mbed-tls.readthedocs.io)

this can be quite challenging so i recommend you stick with the Crytpo module for Netxduo which offer a very similar functionality to the MbedTLS library .

BR

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
srikanthpalvai
Associate III

@STea 
Thank you so much for the information.
Could you please give me some more context below queries as well 

STM32CubeU5/Projects/B-U585I-IOT02A/Applications/FileX at main · STMicroelectronics/STM32CubeU5 (github.com).
Here the example is to create the STM.TXT in the run-time 
/* Create a file called STM32.TXT in the root directory. */
nor_ospi_status = fx_file_create(&nor_ospi_flash_disk, "STM32.TXT");

But I have my pre-configured config.ini file and cacert.pem files for mbedlts communication. 
How can inject them into the stm32 target? Could you please share an example of it?



How can I integrate the NetXDuo TCP/IP stack into my project after establishing a PPP communication link with the SIM7600 module?



Hello @srikanthpalvai ,

Can you please input your new queries in a new thread for better visibility and we can proceed by closing this one .

BR

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.