Skip to main content
Explorer
March 16, 2024
Question

How to Inject Configuration Files into STM32 Target Using FileX?

  • March 16, 2024
  • 6 replies
  • 3650 views

Hello STM community,

I'm working on a project where I need to inject pre-configured config.ini and cacert.pem files into my STM32 target for mbedlts communication. I've gone through the STM32CubeU5 example for FileX, which demonstrates creating a file at runtime.

However, I'm unsure how to modify this example to include code that reads these configuration files from storage internal flash and then perform the necessary operations with them.

Could anyone provide guidance or share an example of how to achieve this using FileX on STM32?

https://github.com/STMicroelectronics/STM32CubeU5/tree/main/Projects/B-U585I-IOT02A/Applications/FileX

 

Thank you in advance for your help!

Best regards,

    This topic has been closed for replies.

    6 replies

    Graduate II
    March 16, 2024

    Could swear you've already asked this. Put the data into a C uint8_t array, put it in it's own .H for convenience. Use pointer and sizeof() to determine location and scope content.

    Perhaps if you have some level of sophistication you can put multiple files, with names, sizes, and pointers into a table/structure.

    Explorer
    March 16, 2024

    Thanks for the quick response 

    Is there any other alternative way to achieve this without this uint8_t array

    By the way could you please give me some examples to uint8_t.

     

    Super User
    March 16, 2024

    Do you need a filesystem, besides these two files? If not: find API that takes the data from memory (pointer/array) rather than named files. If no such API, implement _open() , _read() and whatever else your libraries need to read the files rather than hauling entire filesystem package into your project.

    Explorer
    March 16, 2024

    @Pavel A. 

    I want file system.

     

    Super User
    March 16, 2024

    Great. Then you need SD card or eMMC chip, or something else. Create a filesystem image from your files, put it on the storage. Mount it. Task complete!

     

    Explorer
    March 16, 2024

    Sorry, I don’t want to use the SD card 

    I want to use flash memory for this as I am going to use the STM nucleo which having 4MB flash. 

     

    Super User
    March 16, 2024

    Then the internal flash will be the storage. Same plan.

     

    Explorer
    March 21, 2024

    @Pavel A. 
    But my Basic query is, how can I load my raw files(config.ini and cacert.pem) into the flash memory, Without using the array approch.

    Super User
    March 21, 2024

    You can, for example, just write the data file into internal flash as a binary, at a fixed address, using CubeProgrammer.

    Explorer
    March 22, 2024

    @Pavel A. 
    Sure! I successfully achieved this with the ESP32.
    Now, I'm looking for guidance on how to accomplish the same task of writing data files into flash memory using CubeProgrammer. Are there specific steps, documents, or tutorials available for reference?

    Super User
    March 22, 2024

    Just open the CubeProgrammer. Connect to your MCU.

    Then open the data file (you can change the suffix to .bin).

    Then click on the down arrow on the right of DOWNLOAD button and enter the address on the MCU. For example 0x08001000. It should be on the boundary of the flash erase block. 

    Then click on DOWNLOAD. Watch your data file programmed on the flash...