2025-06-27 12:33 AM - last edited on 2025-06-27 1:23 AM by Andrew Neil
Hello Guys,
I’m working on a project using the STM32F767 evaluation board with STM32CubeIDE and FreeRTOS. In this project, I want to create a .csv file inside the MCU’s storage, write data to it, and then share that file over Ethernet.
So far, I have successfully configured the Ethernet communication and can transfer strings between the MCU and PC. However, when I try to create or open the .csv file, my fopen() call returns NULL, and the file is not created.
Code is attached with the post. Please help me.
Thanks.
FILE *f; //Golobal declare for file
void create(void ) //Function to create file,write
{
{
HAL_GPIO_WritePin(GPIOB, LD2_Pin, GPIO_PIN_SET);
f = fopen("trial.txt","w");
if(f == NULL)
{
printf("\nCann't open file");
HAL_GPIO_WritePin(GPIOB, LD2_Pin, GPIO_PIN_RESET);
}
else{
fprintf (f, "Hello World ");
fclose (f);
}
}
}
2025-06-27 1:22 AM - edited 2025-06-27 2:29 AM
You haven't said what filesystem you're using - FatFS? FileX? other?
Is your filesystem correctly/successfully initialising, mounting the device, etc?
As always, start from a known-good example, which just does the file stuff - no other complications (ethernet, etc).
Here's a couple of Knowledge Base articles on setting up a filesystem on STM32:
How to create a file system on a SD card using STM32CubeIDE.
How to use FileX with eMMC for file system management.
Edit: fixed 1st link.
PS:
@B_D_R wrote:using the STM32F767 evaluation board
You mean the NUCLEO-F767ZI ?
https://www.st.com/en/evaluation-tools/nucleo-f767zi.html