cancel
Showing results for 
Search instead for 
Did you mean: 

stm32f7 file operations on 8GB eMMC

Tp
Associate II

Hi,

we have custom board based on stm32f7 and 8gb emmc is mounted on the board.As i see in other posts,we are also seeing CID,CSD values which results in 1gb capacity(not 8gb capacity).At the moment we don't want to execute EXTCSD and recalculate actual capacity(which is 8gb).we tried writing sample data and read the data back using HAL_MMC_Writeblocks,HAL_MMC_Readblocks.The test data of 10 bytes is written properly and able to read by HAL_MMC_Readblocks.

HAL_MMC_Writeblocks(&hmmc1,wdata,0,1,1000000) // returns HAL_OK

HAL_MMC_Readblocks(&hmmc1,rdata,0,1, 1000000) // able to see written data in rdata

a) But we want to store images in emmc with particular names.

Is it possible to do it so with write and read blocks apis alone?(with out fopen,fwrite ..etc).

b)

fwrite() is linked to HAL_MMC_Writeblocks through userdiskio.c ->emmc_writeblocks.

fopen returns FR_OK.

fwrite is invoking signal fault handler from SDMMC_WriteFIFO() function for simple 2 bytes of data.In fwrite only filepointer,writebuffer ,len,no of bytes written only supplied.is it because we are not supplying block nbr,no of blocks is chosen some random number and is resulting in signalfault ?

STM32CUBE version :1.15.0

Thanks,

P Tulasi Krishna

5 REPLIES 5
Tp
Associate II

Attached relevant screenshots

Not sure byte level interactions at the chip level is going to work. Here we layer FatFs on top, and that works quite effectively.​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Hi Clive,

Thanks for your reply. I applied the following fix and now fwrite is working .I did fclose and have done fread.the content is available.

"https://community.st.com/s/question/0D50X0000ARPK0mSQH/stm32cubemx-sdmmc-fatfs-code-is-broken-with-a-buffer-overrun-here-is-a-fix"

a)Now we have camera image as jpg being stored into USB using fwrite of FATfs for every 1 minute // done

b) Since we are able to store test data into emmc using fwrite, I hope i can implement camera image data to be stored into emmc // could be done

c) How can i copy all stored images from emmc into USB .Below is the code snippet.The idea here is to prove that images are getting stored into eMMC,i have to read them after sometime and copy to USB .Everytime It will be random number of images .

if(HAL_GPIO_ReadPin(GPIOJ,GPIO_PIN_1) == GPIO_PIN_RESET) /* gpio low .store images into emmc */

 {

  /*Store images into emmc*/

   Camera_Capture(); // could be done

 }

 else  /*Copy all images from emmc to usb drive*/

 {

   /* Infinite loop */

 while (1)

  {

 MX_USB_HOST_Process();

   switch(Appli_state)

   {

    case APPLICATION_READY:

    emmctousb_Copy();

    break;

   case APPLICATION_IDLE:

    break;

   }

 }

 }

Thanks,

P Tulasi Krishna

For a dual drive instance of FATFS you can have it scan the source directory for files and subdirectories​, check if a similar one exists on the destination, and if not create it, and then read/write the content, via a buffer, between the source and destination.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Tp
Associate II

Thank you,I have implemented it and now I am able to copy from emmc to usb.