cancel
Showing results for 
Search instead for 
Did you mean: 

I am using STM32H7 board and integrated an SD card using SPI and able to mount it in "/". I am storing a file inside the SD card.

JJoy.1
Associate III

HAL_Delay (500);

 fresult = f_mount(&fs, "/", 1);

  if (fresult != FR_OK)

   Serial_PutString ("ERROR!!! in mounting SD CARD...\n\n");

  else

  {

   Serial_PutString("\n\r SD CARD mounted successfully...\n\n");

  fresult = f_open (&fil, "zephyr_20210506_nbiot_quad_12ec59.bin", FA_READ);

 result = Ymodem_Transmit(&fil, (const uint8_t*)"zephyr_20210506_nbiot_quad_12ec59.bin", 5601949);

My requirement is to pass the start address of the file stored in SD card to the function "Ymodem_Transmit" and transfer file using Y MODEM protocol to some other microcontroller connected to STM32. I used SD card because the above mentioned file is of large size which cannot fit in internal flash of STM.

Remaining small files i am putting in flash and reading by giving the address in flash as below

result = Ymodem_Transmit((uint8_t*)APPLICATION_ADDRESS, (const uint8_t*)"sbl_7243i_v1.0_test.bin", size);

where #define APPLICATION_ADDRESS   (uint32_t)0x08100000 

Complete implementation is given in the attached code.

I am not getting the starting address of file by giving like this.

 result = Ymodem_Transmit(&fil, (const uint8_t*)"zephyr_20210506_nbiot_quad_12ec59.bin", 5601949);

Is by passing &fil will get the address of file stored in SD card?

Or otherwise what i need to get access the file in SD card.

Waiting for the reply. Please help...

Thanks,

Jestina

1 ACCEPTED SOLUTION

Accepted Solutions
Mike_ST
ST Employee

Hello

"fil" is a file descriptor, it is not an address pointing on the file's data.

You have to use "f_read" function after "f_open" to get your data.

View solution in original post

5 REPLIES 5
Mike_ST
ST Employee

Hello

"fil" is a file descriptor, it is not an address pointing on the file's data.

You have to use "f_read" function after "f_open" to get your data.

JJoy.1
Associate III

Hi,

Thanks for the answer.

#define BUFFER_SIZE 5601949

unsigned char buffer[BUFFER_SIZE]; 

fresult = f_read (&fil, buffer, f_size(&fil), &br);

My file is of size 5601949. When i compiled the code, I am getting an error like "region `RAM' overflowed by 5490600 bytes"

How can I solve the issue and store the received data?

Jestina

JJoy.1
Associate III

I need the complete data all in once.

Mike_ST
ST Employee

You're exceeding the maximum chip memory.

You cannot store all your file in the STM32 memory, unless you have external RAM.

You have to declare a smaller array and make a loop to read and transmit the file piece after piece.

JJoy.1
Associate III

OK Thank you.