Nyx: emuMMC Manage window, Tools UI, and misc updates

- Add gui_emu_tools: emuMMC Manage window with correct positioning (LV_PROTECT_PARENT + re-parent to win)
- Tools: single SD button (tap = SD partition manager, 3s hold = eMMC)
- Remove emuSD from Nyx UI (tabs, UMS, partition manager); keep bootloader emusd
- Shorten Create emuMMC description text by one character
- Storage/build/config and dependency updates

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-02-20 20:49:48 +01:00
parent 4eead2c14d
commit fed7f05831
81 changed files with 6932 additions and 3462 deletions

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2018 naehrwert
* Copyright (c) 2018 Rajko Stojadinovic
* Copyright (c) 2018-2025 CTCaer
* Copyright (c) 2018-2024 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,
@@ -18,6 +18,7 @@
//! fix the dram stuff and the pop ups
#include <storage/boot_storage.h>
#include <string.h>
#include <stdlib.h>
@@ -29,10 +30,6 @@
#include "../config.h"
#include <libs/fatfs/ff.h>
#define VERIF_STATUS_OK 0
#define VERIF_STATUS_ERROR 1
#define VERIF_STATUS_ABORT 2
#define NUM_SECTORS_PER_ITER 8192 // 4MB Cache.
#define OUT_FILENAME_SZ 128
#define HASH_FILENAME_SZ (OUT_FILENAME_SZ + 11) // 11 == strlen(".sha256sums")
@@ -141,7 +138,7 @@ static void _update_filename(char *outFilename, u32 sdPathLen, u32 currPartIdx)
itoa(currPartIdx, &outFilename[sdPathLen], 10);
}
static int _emmc_sd_copy_verify(emmc_tool_gui_t *gui, sdmmc_storage_t *storage, u32 lba_curr, const char *outFilename, const emmc_part_t *part)
static int _dump_emmc_verify(emmc_tool_gui_t *gui, sdmmc_storage_t *storage, u32 lba_curr, const char *outFilename, const emmc_part_t *part)
{
FIL fp;
FIL hashFp;
@@ -174,7 +171,7 @@ static int _emmc_sd_copy_verify(emmc_tool_gui_t *gui, sdmmc_storage_t *storage,
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
return VERIF_STATUS_ERROR;
return 1;
}
char chunkSizeAscii[10];
@@ -225,11 +222,10 @@ static int _emmc_sd_copy_verify(emmc_tool_gui_t *gui, sdmmc_storage_t *storage,
if (n_cfg.verification == 3)
f_close(&hashFp);
return VERIF_STATUS_ERROR;
return 1;
}
manual_system_maintenance(false);
se_sha_hash_256_async(hashEm, bufEm, num << 9);
se_calc_sha256(hashEm, NULL, bufEm, num << 9, 0, SHA_INIT_HASH, false);
f_lseek(&fp, (u64)sdFileSector << (u64)9);
if (f_read_fast(&fp, bufSd, num << 9))
@@ -246,11 +242,11 @@ static int _emmc_sd_copy_verify(emmc_tool_gui_t *gui, sdmmc_storage_t *storage,
if (n_cfg.verification == 3)
f_close(&hashFp);
return VERIF_STATUS_ERROR;
return 1;
}
manual_system_maintenance(false);
se_sha_hash_256_finalize(hashEm);
se_sha_hash_256_oneshot(hashSd, bufSd, num << 9);
se_calc_sha256_finalize(hashEm, NULL);
se_calc_sha256_oneshot(hashSd, bufSd, num << 9);
res = memcmp(hashEm, hashSd, SE_SHA_256_SIZE / 2);
if (res)
@@ -267,7 +263,7 @@ static int _emmc_sd_copy_verify(emmc_tool_gui_t *gui, sdmmc_storage_t *storage,
if (n_cfg.verification == 3)
f_close(&hashFp);
return VERIF_STATUS_ERROR;
return 1;
}
if (n_cfg.verification == 3)
@@ -307,7 +303,7 @@ static int _emmc_sd_copy_verify(emmc_tool_gui_t *gui, sdmmc_storage_t *storage,
// Check for cancellation combo.
if (btn_read_vol() == (BTN_VOL_UP | BTN_VOL_DOWN))
{
strcpy(gui->txt_buf, "#FFDD00 Verification was cancelled!#\n");
s_printf(gui->txt_buf, "#FFDD00 Verification was cancelled!#\n");
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
@@ -317,7 +313,7 @@ static int _emmc_sd_copy_verify(emmc_tool_gui_t *gui, sdmmc_storage_t *storage,
f_close(&fp);
f_close(&hashFp);
return VERIF_STATUS_ABORT;
return 0;
}
}
free(clmt);
@@ -329,15 +325,15 @@ static int _emmc_sd_copy_verify(emmc_tool_gui_t *gui, sdmmc_storage_t *storage,
lv_label_set_text(gui->label_pct, gui->txt_buf);
manual_system_maintenance(true);
return VERIF_STATUS_OK;
return 0;
}
else
{
strcpy(gui->txt_buf, "\n#FFDD00 File not found or could not be loaded!#\n#FFDD00 Verification failed..#\n");
s_printf(gui->txt_buf, "\n#FFDD00 File not found or could not be loaded!#\n#FFDD00 Verification failed..#\n");
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
return VERIF_STATUS_ERROR;
return 1;
}
}
@@ -350,7 +346,6 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part,
partial_sd_full_unmount = false;
u32 verification = n_cfg.verification;
u32 multipartSplitSize = (1u << 31);
u32 lba_end = part->lba_end;
u32 totalSectors = part->lba_end - part->lba_start + 1;
@@ -376,7 +371,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part,
_get_valid_partition(&sector_start, &sector_size, &part_idx, true);
if (!part_idx || !sector_size)
{
strcpy(gui->txt_buf, "\n#FFDD00 Failed to find a partition...#\n");
s_printf(gui->txt_buf, "\n#FFDD00 Failed to find a partition...#\n");
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
@@ -399,7 +394,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part,
lv_bar_set_value(gui->bar, 0);
lv_label_set_text(gui->label_pct, " "SYMBOL_DOT" 0%");
lv_bar_set_style(gui->bar, LV_BAR_STYLE_BG, gui->bar_white_bg);
lv_bar_set_style(gui->bar, LV_BAR_STYLE_BG, lv_theme_get_current()->bar.bg);
lv_bar_set_style(gui->bar, LV_BAR_STYLE_INDIC, gui->bar_white_ind);
manual_system_maintenance(true);
@@ -414,13 +409,13 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part,
{
isSmallSdCard = true;
strcpy(gui->txt_buf, "\n#FFBA00 Free space is smaller than backup size.#\n");
s_printf(gui->txt_buf, "\n#FFBA00 Free space is smaller than backup size.#\n");
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
if (!maxSplitParts)
{
strcpy(gui->txt_buf, "#FFDD00 Not enough free space for Partial Backup!#\n");
s_printf(gui->txt_buf, "#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);
@@ -430,7 +425,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part,
// Check if we are continuing a previous raw eMMC or USER partition backup in progress.
if (f_open(&partialIdxFp, partialIdxFilename, FA_READ) == FR_OK && totalSectors > (FAT32_FILESIZE_LIMIT / EMMC_BLOCKSIZE))
{
strcpy(gui->txt_buf, "\n#AEFD14 Partial Backup in progress. Continuing...#\n");
s_printf(gui->txt_buf, "\n#AEFD14 Partial Backup in progress. Continuing...#\n");
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
@@ -443,7 +438,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part,
if (!maxSplitParts)
{
strcpy(gui->txt_buf, "\n#FFDD00 Not enough free space for Partial Backup!#\n");
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);
@@ -541,25 +536,18 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part,
memset(&fp, 0, sizeof(fp));
currPartIdx++;
if (verification && !gui->raw_emummc)
if (n_cfg.verification && !gui->raw_emummc)
{
// Verify part.
res = _emmc_sd_copy_verify(gui, storage, lbaStartPart, outFilename, part);
switch (res)
if (_dump_emmc_verify(gui, storage, lbaStartPart, outFilename, part))
{
case VERIF_STATUS_OK:
break;
case VERIF_STATUS_ERROR:
strcpy(gui->txt_buf, "\n#FFDD00 Please try again...#\n");
s_printf(gui->txt_buf, "#FFDD00 Please try again...#\n");
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
return 0;
case VERIF_STATUS_ABORT:
verification = 0;
break;
}
lv_bar_set_style(gui->bar, LV_BAR_STYLE_BG, gui->bar_white_bg);
return 0;
}
lv_bar_set_style(gui->bar, LV_BAR_STYLE_BG, lv_theme_get_current()->bar.bg);
lv_bar_set_style(gui->bar, LV_BAR_STYLE_INDIC, gui->bar_white_ind);
}
@@ -576,7 +564,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part,
}
else
{
strcpy(gui->txt_buf, "\n#FF0000 Error creating partial.idx file!#\n");
s_printf(gui->txt_buf, "\n#FF0000 Error creating partial.idx file!#\n");
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
@@ -655,7 +643,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part,
msleep(150);
if (retryCount >= 3)
{
strcpy(gui->txt_buf, "#FF0000 Aborting...#\nPlease try again...\n");
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);
@@ -667,7 +655,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part,
}
else
{
strcpy(gui->txt_buf, "#FFDD00 Retrying...#\n");
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);
}
@@ -698,6 +686,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part,
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;
}
@@ -715,7 +704,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part,
// Check for cancellation combo.
if (btn_read_vol() == (BTN_VOL_UP | BTN_VOL_DOWN))
{
strcpy(gui->txt_buf, "\n#FFDD00 The backup was cancelled!#\n");
s_printf(gui->txt_buf, "\n#FFDD00 The backup was cancelled!#\n");
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
@@ -736,12 +725,12 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part,
f_close(&fp);
free(clmt);
if (verification && !gui->raw_emummc)
if (n_cfg.verification && !gui->raw_emummc)
{
// Verify last part or single file backup.
if (_emmc_sd_copy_verify(gui, storage, lbaStartPart, outFilename, part) == VERIF_STATUS_ERROR)
if (_dump_emmc_verify(gui, storage, lbaStartPart, outFilename, part))
{
strcpy(gui->txt_buf, "\n#FFDD00 Please try again...#\n");
s_printf(gui->txt_buf, "\n#FFDD00 Please try again...#\n");
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
@@ -781,14 +770,16 @@ void dump_emmc_selected(emmcPartType_t dumpType, emmc_tool_gui_t *gui)
lv_label_set_text(gui->label_info, "Checking for available free space...");
manual_system_maintenance(true);
if (!sd_mount())
if (!boot_storage_mount())
{
lv_label_set_text(gui->label_info, "#FFDD00 Failed to init SD!#");
lv_label_set_text(gui->label_info, "#FFDD00 Failed to storage!#");
goto out;
}
// Get SD Card free space for Partial Backup.
f_getfree("", &sd_fs.free_clst, NULL);
FATFS *fs = boot_storage_get_fs();
f_getfree("", &fs->free_clst, NULL);
if (!emmc_initialize(false))
{
@@ -845,9 +836,9 @@ void dump_emmc_selected(emmcPartType_t dumpType, emmc_tool_gui_t *gui)
res = _dump_emmc_part(gui, sdPath, i, &emmc_storage, &bootPart);
if (!res)
strcpy(txt_buf, "#FFDD00 Failed!#\n");
s_printf(txt_buf, "#FFDD00 Failed!#\n");
else
strcpy(txt_buf, "Done!\n");
s_printf(txt_buf, "Done!\n");
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, txt_buf);
manual_system_maintenance(true);
@@ -886,12 +877,12 @@ void dump_emmc_selected(emmcPartType_t dumpType, emmc_tool_gui_t *gui)
// If a part failed, don't continue.
if (!res)
{
strcpy(txt_buf, "#FFDD00 Failed!#\n");
s_printf(txt_buf, "#FFDD00 Failed!#\n");
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, txt_buf);
break;
}
else
strcpy(txt_buf, "Done!\n");
s_printf(txt_buf, "Done!\n");
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, txt_buf);
manual_system_maintenance(true);
@@ -928,9 +919,9 @@ void dump_emmc_selected(emmcPartType_t dumpType, emmc_tool_gui_t *gui)
res = _dump_emmc_part(gui, sdPath, 2, &emmc_storage, &rawPart);
if (!res)
strcpy(txt_buf, "#FFDD00 Failed!#\n");
s_printf(txt_buf, "#FFDD00 Failed!#\n");
else
strcpy(txt_buf, "Done!\n");
s_printf(txt_buf, "Done!\n");
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, txt_buf);
manual_system_maintenance(true);
@@ -954,11 +945,11 @@ out:
free(txt_buf);
free(gui->base_path);
if (!partial_sd_full_unmount)
sd_unmount();
boot_storage_unmount();
else
{
partial_sd_full_unmount = false;
sd_end();
boot_storage_end();
}
}
@@ -966,7 +957,6 @@ static int _restore_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_pa
{
static const u32 SECTORS_TO_MIB_COEFF = 11;
u32 verification = n_cfg.verification;
u32 lba_end = part->lba_end;
u32 totalSectors = part->lba_end - part->lba_start + 1;
u32 currPartIdx = 0;
@@ -983,8 +973,8 @@ static int _restore_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_pa
lv_bar_set_value(gui->bar, 0);
lv_label_set_text(gui->label_pct, " "SYMBOL_DOT" 0%");
lv_bar_set_style(gui->bar, LV_BAR_STYLE_BG, gui->bar_orange_bg);
lv_bar_set_style(gui->bar, LV_BAR_STYLE_INDIC, gui->bar_orange_ind);
lv_bar_set_style(gui->bar, LV_BAR_STYLE_BG, lv_theme_get_current()->bar.bg);
lv_bar_set_style(gui->bar, LV_BAR_STYLE_INDIC, gui->bar_white_ind);
manual_system_maintenance(true);
bool use_multipart = false;
@@ -997,7 +987,7 @@ static int _restore_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_pa
if (f_stat(outFilename, &fno))
{
// If not, check if there are partial files and the total size matches.
strcpy(gui->txt_buf, "\nNo single file, checking for part files...\n");
s_printf(gui->txt_buf, "\nNo single file, checking for part files...\n");
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
@@ -1023,7 +1013,7 @@ static int _restore_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_pa
if ((u32)((u64)totalCheckFileSize >> (u64)9) > totalSectors)
{
strcpy(gui->txt_buf, "\n#FF8000 Size of SD Card split backup exceeds#\n#FF8000 eMMC's selected part size!#\n#FFDD00 Aborting...#");
s_printf(gui->txt_buf, "\n#FF8000 Size of SD Card split backup exceeds#\n#FF8000 eMMC's selected part size!#\n#FFDD00 Aborting...#");
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
@@ -1045,14 +1035,13 @@ static int _restore_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_pa
{
// Set new total sectors and lba end sector for percentage calculations.
totalSectors = (u32)((u64)totalCheckFileSize >> (u64)9);
part->lba_end = totalSectors + part->lba_start - 1;
lba_end = part->lba_end;
lba_end = totalSectors + part->lba_start - 1;
}
// Restore folder is empty.
if (!numSplitParts)
{
strcpy(gui->txt_buf, "\n#FFDD00 Restore folder is empty.#\n\n");
s_printf(gui->txt_buf, "\n#FFDD00 Restore folder is empty.#\n\n");
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
@@ -1065,7 +1054,7 @@ static int _restore_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_pa
if (check_4MB_aligned && (((u64)fno.fsize) % SZ_4M))
{
strcpy(gui->txt_buf, "\n#FFDD00 The split file must be a#\n#FFDD00 multiple of 4 MiB.#\n#FFDD00 Aborting...#");
s_printf(gui->txt_buf, "\n#FFDD00 The split file must be a#\n#FFDD00 multiple of 4 MiB.#\n#FFDD00 Aborting...#");
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
@@ -1093,7 +1082,7 @@ static int _restore_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_pa
if (!(btn_wait() & BTN_POWER))
{
lv_obj_del(warn_mbox_bg);
strcpy(gui->txt_buf, "\n#FF0000 Size of SD Card split backup does not match#\n#FF0000 eMMC's selected part size!#\n");
s_printf(gui->txt_buf, "\n#FF0000 Size of SD Card split backup does not match#\n#FF0000 eMMC's selected part size!#\n");
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
@@ -1103,8 +1092,7 @@ static int _restore_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_pa
// Set new total sectors and lba end sector for percentage calculations.
totalSectors = (u32)((u64)totalCheckFileSize >> (u64)9);
part->lba_end = totalSectors + part->lba_start - 1;
lba_end = part->lba_end;
lba_end = totalSectors + part->lba_start - 1;
}
use_multipart = true;
_update_filename(outFilename, sdPathLen, 0);
@@ -1149,7 +1137,7 @@ multipart_not_allowed:
{
if (((u32)((u64)f_size(&fp) >> (u64)9)) > totalSectors)
{
strcpy(gui->txt_buf, "\n#FF8000 Size of SD Card backup exceeds#\n#FF8000 eMMC's selected part size!#\n#FFDD00 Aborting...#");
s_printf(gui->txt_buf, "\n#FF8000 Size of SD Card backup exceeds#\n#FF8000 eMMC's selected part size!#\n#FFDD00 Aborting...#");
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
@@ -1168,7 +1156,7 @@ multipart_not_allowed:
if (!(btn_wait() & BTN_POWER))
{
lv_obj_del(warn_mbox_bg);
strcpy(gui->txt_buf, "\n#FF0000 Size of the SD Card backup does not match#\n#FF0000 eMMC's selected part size.#\n");
s_printf(gui->txt_buf, "\n#FF0000 Size of the SD Card backup does not match#\n#FF0000 eMMC's selected part size.#\n");
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
@@ -1212,7 +1200,7 @@ multipart_not_allowed:
_get_valid_partition(&sector_start, &sector_size, &part_idx, false);
if (!part_idx || !sector_size)
{
strcpy(gui->txt_buf, "\n#FFDD00 Failed to find a partition...#\n");
s_printf(gui->txt_buf, "\n#FFDD00 Failed to find a partition...#\n");
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
@@ -1234,25 +1222,17 @@ multipart_not_allowed:
memset(&fp, 0, sizeof(fp));
currPartIdx++;
if (verification && !gui->raw_emummc)
if (n_cfg.verification && !gui->raw_emummc)
{
// Verify part.
res = _emmc_sd_copy_verify(gui, storage, lbaStartPart, outFilename, part);
switch (res)
if (_dump_emmc_verify(gui, storage, lbaStartPart, outFilename, part))
{
case VERIF_STATUS_OK:
break;
case VERIF_STATUS_ERROR:
strcpy(gui->txt_buf, "\n#FFDD00 Please try again...#\n");
s_printf(gui->txt_buf, "\n#FFDD00 Please try again...#\n");
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
return 0;
case VERIF_STATUS_ABORT:
verification = 0;
break;
}
lv_bar_set_style(gui->bar, LV_BAR_STYLE_BG, gui->bar_orange_bg);
lv_bar_set_style(gui->bar, LV_BAR_STYLE_INDIC, gui->bar_orange_ind);
}
_update_filename(outFilename, sdPathLen, currPartIdx);
@@ -1320,7 +1300,7 @@ multipart_not_allowed:
msleep(150);
if (retryCount >= 3)
{
strcpy(gui->txt_buf, "#FF0000 Aborting...#\n"
s_printf(gui->txt_buf, "#FF0000 Aborting...#\n"
"#FF0000 This device may be in an inoperative state!#\n"
"#FFDD00 Please try again now!#\n");
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
@@ -1332,7 +1312,7 @@ multipart_not_allowed:
}
else
{
strcpy(gui->txt_buf, "#FFDD00 Retrying...#\n");
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);
}
@@ -1364,12 +1344,12 @@ multipart_not_allowed:
f_close(&fp);
free(clmt);
if (verification && !gui->raw_emummc)
if (n_cfg.verification && !gui->raw_emummc)
{
// Verify restored data.
if (_emmc_sd_copy_verify(gui, storage, lbaStartPart, outFilename, part) == VERIF_STATUS_ERROR)
if (_dump_emmc_verify(gui, storage, lbaStartPart, outFilename, part))
{
strcpy(gui->txt_buf, "\n#FFDD00 Please try again...#\n");
s_printf(gui->txt_buf, "#FFDD00 Please try again...#\n");
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
@@ -1394,7 +1374,7 @@ multipart_not_allowed:
f_close(&fp_raw);
s_printf(sdPath, "emuMMC/RAW%d", part_idx);
save_emummc_cfg(part_idx, sector_start, sdPath);
save_emummc_cfg(part_idx, sector_start, sdPath, DRIVE_SD);
}
return 1;
@@ -1413,18 +1393,12 @@ void restore_emmc_selected(emmcPartType_t restoreType, emmc_tool_gui_t *gui)
manual_system_maintenance(true);
if (!gui->raw_emummc)
strcpy(txt_buf, "#FFDD00 This may render the device inoperative!#");
else
strcpy(txt_buf, "#FFDD00 This may render the emuMMC inoperative!#");
strcat(txt_buf, "\n\n#FFDD00 Are you really sure?#");
if (gui->raw_emummc)
strcat(txt_buf, "\n\nOnly the 1st emuMMC found can be restored!");
s_printf(txt_buf,
"#FFDD00 This may render the device inoperative!#\n\n"
"#FFDD00 Are you really sure?#");
if ((restoreType & PART_BOOT) || (restoreType & PART_GP_ALL))
{
strcat(txt_buf,
s_printf(txt_buf + strlen(txt_buf),
"\n\nThe mode you selected will only restore\nthe partitions that it can find.\n"
"If it is not found, it will be skipped\nand continue with the next.");
}
@@ -1513,9 +1487,9 @@ void restore_emmc_selected(emmcPartType_t restoreType, emmc_tool_gui_t *gui)
res = _restore_emmc_part(gui, sdPath, i, &emmc_storage, &bootPart, false);
if (!res)
strcpy(txt_buf, "#FFDD00 Failed!#\n");
s_printf(txt_buf, "#FFDD00 Failed!#\n");
else if (res > 0)
strcpy(txt_buf, "Done!\n");
s_printf(txt_buf, "Done!\n");
if (res >= 0)
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, txt_buf);
@@ -1549,9 +1523,9 @@ void restore_emmc_selected(emmcPartType_t restoreType, emmc_tool_gui_t *gui)
res = _restore_emmc_part(gui, sdPath, 0, &emmc_storage, part, false);
if (!res)
strcpy(txt_buf, "#FFDD00 Failed!#\n");
s_printf(txt_buf, "#FFDD00 Failed!#\n");
else if (res > 0)
strcpy(txt_buf, "Done!\n");
s_printf(txt_buf, "Done!\n");
if (res >= 0)
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, txt_buf);
@@ -1588,9 +1562,9 @@ void restore_emmc_selected(emmcPartType_t restoreType, emmc_tool_gui_t *gui)
res = _restore_emmc_part(gui, sdPath, 2, &emmc_storage, &rawPart, true);
if (!res)
strcpy(txt_buf, "#FFDD00 Failed!#\n");
s_printf(txt_buf, "#FFDD00 Failed!#\n");
else if (res > 0)
strcpy(txt_buf, "Done!\n");
s_printf(txt_buf, "Done!\n");
if (res >= 0)
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, txt_buf);

File diff suppressed because it is too large Load Diff

View File

@@ -30,11 +30,9 @@ typedef struct _emummc_cfg_t
} 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);
void dump_emummc_file(emmc_tool_gui_t *gui);
void dump_emummc_raw(emmc_tool_gui_t *gui, int part_idx, u32 sector_start, u32 resized_count);
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, 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);
int emummc_raw_derive_bis_keys();
#endif

View File

@@ -19,6 +19,7 @@
#include <bdk.h>
#include "gui.h"
#include "gui_emu_tools.h"
#include "gui_emummc_tools.h"
#include "gui_tools.h"
#include "gui_info.h"
@@ -29,6 +30,7 @@
#include "../config.h"
#include <libs/fatfs/ff.h>
#include <storage/boot_storage.h>
extern volatile boot_cfg_t *b_cfg;
extern volatile nyx_storage_t *nyx_str;
@@ -36,7 +38,7 @@ extern volatile nyx_storage_t *nyx_str;
extern lv_res_t launch_payload(lv_obj_t *list);
static bool disp_init_done = false;
static bool do_auto_reload = false;
static bool do_reload = false;
lv_style_t hint_small_style;
lv_style_t hint_small_style_white;
@@ -187,7 +189,7 @@ static void _save_log_to_bmp(char *fname)
char path[0x80];
strcpy(path, "bootloader/screenshots");
s_printf(path + strlen(path), "/nyx%s_log.bmp", fname);
sd_save_to_file(bitmap, file_size, path);
boot_storage_save_to_file(bitmap, file_size, path);
free(bitmap);
free(fb);
@@ -200,8 +202,8 @@ static void _save_fb_to_bmp()
if (get_tmr_ms() < timer)
return;
if (do_auto_reload)
goto exit;
if (do_reload)
return;
// Invalidate data.
bpmp_mmu_maintenance(BPMP_MMU_MAINT_INVALID_WAY, false);
@@ -271,7 +273,7 @@ static void _save_fb_to_bmp()
bmp->res_v = 2834;
bmp->rsvd2 = 0;
sd_mount();
boot_storage_mount();
char path[0x80];
@@ -288,7 +290,7 @@ static void _save_fb_to_bmp()
s_printf(path + strlen(path), "/nyx%s.bmp", fname);
// Save screenshot and log.
int res = sd_save_to_file(bitmap, file_size, path);
int res = boot_storage_save_to_file(bitmap, file_size, path);
if (!res)
_save_log_to_bmp(fname);
@@ -304,7 +306,6 @@ static void _save_fb_to_bmp()
manual_system_maintenance(true);
lv_mbox_start_auto_close(mbox, 4000);
exit:
// Set timer to 2s.
timer = get_tmr_ms() + 2000;
}
@@ -664,7 +665,7 @@ void manual_system_maintenance(bool refresh)
lv_img_dsc_t *bmp_to_lvimg_obj(const char *path)
{
u32 fsize;
u8 *bitmap = sd_file_read(path, &fsize);
u8 *bitmap = boot_storage_file_read(path, &fsize);
if (!bitmap)
return NULL;
@@ -794,7 +795,7 @@ lv_res_t mbox_action(lv_obj_t *btns, const char *txt)
bool nyx_emmc_check_battery_enough()
{
if (h_cfg.devmode)
if (fuse_read_hw_state() == FUSE_NX_HW_STATE_DEV)
return true;
int batt_volt = 0;
@@ -934,34 +935,17 @@ static void _launch_hos(u8 autoboot, u8 autoboot_list)
void (*main_ptr)() = (void *)nyx_str->hekate;
boot_storage_end();
sd_end();
emmc_end();
hw_deinit(false);
(*main_ptr)();
}
void reload_nyx(lv_obj_t *obj, bool force)
void reload_nyx()
{
if (!force)
{
sd_mount();
// Check that Nyx still exists.
if (f_stat("bootloader/sys/nyx.bin", NULL))
{
sd_unmount();
// Remove lvgl object in case of being invoked from a window.
if (obj)
lv_obj_del(obj);
do_auto_reload = false;
return;
}
}
b_cfg->boot_cfg = BOOT_CFG_AUTOBOOT_EN;
b_cfg->autoboot = 0;
b_cfg->autoboot_list = 0;
@@ -969,6 +953,9 @@ void reload_nyx(lv_obj_t *obj, bool force)
void (*main_ptr)() = (void *)nyx_str->hekate;
// TODO:
boot_storage_end();
emmc_end();
sd_end();
hw_deinit(false);
@@ -979,7 +966,7 @@ void reload_nyx(lv_obj_t *obj, bool force)
static lv_res_t reload_action(lv_obj_t *btns, const char *txt)
{
if (!lv_btnm_get_pressed(btns))
reload_nyx(NULL, false);
reload_nyx();
return mbox_action(btns, txt);
}
@@ -1001,7 +988,7 @@ static lv_res_t _removed_sd_action(lv_obj_t *btns, const char *txt)
break;
case 2:
sd_end();
do_auto_reload = false;
do_reload = false;
break;
}
@@ -1010,14 +997,12 @@ static lv_res_t _removed_sd_action(lv_obj_t *btns, const char *txt)
static void _check_sd_card_removed(void *params)
{
static lv_obj_t *dark_bg = NULL;
// The following checks if SDMMC_1 is initialized.
// If yes and card was removed, shows a message box,
// that will reload Nyx, when the card is inserted again.
if (!do_auto_reload && sd_get_card_removed())
if (!do_reload && sd_get_card_removed() && boot_storage_get_drive() == DRIVE_SD)
{
dark_bg = lv_obj_create(lv_scr_act(), NULL);
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);
@@ -1033,12 +1018,12 @@ static void _check_sd_card_removed(void *params)
lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_top(mbox, true);
do_auto_reload = true;
do_reload = true;
}
// If in reload state and card was inserted, reload nyx.
if (do_auto_reload && !sd_get_card_removed())
reload_nyx(dark_bg, false);
if (do_reload && !sd_get_card_removed() && boot_storage_get_drive() == DRIVE_SD)
reload_nyx();
}
lv_task_t *task_emmc_errors;
@@ -1472,14 +1457,15 @@ static lv_res_t _create_mbox_payloads(lv_obj_t *btn)
lv_obj_set_size(list, LV_HOR_RES * 3 / 7, LV_VER_RES * 3 / 7);
lv_list_set_single_mode(list, true);
if (!sd_mount())
if (!boot_storage_mount())
{
// TODO: may not be SD, change error
lv_mbox_set_text(mbox, "#FFDD00 Failed to init SD!#");
goto out_end;
}
dirlist_t *filelist = dirlist("bootloader/payloads", NULL, 0);
dirlist_t *filelist = dirlist("bootloader/payloads", NULL, false, false);
sd_unmount();
u32 i = 0;
@@ -1784,7 +1770,7 @@ static lv_res_t _create_window_home_launch(lv_obj_t *btn)
u32 curr_btn_idx = 0; // Active buttons.
LIST_INIT(ini_sections);
if (!sd_mount())
if (!boot_storage_mount())
goto failed_sd_mount;
// Check if we use custom system icons.
@@ -1980,7 +1966,7 @@ failed_sd_mount:
if (curr_btn_idx < 1)
no_boot_entries = true;
sd_unmount();
boot_storage_unmount();
free(tmp_path);
@@ -2147,7 +2133,7 @@ static void _create_tab_home(lv_theme_t *th, lv_obj_t *parent)
label_btn = lv_label_create(btn_emummc, label_btn);
s_printf(btn_colored_text, "%s%s", text_color, " "SYMBOL_LIST"#");
lv_label_set_text(label_btn, btn_colored_text);
lv_btn_set_action(btn_emummc, LV_BTN_ACTION_CLICK, create_win_emummc_tools);
lv_btn_set_action(btn_emummc, LV_BTN_ACTION_CLICK, create_win_emu_tools);
lv_btn_set_layout(btn_emummc, LV_LAYOUT_OFF);
lv_obj_align(label_btn, NULL, LV_ALIGN_CENTER, 0, -28);
lv_obj_set_pos(btn_emummc, 959, 160);
@@ -2179,7 +2165,7 @@ static lv_res_t _save_options_action(lv_obj_t *btn)
int res = 0;
if (sd_mount())
if (boot_storage_mount())
res = !create_config_entry();
if (res)
@@ -2191,7 +2177,7 @@ static lv_res_t _save_options_action(lv_obj_t *btn)
nyx_options_clear_ini_changes_made();
sd_unmount();
boot_storage_unmount();
return LV_RES_OK;
}

View File

@@ -28,10 +28,7 @@ typedef struct _emmc_tool_gui_t
lv_obj_t *bar;
lv_style_t *bar_teal_bg;
lv_style_t *bar_teal_ind;
lv_style_t *bar_white_bg;
lv_style_t *bar_white_ind;
lv_style_t *bar_orange_bg;
lv_style_t *bar_orange_ind;
char *txt_buf;
char *base_path;
bool raw_emummc;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-2025 CTCaer
* Copyright (c) 2018-2020 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,
@@ -101,7 +101,7 @@ static void _create_window_backup_restore(emmcPartType_t type, const char* win_l
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;
static lv_style_t bar_teal_bg, bar_teal_ind, bar_orange_bg, bar_orange_ind, bar_white_ind;
static lv_style_t bar_teal_bg, bar_teal_ind, bar_white_ind;
lv_style_copy(&bar_teal_bg, lv_theme_get_current()->bar.bg);
bar_teal_bg.body.main_color = LV_COLOR_HEX(0x005a47);
@@ -111,23 +111,12 @@ static void _create_window_backup_restore(emmcPartType_t type, const char* win_l
bar_teal_ind.body.main_color = LV_COLOR_HEX(0x00FFC9);
bar_teal_ind.body.grad_color = bar_teal_ind.body.main_color;
lv_style_copy(&bar_orange_bg, lv_theme_get_current()->bar.bg);
bar_orange_bg.body.main_color = LV_COLOR_HEX(0x755000);
bar_orange_bg.body.grad_color = bar_orange_bg.body.main_color;
lv_style_copy(&bar_orange_ind, lv_theme_get_current()->bar.indic);
bar_orange_ind.body.main_color = LV_COLOR_HEX(0xFFAE00);
bar_orange_ind.body.grad_color = bar_orange_ind.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_teal_ind = &bar_teal_ind;
emmc_tool_gui_ctxt.bar_orange_bg = &bar_orange_bg;
emmc_tool_gui_ctxt.bar_orange_ind = &bar_orange_ind;
emmc_tool_gui_ctxt.bar_white_bg = lv_theme_get_current()->bar.bg;
emmc_tool_gui_ctxt.bar_white_ind = &bar_white_ind;
lv_obj_t *bar = lv_bar_create(h1, NULL);
@@ -250,15 +239,15 @@ static lv_res_t _emmc_backup_buttons_raw_toggle(lv_obj_t *btn)
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_label_set_static_text(lv_obj_get_child(emmc_btn_ctxt.emmc_boot, NULL), SYMBOL_UPLOAD" emuMMC BOOT0 & BOOT1");
else
lv_label_set_static_text(lv_obj_get_child(emmc_btn_ctxt.emmc_boot, NULL), SYMBOL_DOWNLOAD" SD emuMMC BOOT0 & BOOT1");
lv_label_set_static_text(lv_obj_get_child(emmc_btn_ctxt.emmc_boot, NULL), SYMBOL_DOWNLOAD" 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_UPLOAD" SD emuMMC RAW GPP");
lv_label_set_static_text(lv_obj_get_child(emmc_btn_ctxt.emmc_raw_gpp, NULL), SYMBOL_UPLOAD" emuMMC RAW GPP");
else
lv_label_set_static_text(lv_obj_get_child(emmc_btn_ctxt.emmc_raw_gpp, NULL), SYMBOL_DOWNLOAD" SD emuMMC RAW GPP");
lv_label_set_static_text(lv_obj_get_child(emmc_btn_ctxt.emmc_raw_gpp, NULL), SYMBOL_DOWNLOAD" emuMMC RAW GPP");
lv_obj_realign(emmc_btn_ctxt.emmc_raw_gpp);
lv_obj_set_click(emmc_btn_ctxt.emmc_sys, false);
@@ -464,7 +453,7 @@ lv_res_t create_window_backup_restore_tool(lv_obj_t *btn)
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);
sd_emummc_raw, SYMBOL_SD" emuMMC Raw Partition", _emmc_backup_buttons_raw_toggle, false);
emmc_btn_ctxt.raw_emummc = false;
return LV_RES_OK;

View File

@@ -0,0 +1,50 @@
#include "gui_emu_tools.h"
#include "gui.h"
#include "gui_emummc_tools.h"
#include <libs/lvgl/lv_core/lv_obj.h>
#include <libs/lvgl/lv_core/lv_style.h>
#include <libs/lvgl/lv_objx/lv_cont.h>
#include <libs/lvgl/lv_objx/lv_win.h>
static lv_obj_t *_create_container(lv_obj_t *parent){
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 = 0;
h_style.body.padding.ver = 0;
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 - 62);
lv_obj_set_click(h1, false);
lv_cont_set_layout(h1, LV_LAYOUT_OFF);
return h1;
}
lv_res_t create_win_emu_tools(lv_obj_t *btn){
lv_obj_t *win = nyx_create_standard_window(SYMBOL_EDIT " emuMMC Manage");
static lv_style_t win_style_no_pad;
lv_style_copy(&win_style_no_pad, lv_win_get_style(win, LV_WIN_STYLE_CONTENT_BG));
win_style_no_pad.body.padding.hor = 0;
win_style_no_pad.body.padding.inner = 0;
lv_win_set_style(win, LV_WIN_STYLE_CONTENT_BG, &win_style_no_pad);
/* Create container on window; win's CHILD_CHG moves it to the page, so we protect and re-parent to win */
lv_obj_t *cont = _create_container(win);
lv_obj_set_protect(cont, LV_PROTECT_PARENT);
lv_obj_set_parent(cont, win);
lv_obj_set_height(cont, 572);
create_tab_emummc_tools(cont);
/* Align to content area; y offset works now because cont stays on win */
lv_obj_t *content = lv_win_get_content(win);
lv_obj_align(cont, content, LV_ALIGN_IN_TOP_MID, -20, 50);
return LV_RES_OK;
}

View File

@@ -0,0 +1,8 @@
#ifndef _GUI_EMU_TOOLS_H_
#define _GUI_EMU_TOOLS_H_
#include <libs/lvgl/lvgl.h>
lv_res_t create_win_emu_tools(lv_obj_t *btn);
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -19,6 +19,6 @@
#include <libs/lvgl/lvgl.h>
lv_res_t create_win_emummc_tools(lv_obj_t *btn);
lv_res_t create_tab_emummc_tools(lv_obj_t *parent);
#endif

View File

@@ -23,6 +23,7 @@
#include "../hos/hos.h"
#include "../hos/pkg1.h"
#include <libs/fatfs/ff.h>
#include <storage/boot_storage.h>
#include <stdlib.h>
@@ -75,15 +76,15 @@ static lv_res_t _cal0_dump_window_action(lv_obj_t *btns, const char * txt)
if (btn_idx == 1)
{
int error = !sd_mount();
int error = !boot_storage_mount();
if (!error)
{
char path[64];
emmcsn_path_impl(path, "/dumps", "cal0.bin", NULL);
error = sd_save_to_file((u8 *)cal0_buf, SZ_32K, path);
error = boot_storage_save_to_file((u8 *)cal0_buf, SZ_32K, path);
sd_unmount();
boot_storage_unmount();
}
_create_window_dump_done(error, "cal0.bin");
@@ -95,7 +96,7 @@ static lv_res_t _cal0_dump_window_action(lv_obj_t *btns, const char * txt)
static lv_res_t _battery_dump_window_action(lv_obj_t * btn)
{
int error = !sd_mount();
int error = !boot_storage_mount();
if (!error)
{
@@ -105,9 +106,9 @@ static lv_res_t _battery_dump_window_action(lv_obj_t * btn)
max17050_dump_regs(buf);
emmcsn_path_impl(path, "/dumps", "fuel_gauge.bin", NULL);
error = sd_save_to_file((u8 *)buf, 0x200, path);
error = boot_storage_save_to_file((u8 *)buf, 0x200, path);
sd_unmount();
boot_storage_unmount();
}
_create_window_dump_done(error, "fuel_gauge.bin");
@@ -119,7 +120,7 @@ static lv_res_t _bootrom_dump_window_action(lv_obj_t * btn)
{
static const u32 BOOTROM_SIZE = 0x18000;
int error = !sd_mount();
int error = !boot_storage_mount();
if (!error)
{
char path[64];
@@ -129,13 +130,13 @@ static lv_res_t _bootrom_dump_window_action(lv_obj_t * btn)
if (!error)
{
emmcsn_path_impl(path, "/dumps", "evp_thunks.bin", NULL);
error = sd_save_to_file((u8 *)iram_evp_thunks, iram_evp_thunks_len, path);
error = boot_storage_save_to_file((u8 *)iram_evp_thunks, iram_evp_thunks_len, path);
}
else
error = 255;
emmcsn_path_impl(path, "/dumps", "bootrom_patched.bin", NULL);
int res = sd_save_to_file((u8 *)IROM_BASE, BOOTROM_SIZE, path);
int res = boot_storage_save_to_file((u8 *)IROM_BASE, BOOTROM_SIZE, path);
if (!error)
error = res;
@@ -144,13 +145,13 @@ static lv_res_t _bootrom_dump_window_action(lv_obj_t * btn)
memset((void*)IPATCH_BASE, 0, sizeof(ipatch_cam)); // Zeroing valid entries is enough but zero everything.
emmcsn_path_impl(path, "/dumps", "bootrom_unpatched.bin", NULL);
res = sd_save_to_file((u8 *)IROM_BASE, BOOTROM_SIZE, path);
res = boot_storage_save_to_file((u8 *)IROM_BASE, BOOTROM_SIZE, path);
if (!error)
error = res;
memcpy((void*)IPATCH_BASE, ipatch_cam, sizeof(ipatch_cam));
sd_unmount();
boot_storage_unmount();
}
_create_window_dump_done(error, "evp_thunks.bin, bootrom_patched.bin, bootrom_unpatched.bin");
@@ -180,14 +181,14 @@ static void _unlock_reserved_odm_fuses(bool lock)
static lv_res_t _fuse_dump_window_action(lv_obj_t * btn)
{
int error = !sd_mount();
int error = !boot_storage_mount();
if (!error)
{
char path[128];
if (!h_cfg.t210b01)
{
emmcsn_path_impl(path, "/dumps", "fuse_cached_t210.bin", NULL);
error = sd_save_to_file((u8 *)0x7000F900, 0x300, path);
error = boot_storage_save_to_file((u8 *)0x7000F900, 0x300, path);
emmcsn_path_impl(path, "/dumps", "fuse_array_raw_t210.bin", NULL);
}
else
@@ -196,10 +197,10 @@ static lv_res_t _fuse_dump_window_action(lv_obj_t * btn)
_unlock_reserved_odm_fuses(false);
emmcsn_path_impl(path, "/dumps", "fuse_cached_t210b01_x898.bin", NULL);
error = sd_save_to_file((u8 *)0x7000F898, 0x68, path);
error = boot_storage_save_to_file((u8 *)0x7000F898, 0x68, path);
emmcsn_path_impl(path, "/dumps", "fuse_cached_t210b01_x900.bin", NULL);
if (!error)
error = sd_save_to_file((u8 *)0x7000F900, 0x300, path);
error = boot_storage_save_to_file((u8 *)0x7000F900, 0x300, path);
emmcsn_path_impl(path, "/dumps", "fuse_array_raw_t210b01.bin", NULL);
}
@@ -214,7 +215,7 @@ static lv_res_t _fuse_dump_window_action(lv_obj_t * btn)
if (h_cfg.t210b01)
_unlock_reserved_odm_fuses(true);
sd_unmount();
boot_storage_unmount();
}
if (!h_cfg.t210b01)
@@ -231,15 +232,15 @@ static lv_res_t _kfuse_dump_window_action(lv_obj_t * btn)
int error = !kfuse_read(buf);
if (!error)
error = !sd_mount();
error = !boot_storage_mount();
if (!error)
{
char path[64];
emmcsn_path_impl(path, "/dumps", "kfuses.bin", NULL);
error = sd_save_to_file((u8 *)buf, KFUSE_NUM_WORDS * 4, path);
error = boot_storage_save_to_file((u8 *)buf, KFUSE_NUM_WORDS * 4, path);
sd_unmount();
boot_storage_unmount();
}
_create_window_dump_done(error, "kfuses.bin");
@@ -269,7 +270,7 @@ static lv_res_t _create_mbox_cal0(lv_obj_t *btn)
lv_label_set_style(lb_desc, &monospace_text);
lv_obj_set_width(lb_desc, LV_HOR_RES / 9 * 4);
sd_mount();
boot_storage_mount();
// Dump CAL0.
int cal0_res = hos_dump_cal0();
@@ -290,7 +291,7 @@ static lv_res_t _create_mbox_cal0(lv_obj_t *btn)
nx_emmc_cal0_t *cal0 = (nx_emmc_cal0_t *)cal0_buf;
u32 hash[8];
se_sha_hash_256_oneshot(hash, (u8 *)&cal0->cfg_id1, cal0->body_size);
se_calc_sha256_oneshot(hash, (u8 *)&cal0->cfg_id1, cal0->body_size);
s_printf(txt_buf,
"#FF8000 CAL0 Version:# %d\n"
@@ -369,7 +370,7 @@ static lv_res_t _create_mbox_cal0(lv_obj_t *btn)
out:
free(txt_buf);
sd_unmount();
boot_storage_unmount();
lv_mbox_add_btns(mbox, mbox_btn_map, _cal0_dump_window_action);
@@ -1094,6 +1095,30 @@ static lv_res_t _create_window_hw_info_status(lv_obj_t *btn)
switch (display_id)
{
case PANEL_RR_SUPER5_OLED_V1:
strcat(txt_buf, "RR SUPER5 OLED");
switch (display_rev)
{
case 0x01:
strcat(txt_buf, "-V1");
break;
default:
strcat(txt_buf, " #FFDD00 Contact me!#");
break;
}
break;
case PANEL_RR_SUPER5_OLED_HD_V1:
strcat(txt_buf, "RR SUPER5 OLED HD");
switch (display_rev)
{
case 0x01:
strcat(txt_buf, "-V1");
break;
default:
strcat(txt_buf, " #FFDD00 Contact me!#");
break;
}
break;
case PANEL_JDI_LAM062M109A:
strcat(txt_buf, "JDI LAM062M109A");
break;
@@ -1811,7 +1836,7 @@ static lv_res_t _create_mbox_benchmark(bool sd_bench)
for (u32 i = 0; i < rnd_off_cnt; i += 4)
{
// Generate new random numbers.
while (!se_rng_pseudo(random_numbers, SE_RNG_BLOCK_SIZE))
while (!se_gen_prng128(random_numbers))
;
// Clamp offsets to 256MB range.
random_offsets[i + 0] = random_numbers[0] % sct_rem_4kb;
@@ -2881,7 +2906,7 @@ static bool _lockpick_exists_check()
bool found = false;
void *buf = malloc(0x200);
if (sd_mount())
if (boot_storage_mount())
{
FIL fp;
if (f_open(&fp, "bootloader/payloads/Lockpick_RCM.bin", FA_READ))
@@ -2906,7 +2931,7 @@ static bool _lockpick_exists_check()
out:
free(buf);
sd_unmount();
boot_storage_unmount();
return found;
}

View File

@@ -23,6 +23,7 @@
#include "../config.h"
#include <libs/lvgl/lv_themes/lv_theme_hekate.h>
#include <libs/lvgl/lvgl.h>
#include <storage/boot_storage.h>
#define CLOCK_MIN_YEAR 2025
#define CLOCK_MAX_YEAR (CLOCK_MIN_YEAR + 10)
@@ -224,7 +225,7 @@ static void _create_autoboot_window()
lv_obj_set_size(list_main, LV_HOR_RES * 4 / 10, LV_VER_RES * 4 / 7);
lv_list_set_single_mode(list_main, true);
sd_mount();
boot_storage_mount();
// Parse hekate main configuration.
LIST_INIT(ini_sections);
@@ -285,7 +286,7 @@ static void _create_autoboot_window()
ini_free(&ini_list_sections);
}
sd_unmount();
boot_storage_unmount();
}
static lv_res_t _autoboot_hide_delay_action(lv_obj_t *btn)
@@ -429,7 +430,7 @@ static lv_res_t _save_theme_color_action(lv_obj_t *btn)
// Save nyx config.
create_nyx_config_entry(true);
reload_nyx(NULL, false);
reload_nyx();
return LV_RES_OK;
}
@@ -944,7 +945,7 @@ static lv_res_t _joycon_info_dump_action(lv_obj_t * btn)
jc_pad->bt_conn_r.type = is_r_hos ? jc_pad->bt_conn_r.type : 0;
save_data:
error = !sd_mount() ? 5 : 0;
error = !boot_storage_mount() ? 5 : 0;
if (!error)
{
@@ -958,7 +959,8 @@ save_data:
memcpy(data, &jc_pad->bt_conn_l, sizeof(jc_bt_conn_t));
memcpy(data + sizeof(jc_bt_conn_t), &jc_pad->bt_conn_r, sizeof(jc_bt_conn_t));
error = sd_save_to_file((u8 *)data, sizeof(jc_bt_conn_t) * 2, "switchroot/joycon_mac.bin") ? 4 : 0;
// TODO: JC dump should probably go to sd?
error = boot_storage_save_to_file((u8 *)data, sizeof(jc_bt_conn_t) * 2, "switchroot/joycon_mac.bin") ? 4 : 0;
// Save readable dump.
data[0] = 0;
@@ -1080,7 +1082,7 @@ save_data:
}
}
sd_unmount();
boot_storage_unmount();
}
disabled_or_cal0_issue:;

File diff suppressed because it is too large Load Diff

View File

@@ -25,5 +25,6 @@ void create_tab_tools(lv_theme_t *th, lv_obj_t *parent);
void nyx_run_ums(void *param);
bool get_set_autorcm_status(bool change);
lv_res_t action_ums_sd(lv_obj_t *btn);
lv_res_t action_ums_emmc_gpp(lv_obj_t *btn);
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2025 CTCaer
* Copyright (c) 2019-2020 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,
@@ -17,7 +17,6 @@
#ifndef _GUI_TOOLS_PART_MANAGER_H_
#define _GUI_TOOLS_PART_MANAGER_H_
lv_res_t create_window_sd_partition_manager(lv_obj_t *btn);
lv_res_t create_window_emmc_partition_manager(lv_obj_t *btn);
lv_res_t create_window_partition_manager(lv_obj_t *btn, u8 drive);
#endif