cancel
Showing results for 
Search instead for 
Did you mean: 

How to Inject Configuration Files into STM32 Target Using FileX?

srikanthpalvai
Associate III

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,

14 REPLIES 14
Pavel A.
Evangelist III

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

@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?

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...

 

 

@Pavel A. 
Thanks for the suggestion, followed the below steps 
1. I have used the esp32 storage bin file which is been by generated with cacert.pem and confi.ini files.
2. Download it in the stm32 under 0x8001000.
Could you please give me more guidelines on the address and size ? 

coming to the main question, In the case of esp32 here is the way to check them  How can I do this in the stm32 

Please find the screenshots :

storage bin download success.PNG

data files.PNG

srikanthpalvai_0-1711128134916.png

 

read config.png

srikanthpalvai_1-1711128489756.png

 

   

Could you please give me more guidelines on the address and size ? 

Not really. It's up to you. Unleash your creativity ))

coming to the main question, In the case of esp32 here is the way to check them  How can I do this in the stm32 

Hmm... Something like this:

 

 

 

void read_config_ini(void)
{
  const char *config = (const char*)0x08001000;
  const char *endptr = memchr(config, 0xFF, MAX_CONFIG_SIZE);
  unsigned config_size = endptr - config;
  printf("Config:\n%*s\n", config_size, config);
}

 

 

 

A simple read-only filesystem image can be also made using the tool from LwIP httpd demo :

https://lwip.fandom.com/wiki/Sample_Web_Server

(available in the Cube firmware libraries, in Middlewares/Third_Party/LwIP/src/apps/http/makefsdata )