[Nyx] Introducing hekate GUI, named Nyx!
Version 0.8.0. Expect dragons!
This commit is contained in:
1442
nyx/nyx_gui/frontend/fe_emmc_tools.c
Normal file
1442
nyx/nyx_gui/frontend/fe_emmc_tools.c
Normal file
File diff suppressed because it is too large
Load Diff
35
nyx/nyx_gui/frontend/fe_emmc_tools.h
Normal file
35
nyx/nyx_gui/frontend/fe_emmc_tools.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2018 Rajko Stojadinovic
|
||||
* Copyright (c) 2018 CTCaer
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _FE_EMMC_TOOLS_H_
|
||||
#define _FE_EMMC_TOOLS_H_
|
||||
|
||||
#include "gui.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PART_BOOT = (1 << 0),
|
||||
PART_SYSTEM = (1 << 1),
|
||||
PART_USER = (1 << 2),
|
||||
PART_RAW = (1 << 3),
|
||||
PART_GP_ALL = (1 << 7)
|
||||
} emmcPartType_t;
|
||||
|
||||
void dump_emmc_selected(emmcPartType_t dumpType, emmc_tool_gui_t *gui);
|
||||
void restore_emmc_selected(emmcPartType_t restoreType, emmc_tool_gui_t *gui);
|
||||
|
||||
#endif
|
||||
703
nyx/nyx_gui/frontend/fe_emummc_tools.c
Normal file
703
nyx/nyx_gui/frontend/fe_emummc_tools.c
Normal file
@@ -0,0 +1,703 @@
|
||||
/*
|
||||
* Copyright (c) 2018 naehrwert
|
||||
* Copyright (c) 2018 Rajko Stojadinovic
|
||||
* Copyright (c) 2018-2019 CTCaer
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//! fix the dram stuff and the pop ups
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "gui.h"
|
||||
#include "fe_emummc_tools.h"
|
||||
#include "../config/config.h"
|
||||
#include "../libs/fatfs/ff.h"
|
||||
#include "../mem/heap.h"
|
||||
#include "../sec/se.h"
|
||||
#include "../storage/nx_emmc.h"
|
||||
#include "../storage/sdmmc.h"
|
||||
#include "../utils/sprintf.h"
|
||||
#include "../utils/util.h"
|
||||
|
||||
#define EMMC_BUF_ALIGNED 0xB5000000
|
||||
#define SDXC_BUF_ALIGNED 0xB6000000
|
||||
#define MIXD_BUF_ALIGNED 0xB7000000
|
||||
|
||||
#define NUM_SECTORS_PER_ITER 8192 // 4MB Cache.
|
||||
#define OUT_FILENAME_SZ 128
|
||||
#define SHA256_SZ 0x20
|
||||
|
||||
#define MBR_1ST_PART_TYPE_OFF 0x1C2
|
||||
|
||||
extern sdmmc_t sd_sdmmc;
|
||||
extern sdmmc_storage_t sd_storage;
|
||||
extern FATFS sd_fs;
|
||||
extern hekate_config h_cfg;
|
||||
|
||||
extern bool sd_mount();
|
||||
extern void sd_unmount(bool deinit);
|
||||
|
||||
void save_emummc_cfg(u32 part_idx, u32 sector_start, const char *path)
|
||||
{
|
||||
sd_mount();
|
||||
|
||||
char lbuf[16];
|
||||
FIL fp;
|
||||
|
||||
if (f_open(&fp, "emuMMC/emummc.ini", FA_WRITE | FA_CREATE_ALWAYS) != FR_OK)
|
||||
return;
|
||||
|
||||
// Add config entry.
|
||||
f_puts("[emummc]\nenabled=", &fp);
|
||||
if (part_idx && sector_start)
|
||||
{
|
||||
itoa(part_idx, lbuf, 10);
|
||||
f_puts(lbuf, &fp);
|
||||
}
|
||||
else if(path)
|
||||
f_puts("1", &fp);
|
||||
else
|
||||
f_puts("0", &fp);
|
||||
|
||||
if (!sector_start)
|
||||
f_puts("\nsector=0x0", &fp);
|
||||
else
|
||||
{
|
||||
f_puts("\nsector=0x", &fp);
|
||||
itoa(sector_start, lbuf, 16);
|
||||
f_puts(lbuf, &fp);
|
||||
}
|
||||
if (path)
|
||||
{
|
||||
f_puts("\npath=", &fp);
|
||||
f_puts(path, &fp);
|
||||
}
|
||||
f_puts("\nid=0x0000", &fp);
|
||||
f_puts("\nnintendo_path=", &fp);
|
||||
if (path)
|
||||
{
|
||||
f_puts(path, &fp);
|
||||
f_puts("/Nintendo\n", &fp);
|
||||
}
|
||||
else
|
||||
f_puts("\n", &fp);
|
||||
|
||||
f_close(&fp);
|
||||
}
|
||||
|
||||
static void _update_emummc_base_folder(char *outFilename, u32 sdPathLen, u32 currPartIdx)
|
||||
{
|
||||
if (currPartIdx < 10)
|
||||
{
|
||||
outFilename[sdPathLen] = '0';
|
||||
itoa(currPartIdx, &outFilename[sdPathLen + 1], 10);
|
||||
}
|
||||
else
|
||||
itoa(currPartIdx, &outFilename[sdPathLen], 10);
|
||||
}
|
||||
|
||||
static int _dump_emummc_file_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_storage_t *storage, emmc_part_t *part)
|
||||
{
|
||||
static const u32 FAT32_FILESIZE_LIMIT = 0xFFFFFFFF;
|
||||
static const u32 SECTORS_TO_MIB_COEFF = 11;
|
||||
|
||||
u32 multipartSplitSize = 0xFE000000;
|
||||
u32 totalSectors = part->lba_end - part->lba_start + 1;
|
||||
u32 currPartIdx = 0;
|
||||
u32 numSplitParts = 0;
|
||||
int res = 0;
|
||||
char *outFilename = sd_path;
|
||||
u32 sdPathLen = strlen(sd_path);
|
||||
|
||||
s_printf(gui->txt_buf, "#96FF00 SD Card free space:# %d MiB\n#96FF00 Total backup size:# %d MiB\n\n",
|
||||
sd_fs.free_clst * sd_fs.csize >> SECTORS_TO_MIB_COEFF,
|
||||
totalSectors >> SECTORS_TO_MIB_COEFF);
|
||||
lv_label_ins_text(gui->label_info, LV_LABEL_POS_LAST, gui->txt_buf);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
lv_bar_set_value(gui->bar, 0);
|
||||
lv_label_set_text(gui->label_pct, " "SYMBOL_DOT" 0%");
|
||||
manual_system_maintenance(true);
|
||||
|
||||
// Check if the USER partition or the RAW eMMC fits the sd card free space.
|
||||
if (totalSectors > (sd_fs.free_clst * sd_fs.csize))
|
||||
{
|
||||
s_printf(gui->txt_buf, "\n#FFDD00 Not enough free space for Partial Backup!#\n");
|
||||
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Check if filesystem is FAT32 or the free space is smaller and backup in parts.
|
||||
if (totalSectors > (FAT32_FILESIZE_LIMIT / NX_EMMC_BLOCKSIZE))
|
||||
{
|
||||
u32 multipartSplitSectors = multipartSplitSize / NX_EMMC_BLOCKSIZE;
|
||||
numSplitParts = (totalSectors + multipartSplitSectors - 1) / multipartSplitSectors;
|
||||
|
||||
// Continue from where we left, if Partial Backup in progress.
|
||||
_update_emummc_base_folder(outFilename, sdPathLen, 0);
|
||||
}
|
||||
|
||||
FIL fp;
|
||||
s_printf(gui->txt_buf, "#96FF00 Filepath:#\n%s\n#96FF00 Filename:# #FF8000 %s#",
|
||||
gui->base_path, outFilename + strlen(gui->base_path));
|
||||
lv_label_ins_text(gui->label_info, LV_LABEL_POS_LAST, gui->txt_buf);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
res = f_open(&fp, outFilename, FA_CREATE_ALWAYS | FA_WRITE);
|
||||
if (res)
|
||||
{
|
||||
s_printf(gui->txt_buf, "\n#FF0000 Error (%d) while creating#\n#FFDD00 %s#\n", res, outFilename);
|
||||
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
u8 *buf = (u8 *)MIXD_BUF_ALIGNED;
|
||||
|
||||
u32 lba_curr = part->lba_start;
|
||||
u32 bytesWritten = 0;
|
||||
u32 prevPct = 200;
|
||||
int retryCount = 0;
|
||||
DWORD *clmt = NULL;
|
||||
|
||||
u64 totalSize = (u64)((u64)totalSectors << 9);
|
||||
if (totalSize <= FAT32_FILESIZE_LIMIT)
|
||||
clmt = f_expand_cltbl(&fp, 0x400000, totalSize);
|
||||
else
|
||||
clmt = f_expand_cltbl(&fp, 0x400000, MIN(totalSize, multipartSplitSize));
|
||||
|
||||
u32 num = 0;
|
||||
u32 pct = 0;
|
||||
|
||||
lv_obj_set_opa_scale(gui->bar, LV_OPA_COVER);
|
||||
lv_obj_set_opa_scale(gui->label_pct, LV_OPA_COVER);
|
||||
while (totalSectors > 0)
|
||||
{
|
||||
if (numSplitParts != 0 && bytesWritten >= multipartSplitSize)
|
||||
{
|
||||
f_close(&fp);
|
||||
free(clmt);
|
||||
memset(&fp, 0, sizeof(fp));
|
||||
currPartIdx++;
|
||||
|
||||
_update_emummc_base_folder(outFilename, sdPathLen, currPartIdx);
|
||||
|
||||
// Create next part.
|
||||
s_printf(gui->txt_buf, "%s#", outFilename + strlen(gui->base_path));
|
||||
lv_label_ins_text(gui->label_info, strlen(lv_label_get_text(gui->label_info)) - 3, gui->txt_buf);
|
||||
lv_label_cut_text(gui->label_info, strlen(lv_label_get_text(gui->label_info)) - 3, 3);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
res = f_open(&fp, outFilename, FA_CREATE_ALWAYS | FA_WRITE);
|
||||
if (res)
|
||||
{
|
||||
s_printf(gui->txt_buf, "#FF0000 Error (%d) while creating#\n#FFDD00 %s#\n", res, outFilename);
|
||||
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bytesWritten = 0;
|
||||
|
||||
totalSize = (u64)((u64)totalSectors << 9);
|
||||
clmt = f_expand_cltbl(&fp, 0x400000, MIN(totalSize, multipartSplitSize));
|
||||
}
|
||||
|
||||
retryCount = 0;
|
||||
num = MIN(totalSectors, NUM_SECTORS_PER_ITER);
|
||||
while (!sdmmc_storage_read(storage, lba_curr, num, buf))
|
||||
{
|
||||
s_printf(gui->txt_buf,
|
||||
"#FFDD00 Error reading %d blocks @ LBA %08X,#\n"
|
||||
"#FFDD00 from eMMC (try %d). #",
|
||||
num, lba_curr, ++retryCount);
|
||||
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
msleep(150);
|
||||
if (retryCount >= 3)
|
||||
{
|
||||
s_printf(gui->txt_buf, "#FF0000 Aborting...#\nPlease try again...\n");
|
||||
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
f_close(&fp);
|
||||
free(clmt);
|
||||
f_unlink(outFilename);
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
s_printf(gui->txt_buf, "#FFDD00 Retrying...#\n");
|
||||
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
|
||||
manual_system_maintenance(true);
|
||||
}
|
||||
}
|
||||
res = f_write_fast(&fp, buf, NX_EMMC_BLOCKSIZE * num);
|
||||
|
||||
if (res)
|
||||
{
|
||||
s_printf(gui->txt_buf, "#FF0000 Fatal error (%d) when writing to SD Card#\nPlease try again...\n", res);
|
||||
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
f_close(&fp);
|
||||
free(clmt);
|
||||
f_unlink(outFilename);
|
||||
|
||||
return 0;
|
||||
}
|
||||
pct = (u64)((u64)(lba_curr - part->lba_start) * 100u) / (u64)(part->lba_end - part->lba_start);
|
||||
if (pct != prevPct)
|
||||
{
|
||||
lv_bar_set_value(gui->bar, pct);
|
||||
s_printf(gui->txt_buf, " "SYMBOL_DOT" %d%%", pct);
|
||||
lv_label_set_text(gui->label_pct, gui->txt_buf);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
prevPct = pct;
|
||||
}
|
||||
|
||||
lba_curr += num;
|
||||
totalSectors -= num;
|
||||
bytesWritten += num * NX_EMMC_BLOCKSIZE;
|
||||
|
||||
// Force a flush after a lot of data if not splitting.
|
||||
if (numSplitParts == 0 && bytesWritten >= multipartSplitSize)
|
||||
{
|
||||
f_sync(&fp);
|
||||
bytesWritten = 0;
|
||||
}
|
||||
}
|
||||
lv_bar_set_value(gui->bar, 100);
|
||||
lv_label_set_text(gui->label_pct, " "SYMBOL_DOT" 100%");
|
||||
manual_system_maintenance(true);
|
||||
|
||||
// Backup operation ended successfully.
|
||||
f_close(&fp);
|
||||
free(clmt);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void dump_emummc_file(emmc_tool_gui_t *gui)
|
||||
{
|
||||
FILINFO fno;
|
||||
int res = 0;
|
||||
int base_len = 0;
|
||||
u32 timer = 0;
|
||||
//! TODO switch to 800MHz
|
||||
manual_system_maintenance(true);
|
||||
|
||||
char *txt_buf = (char *)malloc(0x1000);
|
||||
gui->txt_buf = txt_buf;
|
||||
s_printf(txt_buf, "");
|
||||
lv_label_set_array_text(gui->label_log, txt_buf, 0x1000);
|
||||
|
||||
if (!sd_mount())
|
||||
{
|
||||
lv_label_set_static_text(gui->label_info, "#FFDD00 Failed to init SD!#");
|
||||
goto out;
|
||||
}
|
||||
|
||||
lv_label_set_static_text(gui->label_info, "Checking for available free space...");
|
||||
manual_system_maintenance(true);
|
||||
|
||||
// Get SD Card free space for Partial Backup.
|
||||
f_getfree("", &sd_fs.free_clst, NULL);
|
||||
|
||||
sdmmc_storage_t storage;
|
||||
sdmmc_t sdmmc;
|
||||
if (!sdmmc_storage_init_mmc(&storage, &sdmmc, SDMMC_4, SDMMC_BUS_WIDTH_8, 4))
|
||||
{
|
||||
lv_label_set_static_text(gui->label_info, "#FFDD00 Failed to init eMMC!#");
|
||||
goto out;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
char sdPath[OUT_FILENAME_SZ];
|
||||
// Create Restore folders, if they do not exist.
|
||||
f_mkdir("emuMMC");
|
||||
strcpy(sdPath, "emuMMC/SD");
|
||||
base_len = strlen(sdPath);
|
||||
gui->base_path = (char *)malloc(OUT_FILENAME_SZ);
|
||||
|
||||
for (int j = 0; j < 100; j++)
|
||||
{
|
||||
_update_emummc_base_folder(sdPath, base_len, j);
|
||||
if(f_stat(sdPath, &fno) == FR_NO_FILE)
|
||||
break;
|
||||
}
|
||||
|
||||
f_mkdir(sdPath);
|
||||
strcat(sdPath, "/eMMC");
|
||||
f_mkdir(sdPath);
|
||||
strcat(sdPath, "/");
|
||||
strcpy(gui->base_path, sdPath);
|
||||
|
||||
timer = get_tmr_s();
|
||||
const u32 BOOT_PART_SIZE = storage.ext_csd.boot_mult << 17;
|
||||
|
||||
emmc_part_t bootPart;
|
||||
memset(&bootPart, 0, sizeof(bootPart));
|
||||
bootPart.lba_start = 0;
|
||||
bootPart.lba_end = (BOOT_PART_SIZE / NX_EMMC_BLOCKSIZE) - 1;
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
memcpy(bootPart.name, "BOOT", 5);
|
||||
bootPart.name[4] = (u8)('0' + i);
|
||||
bootPart.name[5] = 0;
|
||||
|
||||
s_printf(txt_buf, "#00DDFF %02d: %s#\n#00DDFF Range: 0x%08X - 0x%08X#\n\n",
|
||||
i, bootPart.name, bootPart.lba_start, bootPart.lba_end);
|
||||
lv_label_set_array_text(gui->label_info, txt_buf, 0x1000);
|
||||
s_printf(txt_buf, "%02d: %s... ", i, bootPart.name);
|
||||
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, txt_buf);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
sdmmc_storage_set_mmc_partition(&storage, i + 1);
|
||||
|
||||
strcat(sdPath, bootPart.name);
|
||||
res = _dump_emummc_file_part(gui, sdPath, &storage, &bootPart);
|
||||
|
||||
if (!res)
|
||||
{
|
||||
s_printf(txt_buf, "#FFDD00 Failed!#\n");
|
||||
goto out_failed;
|
||||
}
|
||||
else
|
||||
s_printf(txt_buf, "Done!\n");
|
||||
|
||||
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, txt_buf);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
strcpy(sdPath, gui->base_path);
|
||||
}
|
||||
|
||||
// Get GP partition size dynamically.
|
||||
sdmmc_storage_set_mmc_partition(&storage, 0);
|
||||
|
||||
// Get GP partition size dynamically.
|
||||
const u32 RAW_AREA_NUM_SECTORS = storage.sec_cnt;
|
||||
|
||||
emmc_part_t rawPart;
|
||||
memset(&rawPart, 0, sizeof(rawPart));
|
||||
rawPart.lba_start = 0;
|
||||
rawPart.lba_end = RAW_AREA_NUM_SECTORS - 1;
|
||||
strcpy(rawPart.name, "GPP");
|
||||
{
|
||||
s_printf(txt_buf, "#00DDFF %02d: %s#\n#00DDFF Range: 0x%08X - 0x%08X#\n\n",
|
||||
i, rawPart.name, rawPart.lba_start, rawPart.lba_end);
|
||||
lv_label_set_array_text(gui->label_info, txt_buf, 0x1000);
|
||||
s_printf(txt_buf, "%02d: %s... ", i, rawPart.name);
|
||||
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, txt_buf);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
res = _dump_emummc_file_part(gui, sdPath, &storage, &rawPart);
|
||||
|
||||
if (!res)
|
||||
s_printf(txt_buf, "#FFDD00 Failed!#\n");
|
||||
else
|
||||
s_printf(txt_buf, "Done!\n");
|
||||
|
||||
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, txt_buf);
|
||||
manual_system_maintenance(true);
|
||||
}
|
||||
|
||||
out_failed:
|
||||
timer = get_tmr_s() - timer;
|
||||
sdmmc_storage_end(&storage);
|
||||
|
||||
if (res)
|
||||
{
|
||||
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");
|
||||
FIL fp;
|
||||
f_open(&fp, sdPath, 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);
|
||||
}
|
||||
else
|
||||
s_printf(txt_buf, "Time taken: %dm %ds.", timer / 60, timer % 60);
|
||||
|
||||
lv_label_set_array_text(gui->label_finish, txt_buf, 0x1000);
|
||||
|
||||
out:
|
||||
free(txt_buf);
|
||||
free(gui->base_path);
|
||||
sd_unmount(false);
|
||||
}
|
||||
|
||||
static int _dump_emummc_raw_part(emmc_tool_gui_t *gui, int active_part, int part_idx, u32 sd_part_off, sdmmc_storage_t *storage, emmc_part_t *part)
|
||||
{
|
||||
u32 totalSectors = part->lba_end - part->lba_start + 1;
|
||||
|
||||
s_printf(gui->txt_buf, "\n\n\n");
|
||||
lv_label_ins_text(gui->label_info, LV_LABEL_POS_LAST, gui->txt_buf);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
lv_bar_set_value(gui->bar, 0);
|
||||
lv_label_set_text(gui->label_pct, " "SYMBOL_DOT" 0%");
|
||||
manual_system_maintenance(true);
|
||||
|
||||
|
||||
s_printf(gui->txt_buf, "#96FF00 Base folder:#\n%s\n#96FF00 Partition offset:# #FF8000 0x%08X#",
|
||||
gui->base_path, sd_part_off);
|
||||
lv_label_ins_text(gui->label_info, LV_LABEL_POS_LAST, gui->txt_buf);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
u8 *buf = (u8 *)MIXD_BUF_ALIGNED;
|
||||
u32 sd_sector_off = sd_part_off + (0x2000 * active_part);
|
||||
u32 lba_curr = part->lba_start;
|
||||
u32 prevPct = 200;
|
||||
int retryCount = 0;
|
||||
|
||||
u32 num = 0;
|
||||
u32 pct = 0;
|
||||
|
||||
lv_obj_set_opa_scale(gui->bar, LV_OPA_COVER);
|
||||
lv_obj_set_opa_scale(gui->label_pct, LV_OPA_COVER);
|
||||
|
||||
while (totalSectors > 0)
|
||||
{
|
||||
retryCount = 0;
|
||||
num = MIN(totalSectors, NUM_SECTORS_PER_ITER);
|
||||
|
||||
// Read data from eMMC.
|
||||
while (!sdmmc_storage_read(storage, lba_curr, num, buf))
|
||||
{
|
||||
s_printf(gui->txt_buf,
|
||||
"#FFDD00 Error reading %d blocks @LBA %08X,#\n"
|
||||
"#FFDD00 from eMMC (try %d). #",
|
||||
num, lba_curr, ++retryCount);
|
||||
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
msleep(150);
|
||||
if (retryCount >= 3)
|
||||
{
|
||||
s_printf(gui->txt_buf, "#FF0000 Aborting...#\nPlease try again...\n");
|
||||
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
s_printf(gui->txt_buf, "#FFDD00 Retrying...#\n");
|
||||
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
|
||||
manual_system_maintenance(true);
|
||||
}
|
||||
}
|
||||
retryCount = 0;
|
||||
|
||||
// Write data to SD card.
|
||||
while (!sdmmc_storage_write(&sd_storage, sd_sector_off + lba_curr, num, buf))
|
||||
{
|
||||
s_printf(gui->txt_buf,
|
||||
"#FFDD00 Error writing %d blocks @LBA %08X,#\n"
|
||||
"#FFDD00 to SD (try %d). #",
|
||||
num, lba_curr, ++retryCount);
|
||||
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
msleep(150);
|
||||
if (retryCount >= 3)
|
||||
{
|
||||
s_printf(gui->txt_buf, "#FF0000 Aborting...#\nPlease try again...\n");
|
||||
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
s_printf(gui->txt_buf, "#FFDD00 Retrying...#\n");
|
||||
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
|
||||
manual_system_maintenance(true);
|
||||
}
|
||||
}
|
||||
pct = (u64)((u64)(lba_curr - part->lba_start) * 100u) / (u64)(part->lba_end - part->lba_start);
|
||||
if (pct != prevPct)
|
||||
{
|
||||
lv_bar_set_value(gui->bar, pct);
|
||||
s_printf(gui->txt_buf, " "SYMBOL_DOT" %d%%", pct);
|
||||
lv_label_set_text(gui->label_pct, gui->txt_buf);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
prevPct = pct;
|
||||
}
|
||||
|
||||
lba_curr += num;
|
||||
totalSectors -= num;
|
||||
}
|
||||
lv_bar_set_value(gui->bar, 100);
|
||||
lv_label_set_text(gui->label_pct, " "SYMBOL_DOT" 100%");
|
||||
manual_system_maintenance(true);
|
||||
|
||||
// Hide the partition.
|
||||
if (active_part == 2)
|
||||
{
|
||||
u8 *mbr = (u8 *)malloc(0x200);
|
||||
sdmmc_storage_read(&sd_storage, 0, 1, mbr);
|
||||
mbr[MBR_1ST_PART_TYPE_OFF + (0x10 * part_idx)] = 0xEE;
|
||||
sdmmc_storage_write(&sd_storage, 0, 1, mbr);
|
||||
free(mbr);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void dump_emummc_raw(emmc_tool_gui_t *gui, int part_idx, u32 sector_start)
|
||||
{
|
||||
int res = 0;
|
||||
u32 timer = 0;
|
||||
//! TODO switch to 800MHz
|
||||
manual_system_maintenance(true);
|
||||
|
||||
char *txt_buf = (char *)malloc(0x1000);
|
||||
gui->txt_buf = txt_buf;
|
||||
s_printf(txt_buf, "");
|
||||
lv_label_set_array_text(gui->label_log, txt_buf, 0x1000);
|
||||
|
||||
if (!sd_mount())
|
||||
{
|
||||
lv_label_set_static_text(gui->label_info, "#FFDD00 Failed to init SD!#");
|
||||
goto out;
|
||||
}
|
||||
|
||||
sdmmc_storage_t storage;
|
||||
sdmmc_t sdmmc;
|
||||
if (!sdmmc_storage_init_mmc(&storage, &sdmmc, SDMMC_4, SDMMC_BUS_WIDTH_8, 4))
|
||||
{
|
||||
lv_label_set_static_text(gui->label_info, "#FFDD00 Failed to init eMMC!#");
|
||||
goto out;
|
||||
}
|
||||
|
||||
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);
|
||||
gui->base_path = (char *)malloc(OUT_FILENAME_SZ);
|
||||
f_mkdir(sdPath);
|
||||
strcat(sdPath, "/");
|
||||
strcpy(gui->base_path, sdPath);
|
||||
|
||||
timer = get_tmr_s();
|
||||
const u32 BOOT_PART_SIZE = storage.ext_csd.boot_mult << 17;
|
||||
|
||||
emmc_part_t bootPart;
|
||||
memset(&bootPart, 0, sizeof(bootPart));
|
||||
bootPart.lba_start = 0;
|
||||
bootPart.lba_end = (BOOT_PART_SIZE / NX_EMMC_BLOCKSIZE) - 1;
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
memcpy(bootPart.name, "BOOT", 5);
|
||||
bootPart.name[4] = (u8)('0' + i);
|
||||
bootPart.name[5] = 0;
|
||||
|
||||
s_printf(txt_buf, "#00DDFF %02d: %s#\n#00DDFF Range: 0x%08X - 0x%08X#\n\n",
|
||||
i, bootPart.name, bootPart.lba_start, bootPart.lba_end);
|
||||
lv_label_set_array_text(gui->label_info, txt_buf, 0x1000);
|
||||
s_printf(txt_buf, "%02d: %s... ", i, bootPart.name);
|
||||
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, txt_buf);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
sdmmc_storage_set_mmc_partition(&storage, i + 1);
|
||||
|
||||
strcat(sdPath, bootPart.name);
|
||||
res = _dump_emummc_raw_part(gui, i, part_idx, sector_start, &storage, &bootPart);
|
||||
|
||||
if (!res)
|
||||
{
|
||||
s_printf(txt_buf, "#FFDD00 Failed!#\n");
|
||||
goto out_failed;
|
||||
}
|
||||
else
|
||||
s_printf(txt_buf, "Done!\n");
|
||||
|
||||
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, txt_buf);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
strcpy(sdPath, gui->base_path);
|
||||
}
|
||||
|
||||
sdmmc_storage_set_mmc_partition(&storage, 0);
|
||||
|
||||
// Get GP partition size dynamically.
|
||||
const u32 RAW_AREA_NUM_SECTORS = storage.sec_cnt;
|
||||
|
||||
emmc_part_t rawPart;
|
||||
memset(&rawPart, 0, sizeof(rawPart));
|
||||
rawPart.lba_start = 0;
|
||||
rawPart.lba_end = RAW_AREA_NUM_SECTORS - 1;
|
||||
strcpy(rawPart.name, "GPP");
|
||||
{
|
||||
s_printf(txt_buf, "#00DDFF %02d: %s#\n#00DDFF Range: 0x%08X - 0x%08X#\n\n",
|
||||
i, rawPart.name, rawPart.lba_start, rawPart.lba_end);
|
||||
lv_label_set_array_text(gui->label_info, txt_buf, 0x1000);
|
||||
s_printf(txt_buf, "%02d: %s... ", i, rawPart.name);
|
||||
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, txt_buf);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
res = _dump_emummc_raw_part(gui, 2, part_idx, sector_start, &storage, &rawPart);
|
||||
|
||||
if (!res)
|
||||
s_printf(txt_buf, "#FFDD00 Failed!#\n");
|
||||
else
|
||||
s_printf(txt_buf, "Done!\n");
|
||||
|
||||
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, txt_buf);
|
||||
manual_system_maintenance(true);
|
||||
}
|
||||
|
||||
out_failed:
|
||||
timer = get_tmr_s() - timer;
|
||||
sdmmc_storage_end(&storage);
|
||||
|
||||
if (res)
|
||||
{
|
||||
s_printf(txt_buf, "Time taken: %dm %ds.\nFinished!", timer / 60, timer % 60);
|
||||
strcpy(sdPath, gui->base_path);
|
||||
strcat(sdPath, "raw_based");
|
||||
FIL fp;
|
||||
f_open(&fp, sdPath, FA_CREATE_ALWAYS | FA_WRITE);
|
||||
f_write(&fp, §or_start, 4, NULL);
|
||||
f_close(&fp);
|
||||
|
||||
gui->base_path[strlen(gui->base_path) - 1] = 0;
|
||||
save_emummc_cfg(part_idx, sector_start, gui->base_path);
|
||||
}
|
||||
else
|
||||
s_printf(txt_buf, "Time taken: %dm %ds.", timer / 60, timer % 60);
|
||||
|
||||
lv_label_set_array_text(gui->label_finish, txt_buf, 0x1000);
|
||||
|
||||
out:
|
||||
free(txt_buf);
|
||||
free(gui->base_path);
|
||||
sd_unmount(false);
|
||||
}
|
||||
27
nyx/nyx_gui/frontend/fe_emummc_tools.h
Normal file
27
nyx/nyx_gui/frontend/fe_emummc_tools.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) 2018 Rajko Stojadinovic
|
||||
* Copyright (c) 2018 CTCaer
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _FE_EMUMMC_TOOLS_H_
|
||||
#define _FE_EMUMMC_TOOLS_H_
|
||||
|
||||
#include "gui.h"
|
||||
|
||||
void save_emummc_cfg(u32 part_idx, u32 sector_start, const char *path);
|
||||
void dump_emummc_file(emmc_tool_gui_t *gui);
|
||||
void dump_emummc_raw(emmc_tool_gui_t *gui, int part_idx, u32 sector_start);
|
||||
|
||||
#endif
|
||||
2107
nyx/nyx_gui/frontend/gui.c
Normal file
2107
nyx/nyx_gui/frontend/gui.c
Normal file
File diff suppressed because it is too large
Load Diff
63
nyx/nyx_gui/frontend/gui.h
Normal file
63
nyx/nyx_gui/frontend/gui.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2019 CTCaer
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _GUI_H_
|
||||
#define _GUI_H_
|
||||
|
||||
#include "../libs/lvgl/lvgl.h"
|
||||
|
||||
typedef struct _emmc_tool_gui_t
|
||||
{
|
||||
lv_obj_t *label_log;
|
||||
lv_obj_t *label_info;
|
||||
lv_obj_t *label_pct;
|
||||
lv_obj_t *label_finish;
|
||||
lv_obj_t *bar;
|
||||
lv_style_t *bar_teal_bg;
|
||||
lv_style_t *bar_white_ind;
|
||||
char *txt_buf;
|
||||
char *base_path;
|
||||
bool raw_emummc;
|
||||
} emmc_tool_gui_t;
|
||||
|
||||
lv_style_t hint_small_style;
|
||||
lv_style_t hint_small_style_white;
|
||||
lv_style_t monospace_text;
|
||||
|
||||
lv_obj_t *payload_list;
|
||||
|
||||
lv_img_dsc_t *icon_switch;
|
||||
lv_img_dsc_t *icon_payload;
|
||||
lv_img_dsc_t *icon_lakka;
|
||||
|
||||
lv_img_dsc_t *hekate_bg;
|
||||
|
||||
lv_style_t btn_transp_rel, btn_transp_pr, btn_transp_tgl_rel, btn_transp_tgl_pr;
|
||||
lv_style_t ddlist_transp_bg, ddlist_transp_sel;
|
||||
lv_style_t tabview_btn_pr, tabview_btn_tgl_pr;
|
||||
|
||||
lv_style_t mbox_darken;
|
||||
|
||||
lv_img_dsc_t *bmp_to_lvimg_obj(const char *path);
|
||||
lv_res_t mbox_action(lv_obj_t * btns, const char * txt);
|
||||
void nyx_window_toggle_buttons(lv_obj_t *win, bool disable);
|
||||
lv_obj_t *nyx_create_standard_window(const char *win_title);
|
||||
void nyx_create_onoff_button(lv_theme_t *th, lv_obj_t *parent, lv_obj_t *btn, const char *btn_name, lv_action_t action, bool transparent);
|
||||
lv_res_t nyx_generic_onoff_toggle(lv_obj_t *btn);
|
||||
void manual_system_maintenance(bool refresh);
|
||||
void nyx_load_and_run();
|
||||
|
||||
#endif
|
||||
458
nyx/nyx_gui/frontend/gui_emmc_tools.c
Normal file
458
nyx/nyx_gui/frontend/gui_emmc_tools.c
Normal file
@@ -0,0 +1,458 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2019 CTCaer
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "gui.h"
|
||||
#include "gui_emmc_tools.h"
|
||||
#include "fe_emmc_tools.h"
|
||||
#include "../config/config.h"
|
||||
#include "../hos/pkg1.h"
|
||||
#include "../hos/pkg2.h"
|
||||
#include "../hos/hos.h"
|
||||
#include "../hos/sept.h"
|
||||
#include "../libs/fatfs/ff.h"
|
||||
#include "../mem/heap.h"
|
||||
#include "../sec/se.h"
|
||||
#include "../soc/fuse.h"
|
||||
#include "../storage/nx_emmc.h"
|
||||
#include "../storage/sdmmc.h"
|
||||
#include "../utils/sprintf.h"
|
||||
#include "../utils/util.h"
|
||||
|
||||
extern boot_cfg_t b_cfg;
|
||||
extern hekate_config h_cfg;
|
||||
|
||||
extern bool sd_mount();
|
||||
extern int sd_save_to_file(void *buf, u32 size, const char *filename);
|
||||
extern void emmcsn_path_impl(char *path, char *sub_dir, char *filename, sdmmc_storage_t *storage);
|
||||
|
||||
#pragma GCC push_options
|
||||
#pragma GCC target ("thumb")
|
||||
|
||||
typedef struct _emmc_backup_buttons_t
|
||||
{
|
||||
lv_obj_t *emmc_boot;
|
||||
lv_obj_t *emmc_raw_gpp;
|
||||
lv_obj_t *emmc_sys;
|
||||
lv_obj_t *emmc_usr;
|
||||
bool raw_emummc;
|
||||
bool restore;
|
||||
} emmc_backup_buttons_t;
|
||||
|
||||
static emmc_backup_buttons_t emmc_btn_ctxt;
|
||||
|
||||
static void _create_window_backup_restore(emmcPartType_t type, const char* win_label)
|
||||
{
|
||||
emmc_tool_gui_t emmc_tool_gui_ctxt;
|
||||
|
||||
emmc_tool_gui_ctxt.raw_emummc = emmc_btn_ctxt.raw_emummc;
|
||||
|
||||
lv_obj_t *win = nyx_create_standard_window(win_label);
|
||||
|
||||
//Disable buttons.
|
||||
nyx_window_toggle_buttons(win, true);
|
||||
|
||||
// Create important info container.
|
||||
lv_obj_t *h1 = lv_cont_create(win, NULL);
|
||||
lv_cont_set_fit(h1, false, true);
|
||||
lv_obj_set_width(h1, (LV_HOR_RES / 9) * 5);
|
||||
lv_obj_set_click(h1, false);
|
||||
lv_cont_set_layout(h1, LV_LAYOUT_OFF);
|
||||
|
||||
static lv_style_t h_style;
|
||||
lv_style_copy(&h_style, lv_cont_get_style(h1));
|
||||
h_style.body.main_color = LV_COLOR_HEX(0x1d1d1d);
|
||||
h_style.body.grad_color = h_style.body.main_color;
|
||||
h_style.body.opa = LV_OPA_COVER;
|
||||
|
||||
// Create log container.
|
||||
lv_obj_t *h2 = lv_cont_create(win, h1);
|
||||
lv_cont_set_style(h2, &h_style);
|
||||
lv_cont_set_fit(h2, false, false);
|
||||
lv_obj_set_size(h2, (LV_HOR_RES / 11) * 4, LV_DPI * 5);
|
||||
lv_cont_set_layout(h2, LV_LAYOUT_OFF);
|
||||
lv_obj_align(h2, h1, LV_ALIGN_OUT_RIGHT_TOP, 0, LV_DPI / 5);
|
||||
|
||||
lv_obj_t *label_log = lv_label_create(h2, NULL);
|
||||
lv_label_set_recolor(label_log, true);
|
||||
lv_obj_set_style(label_log, &monospace_text);
|
||||
lv_label_set_long_mode(label_log, LV_LABEL_LONG_BREAK);
|
||||
lv_label_set_static_text(label_log, "");
|
||||
lv_obj_set_width(label_log, lv_obj_get_width(h2));
|
||||
lv_obj_align(label_log, h2, LV_ALIGN_IN_TOP_LEFT, LV_DPI / 10, LV_DPI / 10);
|
||||
emmc_tool_gui_ctxt.label_log = label_log;
|
||||
|
||||
lv_obj_t *label_sep = lv_label_create(h1, NULL);
|
||||
lv_label_set_static_text(label_sep, "");
|
||||
|
||||
// Create info elements.
|
||||
lv_obj_t *label_info = lv_label_create(h1, NULL);
|
||||
lv_label_set_recolor(label_info, true);
|
||||
lv_obj_set_width(label_info, lv_obj_get_width(h1));
|
||||
lv_label_set_static_text(label_info, "\n\n\n\n\n\n\n\n\n");
|
||||
lv_obj_set_style(label_info, lv_theme_get_current()->label.prim);
|
||||
lv_obj_align(label_info, label_sep, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI / 4, LV_DPI / 10);
|
||||
emmc_tool_gui_ctxt.label_info = label_info;
|
||||
|
||||
lv_style_t *bar_teal_bg, *bar_white_ind;
|
||||
bar_teal_bg = (lv_style_t *)malloc(sizeof(lv_style_t));
|
||||
bar_white_ind = (lv_style_t *)malloc(sizeof(lv_style_t));
|
||||
|
||||
lv_style_copy(bar_teal_bg, lv_theme_get_current()->bar.bg);
|
||||
bar_teal_bg->body.main_color = LV_COLOR_HEX(0x005a47);
|
||||
bar_teal_bg->body.grad_color = bar_teal_bg->body.main_color;
|
||||
|
||||
lv_style_copy(bar_white_ind, lv_theme_get_current()->bar.indic);
|
||||
bar_white_ind->body.main_color = LV_COLOR_HEX(0xF0F0F0);
|
||||
bar_white_ind->body.grad_color = bar_white_ind->body.main_color;
|
||||
|
||||
emmc_tool_gui_ctxt.bar_teal_bg = bar_teal_bg;
|
||||
emmc_tool_gui_ctxt.bar_white_ind = bar_white_ind;
|
||||
|
||||
lv_obj_t * bar = lv_bar_create(h1, NULL);
|
||||
lv_obj_set_size(bar, LV_DPI * 38 / 10, LV_DPI / 5);
|
||||
lv_bar_set_range(bar, 0, 100);
|
||||
lv_bar_set_value(bar, 0);
|
||||
lv_obj_align(bar, label_info, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 8);
|
||||
lv_obj_set_opa_scale(bar, LV_OPA_0);
|
||||
lv_obj_set_opa_scale_enable(bar, true);
|
||||
emmc_tool_gui_ctxt.bar = bar;
|
||||
|
||||
lv_obj_t *label_pct= lv_label_create(h1, NULL);
|
||||
lv_label_set_recolor(label_pct, true);
|
||||
lv_label_set_static_text(label_pct, " "SYMBOL_DOT" 0%");
|
||||
lv_obj_set_style(label_pct, lv_theme_get_current()->label.prim);
|
||||
lv_obj_align(label_pct, bar, LV_ALIGN_OUT_RIGHT_MID, LV_DPI / 20, 0);
|
||||
lv_obj_set_opa_scale(label_pct, LV_OPA_0);
|
||||
lv_obj_set_opa_scale_enable(label_pct, true);
|
||||
emmc_tool_gui_ctxt.label_pct = label_pct;
|
||||
|
||||
lv_obj_t *label_finish = lv_label_create(h1, NULL);
|
||||
lv_label_set_recolor(label_finish, true);
|
||||
lv_label_set_static_text(label_finish, "");
|
||||
lv_obj_set_style(label_finish, lv_theme_get_current()->label.prim);
|
||||
lv_obj_align(label_finish, bar, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI * 9 / 20);
|
||||
emmc_tool_gui_ctxt.label_finish = label_finish;
|
||||
|
||||
if (!emmc_btn_ctxt.restore)
|
||||
dump_emmc_selected(type, &emmc_tool_gui_ctxt);
|
||||
else
|
||||
restore_emmc_selected(type, &emmc_tool_gui_ctxt);
|
||||
|
||||
nyx_window_toggle_buttons(win, false);
|
||||
|
||||
free(bar_teal_bg);
|
||||
free(bar_white_ind);
|
||||
}
|
||||
|
||||
static lv_res_t _emmc_backup_buttons_decider(lv_obj_t *btn)
|
||||
{
|
||||
char *win_label = lv_label_get_text(lv_obj_get_child(btn, NULL));
|
||||
|
||||
if (emmc_btn_ctxt.emmc_boot == btn)
|
||||
_create_window_backup_restore(PART_BOOT, win_label);
|
||||
else if (emmc_btn_ctxt.emmc_raw_gpp == btn)
|
||||
_create_window_backup_restore(PART_RAW, win_label);
|
||||
else if (emmc_btn_ctxt.emmc_sys == btn)
|
||||
{
|
||||
if (!emmc_btn_ctxt.restore)
|
||||
_create_window_backup_restore(PART_SYSTEM, win_label);
|
||||
else
|
||||
_create_window_backup_restore(PART_GP_ALL, win_label);
|
||||
}
|
||||
else if (!emmc_btn_ctxt.restore && emmc_btn_ctxt.emmc_usr == btn)
|
||||
_create_window_backup_restore(PART_USER, win_label);
|
||||
|
||||
return LV_RES_OK;
|
||||
}
|
||||
|
||||
static lv_res_t _emmc_backup_buttons_raw_toggle(lv_obj_t *btn)
|
||||
{
|
||||
nyx_generic_onoff_toggle(btn);
|
||||
|
||||
lv_obj_set_click(emmc_btn_ctxt.emmc_boot, true);
|
||||
lv_btn_set_state(emmc_btn_ctxt.emmc_boot, LV_BTN_STATE_REL);
|
||||
lv_obj_set_click(emmc_btn_ctxt.emmc_raw_gpp, true);
|
||||
lv_btn_set_state(emmc_btn_ctxt.emmc_raw_gpp, LV_BTN_STATE_REL);
|
||||
|
||||
lv_obj_set_click(emmc_btn_ctxt.emmc_sys, true);
|
||||
lv_btn_set_state(emmc_btn_ctxt.emmc_sys, LV_BTN_STATE_REL);
|
||||
|
||||
// Backup/Restore from and to eMMC.
|
||||
if (!(lv_btn_get_state(btn) & LV_BTN_STATE_TGL_REL))
|
||||
{
|
||||
if (!emmc_btn_ctxt.restore)
|
||||
lv_label_set_static_text(lv_obj_get_child(emmc_btn_ctxt.emmc_boot, NULL), SYMBOL_UPLOAD" eMMC BOOT0 & BOOT1");
|
||||
else
|
||||
lv_label_set_static_text(lv_obj_get_child(emmc_btn_ctxt.emmc_boot, NULL), SYMBOL_DOWNLOAD" eMMC BOOT0 & BOOT1");
|
||||
lv_obj_realign(emmc_btn_ctxt.emmc_boot);
|
||||
|
||||
if (!emmc_btn_ctxt.restore)
|
||||
lv_label_set_static_text(lv_obj_get_child(emmc_btn_ctxt.emmc_raw_gpp, NULL), SYMBOL_DOWNLOAD" eMMC RAW GPP");
|
||||
else
|
||||
lv_label_set_static_text(lv_obj_get_child(emmc_btn_ctxt.emmc_raw_gpp, NULL), SYMBOL_DOWNLOAD" eMMC RAW GPP");
|
||||
lv_obj_realign(emmc_btn_ctxt.emmc_raw_gpp);
|
||||
|
||||
if (!emmc_btn_ctxt.restore)
|
||||
lv_label_set_static_text(lv_obj_get_child(emmc_btn_ctxt.emmc_sys, NULL), SYMBOL_MODULES" eMMC SYS");
|
||||
else
|
||||
lv_label_set_static_text(lv_obj_get_child(emmc_btn_ctxt.emmc_sys, NULL), SYMBOL_MODULES" eMMC ALL");
|
||||
lv_obj_realign(emmc_btn_ctxt.emmc_sys);
|
||||
|
||||
if (!emmc_btn_ctxt.restore)
|
||||
{
|
||||
lv_label_set_static_text(lv_obj_get_child(emmc_btn_ctxt.emmc_usr, NULL), SYMBOL_MODULES_ALT" eMMC USER");
|
||||
lv_obj_realign(emmc_btn_ctxt.emmc_usr);
|
||||
|
||||
lv_obj_set_click(emmc_btn_ctxt.emmc_usr, true);
|
||||
lv_btn_set_state(emmc_btn_ctxt.emmc_usr, LV_BTN_STATE_REL);
|
||||
}
|
||||
|
||||
emmc_btn_ctxt.raw_emummc = false;
|
||||
}
|
||||
else // Backup/Restore from and to emuMMC.
|
||||
{
|
||||
if (!emmc_btn_ctxt.restore)
|
||||
{
|
||||
lv_label_set_static_text(lv_obj_get_child(emmc_btn_ctxt.emmc_boot, NULL), SYMBOL_UPLOAD" SD emuMMC BOOT0 & BOOT1");
|
||||
lv_obj_set_click(emmc_btn_ctxt.emmc_boot, false);
|
||||
lv_btn_set_state(emmc_btn_ctxt.emmc_boot, LV_BTN_STATE_INA);
|
||||
}
|
||||
else
|
||||
lv_label_set_static_text(lv_obj_get_child(emmc_btn_ctxt.emmc_boot, NULL), SYMBOL_DOWNLOAD" SD emuMMC BOOT0 & BOOT1");
|
||||
lv_obj_realign(emmc_btn_ctxt.emmc_boot);
|
||||
|
||||
if (!emmc_btn_ctxt.restore)
|
||||
{
|
||||
lv_label_set_static_text(lv_obj_get_child(emmc_btn_ctxt.emmc_raw_gpp, NULL), SYMBOL_DOWNLOAD" SD emuMMC RAW GPP");
|
||||
lv_obj_set_click(emmc_btn_ctxt.emmc_raw_gpp, false);
|
||||
lv_btn_set_state(emmc_btn_ctxt.emmc_raw_gpp, LV_BTN_STATE_INA);
|
||||
}
|
||||
else
|
||||
lv_label_set_static_text(lv_obj_get_child(emmc_btn_ctxt.emmc_raw_gpp, NULL), SYMBOL_DOWNLOAD" SD emuMMC RAW GPP");
|
||||
lv_obj_realign(emmc_btn_ctxt.emmc_raw_gpp);
|
||||
|
||||
lv_obj_set_click(emmc_btn_ctxt.emmc_sys, false);
|
||||
lv_btn_set_state(emmc_btn_ctxt.emmc_sys, LV_BTN_STATE_INA);
|
||||
|
||||
if (!emmc_btn_ctxt.restore)
|
||||
{
|
||||
lv_obj_set_click(emmc_btn_ctxt.emmc_usr, false);
|
||||
lv_btn_set_state(emmc_btn_ctxt.emmc_usr, LV_BTN_STATE_INA);
|
||||
}
|
||||
|
||||
emmc_btn_ctxt.raw_emummc = true;
|
||||
}
|
||||
|
||||
return LV_RES_OK;
|
||||
}
|
||||
|
||||
lv_res_t create_window_backup_restore_tool(lv_obj_t *btn)
|
||||
{
|
||||
lv_obj_t *win;
|
||||
|
||||
emmc_btn_ctxt.restore = false;
|
||||
if (strcmp(lv_label_get_text(lv_obj_get_child(btn, NULL)), SYMBOL_UPLOAD" Backup eMMC"))
|
||||
emmc_btn_ctxt.restore = true;
|
||||
|
||||
if (!emmc_btn_ctxt.restore)
|
||||
win = nyx_create_standard_window(SYMBOL_SD" Backup");
|
||||
else
|
||||
win = nyx_create_standard_window(SYMBOL_SD" Restore");
|
||||
|
||||
static lv_style_t h_style;
|
||||
lv_style_copy(&h_style, &lv_style_transp);
|
||||
h_style.body.padding.inner = 0;
|
||||
h_style.body.padding.hor = LV_DPI - (LV_DPI / 4);
|
||||
h_style.body.padding.ver = LV_DPI / 9;
|
||||
|
||||
// Create Full container.
|
||||
lv_obj_t *h1 = lv_cont_create(win, NULL);
|
||||
lv_cont_set_style(h1, &h_style);
|
||||
lv_cont_set_fit(h1, false, true);
|
||||
lv_obj_set_width(h1, (LV_HOR_RES / 9) * 4);
|
||||
lv_obj_set_click(h1, false);
|
||||
lv_cont_set_layout(h1, LV_LAYOUT_OFF);
|
||||
|
||||
lv_obj_t *label_sep = lv_label_create(h1, NULL);
|
||||
lv_label_set_static_text(label_sep, "");
|
||||
|
||||
lv_obj_t *label_txt = lv_label_create(h1, NULL);
|
||||
lv_label_set_static_text(label_txt, "Full");
|
||||
lv_obj_set_style(label_txt, lv_theme_get_current()->label.prim);
|
||||
lv_obj_align(label_txt, label_sep, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI / 4, -LV_DPI * 3 / 10);
|
||||
|
||||
lv_obj_t *line_sep = lv_line_create(h1, NULL);
|
||||
static const lv_point_t line_pp[] = { {0, 0}, { LV_HOR_RES - (LV_DPI - (LV_DPI / 4)) * 2, 0} };
|
||||
lv_line_set_points(line_sep, line_pp, 2);
|
||||
lv_line_set_style(line_sep, lv_theme_get_current()->line.decor);
|
||||
lv_obj_align(line_sep, label_txt, LV_ALIGN_OUT_BOTTOM_LEFT, -(LV_DPI / 4), LV_DPI / 8);
|
||||
|
||||
// Create BOOT0 & BOOT1 button.
|
||||
lv_obj_t *btn1 = lv_btn_create(h1, NULL);
|
||||
lv_obj_t *label_btn = lv_label_create(btn1, NULL);
|
||||
lv_btn_set_fit(btn1, true, true);
|
||||
if (!emmc_btn_ctxt.restore)
|
||||
lv_label_set_static_text(label_btn, SYMBOL_UPLOAD" eMMC BOOT0 & BOOT1");
|
||||
else
|
||||
lv_label_set_static_text(label_btn, SYMBOL_DOWNLOAD" eMMC BOOT0 & BOOT1");
|
||||
|
||||
lv_obj_align(btn1, line_sep, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI / 4, LV_DPI / 4);
|
||||
lv_btn_set_action(btn1, LV_BTN_ACTION_CLICK, _emmc_backup_buttons_decider);
|
||||
emmc_btn_ctxt.emmc_boot = btn1;
|
||||
|
||||
lv_obj_t *label_txt2 = lv_label_create(h1, NULL);
|
||||
lv_label_set_recolor(label_txt2, true);
|
||||
if (!emmc_btn_ctxt.restore)
|
||||
{
|
||||
lv_label_set_static_text(label_txt2,
|
||||
"Allows you to backup your BOOT physical partitions.\n"
|
||||
"They contain your BCT, keys and various package1.\n"
|
||||
"#FF8000 These are paired with the RAW GPP backup.#");
|
||||
}
|
||||
else
|
||||
{
|
||||
lv_label_set_static_text(label_txt2,
|
||||
"Allows you to restore your BOOT physical partitions.\n"
|
||||
"They contain your BCT, keys and various package1.\n"
|
||||
"#FF8000 These are paired with the RAW GPP restore.#");
|
||||
}
|
||||
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 RAW GPP button.
|
||||
lv_obj_t *btn2 = lv_btn_create(h1, btn1);
|
||||
label_btn = lv_label_create(btn2, NULL);
|
||||
if (!emmc_btn_ctxt.restore)
|
||||
lv_label_set_static_text(label_btn, SYMBOL_UPLOAD" eMMC RAW GPP");
|
||||
else
|
||||
lv_label_set_static_text(label_btn, SYMBOL_DOWNLOAD" eMMC RAW GPP");
|
||||
lv_obj_align(btn2, label_txt2, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 2);
|
||||
lv_btn_set_action(btn2, LV_BTN_ACTION_CLICK, _emmc_backup_buttons_decider);
|
||||
emmc_btn_ctxt.emmc_raw_gpp= btn2;
|
||||
|
||||
label_txt2 = lv_label_create(h1, NULL);
|
||||
lv_label_set_recolor(label_txt2, true);
|
||||
if (!emmc_btn_ctxt.restore)
|
||||
{
|
||||
lv_label_set_static_text(label_txt2,
|
||||
"Allows you to backup your GPP physical partition.\n"
|
||||
"It contains, CAL0, various package2, SYSTEM, USER, etc.\n"
|
||||
"#FF8000 This is paired with the BOOT0/1 backups.#");
|
||||
}
|
||||
else
|
||||
{
|
||||
lv_label_set_static_text(label_txt2,
|
||||
"Allows you to restore your GPP physical partition.\n"
|
||||
"It contains, CAL0, various package2, SYSTEM, USER, etc.\n"
|
||||
"#FF8000 This is paired with the BOOT0/1 restore.#");
|
||||
}
|
||||
lv_obj_set_style(label_txt2, &hint_small_style);
|
||||
lv_obj_align(label_txt2, btn2, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 3);
|
||||
|
||||
// Create GPP Partitions container.
|
||||
lv_obj_t *h2 = lv_cont_create(win, NULL);
|
||||
lv_cont_set_style(h2, &h_style);
|
||||
lv_cont_set_fit(h2, false, true);
|
||||
lv_obj_set_width(h2, (LV_HOR_RES / 9) * 4);
|
||||
lv_obj_set_click(h2, false);
|
||||
lv_cont_set_layout(h2, LV_LAYOUT_OFF);
|
||||
lv_obj_align(h2, h1, LV_ALIGN_OUT_RIGHT_TOP, LV_DPI * 17 / 29, 0);
|
||||
|
||||
label_sep = lv_label_create(h2, NULL);
|
||||
lv_label_set_static_text(label_sep, "");
|
||||
|
||||
lv_obj_t *label_txt3 = lv_label_create(h2, NULL);
|
||||
lv_label_set_static_text(label_txt3, "GPP Partitions");
|
||||
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 / 4, -LV_DPI * 4 / 21);
|
||||
|
||||
line_sep = lv_line_create(h2, line_sep);
|
||||
lv_obj_align(line_sep, label_txt3, LV_ALIGN_OUT_BOTTOM_LEFT, -(LV_DPI / 4), LV_DPI / 8);
|
||||
|
||||
// Create SYS/ALL button.
|
||||
lv_obj_t *btn3 = lv_btn_create(h2, NULL);
|
||||
label_btn = lv_label_create(btn3, NULL);
|
||||
lv_btn_set_fit(btn3, true, true);
|
||||
if (!emmc_btn_ctxt.restore)
|
||||
lv_label_set_static_text(label_btn, SYMBOL_MODULES" eMMC SYS");
|
||||
else
|
||||
lv_label_set_static_text(label_btn, SYMBOL_MODULES" eMMC ALL");
|
||||
lv_obj_align(btn3, line_sep, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI / 4, LV_DPI / 4);
|
||||
lv_btn_set_action(btn3, LV_BTN_ACTION_CLICK, _emmc_backup_buttons_decider);
|
||||
emmc_btn_ctxt.emmc_sys = btn3;
|
||||
|
||||
lv_obj_t *label_txt4 = lv_label_create(h2, NULL);
|
||||
lv_label_set_recolor(label_txt4, true);
|
||||
if (!emmc_btn_ctxt.restore)
|
||||
{
|
||||
lv_label_set_static_text(label_txt4,
|
||||
"Allows you to backup the partitions from RAW GPP except\n"
|
||||
"USER. It contains, CAL0, various package2, SYSTEM, etc.\n"
|
||||
"#FF8000 This is an incomplete backup.#");
|
||||
}
|
||||
else
|
||||
{
|
||||
lv_label_set_static_text(label_txt4,
|
||||
"Allows you to restore ALL partitions from RAW GPP\n"
|
||||
"It contains, CAL0, various package2, SYSTEM, USER, etc.\n");
|
||||
}
|
||||
|
||||
lv_obj_set_style(label_txt4, &hint_small_style);
|
||||
lv_obj_align(label_txt4, btn3, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 3);
|
||||
|
||||
// Create USER button.
|
||||
if (!emmc_btn_ctxt.restore)
|
||||
{
|
||||
lv_obj_t *btn4 = lv_btn_create(h2, btn1);
|
||||
label_btn = lv_label_create(btn4, NULL);
|
||||
lv_label_set_static_text(label_btn, SYMBOL_MODULES_ALT" eMMC USER");
|
||||
lv_obj_align(btn4, label_txt4, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 2);
|
||||
lv_btn_set_action(btn4, LV_BTN_ACTION_CLICK, _emmc_backup_buttons_decider);
|
||||
emmc_btn_ctxt.emmc_usr = btn4;
|
||||
|
||||
label_txt4 = lv_label_create(h2, NULL);
|
||||
lv_label_set_recolor(label_txt4, true);
|
||||
lv_label_set_static_text(label_txt4,
|
||||
"Allows you to backup the USER partition from RAW GPP.\n"
|
||||
"#FF8000 This is an incomplete backup.#\n");
|
||||
lv_obj_set_style(label_txt4, &hint_small_style);
|
||||
lv_obj_align(label_txt4, btn4, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
emmc_btn_ctxt.emmc_usr = NULL;
|
||||
}
|
||||
|
||||
// Create eMMC/emuMMC On/Off button.
|
||||
lv_obj_t *h3 = lv_cont_create(win, NULL);
|
||||
lv_cont_set_style(h3, &h_style);
|
||||
lv_cont_set_fit(h3, false, true);
|
||||
lv_obj_set_width(h3, (LV_HOR_RES / 10) * 4);
|
||||
lv_obj_set_click(h3, false);
|
||||
lv_cont_set_layout(h3, LV_LAYOUT_OFF);
|
||||
lv_obj_align(h3, h1, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI * 38 / 11, LV_DPI / 7);
|
||||
|
||||
lv_obj_t *sd_emummc_raw = lv_btn_create(h3, NULL);
|
||||
nyx_create_onoff_button(lv_theme_get_current(), h3,
|
||||
sd_emummc_raw, SYMBOL_SD" SD emuMMC Raw Partition", _emmc_backup_buttons_raw_toggle, false);
|
||||
emmc_btn_ctxt.raw_emummc = false;
|
||||
|
||||
return LV_RES_OK;
|
||||
}
|
||||
|
||||
#pragma GCC pop_options
|
||||
24
nyx/nyx_gui/frontend/gui_emmc_tools.h
Normal file
24
nyx/nyx_gui/frontend/gui_emmc_tools.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2019 CTCaer
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _GUI_EMMC_TOOLS_H_
|
||||
#define _GUI_EMMC_TOOLS_H_
|
||||
|
||||
#include "../libs/lvgl/lvgl.h"
|
||||
|
||||
lv_res_t create_window_backup_restore_tool(lv_obj_t *btn);
|
||||
|
||||
#endif
|
||||
1183
nyx/nyx_gui/frontend/gui_emummc_tools.c
Normal file
1183
nyx/nyx_gui/frontend/gui_emummc_tools.c
Normal file
File diff suppressed because it is too large
Load Diff
24
nyx/nyx_gui/frontend/gui_emummc_tools.h
Normal file
24
nyx/nyx_gui/frontend/gui_emummc_tools.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (c) 2019 CTCaer
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _GUI_EMUMMC_TOOLS_H_
|
||||
#define _GUI_EMUMMC_TOOLS_H_
|
||||
|
||||
#include "../libs/lvgl/lvgl.h"
|
||||
|
||||
lv_res_t create_win_emummc_tools(lv_obj_t *btn);
|
||||
|
||||
#endif
|
||||
1179
nyx/nyx_gui/frontend/gui_info.c
Normal file
1179
nyx/nyx_gui/frontend/gui_info.c
Normal file
File diff suppressed because it is too large
Load Diff
24
nyx/nyx_gui/frontend/gui_info.h
Normal file
24
nyx/nyx_gui/frontend/gui_info.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2019 CTCaer
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _GUI_INFO_H_
|
||||
#define _GUI_INFO_H_
|
||||
|
||||
#include "../libs/lvgl/lvgl.h"
|
||||
|
||||
void create_tab_info(lv_theme_t *th, lv_obj_t *parent);
|
||||
|
||||
#endif
|
||||
902
nyx/nyx_gui/frontend/gui_tools.c
Normal file
902
nyx/nyx_gui/frontend/gui_tools.c
Normal file
@@ -0,0 +1,902 @@
|
||||
/*
|
||||
* Copyright (c) 2018 naehrwert
|
||||
* Copyright (c) 2018-2019 CTCaer
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "gui.h"
|
||||
#include "gui_emmc_tools.h"
|
||||
#include "../config/config.h"
|
||||
#include "../hos/pkg1.h"
|
||||
#include "../hos/pkg2.h"
|
||||
#include "../hos/hos.h"
|
||||
#include "../hos/sept.h"
|
||||
#include "../libs/fatfs/ff.h"
|
||||
#include "../mem/heap.h"
|
||||
#include "../sec/se.h"
|
||||
#include "../soc/fuse.h"
|
||||
#include "../storage/nx_emmc.h"
|
||||
#include "../storage/sdmmc.h"
|
||||
#include "../utils/sprintf.h"
|
||||
#include "../utils/util.h"
|
||||
|
||||
extern volatile boot_cfg_t *b_cfg;
|
||||
extern hekate_config h_cfg;
|
||||
|
||||
extern bool sd_mount();
|
||||
extern void sd_unmount(bool deinit);
|
||||
extern int sd_save_to_file(void *buf, u32 size, const char *filename);
|
||||
extern void emmcsn_path_impl(char *path, char *sub_dir, char *filename, sdmmc_storage_t *storage);
|
||||
|
||||
#pragma GCC push_options
|
||||
#pragma GCC target ("thumb")
|
||||
|
||||
static bool _get_autorcm_status(bool change)
|
||||
{
|
||||
u8 corr_mod_byte0;
|
||||
sdmmc_storage_t storage;
|
||||
sdmmc_t sdmmc;
|
||||
bool enabled = false;
|
||||
|
||||
sdmmc_storage_init_mmc(&storage, &sdmmc, SDMMC_4, SDMMC_BUS_WIDTH_8, 4);
|
||||
|
||||
u8 *tempbuf = (u8 *)malloc(0x200);
|
||||
sdmmc_storage_set_mmc_partition(&storage, 1);
|
||||
sdmmc_storage_read(&storage, 0x200 / NX_EMMC_BLOCKSIZE, 1, tempbuf);
|
||||
|
||||
if ((fuse_read_odm(4) & 3) != 3)
|
||||
corr_mod_byte0 = 0xF7;
|
||||
else
|
||||
corr_mod_byte0 = 0x37;
|
||||
|
||||
if (tempbuf[0x10] != corr_mod_byte0)
|
||||
enabled = true;
|
||||
|
||||
// Change autorcm status if requested.
|
||||
if (change)
|
||||
{
|
||||
int i, sect = 0;
|
||||
u8 randomXor = 0;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
sect = (0x200 + (0x4000 * i)) / NX_EMMC_BLOCKSIZE;
|
||||
sdmmc_storage_read(&storage, sect, 1, tempbuf);
|
||||
|
||||
if (!enabled)
|
||||
{
|
||||
do
|
||||
{
|
||||
randomXor = get_tmr_us() & 0xFF; // Bricmii style of bricking.
|
||||
} while (!randomXor); // Avoid the lottery.
|
||||
|
||||
tempbuf[0x10] ^= randomXor;
|
||||
}
|
||||
else
|
||||
tempbuf[0x10] = corr_mod_byte0;
|
||||
sdmmc_storage_write(&storage, sect, 1, tempbuf);
|
||||
}
|
||||
enabled = !(enabled);
|
||||
}
|
||||
|
||||
free(tempbuf);
|
||||
sdmmc_storage_end(&storage);
|
||||
|
||||
return enabled;
|
||||
}
|
||||
|
||||
static lv_res_t _create_mbox_autorcm_status(lv_obj_t *btn)
|
||||
{
|
||||
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[] = { "\211", "\222OK", "\211", "" };
|
||||
lv_obj_t * mbox = lv_mbox_create(dark_bg, NULL);
|
||||
lv_mbox_set_recolor_text(mbox, true);
|
||||
|
||||
bool enabled = _get_autorcm_status(true);
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
lv_mbox_set_text(mbox,
|
||||
"AutoRCM is now #C7EA46 ENABLED!#\n\n"
|
||||
"You can now automatically enter RCM by only pressing #FF8000 POWER#.\n"
|
||||
"Use the AutoRCM button here again if you want to remove it later on.");
|
||||
}
|
||||
else
|
||||
{
|
||||
lv_mbox_set_text(mbox,
|
||||
"AutoRCM is now #FF8000 DISABLED!#\n\n"
|
||||
"The boot process is now normal and you need the #FF8000 VOL-# + #FF8000 HOME# (jig) combo to enter RCM.\n");
|
||||
}
|
||||
|
||||
lv_mbox_add_btns(mbox, mbox_btn_map, mbox_action);
|
||||
lv_obj_set_width(mbox, LV_HOR_RES / 9 * 5);
|
||||
lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_set_top(mbox, true);
|
||||
|
||||
if (enabled)
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_TGL_REL);
|
||||
else
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
nyx_generic_onoff_toggle(btn);
|
||||
|
||||
return LV_RES_OK;
|
||||
}
|
||||
|
||||
static int _fix_attributes(u32 *ufidx, lv_obj_t *lb_val, char *path, u32 *total, u32 hos_folder, u32 check_first_run)
|
||||
{
|
||||
FRESULT res;
|
||||
DIR dir;
|
||||
u32 dirLength = 0;
|
||||
static FILINFO fno;
|
||||
|
||||
if (check_first_run)
|
||||
{
|
||||
// Read file attributes.
|
||||
res = f_stat(path, &fno);
|
||||
if (res != FR_OK)
|
||||
return res;
|
||||
|
||||
// Check if archive bit is set.
|
||||
if (fno.fattrib & AM_ARC)
|
||||
{
|
||||
*(u32 *)total = *(u32 *)total + 1;
|
||||
f_chmod(path, 0, AM_ARC);
|
||||
}
|
||||
}
|
||||
|
||||
// Open directory.
|
||||
res = f_opendir(&dir, path);
|
||||
if (res != FR_OK)
|
||||
return res;
|
||||
|
||||
dirLength = strlen(path);
|
||||
for (;;)
|
||||
{
|
||||
// Clear file or folder path.
|
||||
path[dirLength] = 0;
|
||||
|
||||
// Read a directory item.
|
||||
res = f_readdir(&dir, &fno);
|
||||
|
||||
// Break on error or end of dir.
|
||||
if (res != FR_OK || fno.fname[0] == 0)
|
||||
break;
|
||||
|
||||
// Skip official Nintendo dir if started from root.
|
||||
if (!hos_folder && !strcmp(fno.fname, "Nintendo"))
|
||||
continue;
|
||||
|
||||
// Set new directory or file.
|
||||
memcpy(&path[dirLength], "/", 1);
|
||||
memcpy(&path[dirLength + 1], fno.fname, strlen(fno.fname) + 1);
|
||||
|
||||
// Check if archive bit is set.
|
||||
if (fno.fattrib & AM_ARC)
|
||||
{
|
||||
*total = *total + 1;
|
||||
f_chmod(path, 0, AM_ARC);
|
||||
|
||||
if (*ufidx == 0)
|
||||
lv_label_set_array_text(lb_val, path, 256);
|
||||
*ufidx += 1;
|
||||
if (*ufidx > 9)
|
||||
*ufidx = 0;
|
||||
}
|
||||
|
||||
manual_system_maintenance(true);
|
||||
|
||||
// Is it a directory?
|
||||
if (fno.fattrib & AM_DIR)
|
||||
{
|
||||
// Set archive bit to NCA folders.
|
||||
if (hos_folder && !strcmp(fno.fname + strlen(fno.fname) - 4, ".nca"))
|
||||
{
|
||||
*total = *total + 1;
|
||||
f_chmod(path, AM_ARC, AM_ARC);
|
||||
}
|
||||
lv_label_set_array_text(lb_val, path, 256);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
// Enter the directory.
|
||||
res = _fix_attributes(ufidx, lb_val, path, total, hos_folder, 0);
|
||||
if (res != FR_OK)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
f_closedir(&dir);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static lv_res_t _create_window_unset_abit_tool(lv_obj_t *btn)
|
||||
{
|
||||
lv_obj_t *win;
|
||||
|
||||
// Find which was called and set window's title.
|
||||
bool nintendo_folder = false;
|
||||
if (strcmp(lv_label_get_text(lv_obj_get_child(btn, NULL)), SYMBOL_COPY" Unset archive bit"))
|
||||
nintendo_folder = true;
|
||||
|
||||
if (!nintendo_folder)
|
||||
win = nyx_create_standard_window(SYMBOL_COPY" Unset archive bit (except Nintendo folder)");
|
||||
else
|
||||
win = nyx_create_standard_window(SYMBOL_COPY" Fix archive bit (Nintendo folder)");
|
||||
|
||||
// Disable buttons.
|
||||
nyx_window_toggle_buttons(win, true);
|
||||
|
||||
lv_obj_t *desc = lv_cont_create(win, NULL);
|
||||
lv_obj_set_size(desc, LV_HOR_RES * 10 / 11, LV_VER_RES - (LV_DPI * 11 / 7) * 4);
|
||||
|
||||
lv_obj_t * lb_desc = lv_label_create(desc, NULL);
|
||||
lv_label_set_long_mode(lb_desc, LV_LABEL_LONG_BREAK);
|
||||
lv_label_set_recolor(lb_desc, true);
|
||||
|
||||
if (!sd_mount())
|
||||
{
|
||||
lv_label_set_static_text(lb_desc, "#FFDD00 Failed to init SD!#");
|
||||
lv_obj_set_width(lb_desc, lv_obj_get_width(desc));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!nintendo_folder)
|
||||
lv_label_set_static_text(lb_desc, "#00DDFF Traversing all SD card files!#\nThis may take some time...");
|
||||
else
|
||||
lv_label_set_static_text(lb_desc, "#00DDFF Traversing all Nintendo files!#\nThis may take some time...");
|
||||
lv_obj_set_width(lb_desc, lv_obj_get_width(desc));
|
||||
|
||||
lv_obj_t *val = lv_cont_create(win, NULL);
|
||||
lv_obj_set_size(val, LV_HOR_RES * 10 / 11, LV_VER_RES - (LV_DPI * 11 / 7) * 4);
|
||||
|
||||
lv_obj_t * lb_val = lv_label_create(val, lb_desc);
|
||||
|
||||
char path[256];
|
||||
path[0] = 0;
|
||||
|
||||
lv_label_set_static_text(lb_val, "");
|
||||
lv_obj_set_width(lb_val, lv_obj_get_width(val));
|
||||
lv_obj_align(val, desc, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
|
||||
|
||||
u32 total = 0;
|
||||
|
||||
if (!nintendo_folder)
|
||||
memcpy(path, "", 1);
|
||||
else
|
||||
memcpy(path, "Nintendo", 9);
|
||||
|
||||
u32 ufidx = 0;
|
||||
|
||||
_fix_attributes(&ufidx, lb_val, path, &total, nintendo_folder, nintendo_folder);
|
||||
|
||||
sd_unmount(false);
|
||||
|
||||
lv_obj_t *desc2 = lv_cont_create(win, NULL);
|
||||
lv_obj_set_size(desc2, LV_HOR_RES * 10 / 11, LV_VER_RES - (LV_DPI * 11 / 7) * 4);
|
||||
lv_obj_t * lb_desc2 = lv_label_create(desc2, lb_desc);
|
||||
|
||||
char *txt_buf = (char *)malloc(0x500);
|
||||
|
||||
s_printf(txt_buf, "#96FF00 Total archive bits fixed:# #FF8000 %d!#", total);
|
||||
|
||||
lv_label_set_array_text(lb_desc2, txt_buf, 0x500);
|
||||
lv_obj_set_width(lb_desc2, lv_obj_get_width(desc2));
|
||||
lv_obj_align(desc2, val, LV_ALIGN_OUT_BOTTOM_RIGHT, 0, 0);
|
||||
}
|
||||
|
||||
// Enable buttons.
|
||||
nyx_window_toggle_buttons(win, false);
|
||||
|
||||
return LV_RES_OK;
|
||||
}
|
||||
|
||||
static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn)
|
||||
{
|
||||
lv_obj_t *win = nyx_create_standard_window(SYMBOL_MODULES" Dump package1/2");
|
||||
|
||||
// Disable buttons.
|
||||
nyx_window_toggle_buttons(win, true);
|
||||
|
||||
lv_obj_t *desc = lv_cont_create(win, NULL);
|
||||
lv_obj_set_size(desc, LV_HOR_RES * 10 / 11, LV_VER_RES - (LV_DPI * 12 / 7));
|
||||
|
||||
lv_obj_t * lb_desc = lv_label_create(desc, NULL);
|
||||
lv_obj_set_style(lb_desc, &monospace_text);
|
||||
lv_label_set_long_mode(lb_desc, LV_LABEL_LONG_BREAK);
|
||||
lv_label_set_recolor(lb_desc, true);
|
||||
lv_obj_set_width(lb_desc, lv_obj_get_width(desc));
|
||||
|
||||
if (!sd_mount())
|
||||
{
|
||||
lv_label_set_static_text(lb_desc, "#FFDD00 Failed to init SD!#");
|
||||
|
||||
goto out_end;
|
||||
}
|
||||
|
||||
char path[128];
|
||||
|
||||
u8 *pkg1 = (u8 *)calloc(1, 0x40000);
|
||||
u8 *warmboot = (u8 *)calloc(1, 0x40000);
|
||||
u8 *secmon = (u8 *)calloc(1, 0x40000);
|
||||
u8 *loader = (u8 *)calloc(1, 0x40000);
|
||||
u8 *pkg2 = NULL;
|
||||
u8 kb = 0;
|
||||
|
||||
char *txt_buf = (char *)malloc(0x1000);
|
||||
char *txt_buf2 = (char *)malloc(0x1000);
|
||||
|
||||
tsec_ctxt_t tsec_ctxt;
|
||||
|
||||
sdmmc_storage_t storage;
|
||||
sdmmc_t sdmmc;
|
||||
|
||||
if (!sdmmc_storage_init_mmc(&storage, &sdmmc, SDMMC_4, SDMMC_BUS_WIDTH_8, 4))
|
||||
{
|
||||
lv_label_set_static_text(lb_desc, "#FFDD00 Failed to init eMMC!#");
|
||||
|
||||
goto out_free;
|
||||
}
|
||||
|
||||
sdmmc_storage_set_mmc_partition(&storage, 1);
|
||||
|
||||
// Read package1.
|
||||
char *build_date = malloc(32);
|
||||
sdmmc_storage_read(&storage, 0x100000 / NX_EMMC_BLOCKSIZE, 0x40000 / NX_EMMC_BLOCKSIZE, pkg1);
|
||||
const pkg1_id_t *pkg1_id = pkg1_identify(pkg1, build_date);
|
||||
|
||||
s_printf(txt_buf, "#00DDFF Found pkg1 ('%s')#\n\n", build_date);
|
||||
free(build_date);
|
||||
lv_label_set_array_text(lb_desc, txt_buf, 0x1000);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
// Dump package1 in its encrypted state if unknown.
|
||||
if (!pkg1_id)
|
||||
{
|
||||
s_printf(txt_buf + strlen(txt_buf), "#FFDD00 Unknown pkg1 version for reading\nTSEC firmware!#");
|
||||
lv_label_set_array_text(lb_desc, txt_buf, 0x1000);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
emmcsn_path_impl(path, "/pkg1", "pkg1_enc.bin", &storage);
|
||||
if (sd_save_to_file(pkg1, 0x40000, path))
|
||||
goto out_free;
|
||||
|
||||
s_printf(txt_buf + strlen(txt_buf), "\nEncrypted pkg1 dumped to pkg1_enc.bin");
|
||||
lv_label_set_array_text(lb_desc, txt_buf, 0x1000);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
goto out_free;
|
||||
}
|
||||
|
||||
const pk11_hdr_t *hdr = (pk11_hdr_t *)(pkg1 + pkg1_id->pkg11_off + 0x20);
|
||||
|
||||
kb = pkg1_id->kb;
|
||||
|
||||
if (!h_cfg.se_keygen_done)
|
||||
{
|
||||
tsec_ctxt.fw = (void *)pkg1 + pkg1_id->tsec_off;
|
||||
tsec_ctxt.pkg1 = (void *)pkg1;
|
||||
tsec_ctxt.pkg11_off = pkg1_id->pkg11_off;
|
||||
tsec_ctxt.secmon_base = pkg1_id->secmon_base;
|
||||
|
||||
if (kb >= KB_FIRMWARE_VERSION_700 && !h_cfg.sept_run)
|
||||
{
|
||||
b_cfg->autoboot = 0;
|
||||
b_cfg->autoboot_list = 0;
|
||||
|
||||
if (!reboot_to_sept((u8 *)tsec_ctxt.fw, kb))
|
||||
{
|
||||
lv_label_set_static_text(lb_desc, "FFDD00 Failed to run sept#\n");
|
||||
goto out_free;
|
||||
}
|
||||
}
|
||||
|
||||
// Read keyblob.
|
||||
u8 *keyblob = (u8 *)calloc(NX_EMMC_BLOCKSIZE, 1);
|
||||
sdmmc_storage_read(&storage, 0x180000 / NX_EMMC_BLOCKSIZE + kb, 1, keyblob);
|
||||
|
||||
// Decrypt.
|
||||
keygen(keyblob, kb, &tsec_ctxt);
|
||||
if (kb <= KB_FIRMWARE_VERSION_600)
|
||||
h_cfg.se_keygen_done = 1;
|
||||
free(keyblob);
|
||||
}
|
||||
|
||||
if (kb <= KB_FIRMWARE_VERSION_600)
|
||||
pkg1_decrypt(pkg1_id, pkg1);
|
||||
|
||||
if (kb <= KB_FIRMWARE_VERSION_620)
|
||||
{
|
||||
pkg1_unpack(warmboot, secmon, loader, pkg1_id, pkg1);
|
||||
|
||||
// Display info.
|
||||
s_printf(txt_buf + strlen(txt_buf),
|
||||
"#C7EA46 NX Bootloader size: #0x%05X\n"
|
||||
"#C7EA46 Secure monitor addr: #0x%05X\n"
|
||||
"#C7EA46 Secure monitor size: #0x%05X\n"
|
||||
"#C7EA46 Warmboot addr: #0x%05X\n"
|
||||
"#C7EA46 Warmboot size: #0x%05X\n\n",
|
||||
hdr->ldr_size, pkg1_id->secmon_base, hdr->sm_size, pkg1_id->warmboot_base, hdr->wb_size);
|
||||
|
||||
lv_label_set_array_text(lb_desc, txt_buf, 0x1000);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
// Dump package1.1.
|
||||
emmcsn_path_impl(path, "/pkg1", "pkg1_decr.bin", &storage);
|
||||
if (sd_save_to_file(pkg1, 0x40000, path))
|
||||
goto out_free;
|
||||
s_printf(txt_buf + strlen(txt_buf), "pkg1 dumped to pkg1_decr.bin\n");
|
||||
lv_label_set_array_text(lb_desc, txt_buf, 0x1000);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
// Dump nxbootloader.
|
||||
emmcsn_path_impl(path, "/pkg1", "nxloader.bin", &storage);
|
||||
if (sd_save_to_file(loader, hdr->ldr_size, path))
|
||||
goto out_free;
|
||||
s_printf(txt_buf + strlen(txt_buf), "NX Bootloader dumped to nxloader.bin\n");
|
||||
lv_label_set_array_text(lb_desc, txt_buf, 0x1000);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
// Dump secmon.
|
||||
emmcsn_path_impl(path, "/pkg1", "secmon.bin", &storage);
|
||||
if (sd_save_to_file(secmon, hdr->sm_size, path))
|
||||
goto out_free;
|
||||
s_printf(txt_buf + strlen(txt_buf), "Secure Monitor dumped to secmon.bin\n");
|
||||
lv_label_set_array_text(lb_desc, txt_buf, 0x1000);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
// Dump warmboot.
|
||||
emmcsn_path_impl(path, "/pkg1", "warmboot.bin", &storage);
|
||||
if (sd_save_to_file(warmboot, hdr->wb_size, path))
|
||||
goto out_free;
|
||||
s_printf(txt_buf + strlen(txt_buf), "Warmboot dumped to warmboot.bin\n\n");
|
||||
lv_label_set_array_text(lb_desc, txt_buf, 0x1000);
|
||||
manual_system_maintenance(true);
|
||||
}
|
||||
|
||||
// Dump package2.1.
|
||||
sdmmc_storage_set_mmc_partition(&storage, 0);
|
||||
// Parse eMMC GPT.
|
||||
LIST_INIT(gpt);
|
||||
nx_emmc_gpt_parse(&gpt, &storage);
|
||||
// Find package2 partition.
|
||||
emmc_part_t *pkg2_part = nx_emmc_part_find(&gpt, "BCPKG2-1-Normal-Main");
|
||||
if (!pkg2_part)
|
||||
goto out;
|
||||
|
||||
// Read in package2 header and get package2 real size.
|
||||
u8 *tmp = (u8 *)malloc(NX_EMMC_BLOCKSIZE);
|
||||
nx_emmc_part_read(&storage, pkg2_part, 0x4000 / NX_EMMC_BLOCKSIZE, 1, tmp);
|
||||
u32 *hdr_pkg2_raw = (u32 *)(tmp + 0x100);
|
||||
u32 pkg2_size = hdr_pkg2_raw[0] ^ hdr_pkg2_raw[2] ^ hdr_pkg2_raw[3];
|
||||
free(tmp);
|
||||
// Read in package2.
|
||||
u32 pkg2_size_aligned = ALIGN(pkg2_size, NX_EMMC_BLOCKSIZE);
|
||||
pkg2 = malloc(pkg2_size_aligned);
|
||||
nx_emmc_part_read(&storage, pkg2_part, 0x4000 / NX_EMMC_BLOCKSIZE,
|
||||
pkg2_size_aligned / NX_EMMC_BLOCKSIZE, pkg2);
|
||||
#if 0
|
||||
emmcsn_path_impl(path, "/pkg2", "pkg2_encr.bin", &storage);
|
||||
if (sd_save_to_file(pkg2, pkg2_size_aligned, path))
|
||||
goto out;
|
||||
gfx_puts("\npkg2 dumped to pkg2_encr.bin\n");
|
||||
#endif
|
||||
|
||||
// Decrypt package2 and parse KIP1 blobs in INI1 section.
|
||||
pkg2_hdr_t *pkg2_hdr = pkg2_decrypt(pkg2);
|
||||
if (!pkg2_hdr)
|
||||
{
|
||||
s_printf(txt_buf + strlen(txt_buf), "FFDD00 Pkg2 decryption failed!#");
|
||||
lv_label_set_array_text(lb_desc, txt_buf, 0x1000);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
goto out;
|
||||
}
|
||||
|
||||
// Display info.
|
||||
s_printf(txt_buf + strlen(txt_buf),
|
||||
"#C7EA46 Kernel size: #0x%05X\n"
|
||||
"#C7EA46 INI1 size: #0x%05X\n\n",
|
||||
pkg2_hdr->sec_size[PKG2_SEC_KERNEL], pkg2_hdr->sec_size[PKG2_SEC_INI1]);
|
||||
|
||||
lv_label_set_array_text(lb_desc, txt_buf, 0x1000);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
// Dump pkg2.1.
|
||||
emmcsn_path_impl(path, "/pkg2", "pkg2_decr.bin", &storage);
|
||||
if (sd_save_to_file(pkg2, pkg2_hdr->sec_size[PKG2_SEC_KERNEL] + pkg2_hdr->sec_size[PKG2_SEC_INI1], path))
|
||||
goto out;
|
||||
s_printf(txt_buf + strlen(txt_buf), "pkg2 dumped to pkg2_decr.bin\n");
|
||||
lv_label_set_array_text(lb_desc, txt_buf, 0x1000);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
// Dump kernel.
|
||||
emmcsn_path_impl(path, "/pkg2", "kernel.bin", &storage);
|
||||
if (sd_save_to_file(pkg2_hdr->data, pkg2_hdr->sec_size[PKG2_SEC_KERNEL], path))
|
||||
goto out;
|
||||
s_printf(txt_buf + strlen(txt_buf), "Kernel dumped to kernel.bin\n");
|
||||
lv_label_set_array_text(lb_desc, txt_buf, 0x1000);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
// Dump INI1.
|
||||
u32 ini1_off = pkg2_hdr->sec_size[PKG2_SEC_KERNEL];
|
||||
u32 ini1_size = pkg2_hdr->sec_size[PKG2_SEC_INI1];
|
||||
if (!ini1_size)
|
||||
{
|
||||
ini1_off = *(u32 *)(pkg2_hdr->data + PKG2_NEWKERN_INI1_START);
|
||||
ini1_size = *(u32 *)(pkg2_hdr->data + PKG2_NEWKERN_INI1_END) - *(u32 *)(pkg2_hdr->data + PKG2_NEWKERN_INI1_START);
|
||||
}
|
||||
pkg2_ini1_t *ini1 = (pkg2_ini1_t *)(pkg2_hdr->data + ini1_off);
|
||||
emmcsn_path_impl(path, "/pkg2", "ini1.bin", &storage);
|
||||
if (sd_save_to_file(ini1, ini1_size, path))
|
||||
goto out;
|
||||
|
||||
s_printf(txt_buf + strlen(txt_buf), "INI1 dumped to ini1.bin\n\n");
|
||||
lv_label_set_array_text(lb_desc, txt_buf, 0x1000);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
char filename[32];
|
||||
u8 *ptr = (u8 *)ini1;
|
||||
ptr += sizeof(pkg2_ini1_t);
|
||||
|
||||
// Dump all kips.
|
||||
u8 *kip_buffer = (u8 *)malloc(0x400000);
|
||||
|
||||
for (u32 i = 0; i < ini1->num_procs; i++)
|
||||
{
|
||||
pkg2_kip1_t *kip1 = (pkg2_kip1_t *)ptr;
|
||||
u32 kip1_size = pkg2_calc_kip1_size(kip1);
|
||||
|
||||
s_printf(filename, "%s.kip1", kip1->name);
|
||||
if ((u32)kip1 % 8)
|
||||
{
|
||||
memcpy(kip_buffer, kip1, kip1_size);
|
||||
kip1 = (pkg2_kip1_t *)kip_buffer;
|
||||
}
|
||||
|
||||
emmcsn_path_impl(path, "/pkg2/ini1", filename, &storage);
|
||||
if (sd_save_to_file(kip1, kip1_size, path))
|
||||
{
|
||||
free(kip_buffer);
|
||||
goto out;
|
||||
}
|
||||
|
||||
s_printf(txt_buf + strlen(txt_buf), "%s kip dumped to %s.kip1\n", kip1->name, kip1->name);
|
||||
lv_label_set_array_text(lb_desc, txt_buf, 0x1000);
|
||||
manual_system_maintenance(true);
|
||||
|
||||
ptr += kip1_size;
|
||||
}
|
||||
free(kip_buffer);
|
||||
|
||||
out:
|
||||
nx_emmc_gpt_free(&gpt);
|
||||
out_free:
|
||||
free(pkg1);
|
||||
free(secmon);
|
||||
free(warmboot);
|
||||
free(loader);
|
||||
free(pkg2);
|
||||
free(txt_buf);
|
||||
free(txt_buf2);
|
||||
sdmmc_storage_end(&storage);
|
||||
sd_unmount(false);
|
||||
|
||||
if (kb >= KB_FIRMWARE_VERSION_620)
|
||||
se_aes_key_clear(8);
|
||||
out_end:
|
||||
// Enable buttons.
|
||||
nyx_window_toggle_buttons(win, false);
|
||||
|
||||
return LV_RES_OK;
|
||||
}
|
||||
|
||||
void sept_run_dump()
|
||||
{
|
||||
_create_window_dump_pk12_tool(NULL);
|
||||
}
|
||||
|
||||
static void _create_tab_tools_emmc_pkg12(lv_theme_t *th, lv_obj_t *parent)
|
||||
{
|
||||
lv_page_set_scrl_layout(parent, LV_LAYOUT_PRETTY);
|
||||
|
||||
static lv_style_t h_style;
|
||||
lv_style_copy(&h_style, &lv_style_transp);
|
||||
h_style.body.padding.inner = 0;
|
||||
h_style.body.padding.hor = LV_DPI - (LV_DPI / 4);
|
||||
h_style.body.padding.ver = LV_DPI / 6;
|
||||
|
||||
// Create Backup & Restore container.
|
||||
lv_obj_t *h1 = lv_cont_create(parent, NULL);
|
||||
lv_cont_set_style(h1, &h_style);
|
||||
lv_cont_set_fit(h1, false, true);
|
||||
lv_obj_set_width(h1, (LV_HOR_RES / 9) * 4);
|
||||
lv_obj_set_click(h1, false);
|
||||
lv_cont_set_layout(h1, LV_LAYOUT_OFF);
|
||||
|
||||
lv_obj_t *label_sep = lv_label_create(h1, NULL);
|
||||
lv_label_set_static_text(label_sep, "");
|
||||
|
||||
lv_obj_t *label_txt = lv_label_create(h1, NULL);
|
||||
lv_label_set_static_text(label_txt, "Backup & Restore");
|
||||
lv_obj_set_style(label_txt, th->label.prim);
|
||||
lv_obj_align(label_txt, label_sep, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI / 4, -LV_DPI * 3 / 10);
|
||||
|
||||
lv_obj_t *line_sep = lv_line_create(h1, NULL);
|
||||
static const lv_point_t line_pp[] = { {0, 0}, { LV_HOR_RES - (LV_DPI - (LV_DPI / 4)) * 2, 0} };
|
||||
lv_line_set_points(line_sep, line_pp, 2);
|
||||
lv_line_set_style(line_sep, th->line.decor);
|
||||
lv_obj_align(line_sep, label_txt, LV_ALIGN_OUT_BOTTOM_LEFT, -(LV_DPI / 4), LV_DPI / 8);
|
||||
|
||||
// Create Backup eMMC button.
|
||||
lv_obj_t *btn = lv_btn_create(h1, NULL);
|
||||
if (hekate_bg)
|
||||
{
|
||||
lv_btn_set_style(btn, LV_BTN_STYLE_REL, &btn_transp_rel);
|
||||
lv_btn_set_style(btn, LV_BTN_STYLE_PR, &btn_transp_pr);
|
||||
}
|
||||
lv_obj_t *label_btn = lv_label_create(btn, NULL);
|
||||
lv_btn_set_fit(btn, true, true);
|
||||
lv_label_set_static_text(label_btn, SYMBOL_UPLOAD" Backup eMMC");
|
||||
lv_obj_align(btn, line_sep, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI / 4, LV_DPI / 4);
|
||||
lv_btn_set_action(btn, LV_BTN_ACTION_CLICK, create_window_backup_restore_tool);
|
||||
|
||||
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 backup your eMMC partitions individually or as\n"
|
||||
"a whole raw image to your SD card.\n"
|
||||
"#FF8000 Supports SD cards from 4GB and up. FAT32 and exFAT.#");
|
||||
lv_obj_set_style(label_txt2, &hint_small_style);
|
||||
lv_obj_align(label_txt2, btn, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 3);
|
||||
|
||||
// Create Restore eMMC button.
|
||||
lv_obj_t *btn2 = lv_btn_create(h1, btn);
|
||||
label_btn = lv_label_create(btn2, NULL);
|
||||
lv_label_set_static_text(label_btn, SYMBOL_DOWNLOAD" Restore eMMC");
|
||||
lv_obj_align(btn2, label_txt2, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 2);
|
||||
lv_btn_set_action(btn2, LV_BTN_ACTION_CLICK, create_window_backup_restore_tool);
|
||||
|
||||
label_txt2 = lv_label_create(h1, NULL);
|
||||
lv_label_set_recolor(label_txt2, true);
|
||||
lv_label_set_static_text(label_txt2,
|
||||
"Allows you to restore your eMMC partitions individually or as\n"
|
||||
"a whole raw image to your SD card.\n"
|
||||
"#FF8000 Supports SD cards from 4GB and up. FAT32 and exFAT. #");
|
||||
lv_obj_set_style(label_txt2, &hint_small_style);
|
||||
lv_obj_align(label_txt2, btn2, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 3);
|
||||
|
||||
// Create Misc container.
|
||||
lv_obj_t *h2 = lv_cont_create(parent, NULL);
|
||||
lv_cont_set_style(h2, &h_style);
|
||||
lv_cont_set_fit(h2, false, true);
|
||||
lv_obj_set_width(h2, (LV_HOR_RES / 9) * 4);
|
||||
lv_obj_set_click(h2, false);
|
||||
lv_cont_set_layout(h2, LV_LAYOUT_OFF);
|
||||
lv_obj_align(h2, h1, LV_ALIGN_OUT_RIGHT_TOP, 0, 0);
|
||||
|
||||
label_sep = lv_label_create(h2, NULL);
|
||||
lv_label_set_static_text(label_sep, "");
|
||||
|
||||
lv_obj_t *label_txt3 = lv_label_create(h2, NULL);
|
||||
lv_label_set_static_text(label_txt3, "Misc");
|
||||
lv_obj_set_style(label_txt3, th->label.prim);
|
||||
lv_obj_align(label_txt3, label_sep, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI / 4, -LV_DPI * 3 / 10);
|
||||
|
||||
line_sep = lv_line_create(h2, line_sep);
|
||||
lv_obj_align(line_sep, label_txt3, LV_ALIGN_OUT_BOTTOM_LEFT, -(LV_DPI / 4), LV_DPI / 8);
|
||||
|
||||
// Create Dump Package1/2 button.
|
||||
lv_obj_t *btn3 = lv_btn_create(h2, NULL);
|
||||
if (hekate_bg)
|
||||
{
|
||||
lv_btn_set_style(btn3, LV_BTN_STYLE_REL, &btn_transp_rel);
|
||||
lv_btn_set_style(btn3, LV_BTN_STYLE_PR, &btn_transp_pr);
|
||||
}
|
||||
label_btn = lv_label_create(btn3, NULL);
|
||||
lv_btn_set_fit(btn3, true, true);
|
||||
lv_label_set_static_text(label_btn, SYMBOL_MODULES" Dump Package1/2");
|
||||
lv_obj_align(btn3, line_sep, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI / 4, LV_DPI / 4);
|
||||
lv_btn_set_action(btn3, LV_BTN_ACTION_CLICK, _create_window_dump_pk12_tool);
|
||||
|
||||
lv_obj_t *label_txt4 = lv_label_create(h2, NULL);
|
||||
lv_label_set_recolor(label_txt4, true);
|
||||
lv_label_set_static_text(label_txt4,
|
||||
"Allows you to dump and decrypt pkg1 and pkg2 and further\n"
|
||||
"split it up into their individual parts. It also dumps the kip1.\n\n");
|
||||
lv_obj_set_style(label_txt4, &hint_small_style);
|
||||
lv_obj_align(label_txt4, btn3, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 3);
|
||||
|
||||
label_sep = lv_label_create(h2, NULL);
|
||||
lv_label_set_static_text(label_sep, "");
|
||||
lv_obj_align(label_sep, label_txt4, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI * 11 / 7);
|
||||
}
|
||||
|
||||
static void _create_tab_tools_arc_autorcm(lv_theme_t *th, lv_obj_t *parent)
|
||||
{
|
||||
lv_page_set_scrl_layout(parent, LV_LAYOUT_PRETTY);
|
||||
|
||||
static lv_style_t h_style;
|
||||
lv_style_copy(&h_style, &lv_style_transp);
|
||||
h_style.body.padding.inner = 0;
|
||||
h_style.body.padding.hor = LV_DPI - (LV_DPI / 4);
|
||||
h_style.body.padding.ver = LV_DPI / 6;
|
||||
|
||||
// Create Misc container.
|
||||
lv_obj_t *h1 = lv_cont_create(parent, NULL);
|
||||
lv_cont_set_style(h1, &h_style);
|
||||
lv_cont_set_fit(h1, false, true);
|
||||
lv_obj_set_width(h1, (LV_HOR_RES / 9) * 4);
|
||||
lv_obj_set_click(h1, false);
|
||||
lv_cont_set_layout(h1, LV_LAYOUT_OFF);
|
||||
|
||||
lv_obj_t *label_sep = lv_label_create(h1, NULL);
|
||||
lv_label_set_static_text(label_sep, "");
|
||||
|
||||
lv_obj_t *label_txt = lv_label_create(h1, NULL);
|
||||
lv_label_set_static_text(label_txt, "Misc");
|
||||
lv_obj_set_style(label_txt, th->label.prim);
|
||||
lv_obj_align(label_txt, label_sep, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI / 4, -LV_DPI * 3 / 10);
|
||||
|
||||
lv_obj_t *line_sep = lv_line_create(h1, NULL);
|
||||
static const lv_point_t line_pp[] = { {0, 0}, { LV_HOR_RES - (LV_DPI - (LV_DPI / 4)) * 2, 0} };
|
||||
lv_line_set_points(line_sep, line_pp, 2);
|
||||
lv_line_set_style(line_sep, th->line.decor);
|
||||
lv_obj_align(line_sep, label_txt, LV_ALIGN_OUT_BOTTOM_LEFT, -(LV_DPI / 4), LV_DPI / 8);
|
||||
|
||||
// Create Unset archive bit button.
|
||||
lv_obj_t *btn = lv_btn_create(h1, NULL);
|
||||
if (hekate_bg)
|
||||
{
|
||||
lv_btn_set_style(btn, LV_BTN_STYLE_REL, &btn_transp_rel);
|
||||
lv_btn_set_style(btn, LV_BTN_STYLE_PR, &btn_transp_pr);
|
||||
}
|
||||
lv_obj_t *label_btn = lv_label_create(btn, NULL);
|
||||
lv_btn_set_fit(btn, true, true);
|
||||
lv_label_set_static_text(label_btn, SYMBOL_COPY" Unset archive bit");
|
||||
lv_obj_align(btn, line_sep, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI / 4, LV_DPI / 4);
|
||||
lv_btn_set_action(btn, LV_BTN_ACTION_CLICK, _create_window_unset_abit_tool);
|
||||
|
||||
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 unset the archive bit for all folders except the\n"
|
||||
"Nintendo folder.\n"
|
||||
"#FF8000 If you want the Nintendo folder, use the below option.#");
|
||||
lv_obj_set_style(label_txt2, &hint_small_style);
|
||||
lv_obj_align(label_txt2, btn, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 3);
|
||||
|
||||
// Create Fix archive bit - Nintendo button.
|
||||
lv_obj_t *btn2 = lv_btn_create(h1, btn);
|
||||
label_btn = lv_label_create(btn2, NULL);
|
||||
lv_label_set_static_text(label_btn, SYMBOL_DIRECTORY" Fix archive bit - Nintendo");
|
||||
lv_obj_align(btn2, label_txt2, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 2);
|
||||
lv_btn_set_action(btn2, LV_BTN_ACTION_CLICK, _create_window_unset_abit_tool);
|
||||
|
||||
label_txt2 = lv_label_create(h1, NULL);
|
||||
lv_label_set_recolor(label_txt2, true);
|
||||
lv_label_set_static_text(label_txt2,
|
||||
"Allows you to fix your Nintendo folder's archive bits.\n"
|
||||
"They are required for the NCA folders but not anywhere else.\n"
|
||||
"#FF8000 Use that option when you have corruption messages.#");
|
||||
lv_obj_set_style(label_txt2, &hint_small_style);
|
||||
lv_obj_align(label_txt2, btn2, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 3);
|
||||
|
||||
// Create Others container.
|
||||
lv_obj_t *h2 = lv_cont_create(parent, NULL);
|
||||
lv_cont_set_style(h2, &h_style);
|
||||
lv_cont_set_fit(h2, false, true);
|
||||
lv_obj_set_width(h2, (LV_HOR_RES / 9) * 4);
|
||||
lv_obj_set_click(h2, false);
|
||||
lv_cont_set_layout(h2, LV_LAYOUT_OFF);
|
||||
lv_obj_align(h2, h1, LV_ALIGN_OUT_RIGHT_TOP, 0, 0);
|
||||
|
||||
label_sep = lv_label_create(h2, NULL);
|
||||
lv_label_set_static_text(label_sep, "");
|
||||
|
||||
lv_obj_t *label_txt3 = lv_label_create(h2, NULL);
|
||||
lv_label_set_static_text(label_txt3, "Others");
|
||||
lv_obj_set_style(label_txt3, th->label.prim);
|
||||
lv_obj_align(label_txt3, label_sep, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI / 4, -LV_DPI * 3 / 10);
|
||||
|
||||
line_sep = lv_line_create(h2, line_sep);
|
||||
lv_obj_align(line_sep, label_txt3, LV_ALIGN_OUT_BOTTOM_LEFT, -(LV_DPI / 4), LV_DPI / 8);
|
||||
|
||||
// Create AutoRCM On/Off button.
|
||||
lv_obj_t *btn3 = lv_btn_create(h2, NULL);
|
||||
if (hekate_bg)
|
||||
{
|
||||
lv_btn_set_style(btn3, LV_BTN_STYLE_REL, &btn_transp_rel);
|
||||
lv_btn_set_style(btn3, LV_BTN_STYLE_PR, &btn_transp_pr);
|
||||
lv_btn_set_style(btn3, LV_BTN_STYLE_TGL_REL, &btn_transp_tgl_rel);
|
||||
lv_btn_set_style(btn3, LV_BTN_STYLE_TGL_PR, &btn_transp_tgl_pr);
|
||||
}
|
||||
label_btn = lv_label_create(btn3, NULL);
|
||||
lv_btn_set_fit(btn3, true, true);
|
||||
lv_label_set_recolor(label_btn, true);
|
||||
lv_label_set_static_text(label_btn, SYMBOL_REFRESH" AutoRCM #00ffc9 ON #");
|
||||
lv_obj_align(btn3, line_sep, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI / 4, LV_DPI / 4);
|
||||
lv_btn_set_action(btn3, LV_BTN_ACTION_CLICK, _create_mbox_autorcm_status);
|
||||
|
||||
// Set default state for AutoRCM and lock it out if patched unit.
|
||||
if (_get_autorcm_status(false))
|
||||
lv_btn_set_state(btn3, LV_BTN_STATE_TGL_REL);
|
||||
else
|
||||
lv_btn_set_state(btn3, LV_BTN_STATE_REL);
|
||||
nyx_generic_onoff_toggle(btn3);
|
||||
|
||||
if (h_cfg.rcm_patched)
|
||||
{
|
||||
lv_obj_set_click(btn3, false);
|
||||
lv_btn_set_state(btn3, LV_BTN_STATE_INA);
|
||||
}
|
||||
|
||||
char *txt_buf = (char *)malloc(0x1000);
|
||||
|
||||
s_printf(txt_buf,
|
||||
"Allows you to enter RCM without using #C7EA46 VOL-# + #C7EA46 HOME# (jig).\n"
|
||||
"#FF8000 It can restore all versions of AutoRCM whenever requested.#\n"
|
||||
"#FF3C28 This corrupts your BCT and you can't boot without a custom#\n"
|
||||
"#FF3C28 bootloader.#");
|
||||
|
||||
if (h_cfg.rcm_patched)
|
||||
s_printf(txt_buf + strlen(txt_buf), " #FF8000 This is disabled because this unit is patched!#");
|
||||
|
||||
lv_obj_t *label_txt4 = lv_label_create(h2, NULL);
|
||||
lv_label_set_recolor(label_txt4, true);
|
||||
lv_label_set_array_text(label_txt4, txt_buf, 0x1000);
|
||||
free(txt_buf);
|
||||
|
||||
lv_obj_set_style(label_txt4, &hint_small_style);
|
||||
lv_obj_align(label_txt4, btn3, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 3);
|
||||
|
||||
label_sep = lv_label_create(h2, NULL);
|
||||
lv_label_set_static_text(label_sep, "");
|
||||
lv_obj_align(label_sep, label_txt4, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI * 11 / 7);
|
||||
}
|
||||
|
||||
void create_tab_tools(lv_theme_t *th, lv_obj_t *parent)
|
||||
{
|
||||
lv_obj_t *tv = lv_tabview_create(parent, NULL);
|
||||
|
||||
lv_obj_set_size(tv, LV_HOR_RES, 572);
|
||||
|
||||
static lv_style_t tabview_style;
|
||||
lv_style_copy(&tabview_style, th->tabview.btn.rel);
|
||||
tabview_style.body.padding.ver = LV_DPI / 8;
|
||||
|
||||
lv_tabview_set_style(tv, LV_TABVIEW_STYLE_BTN_REL, &tabview_style);
|
||||
if (hekate_bg)
|
||||
{
|
||||
lv_tabview_set_style(tv, LV_TABVIEW_STYLE_BTN_PR, &tabview_btn_pr);
|
||||
lv_tabview_set_style(tv, LV_TABVIEW_STYLE_BTN_TGL_PR, &tabview_btn_tgl_pr);
|
||||
}
|
||||
|
||||
lv_tabview_set_sliding(tv, false);
|
||||
lv_tabview_set_btns_pos(tv, LV_TABVIEW_BTNS_POS_BOTTOM);
|
||||
|
||||
lv_obj_t *tab1= lv_tabview_add_tab(tv, "eMMC "SYMBOL_DOT" Package1/2");
|
||||
lv_obj_t *tab2 = lv_tabview_add_tab(tv, "Archive bit "SYMBOL_DOT" AutoRCM");
|
||||
|
||||
_create_tab_tools_emmc_pkg12(th, tab1);
|
||||
_create_tab_tools_arc_autorcm(th, tab2);
|
||||
|
||||
lv_tabview_set_tab_act(tv, 0, false);
|
||||
}
|
||||
|
||||
#pragma GCC pop_options
|
||||
25
nyx/nyx_gui/frontend/gui_tools.h
Normal file
25
nyx/nyx_gui/frontend/gui_tools.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2019 CTCaer
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _GUI_TOOLS_H_
|
||||
#define _GUI_TOOLS_H_
|
||||
|
||||
#include "../libs/lvgl/lvgl.h"
|
||||
|
||||
void create_tab_tools(lv_theme_t *th, lv_obj_t *parent);
|
||||
void sept_run_dump();
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user