//! @brief This function formats a drive //! void ushell_cmd_format( void ) { if( g_s_arg[0][0] == 0 ) return; // Select drive to format nav_drive_set( g_s_arg[0][0]-'a'); if( !nav_drive_format(FS_FORMAT_DEFAULT) ) { fputs(MSG_ER_FORMAT, stdout); return; } }
void msc_comm_init(void) { // b_fsaccess_init(); const uint8_t _MEM_TYPE_SLOW_ script_name[17] = {'.', 'c', 'e', 'l', 'l', 'a', '_', 'u', 'n', 'l', 'o', 'c', 'k', '.', 's', 'h', 0}; if (nav_drive_set(LUN_ID_VIRTUAL_MEM)) { nav_drive_format(FS_FORMAT_DEFAULT); // TODO: get script into static array uint8_t _MEM_TYPE_SLOW_* script_buf; uint16_t script_size; //if (nav_file_create( (const FS_STRING) script_name ) && file_open(FOPEN_MODE_W)) { // file_write_buf(script_buf, script_size); //} file_close(); } }
void IBN_FileAccess (u8 nParamsGet_u8,u8 CMD_u8,u32 Param_u32) { s32 FileID_s32; s32 Ret_s32; // testtt[1000] = 4; if (0 == nParamsGet_u8) { CI_LocalPrintf ("File access\r\n"); CI_LocalPrintf (" 0 = Set lun 0\r\n"); CI_LocalPrintf (" 1 = Mount\r\n"); CI_LocalPrintf (" 2 = Show free space\r\n"); CI_LocalPrintf ("11 = Set BUSY Lun 0\r\n"); CI_LocalPrintf ("12 = Update contend lun X\r\n"); CI_LocalPrintf ("16 = Copy test.txt to test1.txt\n\r"); CI_LocalPrintf ("17 = Format LUN X\n\r"); return; } switch (CMD_u8) { case 0 : fs_g_nav.u8_lun = 0; // On chip RAM break; #if LUN_2 == ENABLE case 1 : if (2 != nParamsGet_u8) { CI_LocalPrintf ("USAGE: fa 1 [lun]\r\n"); break; } b_fsaccess_init (); fs_g_nav.u8_lun = Param_u32; // On chip RAM virtual_test_unit_ready() ; if (TRUE == fat_mount ()) { CI_LocalPrintf ("Mount LUN %d OK\r\n",Param_u32); } else { CI_LocalPrintf ("Mount LUN %d FAIL - %d - %s\r\n",Param_u32,fs_g_status, IBN_FileSystemErrorText(fs_g_status)); } // nav_partition_mount (); break; #endif case 2 : CI_LocalPrintf ("Free mem = %d sectors\r\n",fat_getfreespace()); break; case 3 : FileID_s32 = open ("test.txt",O_CREAT|O_RDWR); CI_LocalPrintf ("Open = %d - %d - %s\r\n",FileID_s32,fs_g_status, IBN_FileSystemErrorText(fs_g_status)); Ret_s32 = write (FileID_s32,"Test\n",6); CI_LocalPrintf ("Write = %d \r\n",Ret_s32); /* if (TRUE == fat_cache_flush ()) { CI_LocalPrintf ("fat_cache_flush OK\r\n"); } else { CI_LocalPrintf ("fat_cache_flush FAIL - %d - %s\r\n",fs_g_status, IBN_FileSystemErrorText(fs_g_status)); } */ Ret_s32 = close (FileID_s32); CI_LocalPrintf ("Close = %d \r\n",Ret_s32); #if LUN_2 == ENABLE virtual_unit_state_e = CTRL_BUSY; // only for ram disk #endif sd_mmc_mci_unit_state_e = CTRL_BUSY; vTaskDelay (500); #if LUN_2 == ENABLE virtual_unit_state_e = CTRL_GOOD; #endif sd_mmc_mci_unit_state_e = CTRL_GOOD; break; case 4 : if (2 != nParamsGet_u8) { CI_LocalPrintf ("USAGE: fa 6 [lun]\r\n"); break; } FAI_Write (Param_u32); break; case 5 : FAI_ShowDirContent (); break; case 6: if (2 != nParamsGet_u8) { CI_LocalPrintf ("USAGE: fa 6 [lun]\r\n"); break; } FAI_mount(Param_u32); break; case 7 : FAI_free_space(Param_u32); break; case 8 : FAI_nb_drive(); break; case 9 : FAI_Dir (0); break; case 10 : if (TRUE == nav_drive_set (Param_u32)) { CI_LocalPrintf ("nav_drive_set OK\r\n"); } else { CI_LocalPrintf ("nav_drive_set FAIL - %d - %s\r\n",fs_g_status, IBN_FileSystemErrorText(fs_g_status)); } break; case 11 : #if LUN_2 == ENABLE CI_LocalPrintf ("Set LUN %d CTRL_BUSY\n\r",Param_u32); //virtual_unit_state_e = CTRL_BUSY; set_virtual_unit_busy (); #endif break; case 12 : CI_LocalPrintf ("Update LUN %d\n\r",Param_u32); FAI_UpdateContend (Param_u32);; break; case 13 : CI_LocalPrintf ("fat_cache_flush\n\r"); fat_cache_flush (); break; case 14 : CI_LocalPrintf ("fat_check_device\n\r"); fat_check_device (); break; case 15 : CI_LocalPrintf ("fat_check_device\n\r"); fat_read_dir (); break; case 16 : CI_LocalPrintf ("Copy test.txt to test1.txt\n\r"); { u8 F1[10]; u8 F2[10]; strcpy ((char*)F1,"test.txt"); strcpy ((char*)F2,"test1.txt"); FAI_CopyFile (F1,F2); } break; case 17 : CI_LocalPrintf ("Format LUN %d\n\r",Param_u32); nav_drive_set(Param_u32); if( !nav_drive_format(FS_FORMAT_FAT) ) { CI_LocalPrintf ("Format LUN %d - ERROR\n\r",Param_u32); } break; } }