file based emummc on emmc
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
#include <libs/fatfs/ff.h>
|
||||
#include <gfx_utils.h>
|
||||
|
||||
// TODO: fast read/writes
|
||||
|
||||
static FIL active_file;
|
||||
// -0xff: none, -1: boot 0, -2: boot1, 0+: gpp
|
||||
static s32 active_file_idx;
|
||||
|
||||
@@ -29,11 +29,12 @@ extern u32 sd_power_cycle_time_start;
|
||||
|
||||
typedef enum _sdmmc_type
|
||||
{
|
||||
MMC_SD = 0,
|
||||
MMC_EMMC = 1,
|
||||
MMC_EMUMMC_FILE = 2,
|
||||
MMC_EMUMMC_RAW_SD = 3,
|
||||
MMC_EMUMMC_RAW_EMMC = 4,
|
||||
MMC_SD = 0,
|
||||
MMC_EMMC = 1,
|
||||
MMC_EMUMMC_FILE = 2,
|
||||
MMC_EMUMMC_RAW_SD = 3,
|
||||
MMC_EMUMMC_RAW_EMMC = 4,
|
||||
MMC_EMUMMC_FILE_EMMC = 5,
|
||||
|
||||
EMMC_GPP = 0,
|
||||
EMMC_BOOT0 = 1,
|
||||
|
||||
@@ -1926,7 +1926,15 @@ int usb_device_gadget_ums(usb_ctxt_t *usbs)
|
||||
|
||||
ums.lun.sdmmc = &emmc_sdmmc;
|
||||
ums.lun.storage = &emmc_storage;
|
||||
}else{
|
||||
}else if(usbs->type == MMC_EMUMMC_FILE_EMMC){
|
||||
if(!emmc_get_mounted()){
|
||||
ums.set_text(ums.label, "#FFDD00 Failed to init eMMC!#");
|
||||
res = 1;
|
||||
goto init_fail;
|
||||
}
|
||||
ums.lun.storage = NULL;
|
||||
ums.lun.sdmmc = NULL;
|
||||
} else{
|
||||
if (!emmc_initialize(false))
|
||||
{
|
||||
ums.set_text(ums.label, "#FFDD00 Failed to init eMMC!#");
|
||||
@@ -1967,6 +1975,7 @@ int usb_device_gadget_ums(usb_ctxt_t *usbs)
|
||||
ums.lun.num_sectors = ums.lun.storage->sec_cnt;
|
||||
break;
|
||||
case MMC_EMUMMC_FILE:
|
||||
case MMC_EMUMMC_FILE_EMMC:
|
||||
case MMC_EMUMMC_RAW_SD:
|
||||
case MMC_EMUMMC_RAW_EMMC:
|
||||
ums.set_text(ums.label, "#FFDD00 No sector count set for emuMMC!#");
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
//! fix the dram stuff and the pop ups
|
||||
|
||||
#include <fatfs_cfg.h>
|
||||
#include <libs/lvgl/lv_objx/lv_label.h>
|
||||
#include <mem/heap.h>
|
||||
#include <storage/boot_storage.h>
|
||||
@@ -37,6 +38,7 @@
|
||||
#include "../config.h"
|
||||
#include <libs/fatfs/diskio.h>
|
||||
#include <libs/fatfs/ff.h>
|
||||
#include <utils/sprintf.h>
|
||||
|
||||
#define OUT_FILENAME_SZ 128
|
||||
#define NAND_PATROL_SECTOR 0xC20
|
||||
@@ -45,10 +47,14 @@
|
||||
extern hekate_config h_cfg;
|
||||
extern volatile boot_cfg_t *b_cfg;
|
||||
|
||||
static int _emummc_resize_user(emmc_tool_gui_t *gui, u32 user_offset, u32 resized_cnt, sdmmc_storage_t *raw_based_storage, u32 raw_based_sector_offset, const char *file_based_path){
|
||||
static int _emummc_resize_user(emmc_tool_gui_t *gui, u32 user_offset, u32 resized_cnt, sdmmc_storage_t *raw_based_storage, u32 raw_based_sector_offset, const char *file_based_path, u8 drive){
|
||||
bool file_based = file_based_path != NULL;
|
||||
|
||||
sd_mount();
|
||||
if(drive == DRIVE_SD){
|
||||
sd_mount();
|
||||
}else{
|
||||
emmc_mount();
|
||||
}
|
||||
|
||||
s_printf(gui->txt_buf, "\nFormatting USER... ");
|
||||
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
|
||||
@@ -248,11 +254,21 @@ void save_emummc_cfg(u32 part_idx, u32 sector_start, const char *path, u8 drive)
|
||||
char lbuf[16];
|
||||
FIL fp;
|
||||
|
||||
if (f_open(&fp, "emuMMC/emummc.ini", FA_WRITE | FA_CREATE_ALWAYS) != FR_OK)
|
||||
int res = 0;
|
||||
|
||||
res = f_mkdir("emuMMC");
|
||||
if(res != FR_OK && res != FR_EXIST){
|
||||
return;
|
||||
}
|
||||
|
||||
res = f_open(&fp, "emuMMC/emummc.ini", FA_WRITE | FA_CREATE_ALWAYS);
|
||||
if (res != FR_OK){
|
||||
return;
|
||||
}
|
||||
|
||||
// Add config entry.
|
||||
f_puts("[emummc]\nenabled=", &fp);
|
||||
res = f_puts("[emummc]\nenabled=", &fp);
|
||||
gfx_printf("puts %d\n", res);
|
||||
if (part_idx && sector_start && drive == DRIVE_SD)
|
||||
{
|
||||
// 1: part. 1, 2: part. 2, 3: part. 3
|
||||
@@ -262,10 +278,13 @@ void save_emummc_cfg(u32 part_idx, u32 sector_start, const char *path, u8 drive)
|
||||
// 4: emmc raw based
|
||||
f_puts("4", &fp);
|
||||
}
|
||||
else if (path)
|
||||
else if (path && drive == DRIVE_SD)
|
||||
// 1: enabled, file based
|
||||
f_puts("1", &fp);
|
||||
else
|
||||
else if(path && drive == DRIVE_EMMC){
|
||||
// 4: enabled, emmc file based
|
||||
f_puts("4", &fp);
|
||||
}else
|
||||
// 0: disable
|
||||
f_puts("0", &fp);
|
||||
|
||||
@@ -390,7 +409,7 @@ static int _emummc_raw_derive_bis_keys(emmc_tool_gui_t *gui, u32 resized_count)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _dump_emummc_file_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_storage_t *storage, emmc_part_t *part, u32 resized_cnt)
|
||||
static int _dump_emummc_file_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_storage_t *storage, emmc_part_t *part, u32 resized_cnt, u8 drive)
|
||||
{
|
||||
static const u32 FAT32_FILESIZE_LIMIT = 0xFFFFFFFF;
|
||||
static const u32 SECTORS_TO_MIB_COEFF = 11;
|
||||
@@ -403,10 +422,21 @@ static int _dump_emummc_file_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_sto
|
||||
int res = 0;
|
||||
char *outFilename = sd_path;
|
||||
u32 sdPathLen = strlen(sd_path);
|
||||
u32 free_space;
|
||||
|
||||
FATFS *fs = drive == DRIVE_SD ? &sd_fs : &emmc_fs;
|
||||
if(drive == DRIVE_SD){
|
||||
free_space = (u32)(fs->free_clst * fs->csize >> SECTORS_TO_MIB_COEFF);
|
||||
s_printf(gui->txt_buf, "#96FF00 SD Card free space:# %d MiB\n#96FF00 Total size:# %d MiB\n\n",
|
||||
free_space,
|
||||
sectors_left >> SECTORS_TO_MIB_COEFF);
|
||||
}else{
|
||||
free_space = (u32)(fs->free_clst * fs->csize >> SECTORS_TO_MIB_COEFF);
|
||||
s_printf(gui->txt_buf, "#96FF00 eMMC free space:# %d MiB\n#96FF00 Total size:# %d MiB\n\n",
|
||||
free_space,
|
||||
sectors_left >> SECTORS_TO_MIB_COEFF);
|
||||
}
|
||||
|
||||
s_printf(gui->txt_buf, "#96FF00 SD Card free space:# %d MiB\n#96FF00 Total size:# %d MiB\n\n",
|
||||
(u32)(sd_fs.free_clst * sd_fs.csize >> SECTORS_TO_MIB_COEFF),
|
||||
sectors_left >> SECTORS_TO_MIB_COEFF);
|
||||
lv_label_ins_text(gui->label_info, LV_LABEL_POS_LAST, gui->txt_buf);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
@@ -415,7 +445,7 @@ static int _dump_emummc_file_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_sto
|
||||
manual_system_maintenance(true);
|
||||
|
||||
// Check if the USER partition or the RAW eMMC fits the sd card free space.
|
||||
if (sectors_left > (sd_fs.free_clst * sd_fs.csize))
|
||||
if (sectors_left > (fs->free_clst * fs->csize))
|
||||
{
|
||||
s_printf(gui->txt_buf, "\n#FFDD00 Not enough free space for file based emuMMC!#\n");
|
||||
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
|
||||
@@ -587,7 +617,7 @@ static int _dump_emummc_file_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_sto
|
||||
|
||||
if (res)
|
||||
{
|
||||
s_printf(gui->txt_buf, "\n#FF0000 Fatal error (%d) when writing to SD Card#\nPlease try again...\n", res);
|
||||
s_printf(gui->txt_buf, "\n#FF0000 Fatal error (%d) when writing to %s#\nPlease try again...\n", res, drive == DRIVE_SD ? "SD Card" : "eMMC");
|
||||
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
@@ -642,14 +672,14 @@ static int _dump_emummc_file_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_sto
|
||||
manual_system_maintenance(true);
|
||||
|
||||
sd_path[sdPathLen] = '\0';
|
||||
if(_emummc_resize_user(gui, user_offset, resized_cnt, NULL, 0, sd_path) != FR_OK){
|
||||
if(_emummc_resize_user(gui, user_offset, resized_cnt, NULL, 0, sd_path, drive) != FR_OK){
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void dump_emummc_file(emmc_tool_gui_t *gui, u32 resized_cnt)
|
||||
void dump_emummc_file(emmc_tool_gui_t *gui, u32 resized_cnt, u8 drive)
|
||||
{
|
||||
int res = 0;
|
||||
int base_len = 0;
|
||||
@@ -664,10 +694,20 @@ void dump_emummc_file(emmc_tool_gui_t *gui, u32 resized_cnt)
|
||||
|
||||
manual_system_maintenance(true);
|
||||
|
||||
if (!sd_mount())
|
||||
{
|
||||
lv_label_set_text(gui->label_info, "#FFDD00 Failed to init SD!#");
|
||||
goto out;
|
||||
boot_storage_mount();
|
||||
|
||||
if(drive == DRIVE_SD){
|
||||
if (!sd_mount())
|
||||
{
|
||||
lv_label_set_text(gui->label_info, "#FFDD00 Failed to init SD!#");
|
||||
goto out;
|
||||
}
|
||||
}else{
|
||||
if (!emmc_mount())
|
||||
{
|
||||
lv_label_set_text(gui->label_info, "#FFDD00 Failed to init eMMC!#");
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
lv_label_set_text(gui->label_info, "Checking for available free space...");
|
||||
@@ -694,20 +734,31 @@ void dump_emummc_file(emmc_tool_gui_t *gui, u32 resized_cnt)
|
||||
int i = 0;
|
||||
char sdPath[OUT_FILENAME_SZ];
|
||||
// Create Restore folders, if they do not exist.
|
||||
f_mkdir("sd:emuMMC");
|
||||
strcpy(sdPath, "sd:emuMMC/SD");
|
||||
base_len = strlen(sdPath);
|
||||
|
||||
if(drive == DRIVE_SD){
|
||||
strcpy(sdPath, "sd:emuMMC/SD");
|
||||
f_mkdir("sd:emuMMC");
|
||||
}else{
|
||||
strcpy(sdPath, "emmc:emuMMC/EMMC");
|
||||
f_mkdir("emmc:emuMMC");
|
||||
}
|
||||
|
||||
//also create on boot storage
|
||||
f_mkdir("emuMMC");
|
||||
|
||||
base_len = strlen(sdPath);
|
||||
for (int j = 0; j < 100; j++)
|
||||
{
|
||||
update_emummc_base_folder(sdPath, base_len, j);
|
||||
if (f_stat(sdPath, NULL) == FR_NO_FILE)
|
||||
break;
|
||||
}
|
||||
|
||||
f_mkdir(sdPath);
|
||||
f_mkdir(sdPath + (drive == DRIVE_SD ? 3 : 5));
|
||||
|
||||
strcat(sdPath, "/eMMC");
|
||||
f_mkdir(sdPath);
|
||||
|
||||
strcat(sdPath, "/");
|
||||
strcpy(gui->base_path, sdPath);
|
||||
|
||||
@@ -735,7 +786,7 @@ void dump_emummc_file(emmc_tool_gui_t *gui, u32 resized_cnt)
|
||||
emmc_set_partition(i + 1);
|
||||
|
||||
strcat(sdPath, bootPart.name);
|
||||
res = _dump_emummc_file_part(gui, sdPath, &emmc_storage, &bootPart, 0);
|
||||
res = _dump_emummc_file_part(gui, sdPath, &emmc_storage, &bootPart, 0, drive);
|
||||
|
||||
if (!res)
|
||||
{
|
||||
@@ -770,7 +821,7 @@ void dump_emummc_file(emmc_tool_gui_t *gui, u32 resized_cnt)
|
||||
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, txt_buf);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
res = _dump_emummc_file_part(gui, sdPath, &emmc_storage, &rawPart, resized_cnt);
|
||||
res = _dump_emummc_file_part(gui, sdPath, &emmc_storage, &rawPart, resized_cnt, drive);
|
||||
|
||||
if (!res)
|
||||
s_printf(txt_buf, "#FFDD00 Failed!#\n");
|
||||
@@ -789,13 +840,17 @@ out_failed:
|
||||
s_printf(txt_buf, "Time taken: %dm %ds.\nFinished!", timer / 60, timer % 60);
|
||||
gui->base_path[strlen(gui->base_path) - 5] = '\0';
|
||||
strcpy(sdPath, gui->base_path);
|
||||
strcat(sdPath, "file_based");
|
||||
if(drive == DRIVE_SD){
|
||||
strcat(sdPath, "file_based");
|
||||
}else{
|
||||
strcat(sdPath, "file_emmc_based");
|
||||
}
|
||||
FIL fp;
|
||||
f_open(&fp, sdPath + 3, FA_CREATE_ALWAYS | FA_WRITE);
|
||||
f_open(&fp, sdPath + (drive == DRIVE_SD ? 3 : 5) /* strip drive prefix*/, FA_CREATE_ALWAYS | FA_WRITE);
|
||||
f_close(&fp);
|
||||
|
||||
gui->base_path[strlen(gui->base_path) - 1] = 0;
|
||||
save_emummc_cfg(0, 0, gui->base_path, 0);
|
||||
save_emummc_cfg(0, 0, gui->base_path + (drive == DRIVE_SD ? 3 : 5), drive);
|
||||
}
|
||||
else
|
||||
s_printf(txt_buf, "Time taken: %dm %ds.", timer / 60, timer % 60);
|
||||
@@ -977,7 +1032,7 @@ static int _dump_emummc_raw_part(emmc_tool_gui_t *gui, int active_part, int part
|
||||
{
|
||||
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, "Done!\n");
|
||||
|
||||
if(_emummc_resize_user(gui, user_offset, resized_count, emu_storge, sd_sector_off, NULL) != FR_OK){
|
||||
if(_emummc_resize_user(gui, user_offset, resized_count, emu_storge, sd_sector_off, NULL, drive) != FR_OK){
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ typedef struct _emummc_cfg_t
|
||||
|
||||
void load_emummc_cfg(emummc_cfg_t *emu_info);
|
||||
void save_emummc_cfg(u32 part_idx, u32 sector_start, const char *path, u8 drive);
|
||||
void dump_emummc_file(emmc_tool_gui_t *gui, u32 resized_cnt);
|
||||
void dump_emummc_file(emmc_tool_gui_t *gui, u32 resized_cnt, u8 drive);
|
||||
void dump_emummc_raw(emmc_tool_gui_t *gui, int part_idx, u32 sector_start, u32 resized_count, u8 drive);
|
||||
void update_emummc_base_folder(char *outFilename, u32 sdPathLen, u32 currPartIdx);
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <libs/lvgl/lv_objx/lv_btnm.h>
|
||||
#include <libs/lvgl/lv_objx/lv_cont.h>
|
||||
#include <libs/lvgl/lv_objx/lv_label.h>
|
||||
#include <libs/lvgl/lv_objx/lv_list.h>
|
||||
#include <libs/lvgl/lv_objx/lv_mbox.h>
|
||||
#include <libs/lvgl/lv_objx/lv_slider.h>
|
||||
#include <memory_map.h>
|
||||
@@ -171,7 +172,7 @@ static void _create_window_emummc()
|
||||
emmc_tool_gui_ctxt.label_finish = label_finish;
|
||||
|
||||
if (emummc_part_cfg.file_based)
|
||||
dump_emummc_file(&emmc_tool_gui_ctxt, emummc_part_cfg.resized_cnt);
|
||||
dump_emummc_file(&emmc_tool_gui_ctxt, emummc_part_cfg.resized_cnt, emummc_part_cfg.drive);
|
||||
else
|
||||
dump_emummc_raw(&emmc_tool_gui_ctxt, emummc_part_cfg.part_idx, emummc_part_cfg.sector, emummc_part_cfg.resized_cnt, emummc_part_cfg.drive);
|
||||
|
||||
@@ -625,6 +626,8 @@ static lv_res_t _create_emummc_file_based_action(lv_obj_t *btns, const char *txt
|
||||
}
|
||||
|
||||
static void _create_mbox_emummc_file_based(){
|
||||
char *txt_buf = malloc(SZ_4K);
|
||||
|
||||
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);
|
||||
@@ -645,27 +648,39 @@ static void _create_mbox_emummc_file_based(){
|
||||
|
||||
gfx_printf("full: 0x%x\n", emmc_storage.sec_cnt);
|
||||
|
||||
char txt_buf[0x20];
|
||||
|
||||
sd_mount();
|
||||
FATFS *fs;
|
||||
if(emummc_part_cfg.drive == DRIVE_SD){
|
||||
sd_mount();
|
||||
fs = &sd_fs;
|
||||
f_getfree("sd:", &fs->free_clst, NULL);
|
||||
}else{
|
||||
emmc_mount();
|
||||
fs = &emmc_fs;
|
||||
f_getfree("emmc:", &fs->free_clst, NULL);
|
||||
}
|
||||
emmc_initialize(false);
|
||||
f_getfree("sd:", &sd_fs.free_clst, NULL);
|
||||
sd_unmount();
|
||||
if(emummc_part_cfg.drive == DRIVE_SD){
|
||||
sd_unmount();
|
||||
}else{
|
||||
emmc_unmount();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// leave 1gb free
|
||||
u32 available = sd_fs.free_clst * sd_fs.csize;
|
||||
u32 available = fs->free_clst * fs->csize;
|
||||
available >>= 11;
|
||||
available = available > (5 * 1024) ? available - (1 * 1024) : 0;
|
||||
|
||||
if(available == 0){
|
||||
lv_mbox_set_text(mbox, "#C7EA46 Select emuMMC size!#\n\n"
|
||||
"#FFDD00 Note:# Not enough free space on SD");
|
||||
s_printf(txt_buf, "#C7EA46 Select emuMMC size!#\n\n"
|
||||
"#FFDD00 Note:# Not enough free space on %s", emummc_part_cfg.drive == DRIVE_SD ? "SD" : "eMMC");
|
||||
lv_mbox_set_text(mbox, txt_buf);
|
||||
|
||||
}else if(value_full > available){
|
||||
lv_mbox_set_text(mbox, "#C7EA46 Select emuMMC size!#\n\n"
|
||||
"#FFDD00 Note:# Not enough space for full eMMC, \nUSER will be resized and formatted");
|
||||
s_printf(txt_buf, "#C7EA46 Select emuMMC size!#\n\n"
|
||||
"#FFDD00 Note:# Not enough space on %s for for full eMMC, \nUSER will be resized and formatted", emummc_part_cfg.drive == DRIVE_SD ? "SD" : "eMMC");
|
||||
lv_mbox_set_text(mbox, txt_buf);
|
||||
}else{
|
||||
lv_mbox_set_text(mbox, "#C7EA46 Select emuMMC size!#\n\n"
|
||||
"#FFDD00 Note:# Any value other than \"FULL\" will format USER");
|
||||
@@ -725,34 +740,109 @@ static void _create_mbox_emummc_file_based(){
|
||||
lv_mbox_add_btns(mbox, mbox_btns_ok, _create_emummc_file_based_action);
|
||||
}
|
||||
|
||||
|
||||
lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
emummc_part_cfg.file_based = true;
|
||||
}
|
||||
|
||||
static lv_res_t _create_emummc_action(lv_obj_t * btns, const char * txt)
|
||||
{
|
||||
static lv_res_t _create_emummc_select_file_type_action(lv_obj_t *btns, const char *txt){
|
||||
int btn_idx = lv_btnm_get_pressed(btns);
|
||||
// lv_obj_t *bg = lv_obj_get_parent(lv_obj_get_parent(btns));
|
||||
|
||||
memset(&emummc_part_cfg, 0, sizeof(emummc_part_cfg));
|
||||
|
||||
mbox_action(btns, txt);
|
||||
|
||||
switch (btn_idx)
|
||||
{
|
||||
memset(&emummc_part_cfg, 0, sizeof(emummc_part_cfg));
|
||||
|
||||
switch(btn_idx){
|
||||
case 0:
|
||||
// lv_obj_set_style(bg, &lv_style_transp);
|
||||
emummc_part_cfg.drive = DRIVE_SD;
|
||||
_create_mbox_emummc_file_based();
|
||||
break;
|
||||
case 1:
|
||||
_create_mbox_emummc_raw();
|
||||
emummc_part_cfg.drive = DRIVE_EMMC;
|
||||
_create_mbox_emummc_file_based();
|
||||
break;
|
||||
case 2:
|
||||
_create_mbox_emummc_emmc_raw();
|
||||
break;
|
||||
}
|
||||
|
||||
return LV_RES_INV;
|
||||
}
|
||||
|
||||
static lv_res_t _create_emummc_select_raw_type_action(lv_obj_t *btns, const char *txt){
|
||||
int btn_idx = lv_btnm_get_pressed(btns);
|
||||
|
||||
mbox_action(btns, txt);
|
||||
|
||||
memset(&emummc_part_cfg, 0, sizeof(emummc_part_cfg));
|
||||
|
||||
switch(btn_idx){
|
||||
case 0:
|
||||
_create_mbox_emummc_raw();
|
||||
break;
|
||||
case 1:
|
||||
_create_mbox_emummc_emmc_raw();
|
||||
break;
|
||||
case 2:
|
||||
break;
|
||||
}
|
||||
|
||||
return LV_RES_INV;
|
||||
}
|
||||
|
||||
static void _create_mbox_emummc_select_raw_type(){
|
||||
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);
|
||||
|
||||
static const char * mbox_btn_map[] = { "\222SD partition", "\222eMMC partition", "\222Cancel", "" };
|
||||
lv_obj_t * mbox = lv_mbox_create(dark_bg, NULL);
|
||||
lv_mbox_set_recolor_text(mbox, true);
|
||||
lv_obj_set_width(mbox, LV_HOR_RES / 9 * 6);
|
||||
|
||||
lv_mbox_set_text(mbox,
|
||||
"Welcome to #C7EA46 emuMMC# creation tool!\n\n"
|
||||
"Please choose what type of partition based emuMMC to create.");
|
||||
|
||||
lv_mbox_add_btns(mbox, mbox_btn_map, _create_emummc_select_raw_type_action);
|
||||
|
||||
lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_set_top(mbox, true);
|
||||
}
|
||||
|
||||
static void _create_mbox_emummc_select_file_type(){
|
||||
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);
|
||||
|
||||
static const char * mbox_btn_map[] = { "\222SD file", "\222eMMC file", "\222Cancel", "" };
|
||||
lv_obj_t * mbox = lv_mbox_create(dark_bg, NULL);
|
||||
lv_mbox_set_recolor_text(mbox, true);
|
||||
lv_obj_set_width(mbox, LV_HOR_RES / 9 * 6);
|
||||
|
||||
lv_mbox_set_text(mbox,
|
||||
"Welcome to #C7EA46 emuMMC# creation tool!\n\n"
|
||||
"Please choose what type of file based emuMMC to create.");
|
||||
|
||||
lv_mbox_add_btns(mbox, mbox_btn_map, _create_emummc_select_file_type_action);
|
||||
|
||||
lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_set_top(mbox, true);
|
||||
}
|
||||
|
||||
static lv_res_t _create_emummc_select_type_action(lv_obj_t *btns, const char *txt){
|
||||
int btn_idx = lv_btnm_get_pressed(btns);
|
||||
|
||||
mbox_action(btns, txt);
|
||||
|
||||
switch(btn_idx){
|
||||
case 0:
|
||||
_create_mbox_emummc_select_file_type();
|
||||
break;
|
||||
case 1:
|
||||
_create_mbox_emummc_select_raw_type();
|
||||
break;
|
||||
case 2:
|
||||
break;
|
||||
}
|
||||
|
||||
return LV_RES_INV;
|
||||
}
|
||||
@@ -766,7 +856,7 @@ static lv_res_t _create_mbox_emummc_create(lv_obj_t *btn)
|
||||
lv_obj_set_style(dark_bg, &mbox_darken);
|
||||
lv_obj_set_size(dark_bg, LV_HOR_RES, LV_VER_RES);
|
||||
|
||||
static const char * mbox_btn_map[] = { "\222SD File", "\222SD Partition", "\222eMMC Partition", "\222Cancel", "" };
|
||||
static const char * mbox_btn_map[] = { "\222File based", "\222Partition Based", "\222Cancel", "" };
|
||||
lv_obj_t * mbox = lv_mbox_create(dark_bg, NULL);
|
||||
lv_mbox_set_recolor_text(mbox, true);
|
||||
lv_obj_set_width(mbox, LV_HOR_RES / 9 * 6);
|
||||
@@ -774,10 +864,10 @@ static lv_res_t _create_mbox_emummc_create(lv_obj_t *btn)
|
||||
lv_mbox_set_text(mbox,
|
||||
"Welcome to #C7EA46 emuMMC# creation tool!\n\n"
|
||||
"Please choose what type of emuMMC you want to create.\n"
|
||||
"#FF8000 SD File# is saved as files in the SD FAT partition.\n"
|
||||
"#FF8000 SD# and #FF8000 eMMC Partition# is saved as raw image in an available partition.");
|
||||
"#FF8000 File based# is saved as files in\nthe SD or eMMC FAT partition.\n"
|
||||
"#FF8000 Partition based# is saved as raw image in a\navailable SD or eMMC partition.");
|
||||
|
||||
lv_mbox_add_btns(mbox, mbox_btn_map, _create_emummc_action);
|
||||
lv_mbox_add_btns(mbox, mbox_btn_map, _create_emummc_select_type_action);
|
||||
|
||||
lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_set_top(mbox, true);
|
||||
@@ -1496,13 +1586,28 @@ static lv_res_t _save_disable_emummc_cfg_action(lv_obj_t * btn)
|
||||
save_emummc_cfg(0, 0, NULL, 0);
|
||||
_create_emummc_saved_mbox();
|
||||
sd_unmount();
|
||||
boot_storage_unmount();
|
||||
|
||||
return LV_RES_INV;
|
||||
}
|
||||
|
||||
static lv_res_t _save_file_emummc_emmc_cfg_action(lv_obj_t *btn)
|
||||
{
|
||||
const char *btn_txt = lv_list_get_btn_text(btn);
|
||||
gfx_printf("save emu %s\n", btn_txt);
|
||||
save_emummc_cfg(0, 0, btn_txt, DRIVE_EMMC);
|
||||
_create_emummc_saved_mbox();
|
||||
sd_unmount();
|
||||
boot_storage_unmount();
|
||||
|
||||
return LV_RES_INV;
|
||||
}
|
||||
|
||||
static lv_res_t _save_file_emummc_cfg_action(lv_obj_t *btn)
|
||||
{
|
||||
save_emummc_cfg(0, 0, lv_list_get_btn_text(btn), 0);
|
||||
const char *btn_txt = lv_list_get_btn_text(btn);
|
||||
gfx_printf("save sd %s\n", btn_txt);
|
||||
save_emummc_cfg(0, 0, btn_txt, DRIVE_SD);
|
||||
_create_emummc_saved_mbox();
|
||||
sd_unmount();
|
||||
boot_storage_unmount();
|
||||
@@ -1632,6 +1737,7 @@ static lv_res_t _create_change_emummc_window(lv_obj_t *btn_caller)
|
||||
u32 file_based_idx = 0;
|
||||
|
||||
// Sanitize the directory list with sd file based ones.
|
||||
u8 file_based_drives[DIR_MAX_ENTRIES];
|
||||
while (emummc_img->dirlist->name[emummc_idx])
|
||||
{
|
||||
s_printf(path, "emuMMC/%s/file_based", emummc_img->dirlist->name[emummc_idx]);
|
||||
@@ -1640,6 +1746,16 @@ static lv_res_t _create_change_emummc_window(lv_obj_t *btn_caller)
|
||||
{
|
||||
char *tmp = emummc_img->dirlist->name[emummc_idx];
|
||||
memcpy(emummc_img->dirlist->name[file_based_idx], tmp, strlen(tmp) + 1);
|
||||
file_based_drives[file_based_idx] = DRIVE_SD;
|
||||
file_based_idx++;
|
||||
}
|
||||
|
||||
s_printf(path, "emuMMC/%s/file_emmc_based", emummc_img->dirlist->name[emummc_idx]);
|
||||
if (!f_stat(path, NULL))
|
||||
{
|
||||
char *tmp = emummc_img->dirlist->name[emummc_idx];
|
||||
memcpy(emummc_img->dirlist->name[file_based_idx], tmp, strlen(tmp) + 1);
|
||||
file_based_drives[file_based_idx] = DRIVE_EMMC;
|
||||
file_based_idx++;
|
||||
}
|
||||
emummc_idx++;
|
||||
@@ -1803,7 +1919,7 @@ out0:;
|
||||
lv_label_set_static_text(label_sep, "");
|
||||
|
||||
lv_obj_t *label_txt3 = lv_label_create(h2, NULL);
|
||||
lv_label_set_static_text(label_txt3, "SD File Based");
|
||||
lv_label_set_static_text(label_txt3, "SD/eMMC File Based");
|
||||
lv_obj_set_style(label_txt3, lv_theme_get_current()->label.prim);
|
||||
lv_obj_align(label_txt3, label_sep, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI * 2 / 9, -LV_DPI / 7);
|
||||
|
||||
@@ -1827,7 +1943,11 @@ out0:;
|
||||
{
|
||||
s_printf(path, "emuMMC/%s", emummc_img->dirlist->name[emummc_idx]);
|
||||
|
||||
lv_list_add(list_sd_based, NULL, path, _save_file_emummc_cfg_action);
|
||||
if(file_based_drives[emummc_idx] == DRIVE_SD){
|
||||
lv_list_add(list_sd_based, NULL, path, _save_file_emummc_cfg_action);
|
||||
}else{
|
||||
lv_list_add(list_sd_based, NULL, path, _save_file_emummc_emmc_cfg_action);
|
||||
}
|
||||
|
||||
emummc_idx++;
|
||||
}
|
||||
|
||||
@@ -615,7 +615,7 @@ static lv_res_t _ums_emummc(u32 part){
|
||||
load_emummc_cfg(&emu_info);
|
||||
if(emu_info.enabled){
|
||||
error = 0;
|
||||
if(emu_info.enabled == 4){
|
||||
if(emu_info.enabled == 4 && emu_info.sector){
|
||||
// emmc raw based
|
||||
if(!emmc_initialize(false)){
|
||||
error = 3;
|
||||
@@ -627,13 +627,25 @@ static lv_res_t _ums_emummc(u32 part){
|
||||
error = 4;
|
||||
}
|
||||
storage = &sd_storage;
|
||||
}else if(emu_info.enabled == 1 && !emu_info.sector){
|
||||
}else if((emu_info.enabled == 1 || emu_info.enabled == 4) && !emu_info.sector){
|
||||
// sd file based
|
||||
if(!sd_mount()){
|
||||
error = 4;
|
||||
if(emu_info.enabled == 1){
|
||||
if(!sd_mount()){
|
||||
error = 4;
|
||||
}
|
||||
}else{
|
||||
if(!emmc_mount()){
|
||||
error = 3;
|
||||
}
|
||||
}
|
||||
if(error == 0){
|
||||
file_based = true;
|
||||
strcpy(path, emu_info.path);
|
||||
if(emu_info.enabled == 1){
|
||||
strcpy(path, "sd:");
|
||||
}else{
|
||||
strcpy(path, "emmc:");
|
||||
}
|
||||
strcat(path, emu_info.path);
|
||||
strcat(path, "/eMMC/");
|
||||
if(!emummc_storage_file_based_init(path)){
|
||||
error = 8;
|
||||
@@ -651,12 +663,14 @@ static lv_res_t _ums_emummc(u32 part){
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
error = 2;
|
||||
}
|
||||
}else{
|
||||
error = 2;
|
||||
}
|
||||
|
||||
if(error == 0 && emu_info.enabled == 1){
|
||||
if(error == 0 && emu_info.enabled){
|
||||
error = 6;
|
||||
if(file_based){
|
||||
usbs.offset = 0;
|
||||
@@ -713,7 +727,7 @@ static lv_res_t _ums_emummc(u32 part){
|
||||
_create_mbox_ums_error(error);
|
||||
}else{
|
||||
if(file_based){
|
||||
usbs.type = MMC_EMUMMC_FILE;
|
||||
usbs.type = emu_info.enabled == 4 ? MMC_EMUMMC_FILE_EMMC : MMC_EMUMMC_FILE;
|
||||
}else{
|
||||
usbs.type = emu_info.enabled == 4 ? MMC_EMUMMC_RAW_EMMC : MMC_EMUMMC_RAW_SD;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user