Support for NYX to load from BOOT1/GPP/SD in that order, UMS option to mount whatever volume is selected as boot storage
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <storage/boot_storage.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "ianos.h"
|
||||
@@ -75,7 +76,7 @@ uintptr_t ianos_loader(char *path, elfType_t type, void *moduleConfig)
|
||||
uintptr_t epaddr = 0;
|
||||
|
||||
// Read library.
|
||||
fileBuf = sd_file_read(path, NULL);
|
||||
fileBuf = boot_storage_file_read(path, NULL);
|
||||
|
||||
if (!fileBuf)
|
||||
goto out;
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include <storage/sd.h>
|
||||
#include <storage/emmc.h>
|
||||
#include <utils/types.h>
|
||||
#include <gfx_utils.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define DEV_INVALID 0xff
|
||||
|
||||
@@ -11,10 +13,10 @@ static FATFS boot_storage_fs;
|
||||
static BYTE drive = -1;
|
||||
|
||||
static const char* drive_base_paths[] = {
|
||||
[DRIVE_SD] = XSTR(DRIVE_SD) ":",
|
||||
[DRIVE_BOOT1] = XSTR(DRIVE_BOOT1) ":",
|
||||
[DRIVE_BOOT1_1MB] = XSTR(DRIVE_BOOT1_1MB) ":",
|
||||
[DRIVE_EMMC] = XSTR(DRIVE_EMMC) ":",
|
||||
[DRIVE_SD] = "sd:",
|
||||
[DRIVE_BOOT1] = "boot1_:",
|
||||
[DRIVE_BOOT1_1MB] = "boot1_1mb:",
|
||||
[DRIVE_EMMC] = "emmc:",
|
||||
};
|
||||
|
||||
static bool _is_eligible(){
|
||||
@@ -78,6 +80,10 @@ void boot_storage_end(){
|
||||
_boot_storage_end(true);
|
||||
}
|
||||
|
||||
u8 boot_storage_get_drive(){
|
||||
return drive;
|
||||
}
|
||||
|
||||
static bool _boot_storage_mount(){
|
||||
// may want to check sd card first and prioritize it
|
||||
|
||||
@@ -90,14 +96,17 @@ static bool _boot_storage_mount(){
|
||||
static const BYTE emmc_drives[] = {DRIVE_BOOT1_1MB, DRIVE_BOOT1, DRIVE_EMMC};
|
||||
|
||||
for(BYTE i = 0; i < ARRAY_SIZE(emmc_drives); i++){
|
||||
res = f_mount(&boot_storage_fs, drive_base_paths[i], true);
|
||||
res = f_mount(&boot_storage_fs, drive_base_paths[emmc_drives[i]], true);
|
||||
if(res == FR_OK){
|
||||
gfx_printf("trying %s\n", drive_base_paths[emmc_drives[i]]);
|
||||
res = f_chdrive(drive_base_paths[i]);
|
||||
if(res == FR_OK && _is_eligible()){
|
||||
drive = i;
|
||||
gfx_printf("%s ok\n", drive_base_paths[emmc_drives[i]]);
|
||||
drive = emmc_drives[i];
|
||||
break;
|
||||
}else{
|
||||
f_mount(NULL, drive_base_paths[i],false);
|
||||
gfx_printf("%s fail\n", drive_base_paths[emmc_drives[i]]);
|
||||
f_mount(NULL, drive_base_paths[emmc_drives[i]],false);
|
||||
res = FR_INVALID_DRIVE;
|
||||
}
|
||||
}
|
||||
@@ -112,11 +121,14 @@ static bool _boot_storage_mount(){
|
||||
}
|
||||
|
||||
emmc_init_fail:
|
||||
gfx_printf("trying %s\n", drive_base_paths[DRIVE_SD]);
|
||||
if(!sd_initialize(false)){
|
||||
gfx_printf("%s fail\n", drive_base_paths[DRIVE_SD]);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if(!sd_mount()){
|
||||
gfx_printf("%s fail\n", drive_base_paths[DRIVE_SD]);
|
||||
sd_end();
|
||||
goto out;
|
||||
}
|
||||
@@ -124,6 +136,7 @@ emmc_init_fail:
|
||||
res = f_chdrive(drive_base_paths[DRIVE_SD]);
|
||||
|
||||
if(res == FR_OK && _is_eligible()){
|
||||
gfx_printf("%s ok\n", drive_base_paths[DRIVE_SD]);
|
||||
drive = DRIVE_SD;
|
||||
return true;
|
||||
}
|
||||
@@ -137,18 +150,65 @@ out:
|
||||
bool boot_storage_mount(){
|
||||
bool mounted = boot_storage_get_mounted();
|
||||
bool initialized = boot_storage_get_initialized();
|
||||
if(mounted && initialized){
|
||||
return true;
|
||||
}
|
||||
|
||||
bool res = mounted && initialized;
|
||||
if(!mounted){
|
||||
// not mounted. mounting will also initialize.
|
||||
return _boot_storage_mount();
|
||||
res = _boot_storage_mount();
|
||||
}else if(!initialized){
|
||||
res = _boot_storage_initialize();
|
||||
}
|
||||
|
||||
if(!initialized){
|
||||
return _boot_storage_initialize();
|
||||
if(res){
|
||||
res = f_chdrive(drive_base_paths[drive]) == FR_OK;
|
||||
}
|
||||
|
||||
return true;
|
||||
return res;
|
||||
}
|
||||
|
||||
void *boot_storage_file_read(const char *path, u32 *fsize)
|
||||
{
|
||||
FIL fp;
|
||||
if (!boot_storage_get_mounted())
|
||||
return NULL;
|
||||
|
||||
if (f_open(&fp, path, FA_READ) != FR_OK)
|
||||
return NULL;
|
||||
|
||||
u32 size = f_size(&fp);
|
||||
if (fsize)
|
||||
*fsize = size;
|
||||
|
||||
void *buf = malloc(size);
|
||||
|
||||
if (f_read(&fp, buf, size, NULL) != FR_OK)
|
||||
{
|
||||
free(buf);
|
||||
f_close(&fp);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
f_close(&fp);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
int boot_storage_save_to_file(const void *buf, u32 size, const char *filename)
|
||||
{
|
||||
FIL fp;
|
||||
u32 res = 0;
|
||||
if (!boot_storage_get_mounted())
|
||||
return FR_DISK_ERR;
|
||||
|
||||
res = f_open(&fp, filename, FA_CREATE_ALWAYS | FA_WRITE);
|
||||
if (res)
|
||||
{
|
||||
EPRINTFARGS("Error (%d) creating file\n%s.\n", res, filename);
|
||||
return res;
|
||||
}
|
||||
|
||||
f_write(&fp, buf, size, NULL);
|
||||
f_close(&fp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -13,4 +13,9 @@ void boot_storage_end();
|
||||
bool boot_storage_get_mounted();
|
||||
bool boot_storage_get_initialized();
|
||||
|
||||
void *boot_storage_file_read(const char *path, u32 *fsize);
|
||||
int boot_storage_save_to_file(const void *buf, u32 size, const char *filename);
|
||||
|
||||
u8 boot_storage_get_drive();
|
||||
|
||||
#endif
|
||||
@@ -199,7 +199,7 @@ bool sd_mount()
|
||||
else
|
||||
{
|
||||
if (!sd_mounted)
|
||||
res = f_mount(&sd_fs, XSTR(FF_DEV_SD) ":", 1); // Volume 0 is SD.
|
||||
res = f_mount(&sd_fs, "sd:", 1); // Volume 0 is SD.
|
||||
if (res == FR_OK)
|
||||
{
|
||||
sd_mounted = true;
|
||||
@@ -227,7 +227,7 @@ static void _sd_deinit(bool deinit)
|
||||
if (sd_init_done)
|
||||
{
|
||||
if (sd_mounted)
|
||||
f_mount(NULL, XSTR(FF_DEV_SD) ":", 1); // Volume 0 is SD.
|
||||
f_mount(NULL, "sd:", 1); // Volume 0 is SD.
|
||||
|
||||
if (deinit)
|
||||
{
|
||||
@@ -246,14 +246,30 @@ bool sd_is_gpt()
|
||||
return sd_fs.part_type;
|
||||
}
|
||||
|
||||
|
||||
void *sd_file_read(const char *path, u32 *fsize)
|
||||
{
|
||||
FIL fp;
|
||||
if (!sd_get_card_mounted())
|
||||
return NULL;
|
||||
|
||||
if (f_open(&fp, path, FA_READ) != FR_OK)
|
||||
char *cwd = (char*)malloc(0x200);
|
||||
|
||||
if(f_getcwd(cwd, 0x200) != FR_OK){
|
||||
free(cwd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(f_chdrive("sd:") != FR_OK){
|
||||
free(cwd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (f_open(&fp, path, FA_READ) != FR_OK){
|
||||
f_chdrive(cwd);
|
||||
free(cwd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
u32 size = f_size(&fp);
|
||||
if (fsize)
|
||||
@@ -263,13 +279,17 @@ void *sd_file_read(const char *path, u32 *fsize)
|
||||
|
||||
if (f_read(&fp, buf, size, NULL) != FR_OK)
|
||||
{
|
||||
f_chdrive(cwd);
|
||||
free(buf);
|
||||
free(cwd);
|
||||
f_close(&fp);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
f_chdrive(cwd);
|
||||
f_close(&fp);
|
||||
free(cwd);
|
||||
|
||||
return buf;
|
||||
}
|
||||
@@ -281,13 +301,33 @@ int sd_save_to_file(const void *buf, u32 size, const char *filename)
|
||||
if (!sd_get_card_mounted())
|
||||
return FR_DISK_ERR;
|
||||
|
||||
char *cwd = malloc(0x200);
|
||||
|
||||
res = f_getcwd(cwd, 0x200);
|
||||
|
||||
if(res != FR_OK){
|
||||
free(cwd);
|
||||
return res;
|
||||
}
|
||||
|
||||
res = f_chdrive("sd:");
|
||||
|
||||
if(res != FR_OK){
|
||||
free(cwd);
|
||||
return res;
|
||||
}
|
||||
|
||||
res = f_open(&fp, filename, FA_CREATE_ALWAYS | FA_WRITE);
|
||||
if (res)
|
||||
{
|
||||
EPRINTFARGS("Error (%d) creating file\n%s.\n", res, filename);
|
||||
f_chdrive(cwd);
|
||||
free(cwd);
|
||||
return res;
|
||||
}
|
||||
|
||||
f_chdrive(cwd);
|
||||
free(cwd);
|
||||
f_write(&fp, buf, size, NULL);
|
||||
f_close(&fp);
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <storage/boot_storage.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <mem/heap.h>
|
||||
@@ -258,6 +259,7 @@ void power_set_state(power_state_t state)
|
||||
u8 reg;
|
||||
|
||||
// Unmount and power down sd card.
|
||||
boot_storage_end();
|
||||
sd_end();
|
||||
|
||||
// De-initialize and power down various hardware.
|
||||
|
||||
@@ -236,7 +236,7 @@ void print_sdcard_info()
|
||||
if (sd_mount())
|
||||
{
|
||||
gfx_puts("Acquiring FAT volume info...\n\n");
|
||||
f_getfree(XSTR(FF_DEV_SD) ":", &sd_fs.free_clst, NULL);
|
||||
f_getfree("sd:", &sd_fs.free_clst, NULL);
|
||||
gfx_printf("%kFound %s volume:%k\n Free: %d MiB\n Cluster: %d KiB\n",
|
||||
TXT_CLR_CYAN_L, sd_fs.fs_type == FS_EXFAT ? "exFAT" : "FAT32", TXT_CLR_DEFAULT,
|
||||
sd_fs.free_clst * sd_fs.csize >> SECTORS_TO_MIB_COEFF, (sd_fs.csize > 1) ? (sd_fs.csize >> 1) : 512);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <storage/boot_storage.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <bdk.h>
|
||||
@@ -84,7 +85,7 @@ typedef struct _fss_content_t
|
||||
|
||||
static void _fss_update_r2p()
|
||||
{
|
||||
u8 *r2p_payload = sd_file_read("atmosphere/reboot_payload.bin", NULL);
|
||||
u8 *r2p_payload = boot_storage_file_read("atmosphere/reboot_payload.bin", NULL);
|
||||
|
||||
is_ipl_updated(r2p_payload, "atmosphere/reboot_payload.bin", h_cfg.updater2p ? true : false);
|
||||
|
||||
|
||||
@@ -410,7 +410,7 @@ int hos_keygen(void *keyblob, u32 kb, tsec_ctxt_t *tsec_ctxt, bool stock, bool i
|
||||
*/
|
||||
|
||||
// Use custom TSEC Hovi Keygen firmware.
|
||||
tsec_ctxt->fw = sd_file_read("bootloader/sys/thk.bin", NULL);
|
||||
tsec_ctxt->fw = boot_storage_file_read("bootloader/sys/thk.bin", NULL);
|
||||
if (!tsec_ctxt->fw)
|
||||
{
|
||||
_hos_crit_error("\nFailed to load thk.bin");
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <storage/boot_storage.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <bdk.h>
|
||||
@@ -29,7 +30,7 @@
|
||||
|
||||
static int _config_warmboot(launch_ctxt_t *ctxt, const char *value)
|
||||
{
|
||||
ctxt->warmboot = sd_file_read(value, &ctxt->warmboot_size);
|
||||
ctxt->warmboot = boot_storage_file_read(value, &ctxt->warmboot_size);
|
||||
if (!ctxt->warmboot)
|
||||
return 0;
|
||||
|
||||
@@ -38,7 +39,7 @@ static int _config_warmboot(launch_ctxt_t *ctxt, const char *value)
|
||||
|
||||
static int _config_secmon(launch_ctxt_t *ctxt, const char *value)
|
||||
{
|
||||
ctxt->secmon = sd_file_read(value, &ctxt->secmon_size);
|
||||
ctxt->secmon = boot_storage_file_read(value, &ctxt->secmon_size);
|
||||
if (!ctxt->secmon)
|
||||
return 0;
|
||||
|
||||
@@ -47,7 +48,7 @@ static int _config_secmon(launch_ctxt_t *ctxt, const char *value)
|
||||
|
||||
static int _config_kernel(launch_ctxt_t *ctxt, const char *value)
|
||||
{
|
||||
ctxt->kernel = sd_file_read(value, &ctxt->kernel_size);
|
||||
ctxt->kernel = boot_storage_file_read(value, &ctxt->kernel_size);
|
||||
if (!ctxt->kernel)
|
||||
return 0;
|
||||
|
||||
@@ -81,7 +82,7 @@ static int _config_kip1(launch_ctxt_t *ctxt, const char *value)
|
||||
strcpy(dir + dirlen, filelist->name[i]);
|
||||
|
||||
merge_kip_t *mkip1 = (merge_kip_t *)malloc(sizeof(merge_kip_t));
|
||||
mkip1->kip1 = sd_file_read(dir, &size);
|
||||
mkip1->kip1 = boot_storage_file_read(dir, &size);
|
||||
if (!mkip1->kip1)
|
||||
{
|
||||
free(mkip1);
|
||||
@@ -103,7 +104,7 @@ static int _config_kip1(launch_ctxt_t *ctxt, const char *value)
|
||||
else
|
||||
{
|
||||
merge_kip_t *mkip1 = (merge_kip_t *)malloc(sizeof(merge_kip_t));
|
||||
mkip1->kip1 = sd_file_read(value, &size);
|
||||
mkip1->kip1 = boot_storage_file_read(value, &size);
|
||||
if (!mkip1->kip1)
|
||||
{
|
||||
free(mkip1);
|
||||
@@ -265,7 +266,7 @@ static int _config_fss(launch_ctxt_t *ctxt, const char *value)
|
||||
|
||||
static int _config_exo_fatal_payload(launch_ctxt_t *ctxt, const char *value)
|
||||
{
|
||||
ctxt->exofatal = sd_file_read(value, &ctxt->exofatal_size);
|
||||
ctxt->exofatal = boot_storage_file_read(value, &ctxt->exofatal_size);
|
||||
if (!ctxt->exofatal)
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <storage/boot_storage.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -387,7 +388,7 @@ int pkg1_warmboot_config(void *hos_ctxt, u32 warmboot_base, u32 fuses_fw, u8 kb)
|
||||
_warmboot_filename(path, burnt_fuses);
|
||||
if (!f_stat(path, NULL))
|
||||
{
|
||||
ctxt->warmboot = sd_file_read(path, &ctxt->warmboot_size);
|
||||
ctxt->warmboot = boot_storage_file_read(path, &ctxt->warmboot_size);
|
||||
burnt_fuses = tmp_fuses;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <storage/boot_storage.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <bdk.h>
|
||||
@@ -382,7 +383,7 @@ static int _kipm_inject(const char *kipm_path, char *target_name, pkg2_kip1_info
|
||||
if (!strcmp((char *)ki->kip1->name, target_name))
|
||||
{
|
||||
u32 size = 0;
|
||||
u8 *kipm_data = (u8 *)sd_file_read(kipm_path, &size);
|
||||
u8 *kipm_data = (u8 *)boot_storage_file_read(kipm_path, &size);
|
||||
if (!kipm_data)
|
||||
return 1;
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@
|
||||
*/
|
||||
|
||||
|
||||
#define FF_FS_RPATH 1
|
||||
#define FF_FS_RPATH 2
|
||||
/* This option configures support for relative path.
|
||||
/
|
||||
/ 0: Disable relative path and remove related functions.
|
||||
@@ -183,8 +183,8 @@
|
||||
/* Number of volumes (logical drives) to be used. (1-10) */
|
||||
|
||||
|
||||
#define FF_STR_VOLUME_ID 0
|
||||
#define FF_VOLUME_STRS "sd", "boot1", "boot1_1mb", "gpp"
|
||||
#define FF_STR_VOLUME_ID 1
|
||||
#define FF_VOLUME_STRS "sd", "boot1", "boot1_1mb", "emmc"
|
||||
/* FF_STR_VOLUME_ID switches support for volume ID in arbitrary strings.
|
||||
/ When FF_STR_VOLUME_ID is set to 1 or 2, arbitrary strings can be used as drive
|
||||
/ number in the path name. FF_VOLUME_STRS defines the volume ID strings for each
|
||||
|
||||
@@ -612,7 +612,7 @@ out:
|
||||
|
||||
static void _nyx_load_run()
|
||||
{
|
||||
u8 *nyx = sd_file_read("bootloader/sys/nyx.bin", NULL);
|
||||
u8 *nyx = boot_storage_file_read("bootloader/sys/nyx.bin", NULL);
|
||||
if (!nyx)
|
||||
return;
|
||||
|
||||
@@ -914,11 +914,11 @@ skip_list:
|
||||
|
||||
// Check if user set custom logo path at the boot entry.
|
||||
if (bootlogoCustomEntry)
|
||||
bitmap = (u8 *)sd_file_read(bootlogoCustomEntry, &fsize);
|
||||
bitmap = (u8 *)boot_storage_file_read(bootlogoCustomEntry, &fsize);
|
||||
|
||||
// Custom entry bootlogo not found, trying default custom one.
|
||||
if (!bitmap)
|
||||
bitmap = (u8 *)sd_file_read("bootloader/bootlogo.bmp", &fsize);
|
||||
bitmap = (u8 *)boot_storage_file_read("bootloader/bootlogo.bmp", &fsize);
|
||||
|
||||
if (bitmap)
|
||||
{
|
||||
|
||||
@@ -23,8 +23,6 @@
|
||||
#include "../config.h"
|
||||
#include <libs/fatfs/ff.h>
|
||||
|
||||
#define DEV_SD_BASE_PATH XSTR(FF_DEV_SD) ":"
|
||||
|
||||
extern hekate_config h_cfg;
|
||||
emummc_cfg_t emu_cfg = { 0 };
|
||||
|
||||
@@ -79,7 +77,8 @@ bool emummc_set_path(char *path)
|
||||
FIL fp;
|
||||
bool found = false;
|
||||
|
||||
strcpy(emu_cfg.emummc_file_based_path, DEV_SD_BASE_PATH);
|
||||
// strcpy(emu_cfg.emummc_file_based_path, "sd:");
|
||||
strcpy(emu_cfg.emummc_file_based_path, "");
|
||||
strcat(emu_cfg.emummc_file_based_path, path);
|
||||
strcat(emu_cfg.emummc_file_based_path, "/raw_based");
|
||||
|
||||
@@ -91,7 +90,8 @@ bool emummc_set_path(char *path)
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(emu_cfg.emummc_file_based_path, DEV_SD_BASE_PATH);
|
||||
// strcpy(emu_cfg.emummc_file_based_path, "sd:");
|
||||
strcpy(emu_cfg.emummc_file_based_path, "");
|
||||
strcat(emu_cfg.emummc_file_based_path, path);
|
||||
strcat(emu_cfg.emummc_file_based_path, "/file_based");
|
||||
|
||||
@@ -153,7 +153,7 @@ int emummc_storage_init_mmc()
|
||||
|
||||
if (!emu_cfg.sector)
|
||||
{
|
||||
strcpy(emu_cfg.emummc_file_based_path, DEV_SD_BASE_PATH);
|
||||
strcpy(emu_cfg.emummc_file_based_path, "sd:");
|
||||
strcat(emu_cfg.emummc_file_based_path, emu_cfg.path);
|
||||
strcat(emu_cfg.emummc_file_based_path, "/eMMC");
|
||||
|
||||
@@ -275,6 +275,8 @@ int emummc_storage_write(u32 sector, u32 num_sectors, void *buf)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// TODO: active partition may be changed by boot storage access
|
||||
int emummc_storage_set_mmc_partition(u32 partition)
|
||||
{
|
||||
emu_cfg.active_part = partition;
|
||||
@@ -284,7 +286,7 @@ int emummc_storage_set_mmc_partition(u32 partition)
|
||||
return 1;
|
||||
else
|
||||
{
|
||||
strcpy(emu_cfg.emummc_file_based_path, DEV_SD_BASE_PATH);
|
||||
strcpy(emu_cfg.emummc_file_based_path, "sd:");
|
||||
strcat(emu_cfg.emummc_file_based_path, emu_cfg.path);
|
||||
strcat(emu_cfg.emummc_file_based_path, "/eMMC");
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ OBJS += $(addprefix $(BUILDDIR)/$(TARGET)/, \
|
||||
bm92t36.o bq24193.o max17050.o max7762x.o max77620-rtc.o regulator_5v.o \
|
||||
touch.o joycon.o tmp451.o fan.o \
|
||||
usbd.o xusbd.o usb_descriptors.o usb_gadget_ums.o usb_gadget_hid.o \
|
||||
hw_init.o \
|
||||
hw_init.o boot_storage.o \
|
||||
)
|
||||
|
||||
# Utilities.
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "config.h"
|
||||
#include <libs/fatfs/ff.h>
|
||||
#include <storage/boot_storage.h>
|
||||
|
||||
extern hekate_config h_cfg;
|
||||
extern nyx_config n_cfg;
|
||||
@@ -187,9 +188,9 @@ int create_config_entry()
|
||||
|
||||
int create_nyx_config_entry(bool force_unmount)
|
||||
{
|
||||
bool sd_mounted = sd_get_card_mounted();
|
||||
bool sd_mounted = boot_storage_get_mounted();
|
||||
|
||||
if (!sd_mount())
|
||||
if (!boot_storage_mount())
|
||||
return 1;
|
||||
|
||||
char lbuf[64];
|
||||
@@ -247,7 +248,7 @@ int create_nyx_config_entry(bool force_unmount)
|
||||
f_close(&fp);
|
||||
|
||||
if (force_unmount || !sd_mounted)
|
||||
sd_unmount();
|
||||
boot_storage_unmount();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
//! fix the dram stuff and the pop ups
|
||||
|
||||
#include <storage/boot_storage.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -932,11 +933,11 @@ out:
|
||||
free(txt_buf);
|
||||
free(gui->base_path);
|
||||
if (!partial_sd_full_unmount)
|
||||
sd_unmount();
|
||||
boot_storage_unmount();
|
||||
else
|
||||
{
|
||||
partial_sd_full_unmount = false;
|
||||
sd_end();
|
||||
boot_storage_end();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
//! fix the dram stuff and the pop ups
|
||||
|
||||
#include <storage/boot_storage.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -78,7 +79,7 @@ void load_emummc_cfg(emummc_cfg_t *emu_info)
|
||||
|
||||
void save_emummc_cfg(u32 part_idx, u32 sector_start, const char *path)
|
||||
{
|
||||
sd_mount();
|
||||
boot_storage_mount();
|
||||
|
||||
char lbuf[16];
|
||||
FIL fp;
|
||||
@@ -381,7 +382,7 @@ void dump_emummc_file(emmc_tool_gui_t *gui)
|
||||
manual_system_maintenance(true);
|
||||
|
||||
// Get SD Card free space for file based emuMMC.
|
||||
f_getfree("", &sd_fs.free_clst, NULL);
|
||||
f_getfree("sd:", &sd_fs.free_clst, NULL);
|
||||
|
||||
if (!emmc_initialize(false))
|
||||
{
|
||||
@@ -392,8 +393,8 @@ void dump_emummc_file(emmc_tool_gui_t *gui)
|
||||
int i = 0;
|
||||
char sdPath[OUT_FILENAME_SZ];
|
||||
// Create Restore folders, if they do not exist.
|
||||
f_mkdir("emuMMC");
|
||||
strcpy(sdPath, "emuMMC/SD");
|
||||
f_mkdir("sd:emuMMC");
|
||||
strcpy(sdPath, "sd:emuMMC/SD");
|
||||
base_len = strlen(sdPath);
|
||||
|
||||
for (int j = 0; j < 100; j++)
|
||||
@@ -854,6 +855,9 @@ void dump_emummc_raw(emmc_tool_gui_t *gui, int part_idx, u32 sector_start, u32 r
|
||||
|
||||
manual_system_maintenance(true);
|
||||
|
||||
// TODO: check result of boot storage mount
|
||||
boot_storage_mount();
|
||||
|
||||
if (!sd_mount())
|
||||
{
|
||||
lv_label_set_text(gui->label_info, "#FFDD00 Failed to init SD!#");
|
||||
@@ -877,8 +881,8 @@ void dump_emummc_raw(emmc_tool_gui_t *gui, int part_idx, u32 sector_start, u32 r
|
||||
int i = 0;
|
||||
char sdPath[OUT_FILENAME_SZ];
|
||||
// Create Restore folders, if they do not exist.
|
||||
f_mkdir("emuMMC");
|
||||
s_printf(sdPath, "emuMMC/RAW%d", part_idx);
|
||||
f_mkdir("sd:emuMMC");
|
||||
s_printf(sdPath, "sd:emuMMC/RAW%d", part_idx);
|
||||
f_mkdir(sdPath);
|
||||
strcat(sdPath, "/");
|
||||
strcpy(gui->base_path, sdPath);
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
#include "../config.h"
|
||||
#include <libs/fatfs/ff.h>
|
||||
#include <storage/boot_storage.h>
|
||||
|
||||
extern hekate_config h_cfg;
|
||||
extern nyx_config n_cfg;
|
||||
@@ -187,7 +188,7 @@ static void _save_log_to_bmp(char *fname)
|
||||
char path[0x80];
|
||||
strcpy(path, "bootloader/screenshots");
|
||||
s_printf(path + strlen(path), "/nyx%s_log.bmp", fname);
|
||||
sd_save_to_file(bitmap, file_size, path);
|
||||
boot_storage_save_to_file(bitmap, file_size, path);
|
||||
|
||||
free(bitmap);
|
||||
free(fb);
|
||||
@@ -271,7 +272,7 @@ static void _save_fb_to_bmp()
|
||||
bmp->res_v = 2834;
|
||||
bmp->rsvd2 = 0;
|
||||
|
||||
sd_mount();
|
||||
boot_storage_mount();
|
||||
|
||||
char path[0x80];
|
||||
|
||||
@@ -288,7 +289,7 @@ static void _save_fb_to_bmp()
|
||||
s_printf(path + strlen(path), "/nyx%s.bmp", fname);
|
||||
|
||||
// Save screenshot and log.
|
||||
int res = sd_save_to_file(bitmap, file_size, path);
|
||||
int res = boot_storage_save_to_file(bitmap, file_size, path);
|
||||
if (!res)
|
||||
_save_log_to_bmp(fname);
|
||||
|
||||
@@ -651,7 +652,7 @@ void manual_system_maintenance(bool refresh)
|
||||
lv_img_dsc_t *bmp_to_lvimg_obj(const char *path)
|
||||
{
|
||||
u32 fsize;
|
||||
u8 *bitmap = sd_file_read(path, &fsize);
|
||||
u8 *bitmap = boot_storage_file_read(path, &fsize);
|
||||
if (!bitmap)
|
||||
return NULL;
|
||||
|
||||
@@ -1387,8 +1388,9 @@ static lv_res_t _create_mbox_payloads(lv_obj_t *btn)
|
||||
lv_obj_set_size(list, LV_HOR_RES * 3 / 7, LV_VER_RES * 3 / 7);
|
||||
lv_list_set_single_mode(list, true);
|
||||
|
||||
if (!sd_mount())
|
||||
if (!boot_storage_mount())
|
||||
{
|
||||
// TODO: may not be SD, change error
|
||||
lv_mbox_set_text(mbox, "#FFDD00 Failed to init SD!#");
|
||||
|
||||
goto out_end;
|
||||
@@ -1699,7 +1701,7 @@ static lv_res_t _create_window_home_launch(lv_obj_t *btn)
|
||||
u32 curr_btn_idx = 0; // Active buttons.
|
||||
LIST_INIT(ini_sections);
|
||||
|
||||
if (!sd_mount())
|
||||
if (!boot_storage_mount())
|
||||
goto failed_sd_mount;
|
||||
|
||||
// Check if we use custom system icons.
|
||||
@@ -1895,7 +1897,7 @@ failed_sd_mount:
|
||||
if (curr_btn_idx < 1)
|
||||
no_boot_entries = true;
|
||||
|
||||
sd_unmount();
|
||||
boot_storage_unmount();
|
||||
|
||||
free(tmp_path);
|
||||
|
||||
@@ -2058,7 +2060,7 @@ static lv_res_t _save_options_action(lv_obj_t *btn)
|
||||
|
||||
int res = 0;
|
||||
|
||||
if (sd_mount())
|
||||
if (boot_storage_mount())
|
||||
res = !create_config_entry();
|
||||
|
||||
if (res)
|
||||
@@ -2070,7 +2072,7 @@ static lv_res_t _save_options_action(lv_obj_t *btn)
|
||||
|
||||
nyx_options_clear_ini_changes_made();
|
||||
|
||||
sd_unmount();
|
||||
boot_storage_unmount();
|
||||
|
||||
return LV_RES_OK;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#include "fe_emummc_tools.h"
|
||||
#include "gui_tools_partition_manager.h"
|
||||
#include <libs/fatfs/ff.h>
|
||||
#include <storage/boot_storage.h>
|
||||
#include <storage/sd.h>
|
||||
|
||||
extern char *emmcsn_path_impl(char *path, char *sub_dir, char *filename, sdmmc_storage_t *storage);
|
||||
|
||||
@@ -407,7 +409,7 @@ static void _migrate_sd_raw_based()
|
||||
{
|
||||
mbr_ctx.sector_start = 2;
|
||||
|
||||
sd_mount();
|
||||
boot_storage_mount();
|
||||
f_mkdir("emuMMC");
|
||||
f_mkdir("emuMMC/ER00");
|
||||
|
||||
@@ -419,7 +421,7 @@ static void _migrate_sd_raw_based()
|
||||
|
||||
save_emummc_cfg(1, mbr_ctx.sector_start, "emuMMC/ER00");
|
||||
_create_emummc_migrated_mbox();
|
||||
sd_unmount();
|
||||
boot_storage_unmount();
|
||||
}
|
||||
|
||||
static void _migrate_sd_raw_emummc_based()
|
||||
@@ -427,6 +429,7 @@ static void _migrate_sd_raw_emummc_based()
|
||||
char *tmp = (char *)malloc(0x80);
|
||||
s_printf(tmp, "emuMMC/RAW%d", mbr_ctx.part_idx);
|
||||
|
||||
boot_storage_mount();
|
||||
sd_mount();
|
||||
f_mkdir("emuMMC");
|
||||
f_mkdir(tmp);
|
||||
@@ -447,35 +450,40 @@ static void _migrate_sd_raw_emummc_based()
|
||||
_create_emummc_migrated_mbox();
|
||||
free(tmp);
|
||||
|
||||
boot_storage_unmount();
|
||||
sd_unmount();
|
||||
}
|
||||
|
||||
static void _migrate_sd_file_based()
|
||||
{
|
||||
sd_mount();
|
||||
boot_storage_mount();
|
||||
f_mkdir("sd:emuMMC");
|
||||
f_mkdir("sd:emuMMC/EF00");
|
||||
|
||||
f_rename("sd:Emutendo", "sd:emuMMC/EF00/Nintendo");
|
||||
FIL fp;
|
||||
|
||||
f_mkdir("emuMMC");
|
||||
f_mkdir("emuMMC/EF00");
|
||||
|
||||
f_rename("Emutendo", "emuMMC/EF00/Nintendo");
|
||||
FIL fp;
|
||||
f_open(&fp, "emuMMC/EF00/file_based", FA_CREATE_ALWAYS | FA_WRITE);
|
||||
f_close(&fp);
|
||||
|
||||
char *path = (char *)malloc(128);
|
||||
char *path2 = (char *)malloc(128);
|
||||
s_printf(path, "%c%c%c%c%s", 's', 'x', 'o', 's', "/emunand");
|
||||
f_rename(path, "emuMMC/EF00/eMMC");
|
||||
s_printf(path, "sd:%c%c%c%c%s", 's', 'x', 'o', 's', "/emunand");
|
||||
f_rename(path, "sd:emuMMC/EF00/eMMC");
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
s_printf(path, "emuMMC/EF00/eMMC/boot%d.bin", i);
|
||||
s_printf(path2, "emuMMC/EF00/eMMC/BOOT%d", i);
|
||||
s_printf(path, "sd:emuMMC/EF00/eMMC/boot%d.bin", i);
|
||||
s_printf(path2, "sd:emuMMC/EF00/eMMC/BOOT%d", i);
|
||||
f_rename(path, path2);
|
||||
}
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
s_printf(path, "emuMMC/EF00/eMMC/full.%02d.bin", i);
|
||||
s_printf(path2, "emuMMC/EF00/eMMC/%02d", i);
|
||||
s_printf(path, "sd:emuMMC/EF00/eMMC/full.%02d.bin", i);
|
||||
s_printf(path2, "sd:emuMMC/EF00/eMMC/%02d", i);
|
||||
f_rename(path, path2);
|
||||
}
|
||||
|
||||
@@ -485,6 +493,7 @@ static void _migrate_sd_file_based()
|
||||
save_emummc_cfg(0, 0, "emuMMC/EF00");
|
||||
_create_emummc_migrated_mbox();
|
||||
sd_unmount();
|
||||
boot_storage_unmount();
|
||||
}
|
||||
|
||||
static void _migrate_sd_backup_file_based()
|
||||
@@ -495,9 +504,11 @@ static void _migrate_sd_backup_file_based()
|
||||
char *backup_file_path = (char *)malloc(128);
|
||||
|
||||
sd_mount();
|
||||
boot_storage_mount();
|
||||
f_mkdir("sd:emuMMC");
|
||||
f_mkdir("emuMMC");
|
||||
|
||||
strcpy(emu_path, "emuMMC/BK");
|
||||
strcpy(emu_path, "sd:emuMMC/BK");
|
||||
u32 base_len = strlen(emu_path);
|
||||
|
||||
for (int j = 0; j < 100; j++)
|
||||
@@ -509,13 +520,14 @@ static void _migrate_sd_backup_file_based()
|
||||
base_len = strlen(emu_path);
|
||||
|
||||
f_mkdir(emu_path);
|
||||
f_mkdir(emu_path + 3);
|
||||
strcat(emu_path, "/eMMC");
|
||||
f_mkdir(emu_path);
|
||||
|
||||
FIL fp;
|
||||
// Create file based flag.
|
||||
strcpy(emu_path + base_len, "/file_based");
|
||||
f_open(&fp, "emuMMC/BK00/file_based", FA_CREATE_ALWAYS | FA_WRITE);
|
||||
f_open(&fp, (emu_path + 3), FA_CREATE_ALWAYS | FA_WRITE);
|
||||
f_close(&fp);
|
||||
|
||||
if (!emummc_backup)
|
||||
@@ -523,6 +535,7 @@ static void _migrate_sd_backup_file_based()
|
||||
else
|
||||
emmcsn_path_impl(backup_path, "/emummc", "", NULL);
|
||||
|
||||
// TODO: f_rename wont work if src/dst are on different drives
|
||||
// Move BOOT0.
|
||||
s_printf(backup_file_path, "%s/BOOT0", backup_path);
|
||||
strcpy(emu_path + base_len, "/eMMC/BOOT0");
|
||||
@@ -565,6 +578,7 @@ static void _migrate_sd_backup_file_based()
|
||||
save_emummc_cfg(0, 0, "emuMMC/BK00");
|
||||
_create_emummc_migrated_mbox();
|
||||
sd_unmount();
|
||||
boot_storage_unmount();
|
||||
}
|
||||
|
||||
static lv_res_t _create_emummc_mig1_action(lv_obj_t * btns, const char * txt)
|
||||
@@ -826,7 +840,7 @@ static lv_res_t _create_mbox_emummc_migrate(lv_obj_t *btn)
|
||||
em_raw = true;
|
||||
}
|
||||
|
||||
s_printf(path_buf, "%c%c%c%c%s", 's', 'x', 'o','s', "/emunand/boot0.bin");
|
||||
s_printf(path_buf, "sd:%c%c%c%c%s", 's', 'x', 'o','s', "/emunand/boot0.bin");
|
||||
|
||||
if (!f_stat(path_buf, NULL))
|
||||
em_file = true;
|
||||
@@ -970,6 +984,7 @@ static lv_res_t _save_file_emummc_cfg_action(lv_obj_t *btn)
|
||||
save_emummc_cfg(0, 0, lv_list_get_btn_text(btn));
|
||||
_create_emummc_saved_mbox();
|
||||
sd_unmount();
|
||||
boot_storage_unmount();
|
||||
|
||||
return LV_RES_INV;
|
||||
}
|
||||
@@ -1203,12 +1218,12 @@ lv_res_t create_win_emummc_tools(lv_obj_t *btn)
|
||||
emummc_manage_window = win;
|
||||
emummc_tools = (void *)create_win_emummc_tools;
|
||||
|
||||
sd_mount();
|
||||
boot_storage_mount();
|
||||
|
||||
emummc_cfg_t emu_info;
|
||||
load_emummc_cfg(&emu_info);
|
||||
|
||||
sd_unmount();
|
||||
boot_storage_unmount();
|
||||
|
||||
static lv_style_t h_style;
|
||||
lv_style_copy(&h_style, &lv_style_transp);
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "../hos/hos.h"
|
||||
#include "../hos/pkg1.h"
|
||||
#include <libs/fatfs/ff.h>
|
||||
#include <storage/boot_storage.h>
|
||||
|
||||
#define SECTORS_TO_MIB_COEFF 11
|
||||
|
||||
@@ -72,15 +73,15 @@ static lv_res_t _cal0_dump_window_action(lv_obj_t *btns, const char * txt)
|
||||
|
||||
if (btn_idx == 1)
|
||||
{
|
||||
int error = !sd_mount();
|
||||
int error = !boot_storage_mount();
|
||||
|
||||
if (!error)
|
||||
{
|
||||
char path[64];
|
||||
emmcsn_path_impl(path, "/dumps", "cal0.bin", NULL);
|
||||
error = sd_save_to_file((u8 *)cal0_buf, SZ_32K, path);
|
||||
error = boot_storage_save_to_file((u8 *)cal0_buf, SZ_32K, path);
|
||||
|
||||
sd_unmount();
|
||||
boot_storage_unmount();
|
||||
}
|
||||
|
||||
_create_window_dump_done(error, "cal0.bin");
|
||||
@@ -92,7 +93,7 @@ static lv_res_t _cal0_dump_window_action(lv_obj_t *btns, const char * txt)
|
||||
|
||||
static lv_res_t _battery_dump_window_action(lv_obj_t * btn)
|
||||
{
|
||||
int error = !sd_mount();
|
||||
int error = !boot_storage_mount();
|
||||
|
||||
if (!error)
|
||||
{
|
||||
@@ -102,9 +103,9 @@ static lv_res_t _battery_dump_window_action(lv_obj_t * btn)
|
||||
max17050_dump_regs(buf);
|
||||
|
||||
emmcsn_path_impl(path, "/dumps", "fuel_gauge.bin", NULL);
|
||||
error = sd_save_to_file((u8 *)buf, 0x200, path);
|
||||
error = boot_storage_save_to_file((u8 *)buf, 0x200, path);
|
||||
|
||||
sd_unmount();
|
||||
boot_storage_unmount();
|
||||
}
|
||||
|
||||
_create_window_dump_done(error, "fuel_gauge.bin");
|
||||
@@ -116,7 +117,7 @@ static lv_res_t _bootrom_dump_window_action(lv_obj_t * btn)
|
||||
{
|
||||
static const u32 BOOTROM_SIZE = 0x18000;
|
||||
|
||||
int error = !sd_mount();
|
||||
int error = !boot_storage_mount();
|
||||
if (!error)
|
||||
{
|
||||
char path[64];
|
||||
@@ -126,13 +127,13 @@ static lv_res_t _bootrom_dump_window_action(lv_obj_t * btn)
|
||||
if (!error)
|
||||
{
|
||||
emmcsn_path_impl(path, "/dumps", "evp_thunks.bin", NULL);
|
||||
error = sd_save_to_file((u8 *)iram_evp_thunks, iram_evp_thunks_len, path);
|
||||
error = boot_storage_save_to_file((u8 *)iram_evp_thunks, iram_evp_thunks_len, path);
|
||||
}
|
||||
else
|
||||
error = 255;
|
||||
|
||||
emmcsn_path_impl(path, "/dumps", "bootrom_patched.bin", NULL);
|
||||
int res = sd_save_to_file((u8 *)IROM_BASE, BOOTROM_SIZE, path);
|
||||
int res = boot_storage_save_to_file((u8 *)IROM_BASE, BOOTROM_SIZE, path);
|
||||
if (!error)
|
||||
error = res;
|
||||
|
||||
@@ -141,13 +142,13 @@ static lv_res_t _bootrom_dump_window_action(lv_obj_t * btn)
|
||||
memset((void*)IPATCH_BASE, 0, sizeof(ipatch_cam)); // Zeroing valid entries is enough but zero everything.
|
||||
|
||||
emmcsn_path_impl(path, "/dumps", "bootrom_unpatched.bin", NULL);
|
||||
res = sd_save_to_file((u8 *)IROM_BASE, BOOTROM_SIZE, path);
|
||||
res = boot_storage_save_to_file((u8 *)IROM_BASE, BOOTROM_SIZE, path);
|
||||
if (!error)
|
||||
error = res;
|
||||
|
||||
memcpy((void*)IPATCH_BASE, ipatch_cam, sizeof(ipatch_cam));
|
||||
|
||||
sd_unmount();
|
||||
boot_storage_unmount();
|
||||
}
|
||||
_create_window_dump_done(error, "evp_thunks.bin, bootrom_patched.bin, bootrom_unpatched.bin");
|
||||
|
||||
@@ -158,22 +159,22 @@ static lv_res_t _fuse_dump_window_action(lv_obj_t * btn)
|
||||
{
|
||||
const u32 fuse_array_size = (h_cfg.t210b01 ? FUSE_ARRAY_WORDS_NUM_B01 : FUSE_ARRAY_WORDS_NUM) * sizeof(u32);
|
||||
|
||||
int error = !sd_mount();
|
||||
int error = !boot_storage_mount();
|
||||
if (!error)
|
||||
{
|
||||
char path[128];
|
||||
if (!h_cfg.t210b01)
|
||||
{
|
||||
emmcsn_path_impl(path, "/dumps", "fuse_cached_t210.bin", NULL);
|
||||
error = sd_save_to_file((u8 *)0x7000F900, 0x300, path);
|
||||
error = boot_storage_save_to_file((u8 *)0x7000F900, 0x300, path);
|
||||
}
|
||||
else
|
||||
{
|
||||
emmcsn_path_impl(path, "/dumps", "fuse_cached_t210b01_x898.bin", NULL);
|
||||
error = sd_save_to_file((u8 *)0x7000F898, 0x68, path);
|
||||
error = boot_storage_save_to_file((u8 *)0x7000F898, 0x68, path);
|
||||
emmcsn_path_impl(path, "/dumps", "fuse_cached_t210b01_x900.bin", NULL);
|
||||
if (!error)
|
||||
error = sd_save_to_file((u8 *)0x7000F900, 0x300, path);
|
||||
error = boot_storage_save_to_file((u8 *)0x7000F900, 0x300, path);
|
||||
}
|
||||
|
||||
u32 words[FUSE_ARRAY_WORDS_NUM_B01];
|
||||
@@ -182,11 +183,11 @@ static lv_res_t _fuse_dump_window_action(lv_obj_t * btn)
|
||||
emmcsn_path_impl(path, "/dumps", "fuse_array_raw_t210.bin", NULL);
|
||||
else
|
||||
emmcsn_path_impl(path, "/dumps", "fuse_array_raw_t210b01.bin", NULL);
|
||||
int res = sd_save_to_file((u8 *)words, fuse_array_size, path);
|
||||
int res = boot_storage_save_to_file((u8 *)words, fuse_array_size, path);
|
||||
if (!error)
|
||||
error = res;
|
||||
|
||||
sd_unmount();
|
||||
boot_storage_unmount();
|
||||
}
|
||||
|
||||
if (!h_cfg.t210b01)
|
||||
@@ -203,15 +204,15 @@ static lv_res_t _kfuse_dump_window_action(lv_obj_t * btn)
|
||||
int error = !kfuse_read(buf);
|
||||
|
||||
if (!error)
|
||||
error = !sd_mount();
|
||||
error = !boot_storage_mount();
|
||||
|
||||
if (!error)
|
||||
{
|
||||
char path[64];
|
||||
emmcsn_path_impl(path, "/dumps", "kfuses.bin", NULL);
|
||||
error = sd_save_to_file((u8 *)buf, KFUSE_NUM_WORDS * 4, path);
|
||||
error = boot_storage_save_to_file((u8 *)buf, KFUSE_NUM_WORDS * 4, path);
|
||||
|
||||
sd_unmount();
|
||||
boot_storage_unmount();
|
||||
}
|
||||
|
||||
_create_window_dump_done(error, "kfuses.bin");
|
||||
@@ -241,7 +242,7 @@ static lv_res_t _create_mbox_cal0(lv_obj_t *btn)
|
||||
lv_label_set_style(lb_desc, &monospace_text);
|
||||
lv_obj_set_width(lb_desc, LV_HOR_RES / 9 * 4);
|
||||
|
||||
sd_mount();
|
||||
boot_storage_mount();
|
||||
|
||||
// Dump CAL0.
|
||||
int cal0_res = hos_dump_cal0();
|
||||
@@ -341,7 +342,7 @@ static lv_res_t _create_mbox_cal0(lv_obj_t *btn)
|
||||
|
||||
out:
|
||||
free(txt_buf);
|
||||
sd_unmount();
|
||||
boot_storage_unmount();
|
||||
|
||||
lv_mbox_add_btns(mbox, mbox_btn_map, _cal0_dump_window_action);
|
||||
|
||||
@@ -2432,7 +2433,7 @@ static bool _lockpick_exists_check()
|
||||
|
||||
bool found = false;
|
||||
void *buf = malloc(0x200);
|
||||
if (sd_mount())
|
||||
if (boot_storage_mount())
|
||||
{
|
||||
FIL fp;
|
||||
if (f_open(&fp, "bootloader/payloads/Lockpick_RCM.bin", FA_READ))
|
||||
@@ -2457,7 +2458,7 @@ static bool _lockpick_exists_check()
|
||||
|
||||
out:
|
||||
free(buf);
|
||||
sd_unmount();
|
||||
boot_storage_unmount();
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "../config.h"
|
||||
#include <libs/lvgl/lv_themes/lv_theme_hekate.h>
|
||||
#include <libs/lvgl/lvgl.h>
|
||||
#include <storage/boot_storage.h>
|
||||
|
||||
#define CLOCK_MIN_YEAR 2024
|
||||
#define CLOCK_MAX_YEAR (CLOCK_MIN_YEAR + 10)
|
||||
@@ -227,7 +228,7 @@ static void _create_autoboot_window()
|
||||
lv_obj_set_size(list_main, LV_HOR_RES * 4 / 10, LV_VER_RES * 4 / 7);
|
||||
lv_list_set_single_mode(list_main, true);
|
||||
|
||||
sd_mount();
|
||||
boot_storage_mount();
|
||||
|
||||
// Parse hekate main configuration.
|
||||
LIST_INIT(ini_sections);
|
||||
@@ -288,7 +289,7 @@ static void _create_autoboot_window()
|
||||
ini_free(&ini_list_sections);
|
||||
}
|
||||
|
||||
sd_unmount();
|
||||
boot_storage_unmount();
|
||||
}
|
||||
|
||||
static lv_res_t _autoboot_hide_delay_action(lv_obj_t *btn)
|
||||
@@ -882,7 +883,7 @@ static lv_res_t _joycon_info_dump_action(lv_obj_t * btn)
|
||||
jc_pad->bt_conn_r.type = is_r_hos ? jc_pad->bt_conn_r.type : 0;
|
||||
|
||||
save_data:
|
||||
error = !sd_mount() ? 5 : 0;
|
||||
error = !boot_storage_mount() ? 5 : 0;
|
||||
|
||||
if (!error)
|
||||
{
|
||||
@@ -896,7 +897,8 @@ save_data:
|
||||
memcpy(data, &jc_pad->bt_conn_l, sizeof(jc_bt_conn_t));
|
||||
memcpy(data + sizeof(jc_bt_conn_t), &jc_pad->bt_conn_r, sizeof(jc_bt_conn_t));
|
||||
|
||||
error = sd_save_to_file((u8 *)data, sizeof(jc_bt_conn_t) * 2, "switchroot/joycon_mac.bin") ? 4 : 0;
|
||||
// TODO: JC dump should probably go to sd?
|
||||
error = boot_storage_save_to_file((u8 *)data, sizeof(jc_bt_conn_t) * 2, "switchroot/joycon_mac.bin") ? 4 : 0;
|
||||
|
||||
// Save readable dump.
|
||||
jc_bt_conn_t *bt = &jc_pad->bt_conn_l;
|
||||
@@ -1024,7 +1026,7 @@ save_data:
|
||||
}
|
||||
}
|
||||
|
||||
sd_unmount();
|
||||
boot_storage_unmount();
|
||||
}
|
||||
|
||||
disabled_or_cal0_issue:;
|
||||
|
||||
@@ -15,6 +15,10 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <fatfs_cfg.h>
|
||||
#include <libs/lvgl/lv_core/lv_obj.h>
|
||||
#include <libs/lvgl/lv_objx/lv_btn.h>
|
||||
#include <libs/lvgl/lv_objx/lv_label.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <bdk.h>
|
||||
@@ -29,6 +33,9 @@
|
||||
#include "../hos/pkg2.h"
|
||||
#include "../hos/hos.h"
|
||||
#include <libs/fatfs/ff.h>
|
||||
#include <storage/boot_storage.h>
|
||||
#include <storage/sdmmc.h>
|
||||
#include <string.h>
|
||||
|
||||
extern volatile boot_cfg_t *b_cfg;
|
||||
extern hekate_config h_cfg;
|
||||
@@ -441,6 +448,45 @@ static lv_res_t _action_ums_emmc_boot0(lv_obj_t *btn)
|
||||
return LV_RES_OK;
|
||||
}
|
||||
|
||||
static lv_res_t _action_ums_boot_storage(lv_obj_t *btn){
|
||||
if(!nyx_emmc_check_battery_enough()){
|
||||
return LV_RES_OK;
|
||||
}
|
||||
|
||||
boot_storage_mount();
|
||||
|
||||
u8 drive = boot_storage_get_drive();
|
||||
|
||||
usb_ctxt_t usbs;
|
||||
usbs.type = drive == DRIVE_SD ? MMC_SD : MMC_EMMC;
|
||||
switch(drive){
|
||||
case DRIVE_EMMC:
|
||||
usbs.partition = EMMC_GPP + 1;
|
||||
break;
|
||||
case DRIVE_BOOT1:
|
||||
case DRIVE_BOOT1_1MB:
|
||||
usbs.partition = EMMC_BOOT1 + 1;
|
||||
break;
|
||||
case DRIVE_SD:
|
||||
usbs.partition = 0;
|
||||
break;
|
||||
default:
|
||||
boot_storage_unmount();
|
||||
return LV_RES_OK;
|
||||
}
|
||||
usbs.offset = drive == DRIVE_BOOT1_1MB ? (0x100000 / 0x200) : 0;
|
||||
usbs.sectors = 0;
|
||||
usbs.ro = false;
|
||||
usbs.system_maintenance = &manual_system_maintenance;
|
||||
usbs.set_text = &usb_gadget_set_text;
|
||||
|
||||
_create_mbox_ums(&usbs);
|
||||
|
||||
boot_storage_unmount();
|
||||
|
||||
return LV_RES_OK;
|
||||
}
|
||||
|
||||
static lv_res_t _action_ums_emmc_boot1(lv_obj_t *btn)
|
||||
{
|
||||
if (!nyx_emmc_check_battery_enough())
|
||||
@@ -487,6 +533,7 @@ static lv_res_t _action_ums_emuemmc_boot0(lv_obj_t *btn)
|
||||
usb_ctxt_t usbs;
|
||||
|
||||
int error = !sd_mount();
|
||||
error &= boot_storage_mount();
|
||||
if (!error)
|
||||
{
|
||||
emummc_cfg_t emu_info;
|
||||
@@ -509,6 +556,7 @@ static lv_res_t _action_ums_emuemmc_boot0(lv_obj_t *btn)
|
||||
free(emu_info.nintendo_path);
|
||||
}
|
||||
sd_unmount();
|
||||
boot_storage_unmount();
|
||||
|
||||
if (error)
|
||||
_create_mbox_ums_error(error);
|
||||
@@ -534,6 +582,7 @@ static lv_res_t _action_ums_emuemmc_boot1(lv_obj_t *btn)
|
||||
usb_ctxt_t usbs;
|
||||
|
||||
int error = !sd_mount();
|
||||
error &= boot_storage_mount();
|
||||
if (!error)
|
||||
{
|
||||
emummc_cfg_t emu_info;
|
||||
@@ -556,6 +605,7 @@ static lv_res_t _action_ums_emuemmc_boot1(lv_obj_t *btn)
|
||||
free(emu_info.nintendo_path);
|
||||
}
|
||||
sd_unmount();
|
||||
boot_storage_unmount();
|
||||
|
||||
if (error)
|
||||
_create_mbox_ums_error(error);
|
||||
@@ -581,6 +631,7 @@ static lv_res_t _action_ums_emuemmc_gpp(lv_obj_t *btn)
|
||||
usb_ctxt_t usbs;
|
||||
|
||||
int error = !sd_mount();
|
||||
error &= boot_storage_mount();
|
||||
if (!error)
|
||||
{
|
||||
emummc_cfg_t emu_info;
|
||||
@@ -613,6 +664,7 @@ static lv_res_t _action_ums_emuemmc_gpp(lv_obj_t *btn)
|
||||
free(emu_info.nintendo_path);
|
||||
}
|
||||
sd_unmount();
|
||||
boot_storage_unmount();
|
||||
|
||||
if (error)
|
||||
_create_mbox_ums_error(error);
|
||||
@@ -718,12 +770,26 @@ static lv_res_t _create_window_usb_tools(lv_obj_t *parent)
|
||||
lv_obj_t *label_txt2 = lv_label_create(h1, NULL);
|
||||
lv_label_set_recolor(label_txt2, true);
|
||||
lv_label_set_static_text(label_txt2,
|
||||
"Allows you to mount the SD Card to a PC/Phone.\n"
|
||||
"Allows you to mount the SD Card or boot storage to a PC/Phone.\n"
|
||||
"#C7EA46 All operating systems are supported. Access is# #FF8000 Read/Write.#");
|
||||
|
||||
lv_obj_set_style(label_txt2, &hint_small_style);
|
||||
lv_obj_align(label_txt2, btn1, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 3);
|
||||
|
||||
// Create Boot Storage UMS button
|
||||
lv_obj_t *btn_boot_strg = lv_btn_create(h1, btn1);
|
||||
label_btn = lv_label_create(btn_boot_strg, NULL);
|
||||
lv_label_set_text(label_btn, SYMBOL_SD " Boot Storage");
|
||||
lv_obj_align(btn_boot_strg, btn1, LV_ALIGN_OUT_RIGHT_MID, LV_DPI / 10, 0);
|
||||
lv_btn_set_action(btn_boot_strg, LV_BTN_ACTION_CLICK, _action_ums_boot_storage);
|
||||
|
||||
if(!boot_storage_mount()){
|
||||
lv_obj_set_click(btn_boot_strg, false);
|
||||
lv_btn_set_state(btn_boot_strg, LV_BTN_STATE_INA);
|
||||
}
|
||||
boot_storage_unmount();
|
||||
|
||||
|
||||
// Create RAW GPP button.
|
||||
lv_obj_t *btn_gpp = lv_btn_create(h1, btn1);
|
||||
label_btn = lv_label_create(btn_gpp, NULL);
|
||||
@@ -927,6 +993,8 @@ out:
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
// TODO: emusd
|
||||
static lv_res_t _create_window_unset_abit_tool(lv_obj_t *btn)
|
||||
{
|
||||
lv_obj_t *win = nyx_create_standard_window(SYMBOL_COPY" Fix Archive Bit (All folders)");
|
||||
@@ -957,7 +1025,8 @@ static lv_res_t _create_window_unset_abit_tool(lv_obj_t *btn)
|
||||
lv_obj_t * lb_val = lv_label_create(val, lb_desc);
|
||||
|
||||
char *path = malloc(0x1000);
|
||||
path[0] = 0;
|
||||
strcpy(path, "sd:");
|
||||
// path[0] = 0;
|
||||
|
||||
lv_label_set_text(lb_val, "");
|
||||
lv_obj_set_width(lb_val, lv_obj_get_width(val));
|
||||
@@ -1135,8 +1204,9 @@ static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn)
|
||||
lv_label_set_recolor(lb_desc, true);
|
||||
lv_obj_set_width(lb_desc, lv_obj_get_width(desc));
|
||||
|
||||
if (!sd_mount())
|
||||
if (!boot_storage_mount())
|
||||
{
|
||||
// may not be sd, fix error
|
||||
lv_label_set_text(lb_desc, "#FFDD00 Failed to init SD!#");
|
||||
|
||||
goto out_end;
|
||||
@@ -1180,7 +1250,7 @@ static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn)
|
||||
|
||||
// Dump package1 in its encrypted state.
|
||||
emmcsn_path_impl(path, "/pkg1", "pkg1_enc.bin", &emmc_storage);
|
||||
bool res = sd_save_to_file(pkg1, BOOTLOADER_SIZE, path);
|
||||
bool res = boot_storage_save_to_file(pkg1, BOOTLOADER_SIZE, path);
|
||||
|
||||
// Exit if unknown.
|
||||
if (!pkg1_id)
|
||||
@@ -1245,7 +1315,7 @@ static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn)
|
||||
|
||||
// Dump package1.1.
|
||||
emmcsn_path_impl(path, "/pkg1", "pkg1_decr.bin", &emmc_storage);
|
||||
if (sd_save_to_file(pkg1, SZ_256K, path))
|
||||
if (boot_storage_save_to_file(pkg1, SZ_256K, path))
|
||||
goto out_free;
|
||||
strcat(txt_buf, "pkg1 dumped to pkg1_decr.bin\n");
|
||||
lv_label_set_text(lb_desc, txt_buf);
|
||||
@@ -1253,7 +1323,7 @@ static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn)
|
||||
|
||||
// Dump nxbootloader.
|
||||
emmcsn_path_impl(path, "/pkg1", "nxloader.bin", &emmc_storage);
|
||||
if (sd_save_to_file(loader, hdr_pk11->ldr_size, path))
|
||||
if (boot_storage_save_to_file(loader, hdr_pk11->ldr_size, path))
|
||||
goto out_free;
|
||||
strcat(txt_buf, "NX Bootloader dumped to nxloader.bin\n");
|
||||
lv_label_set_text(lb_desc, txt_buf);
|
||||
@@ -1261,7 +1331,7 @@ static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn)
|
||||
|
||||
// Dump secmon.
|
||||
emmcsn_path_impl(path, "/pkg1", "secmon.bin", &emmc_storage);
|
||||
if (sd_save_to_file(secmon, hdr_pk11->sm_size, path))
|
||||
if (boot_storage_save_to_file(secmon, hdr_pk11->sm_size, path))
|
||||
goto out_free;
|
||||
strcat(txt_buf, "Secure Monitor dumped to secmon.bin\n");
|
||||
lv_label_set_text(lb_desc, txt_buf);
|
||||
@@ -1269,7 +1339,7 @@ static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn)
|
||||
|
||||
// Dump warmboot.
|
||||
emmcsn_path_impl(path, "/pkg1", "warmboot.bin", &emmc_storage);
|
||||
if (sd_save_to_file(warmboot, hdr_pk11->wb_size, path))
|
||||
if (boot_storage_save_to_file(warmboot, hdr_pk11->wb_size, path))
|
||||
goto out_free;
|
||||
// If T210B01, save a copy of decrypted warmboot binary also.
|
||||
if (h_cfg.t210b01)
|
||||
@@ -1279,7 +1349,7 @@ static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn)
|
||||
se_aes_crypt_cbc(13, DECRYPT, warmboot + 0x330, hdr_pk11->wb_size - 0x330,
|
||||
warmboot + 0x330, hdr_pk11->wb_size - 0x330);
|
||||
emmcsn_path_impl(path, "/pkg1", "warmboot_dec.bin", &emmc_storage);
|
||||
if (sd_save_to_file(warmboot, hdr_pk11->wb_size, path))
|
||||
if (boot_storage_save_to_file(warmboot, hdr_pk11->wb_size, path))
|
||||
goto out_free;
|
||||
}
|
||||
strcat(txt_buf, "Warmboot dumped to warmboot.bin\n\n");
|
||||
@@ -1311,7 +1381,7 @@ static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn)
|
||||
|
||||
// Dump encrypted package2.
|
||||
emmcsn_path_impl(path, "/pkg2", "pkg2_encr.bin", &emmc_storage);
|
||||
res = sd_save_to_file(pkg2, pkg2_size, path);
|
||||
res = boot_storage_save_to_file(pkg2, pkg2_size, path);
|
||||
|
||||
// Decrypt package2 and parse KIP1 blobs in INI1 section.
|
||||
pkg2_hdr_t *pkg2_hdr = pkg2_decrypt(pkg2, kb);
|
||||
@@ -1345,7 +1415,7 @@ static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn)
|
||||
|
||||
// Dump pkg2.1.
|
||||
emmcsn_path_impl(path, "/pkg2", "pkg2_decr.bin", &emmc_storage);
|
||||
if (sd_save_to_file(pkg2, pkg2_hdr->sec_size[PKG2_SEC_KERNEL] + pkg2_hdr->sec_size[PKG2_SEC_INI1], path))
|
||||
if (boot_storage_save_to_file(pkg2, pkg2_hdr->sec_size[PKG2_SEC_KERNEL] + pkg2_hdr->sec_size[PKG2_SEC_INI1], path))
|
||||
goto out;
|
||||
strcat(txt_buf, "pkg2 dumped to pkg2_decr.bin\n");
|
||||
lv_label_set_text(lb_desc, txt_buf);
|
||||
@@ -1353,7 +1423,7 @@ static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn)
|
||||
|
||||
// Dump kernel.
|
||||
emmcsn_path_impl(path, "/pkg2", "kernel.bin", &emmc_storage);
|
||||
if (sd_save_to_file(pkg2_hdr->data, pkg2_hdr->sec_size[PKG2_SEC_KERNEL], path))
|
||||
if (boot_storage_save_to_file(pkg2_hdr->data, pkg2_hdr->sec_size[PKG2_SEC_KERNEL], path))
|
||||
goto out;
|
||||
strcat(txt_buf, "Kernel dumped to kernel.bin\n");
|
||||
lv_label_set_text(lb_desc, txt_buf);
|
||||
@@ -1377,7 +1447,7 @@ static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn)
|
||||
|
||||
pkg2_ini1_t *ini1 = (pkg2_ini1_t *)(pkg2_hdr->data + ini1_off);
|
||||
emmcsn_path_impl(path, "/pkg2", "ini1.bin", &emmc_storage);
|
||||
if (sd_save_to_file(ini1, ini1_size, path))
|
||||
if (boot_storage_save_to_file(ini1, ini1_size, path))
|
||||
goto out;
|
||||
|
||||
strcat(txt_buf, "INI1 dumped to ini1.bin\n\n");
|
||||
@@ -1404,7 +1474,7 @@ static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn)
|
||||
}
|
||||
|
||||
emmcsn_path_impl(path, "/pkg2/ini1", filename, &emmc_storage);
|
||||
if (sd_save_to_file(kip1, kip1_size, path))
|
||||
if (boot_storage_save_to_file(kip1, kip1_size, path))
|
||||
{
|
||||
free(kip_buffer);
|
||||
goto out;
|
||||
@@ -1429,6 +1499,7 @@ out_free:
|
||||
free(txt_buf);
|
||||
emmc_end();
|
||||
sd_unmount();
|
||||
boot_storage_unmount();
|
||||
|
||||
if (kb >= HOS_KB_VERSION_620)
|
||||
se_aes_key_clear(8);
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <libs/fatfs/ff.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <bdk.h>
|
||||
@@ -23,6 +24,8 @@
|
||||
#include "gui_tools_partition_manager.h"
|
||||
#include <libs/fatfs/diskio.h>
|
||||
#include <libs/lvgl/lvgl.h>
|
||||
#include <storage/boot_storage.h>
|
||||
#include <storage/sd.h>
|
||||
|
||||
#define AU_ALIGN_SECTORS 0x8000 // 16MB.
|
||||
#define AU_ALIGN_BYTES (AU_ALIGN_SECTORS * SD_BLOCKSIZE)
|
||||
@@ -536,7 +539,7 @@ static lv_res_t _action_delete_linux_installer_files(lv_obj_t * btns, const char
|
||||
{
|
||||
char path[128];
|
||||
|
||||
sd_mount();
|
||||
boot_storage_mount();
|
||||
|
||||
strcpy(path, "switchroot/install/l4t.");
|
||||
|
||||
@@ -562,7 +565,7 @@ static lv_res_t _action_delete_linux_installer_files(lv_obj_t * btns, const char
|
||||
idx++;
|
||||
}
|
||||
|
||||
sd_unmount();
|
||||
boot_storage_unmount();
|
||||
}
|
||||
|
||||
return LV_RES_INV;
|
||||
@@ -616,6 +619,7 @@ static lv_res_t _action_flash_linux_data(lv_obj_t * btns, const char * txt)
|
||||
lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_set_top(mbox, true);
|
||||
|
||||
boot_storage_mount();
|
||||
sd_mount();
|
||||
|
||||
int res = 0;
|
||||
@@ -761,6 +765,7 @@ exit:
|
||||
lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
sd_unmount();
|
||||
boot_storage_unmount();
|
||||
|
||||
return LV_RES_INV;
|
||||
}
|
||||
@@ -876,7 +881,7 @@ static lv_res_t _action_check_flash_linux(lv_obj_t *btn)
|
||||
|
||||
manual_system_maintenance(true);
|
||||
|
||||
sd_mount();
|
||||
boot_storage_mount();
|
||||
|
||||
// Check if L4T image exists.
|
||||
strcpy(path, "switchroot/install/l4t.00");
|
||||
@@ -964,7 +969,7 @@ error:
|
||||
exit:
|
||||
lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
sd_unmount();
|
||||
boot_storage_unmount();
|
||||
|
||||
return LV_RES_OK;
|
||||
}
|
||||
@@ -1038,6 +1043,7 @@ static lv_res_t _action_flash_android_data(lv_obj_t * btns, const char * txt)
|
||||
manual_system_maintenance(true);
|
||||
|
||||
sd_mount();
|
||||
boot_storage_mount();
|
||||
|
||||
// Read main GPT.
|
||||
sdmmc_storage_read(&sd_storage, 1, sizeof(gpt_t) >> 9, gpt);
|
||||
@@ -1078,7 +1084,7 @@ static lv_res_t _action_flash_android_data(lv_obj_t * btns, const char * txt)
|
||||
if (offset_sct && size_sct)
|
||||
{
|
||||
u32 file_size = 0;
|
||||
u8 *buf = sd_file_read(path, &file_size);
|
||||
u8 *buf = boot_storage_file_read(path, &file_size);
|
||||
|
||||
if (file_size % 0x200)
|
||||
{
|
||||
@@ -1142,7 +1148,7 @@ boot_img_not_found:
|
||||
if (offset_sct && size_sct)
|
||||
{
|
||||
u32 file_size = 0;
|
||||
u8 *buf = sd_file_read(path, &file_size);
|
||||
u8 *buf = boot_storage_file_read(path, &file_size);
|
||||
|
||||
if (file_size % 0x200)
|
||||
{
|
||||
@@ -1204,7 +1210,7 @@ recovery_not_found:
|
||||
if (offset_sct && size_sct)
|
||||
{
|
||||
u32 file_size = 0;
|
||||
u8 *buf = sd_file_read(path, &file_size);
|
||||
u8 *buf = boot_storage_file_read(path, &file_size);
|
||||
|
||||
if (file_size % 0x200)
|
||||
{
|
||||
@@ -1266,6 +1272,7 @@ error:
|
||||
free(gpt);
|
||||
|
||||
sd_unmount();
|
||||
boot_storage_unmount();
|
||||
|
||||
return LV_RES_INV;
|
||||
}
|
||||
@@ -1419,6 +1426,9 @@ static int _backup_and_restore_files(bool backup, lv_obj_t **labels)
|
||||
|
||||
static lv_res_t _create_mbox_start_partitioning(lv_obj_t *btn)
|
||||
{
|
||||
char cwd[0x200];
|
||||
f_getcwd(cwd, sizeof(cwd));
|
||||
|
||||
lv_obj_t *dark_bg = lv_obj_create(lv_scr_act(), NULL);
|
||||
lv_obj_set_style(dark_bg, &mbox_darken);
|
||||
lv_obj_set_size(dark_bg, LV_HOR_RES, LV_VER_RES);
|
||||
@@ -1522,7 +1532,7 @@ static lv_res_t _create_mbox_start_partitioning(lv_obj_t *btn)
|
||||
goto error;
|
||||
}
|
||||
|
||||
f_mount(NULL, "sd:", 1); // Unmount SD card.
|
||||
sd_unmount();
|
||||
|
||||
lv_label_set_text(lbl_status, "#00DDFF Status:# Formatting FAT32 partition...");
|
||||
lv_label_set_text(lbl_paths[0], "Please wait...");
|
||||
@@ -1593,7 +1603,7 @@ mkfs_no_error:
|
||||
free(buf);
|
||||
|
||||
// Remount sd card as it was unmounted from formatting it.
|
||||
f_mount(&sd_fs, "sd:", 1); // Mount SD card.
|
||||
sd_mount();
|
||||
|
||||
lv_label_set_text(lbl_status, "#00DDFF Status:# Restoring files...");
|
||||
manual_system_maintenance(true);
|
||||
@@ -1610,10 +1620,10 @@ mkfs_no_error:
|
||||
}
|
||||
|
||||
f_mount(NULL, "ram:", 1); // Unmount ramdisk.
|
||||
f_chdrive("sd:");
|
||||
f_chdrive(cwd);
|
||||
|
||||
// Set Volume label.
|
||||
f_setlabel("0:SWITCH SD");
|
||||
f_setlabel("sd:SWITCH SD");
|
||||
|
||||
lv_label_set_text(lbl_status, "#00DDFF Status:# Flashing partition table...");
|
||||
lv_label_set_text(lbl_paths[0], "Please wait...");
|
||||
@@ -1665,7 +1675,7 @@ mkfs_no_error:
|
||||
goto out;
|
||||
|
||||
error:
|
||||
f_chdrive("sd:");
|
||||
f_chdrive(cwd);
|
||||
|
||||
out:
|
||||
lv_obj_del(lbl_paths[0]);
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <bdk.h>
|
||||
|
||||
#include "hos.h"
|
||||
#include <storage/boot_storage.h>
|
||||
#include "../config.h"
|
||||
|
||||
extern hekate_config h_cfg;
|
||||
@@ -393,7 +394,7 @@ int hos_keygen(void *keyblob, u32 kb, tsec_ctxt_t *tsec_ctxt)
|
||||
*/
|
||||
|
||||
// Use custom TSEC Hovi Keygen firmware.
|
||||
tsec_ctxt->fw = sd_file_read("bootloader/sys/thk.bin", NULL);
|
||||
tsec_ctxt->fw = boot_storage_file_read("bootloader/sys/thk.bin", NULL);
|
||||
if (!tsec_ctxt->fw)
|
||||
{
|
||||
EPRINTF("\nFailed to load thk.bin");
|
||||
|
||||
@@ -9,16 +9,44 @@
|
||||
/* storage control modules to the FatFs module with a defined API. */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
#include <storage/emmc.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <bdk.h>
|
||||
|
||||
#include <libs/fatfs/diskio.h> /* FatFs lower layer API */
|
||||
#include <fatfs_cfg.h>
|
||||
|
||||
static u32 sd_rsvd_sectors = 0;
|
||||
static u32 ramdisk_sectors = 0;
|
||||
static u32 emummc_sectors = 0;
|
||||
|
||||
static bool ensure_partition(BYTE pdrv){
|
||||
u8 part;
|
||||
switch(pdrv){
|
||||
case DRIVE_BOOT1:
|
||||
case DRIVE_BOOT1_1MB:
|
||||
part = EMMC_BOOT1;
|
||||
break;
|
||||
case DRIVE_EMMC:
|
||||
part = EMMC_GPP;
|
||||
break;
|
||||
case DRIVE_SD:
|
||||
case DRIVE_RAM:
|
||||
case DRIVE_BIS:
|
||||
case DRIVE_EMU:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
if(emmc_storage.partition != part){
|
||||
return emmc_set_partition(part);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Get Drive Status */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
@@ -49,6 +77,10 @@ DRESULT disk_read (
|
||||
UINT count /* Number of sectors to read */
|
||||
)
|
||||
{
|
||||
if(!ensure_partition(pdrv)){
|
||||
return RES_ERROR;
|
||||
}
|
||||
|
||||
switch (pdrv)
|
||||
{
|
||||
case DRIVE_SD:
|
||||
@@ -60,6 +92,10 @@ DRESULT disk_read (
|
||||
case DRIVE_BIS:
|
||||
case DRIVE_EMU:
|
||||
return nx_emmc_bis_read(sector, count, (void *)buff) ? RES_OK : RES_ERROR;
|
||||
case DRIVE_BOOT1_1MB:
|
||||
return sdmmc_storage_read(&emmc_storage, sector + (0x100000 / 512), count, buff) ? RES_OK : RES_ERROR;
|
||||
case DRIVE_BOOT1:
|
||||
return sdmmc_storage_read(&emmc_storage, sector, count, buff) ? RES_OK : RES_ERROR;
|
||||
}
|
||||
|
||||
return RES_ERROR;
|
||||
@@ -75,6 +111,10 @@ DRESULT disk_write (
|
||||
UINT count /* Number of sectors to write */
|
||||
)
|
||||
{
|
||||
if(!ensure_partition(pdrv)){
|
||||
return RES_ERROR;
|
||||
}
|
||||
|
||||
switch (pdrv)
|
||||
{
|
||||
case DRIVE_SD:
|
||||
@@ -86,6 +126,10 @@ DRESULT disk_write (
|
||||
return RES_WRPRT;
|
||||
case DRIVE_EMU:
|
||||
return nx_emmc_bis_write(sector, count, (void *)buff) ? RES_OK : RES_ERROR;
|
||||
case DRIVE_BOOT1_1MB:
|
||||
return sdmmc_storage_write(&emmc_storage, sector + (0x100000 / 512), count, (void*)buff) ? RES_OK : RES_ERROR;
|
||||
case DRIVE_BOOT1:
|
||||
return sdmmc_storage_write(&emmc_storage, sector, count, (void*)buff) ? RES_OK : RES_ERROR;
|
||||
}
|
||||
|
||||
return RES_ERROR;
|
||||
|
||||
@@ -166,7 +166,7 @@
|
||||
*/
|
||||
|
||||
|
||||
#define FF_FS_RPATH 1
|
||||
#define FF_FS_RPATH 2
|
||||
/* This option configures support for relative path.
|
||||
/
|
||||
/ 0: Disable relative path and remove related functions.
|
||||
@@ -179,13 +179,13 @@
|
||||
/ Drive/Volume Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define FF_VOLUMES 5
|
||||
#define FF_VOLUMES 7
|
||||
/* Number of volumes (logical drives) to be used. (1-10) */
|
||||
|
||||
|
||||
#define FF_STR_VOLUME_ID 1
|
||||
// Order is important. Any change to order, must also be reflected to diskio drive enum.
|
||||
#define FF_VOLUME_STRS "sd","ram","emmc","bis","emu"
|
||||
#define FF_VOLUME_STRS "sd","ram","emmc","bis","emu", "boot1", "boot1_1mb"
|
||||
/* FF_STR_VOLUME_ID switches support for volume ID in arbitrary strings.
|
||||
/ When FF_STR_VOLUME_ID is set to 1 or 2, arbitrary strings can be used as drive
|
||||
/ number in the path name. FF_VOLUME_STRS defines the volume ID strings for each
|
||||
@@ -301,6 +301,14 @@
|
||||
/ SemaphoreHandle_t and etc. A header file for O/S definitions needs to be
|
||||
/ included somewhere in the scope of ff.h. */
|
||||
|
||||
|
||||
typedef enum {
|
||||
DRIVE_SD = 0,
|
||||
DRIVE_RAM = 1,
|
||||
DRIVE_EMMC = 2,
|
||||
DRIVE_BIS = 3,
|
||||
DRIVE_EMU = 4,
|
||||
DRIVE_BOOT1 = 5,
|
||||
DRIVE_BOOT1_1MB = 6,
|
||||
} DDRIVE;
|
||||
|
||||
/*--- End of configuration options ---*/
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <ianos/ianos.h>
|
||||
#include <libs/compr/blz.h>
|
||||
#include <libs/fatfs/ff.h>
|
||||
#include <storage/boot_storage.h>
|
||||
|
||||
#include "frontend/fe_emmc_tools.h"
|
||||
#include "frontend/gui.h"
|
||||
@@ -34,10 +35,10 @@ nyx_config n_cfg;
|
||||
hekate_config h_cfg;
|
||||
|
||||
const volatile ipl_ver_meta_t __attribute__((section ("._ipl_version"))) ipl_ver = {
|
||||
.magic = NYX_MAGIC,
|
||||
.magic = NYX_MAGIC,
|
||||
.version = (NYX_VER_MJ + '0') | ((NYX_VER_MN + '0') << 8) | ((NYX_VER_HF + '0') << 16) | ((NYX_VER_RL) << 24),
|
||||
.rsvd0 = 0,
|
||||
.rsvd1 = 0
|
||||
.rsvd0 = 0,
|
||||
.rsvd1 = 0
|
||||
};
|
||||
|
||||
volatile nyx_storage_t *nyx_str = (nyx_storage_t *)NYX_STORAGE_ADDR;
|
||||
@@ -134,7 +135,7 @@ lv_res_t launch_payload(lv_obj_t *list)
|
||||
strcpy(path,"bootloader/payloads/");
|
||||
strcat(path, filename);
|
||||
|
||||
if (!sd_mount())
|
||||
if (!boot_storage_mount())
|
||||
goto out;
|
||||
|
||||
FIL fp;
|
||||
@@ -174,7 +175,7 @@ lv_res_t launch_payload(lv_obj_t *list)
|
||||
|
||||
f_close(&fp);
|
||||
|
||||
sd_end();
|
||||
boot_storage_end();
|
||||
|
||||
if (size < 0x30000)
|
||||
{
|
||||
@@ -351,8 +352,8 @@ static void _show_errors(int sd_error)
|
||||
|
||||
if (*excp_enabled == EXCP_MAGIC || sd_error)
|
||||
{
|
||||
gfx_clear_grey(0);
|
||||
gfx_con_setpos(0, 0, 0);
|
||||
// gfx_clear_grey(0);
|
||||
// gfx_con_setpos(0, 0, 0);
|
||||
display_backlight_brightness(150, 1000);
|
||||
display_init_window_d_console();
|
||||
display_window_d_console_enable();
|
||||
@@ -440,13 +441,13 @@ void nyx_init_load_res()
|
||||
_show_errors(SD_NO_ERROR);
|
||||
|
||||
// Try 2 times to mount SD card.
|
||||
if (!sd_mount())
|
||||
if (!boot_storage_mount())
|
||||
{
|
||||
// Restore speed to SDR104.
|
||||
sd_end();
|
||||
boot_storage_end();
|
||||
|
||||
// Retry.
|
||||
if (!sd_mount())
|
||||
if (!boot_storage_mount())
|
||||
_show_errors(SD_MOUNT_ERROR); // Fatal.
|
||||
}
|
||||
|
||||
@@ -496,7 +497,7 @@ void nyx_init_load_res()
|
||||
nyx_load_bg_icons();
|
||||
|
||||
// Unmount FAT partition.
|
||||
sd_unmount();
|
||||
boot_storage_unmount();
|
||||
}
|
||||
|
||||
void ipl_main()
|
||||
|
||||
Reference in New Issue
Block a user