cancel
Showing results for 
Search instead for 
Did you mean: 

how to acess internal flash as mass storage device

vs.3
Associate II

i tried but it asking formate the device in my computer.

i am using #Stm32f103ret6​  #USB​  #Mass-storage​ 

13 REPLIES 13

in read and write functions what i need to write to formate my device [total 256 pages,each page 2k 512kb= flash memory]

i am using page 6 so i am formating page6 is it enough to formate myy device or completly formate my device memory

init_fs()

{

 EraseInitStruct.TypeErase = FLASH_TYPEERASE_PAGES;

  EraseInitStruct.Banks =FLASH_BASE;

  EraseInitStruct.PageAddress=FLASH_USER_START_ADDR; // page 6 i am using to read/write

  EraseInitStruct.NbPages = 1;

}

in write functuon

int8_t STORAGE_Write_FS (uint8_t lun, uint8_t *buf,  uint32_t blk_addr, uint16_t blk_len) //(blk_addr=0, blk_len=0)

   {

 HAL_FLASH_Unlock();

 HAL_FLASHEx_Erase(&EraseInitStruct, &pageError);

HAL_FLASH_Lock()

};

I think You need to go right back to basics and understand how the flash is organised in the processor and how to read and write to it and how you would implement a driver for it.

you will only be able to use the FAT12 storage because of the limited about of space available, but you need to write the driver fully before you continue any further.

That's not writing any data to the block number blk_addr, also seriously doubt blk_len = 0

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

in read /write operation  blk_addr, blk_len alway it shows zero value.