Hi!
I'm trying to test the FatFS in a virtual memory disk with SAMD21 Xplained pro. I found no example on Virtual Memory ASF module but found FatFS with MMC. So I modified the example code to use the virtual memory "disk". I can't make it work, when I try to open a file for writing some text, I get a FR_NO_FILESYSTEM error.
this are the steps that I did to test the modules:
1- included the virtual memory ASF module,
2- changed the conf_access.h to use the virtual memory
#define LUN_0 ENABLE //!< On-Chip Virtual Memory. #define LUN_1 DISABLE //!< AT45DBX Data Flash. #define LUN_2 DISABLE //!< SD/MMC Card over Slot 0 #define LUN_3 DISABLE //!< Spare #define LUN_4 DISABLE //!< Spare #define LUN_5 DISABLE //!< Spare #define LUN_6 DISABLE //!< Spare #define LUN_7 DISABLE //!< Spare #define LUN_USB DISABLE //!< Host Mass-Storage Memory.
enabled access mem to ram in the conf_virtual_mem.h
#define ACCESS_MEM_TO_RAM true
the main code is f_mount, f_open, f_put.
int main(void) { char test_file_name[] = "0:test.txt"; FRESULT res; FATFS fs; FIL file_object; system_init(); delay_init(); cdc_uart_init(); delay_ms(1000); irq_initialize_vectors(); cpu_irq_enable(); printf("Mount disk (f_mount)...\r\n"); memset(&fs, 0, sizeof(FATFS)); res = f_mount(LUN_ID_VIRTUAL_MEM, &fs); printf("f_mount: [ret]-> %d \r\n", res); printf("Create a file (f_open)...\r\n"); res = f_open(&file_object,test_file_name, FA_WRITE | FA_CREATE_ALWAYS ); if (res != FR_OK) { printf("f_open: [ret]-> %d\r\n", res); } else { printf("[OK]\r\n"); printf("Write to test file (f_puts)...\r\n"); if (0 == f_puts(&file_object, "Test \n")) { f_close(&file_object); printf("[FAIL]\r\n"); } printf("[OK]\r\n"); f_close(&file_object); printf("Test is successful.\n\r"); } while(1); }
and the output is
Mount disk (f_mount)... f_mount: [ret]-> 0 Create a file (f_open)... f_open: [ret]-> 13
There is no example on Virtual Memory. I don't know if I'm missing some initialization.
I cant'f find what I'm missing.
Any toughts?
thanks,
Jorge