From c559a8a0fd8d2e883d10ae0e197cbc855209fc7e Mon Sep 17 00:00:00 2001 From: TheFloW Date: Mon, 27 Aug 2018 10:33:07 +0200 Subject: [PATCH] Fixed usb --- CMakeLists.txt | 4 +- README.md | 5 +++ main.h | 2 +- pkg/sce_sys/livearea/contents/template.xml | 2 +- resources/english_us.txt | 2 +- usb.c | 47 +++++++++++----------- 6 files changed, 33 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d8728ad..403a800 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ project(VitaShell) include("${VITASDK}/share/vita.cmake" REQUIRED) set(VITA_APP_NAME "VitaShell") set(VITA_TITLEID "VITASHELL") -set(VITA_VERSION "01.94") +set(VITA_VERSION "01.95") # Flags and includes set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O3 -Wno-unused-variable -Wno-unused-but-set-variable -Wno-format-truncation -fno-lto") @@ -205,6 +205,6 @@ add_custom_target(send ) add_custom_target(copy - COMMAND cp eboot.bin H:/app/${VITA_TITLEID}/eboot.bin + COMMAND cp eboot.bin G:/app/${VITA_TITLEID}/eboot.bin DEPENDS eboot.bin ) diff --git a/README.md b/README.md index cb9ca66..b43945d 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,12 @@ Credits Changelog --------- +### Changelog 1.95 + +- Fixed bug in USB connection, where your Memory Card could be corrupted. + ### Changelog 1.94 + - Added ability to umount all partitions that you can mount. - Fixed crash when using StorageMgr. diff --git a/main.h b/main.h index 6590384..3cfa773 100644 --- a/main.h +++ b/main.h @@ -54,7 +54,7 @@ // VitaShell version major.minor #define VITASHELL_VERSION_MAJOR 0x01 -#define VITASHELL_VERSION_MINOR 0x94 +#define VITASHELL_VERSION_MINOR 0x95 #define VITASHELL_VERSION ((VITASHELL_VERSION_MAJOR << 0x18) | (VITASHELL_VERSION_MINOR << 0x10)) diff --git a/pkg/sce_sys/livearea/contents/template.xml b/pkg/sce_sys/livearea/contents/template.xml index 50f8e18..553ad00 100644 --- a/pkg/sce_sys/livearea/contents/template.xml +++ b/pkg/sce_sys/livearea/contents/template.xml @@ -28,7 +28,7 @@ - v1.94 + v1.95 diff --git a/resources/english_us.txt b/resources/english_us.txt index a70f5d5..9358a61 100644 --- a/resources/english_us.txt +++ b/resources/english_us.txt @@ -207,7 +207,7 @@ PLEASE_WAIT = "Please wait..." MEMORY_CARD_NOT_FOUND = "Please insert a Memory Card." GAME_CARD_NOT_FOUND = "Please insert a Game Card." MICROSD_NOT_FOUND = "Please insert a microSD." -NO_SPACE_ERROR = "There is not enough free space on the memory\card.\At least %s more space is needed." +NO_SPACE_ERROR = "There is not enough free space on the Memory\Card.\At least %s more space is needed." EXTENDED_PERMISSIONS_REQUIRED = "This feature requires extended permissions.\Please activate 'Enable unsafe homebrew' first." WIFI_ERROR = "You must use Wi-Fi to do this." FTP_SERVER = "FTP server is now running at\ftp://%s:%i\\Select 'OK' to keep it in background.\Select 'Cancel' to disconnect." diff --git a/usb.c b/usb.c index e22a787..e40f5bd 100644 --- a/usb.c +++ b/usb.c @@ -135,7 +135,6 @@ int umountUsbUx0() { int remount_uma0 = 0, remount_xmc0 = 0, remount_imc0 = 0, remount_ux0 = 0; void remount_partitions() { - // Remount partitions if (remount_ux0) vshIoMount(0x800, NULL, 0, 0, 0, 0); if (remount_imc0) @@ -154,6 +153,28 @@ SceUID startUsb(const char *usbDevicePath, const char *imgFilePath, int type) { // Destroy other apps sceAppMgrDestroyOtherApp(); + // Load and start usbdevice module + res = taiLoadStartKernelModule(usbDevicePath, 0, NULL, 0); + if (res < 0) + goto ERROR_LOAD_MODULE; + + modid = res; + + // Stop MTP driver + res = sceMtpIfStopDriver(1); + if (res < 0) + goto ERROR_STOP_DRIVER; + + // Set device information + res = sceUsbstorVStorSetDeviceInfo("\"PS Vita\" MC", "1.00"); + if (res < 0) + goto ERROR_USBSTOR_VSTOR; + + // Set image file path + res = sceUsbstorVStorSetImgFilePath(imgFilePath); + if (res < 0) + goto ERROR_USBSTOR_VSTOR; + // Umount all partitions remount_uma0 = remount_xmc0 = remount_imc0 = remount_ux0 = 0; if (checkFolderExist("uma0:")) { @@ -173,28 +194,6 @@ SceUID startUsb(const char *usbDevicePath, const char *imgFilePath, int type) { remount_ux0 = 1; } - // Load and start usbdevice module - res = taiLoadStartKernelModule(usbDevicePath, 0, NULL, 0); - if (res < 0) - goto ERROR_LOAD_MODULE; - - modid = res; - - // Stop MTP driver - res = sceMtpIfStopDriver(1); - if (res < 0 && res != 0x8054360C) - goto ERROR_STOP_DRIVER; - - // Set device information - res = sceUsbstorVStorSetDeviceInfo("\"PS Vita\" MC", "1.00"); - if (res < 0) - goto ERROR_USBSTOR_VSTOR; - - // Set image file path - res = sceUsbstorVStorSetImgFilePath(imgFilePath); - if (res < 0) - goto ERROR_USBSTOR_VSTOR; - // Start USB storage res = sceUsbstorVStorStart(type); if (res < 0) @@ -203,13 +202,13 @@ SceUID startUsb(const char *usbDevicePath, const char *imgFilePath, int type) { return modid; ERROR_USBSTOR_VSTOR: + remount_partitions(); sceMtpIfStartDriver(1); ERROR_STOP_DRIVER: taiStopUnloadKernelModule(modid, 0, NULL, 0, NULL, NULL); ERROR_LOAD_MODULE: - remount_partitions(); return res; }