Compare commits

...

16 Commits

Author SHA1 Message Date
ctcaer@gmail.com
101c8bc1d0 Bump hekate to v5.0.1 and Nyx to v0.8.1 2019-07-06 22:43:53 +03:00
ctcaer@gmail.com
9b80ec9ac7 [emuMMC] Improve change logic
It can now properly show the existing sd parition emuMMC
2019-07-06 22:42:59 +03:00
ctcaer@gmail.com
ac425368e4 [emuMMC] Improve migrate logic
It can now find more existing emuMMC
2019-07-06 22:42:01 +03:00
ctcaer@gmail.com
205dab6cbd [Nyx] Add power options when sd card removed
Additionally disable screenshot function.
2019-07-06 22:40:39 +03:00
ctcaer@gmail.com
ac7eb092d5 [emuMMC] Change partition type to xE0 2019-07-06 22:39:44 +03:00
ctcaer@gmail.com
fed15a2f2f [Nyx] Add init of temperature sensor 2019-07-06 22:36:35 +03:00
ctcaer@gmail.com
2bb0dba724 [Nyx] Add button to force HOS boot screen logs 2019-07-06 22:34:03 +03:00
ctcaer@gmail.com
078ef1c4f1 Remove backup hash mode from main to reduce bin size. 2019-07-06 22:32:49 +03:00
ctcaer@gmail.com
c40c125462 [emuMMC] Disable stock emuMMC unti it's fixed 2019-07-06 22:30:22 +03:00
ctcaer@gmail.com
5b919cb12e [Touch] Fix touch hang for some SoC revisions
Fixes the hang on Nyx boot.
2019-07-06 22:24:03 +03:00
ctcaer@gmail.com
138da26a9a [BPMP] Fix cache coherency issues
+ Fix framebuffer memfetcher for some SoC revisions.
2019-07-06 22:22:47 +03:00
ctcaer@gmail.com
18a29c641c [HOS] Easier kip patching update from release
Kip patches will be loaded from patches.ini.
If that's not found, then patches_template.ini will be used.
2019-07-06 22:18:32 +03:00
ctcaer@gmail.com
0862cb1e7e [HOS] Fixed 6.0.x/6.1.0 stock 2019-07-06 22:16:42 +03:00
ctcaer@gmail.com
f26cfac10d [HOS] Add CFW custom keygen for 6.2.0 2019-07-06 22:10:23 +03:00
ctcaer@gmail.com
08b84384a6 Bugfixes and cleanup 2019-07-06 22:08:37 +03:00
CTCaer
d55634638f Update banner in readme 2019-06-30 06:38:48 +03:00
50 changed files with 548 additions and 657 deletions

View File

@@ -11,7 +11,7 @@ NYX_STORAGE_ADDR := 0xED000000
IPL_MAGIC := 0x43544349 #"ICTC"
BLVERSION_MAJOR := 5
BLVERSION_MINOR := 0
BLVERSION_HOTFX := 0
BLVERSION_HOTFX := 1
BL_RESERVED := 0

View File

@@ -1,6 +1,6 @@
# hekate - CTCaer mod
![Image of Hekate](https://i.imgur.com/O3REoy5.png)
![Image of Hekate](https://user-images.githubusercontent.com/3665130/60391760-bc1e8c00-9afe-11e9-8b7a-b065873081b2.png)
Custom Nintendo Switch bootloader, firmware patcher, and more.
@@ -13,7 +13,7 @@ Custom Nintendo Switch bootloader, firmware patcher, and more.
| bootloader | Main folder. |
| \|__ bootlogo.bmp | It is used when custom is on and no logopath found. Can be skipped. |
| \|__ hekate_ipl.ini | Main bootloader configuration and boot entries. |
| \|__ patches | Add external patches. Can be skipped |
| \|__ patches.ini | Add external patches. Can be skipped |
| \|__ update.bin | If newer, it is loaded at boot. For modchips. Can be skipped. |
| bootloader/ini/ | For individual inis. 'More configs...' menu. Autoboot is supported. |
| bootloader/res/ | Nyx user resources. Icons and more. |

View File

@@ -161,9 +161,6 @@ int create_config_entry()
f_close(&fp);
sd_unmount();
if (mainIniFound)
ini_free(&ini_sections);
return 0;
}
@@ -269,7 +266,6 @@ out2:;
free(ments);
free(boot_values);
free(boot_text);
ini_free(&ini_sections);
sd_unmount();
}
@@ -382,7 +378,6 @@ out2:;
free(ments);
free(boot_values);
free(boot_text);
ini_free(&ini_sections);
sd_unmount();
@@ -455,11 +450,11 @@ void config_verification()
gfx_clear_grey(0x1B);
gfx_con_setpos(0, 0);
ment_t *ments = (ment_t *)malloc(sizeof(ment_t) * 7);
u32 *vr_values = (u32 *)malloc(sizeof(u32) * 4);
char *vr_text = (char *)malloc(64 * 4);
ment_t *ments = (ment_t *)malloc(sizeof(ment_t) * 6);
u32 *vr_values = (u32 *)malloc(sizeof(u32) * 3);
char *vr_text = (char *)malloc(64 * 3);
for (u32 j = 0; j < 4; j++)
for (u32 j = 0; j < 3; j++)
{
vr_values[j] = j;
ments[j + 2].type = MENT_DATA;
@@ -474,9 +469,8 @@ void config_verification()
memcpy(vr_text, " Disable (Fastest - Unsafe)", 28);
memcpy(vr_text + 64, " Sparse (Fast - Safe)", 23);
memcpy(vr_text + 128, " Full (Slow - Safe)", 23);
memcpy(vr_text + 192, " Full (w/ hashfile)", 23);
for (u32 i = 0; i < 4; i++)
for (u32 i = 0; i < 3; i++)
{
if (h_cfg.verification != i)
vr_text[64 * i] = ' ';
@@ -485,7 +479,7 @@ void config_verification()
ments[2 + i].caption = vr_text + (i * 64);
}
memset(&ments[6], 0, sizeof(ment_t));
memset(&ments[5], 0, sizeof(ment_t));
menu_t menu = {ments, "Backup & Restore verification", 0, 0};
u32 *temp_verification = (u32 *)tui_do_menu(&menu);

View File

@@ -178,64 +178,6 @@ int ini_parse(link_t *dst, char *ini_path, bool is_dir)
return 1;
}
void ini_free(link_t *dst)
{
if (!dst->prev || !dst->next)
return;
LIST_FOREACH_ENTRY(ini_sec_t, ini_sec, dst, link)
{
if (ini_sec->type == INI_CHOICE)
{
LIST_FOREACH_ENTRY(ini_kv_t, kv, &ini_sec->kvs, link)
{
free(kv->key);
free(kv->val);
//free(kv);
}
}
free(ini_sec->name);
//free(ini_sec);
}
list_init(dst);
}
ini_sec_t *ini_clone_section(ini_sec_t *cfg)
{
if (cfg == NULL)
return NULL;
ini_sec_t *csec = (ini_sec_t *)malloc(sizeof(ini_sec_t));
list_init(&csec->kvs);
LIST_FOREACH_ENTRY(ini_kv_t, kv, &cfg->kvs, link)
{
ini_kv_t *kvcfg = (ini_kv_t *)malloc(sizeof(ini_kv_t));
kvcfg->key = _strdup(kv->key);
kvcfg->val = _strdup(kv->val);
list_append(&csec->kvs, &kvcfg->link);
}
return csec;
}
void ini_free_section(ini_sec_t *cfg)
{
if (cfg == NULL)
return;
LIST_FOREACH_ENTRY(ini_kv_t, kv, &cfg->kvs, link)
{
free(kv->key);
free(kv->val);
//free(kv);
}
//free(cfg);
cfg = NULL;
}
char *ini_check_payload_section(ini_sec_t *cfg)
{
char *path = NULL;

View File

@@ -44,9 +44,6 @@ typedef struct _ini_sec_t
} ini_sec_t;
int ini_parse(link_t *dst, char *ini_path, bool is_dir);
void ini_free(link_t *dst);
ini_sec_t *ini_clone_section(ini_sec_t *cfg);
void ini_free_section(ini_sec_t *cfg);
char *ini_check_payload_section(ini_sec_t *cfg);
#endif

View File

@@ -37,7 +37,6 @@
#define NUM_SECTORS_PER_ITER 8192 // 4MB Cache.
#define OUT_FILENAME_SZ 128
#define HASH_FILENAME_SZ (OUT_FILENAME_SZ + 11) // 11 == strlen(".sha256sums")
#define SHA256_SZ 0x20
extern sdmmc_t sd_sdmmc;
@@ -55,44 +54,17 @@ extern void emmcsn_path_impl(char *path, char *sub_dir, char *filename, sdmmc_st
static int _dump_emmc_verify(sdmmc_storage_t *storage, u32 lba_curr, char *outFilename, emmc_part_t *part)
{
FIL fp;
FIL hashFp;
u8 sparseShouldVerify = 4;
u32 btn = 0;
u32 prevPct = 200;
u32 sdFileSector = 0;
int res = 0;
const char hexa[] = "0123456789abcdef";
u8 hashEm[SHA256_SZ];
u8 hashSd[SHA256_SZ];
if (f_open(&fp, outFilename, FA_READ) == FR_OK)
{
if (h_cfg.verification == 3)
{
char hashFilename[HASH_FILENAME_SZ];
strncpy(hashFilename, outFilename, OUT_FILENAME_SZ - 1);
strcat(hashFilename, ".sha256sums");
res = f_open(&hashFp, hashFilename, FA_CREATE_ALWAYS | FA_WRITE);
if (res)
{
f_close(&fp);
gfx_con.fntsz = 16;
EPRINTFARGS("\nHash file could not be opened for write (error %d).\n\nAborting..\n", res);
return 1;
}
char chunkSizeAscii[10];
itoa(NUM_SECTORS_PER_ITER * NX_EMMC_BLOCKSIZE, chunkSizeAscii, 10);
chunkSizeAscii[9] = '\0';
f_puts("# chunksize: ", &hashFp);
f_puts(chunkSizeAscii, &hashFp);
f_puts("\n", &hashFp);
}
u32 totalSectorsVer = (u32)((u64)f_size(&fp) >> (u64)9);
u8 *bufEm = (u8 *)EMMC_BUF_ALIGNED;
@@ -118,8 +90,6 @@ static int _dump_emmc_verify(sdmmc_storage_t *storage, u32 lba_curr, char *outFi
num, lba_curr);
f_close(&fp);
if (h_cfg.verification == 3)
f_close(&hashFp);
return 1;
}
f_lseek(&fp, (u64)sdFileSector << (u64)9);
@@ -129,9 +99,6 @@ static int _dump_emmc_verify(sdmmc_storage_t *storage, u32 lba_curr, char *outFi
EPRINTFARGS("\nFailed to read %d blocks (@LBA %08X),\nfrom sd card!\n\nVerification failed..\n", num, lba_curr);
f_close(&fp);
if (h_cfg.verification == 3)
f_close(&hashFp);
return 1;
}
@@ -145,27 +112,8 @@ static int _dump_emmc_verify(sdmmc_storage_t *storage, u32 lba_curr, char *outFi
EPRINTFARGS("\nSD and eMMC data (@LBA %08X),\ndo not match!\n\nVerification failed..\n", lba_curr);
f_close(&fp);
if (h_cfg.verification == 3)
f_close(&hashFp);
return 1;
}
if (h_cfg.verification == 3)
{
// Transform computed hash to readable hexadecimal
char hashStr[SHA256_SZ * 2 + 1];
char *hashStrPtr = hashStr;
for (int i = 0; i < SHA256_SZ; i++)
{
*(hashStrPtr++) = hexa[hashSd[i] >> 4];
*(hashStrPtr++) = hexa[hashSd[i] & 0x0F];
}
hashStr[SHA256_SZ * 2] = '\0';
f_puts(hashStr, &hashFp);
f_puts("\n", &hashFp);
}
}
pct = (u64)((u64)(lba_curr - part->lba_start) * 100u) / (u64)(part->lba_end - part->lba_start);
@@ -189,13 +137,11 @@ static int _dump_emmc_verify(sdmmc_storage_t *storage, u32 lba_curr, char *outFi
msleep(1000);
f_close(&fp);
f_close(&hashFp);
return 0;
}
}
f_close(&fp);
f_close(&hashFp);
tui_pbar(0, gfx_con.y, pct, 0xFFCCCCCC, 0xFF555555);

View File

@@ -121,7 +121,7 @@ void dump_packages12()
sdmmc_storage_read(&storage, 0x180000 / NX_EMMC_BLOCKSIZE + kb, 1, keyblob);
// Decrypt.
keygen(keyblob, kb, &tsec_ctxt);
keygen(keyblob, kb, &tsec_ctxt, NULL);
if (kb <= KB_FIRMWARE_VERSION_600)
h_cfg.se_keygen_done = 1;
free(keyblob);

View File

@@ -21,8 +21,8 @@
#include "../../common/common_gfx.h"
#define EPRINTF(text) ({ gfx_con.mute = false; gfx_printf("%k"text"%k\n", 0xFFFF0000, 0xFFCCCCCC); })
#define EPRINTFARGS(text, args...) ({ gfx_con.mute = false; gfx_printf("%k"text"%k\n", 0xFFFF0000, args, 0xFFCCCCCC); })
#define EPRINTF(text) gfx_printf("%k"text"%k\n", 0xFFFF0000, 0xFFCCCCCC)
#define EPRINTFARGS(text, args...) gfx_printf("%k"text"%k\n", 0xFFFF0000, args, 0xFFCCCCCC)
#define WPRINTF(text) gfx_printf("%k"text"%k\n", 0xFFFFDD00, 0xFFCCCCCC)
#define WPRINTFARGS(text, args...) gfx_printf("%k"text"%k\n", 0xFFFFDD00, args, 0xFFCCCCCC)

View File

@@ -52,6 +52,15 @@ extern bool sd_mount();
//#define DPRINTF(...) gfx_printf(__VA_ARGS__)
#define DPRINTF(...)
#define EHPRINTF(text) \
({ display_backlight_brightness(h_cfg.backlight, 1000); \
gfx_con.mute = false; \
gfx_printf("%k"text"%k\n", 0xFFFF0000, 0xFFCCCCCC); })
#define EHPRINTFARGS(text, args...) \
({ display_backlight_brightness(h_cfg.backlight, 1000); \
gfx_con.mute = false; \
gfx_printf("%k"text"%k\n", 0xFFFF0000, args, 0xFFCCCCCC); })
#define PKG2_LOAD_ADDR 0xA9800000
// Secmon mailbox.
@@ -174,9 +183,9 @@ void _sysctr0_reset()
SYSCTR0(SYSCTR0_COUNTERID11) = 0;
}
int keygen(u8 *keyblob, u32 kb, tsec_ctxt_t *tsec_ctxt)
int keygen(u8 *keyblob, u32 kb, tsec_ctxt_t *tsec_ctxt, launch_ctxt_t *hos_ctxt)
{
u8 tmp[0x20];
u8 tmp[0x30];
u32 retries = 0;
if (kb > KB_FIRMWARE_VERSION_MAX)
@@ -210,7 +219,7 @@ int keygen(u8 *keyblob, u32 kb, tsec_ctxt_t *tsec_ctxt)
// We rely on racing conditions, make sure we cover even the unluckiest cases.
if (retries > 15)
{
EPRINTF("\nFailed to get TSEC keys. Please try again.\n");
EHPRINTF("\nFailed to get TSEC keys. Please try again.\n");
return 0;
}
}
@@ -225,11 +234,31 @@ int keygen(u8 *keyblob, u32 kb, tsec_ctxt_t *tsec_ctxt)
// Set TSEC root key.
se_aes_key_set(13, tmp + 0x10, 0x10);
// Package2 key.
se_aes_key_set(8, tmp + 0x10, 0x10);
se_aes_unwrap_key(8, 8, master_keyseed_620);
se_aes_unwrap_key(8, 8, master_keyseed_retail);
se_aes_unwrap_key(8, 8, package2_keyseed);
if (!(emu_cfg.enabled && !h_cfg.emummc_force_disable) && hos_ctxt->stock)
{
// Package2 key.
se_aes_key_set(8, tmp + 0x10, 0x10);
se_aes_unwrap_key(8, 8, master_keyseed_620);
se_aes_unwrap_key(8, 8, master_keyseed_retail);
se_aes_unwrap_key(8, 8, package2_keyseed);
}
else
{
// Decrypt keyblob and set keyslots
se_aes_crypt_block_ecb(12, 0, tmp + 0x20, keyblob_keyseeds[0]);
se_aes_unwrap_key(15, 14, tmp + 0x20);
se_aes_unwrap_key(14, 15, console_keyseed_4xx_5xx);
se_aes_unwrap_key(15, 15, console_keyseed);
se_aes_unwrap_key(13, 13, master_keyseed_620);
se_aes_unwrap_key(12, 13, master_keyseed_retail);
se_aes_unwrap_key(10, 13, master_keyseed_4xx_5xx_610);
// Package2 key.
se_aes_unwrap_key(8, 12, package2_keyseed);
h_cfg.se_keygen_done = 1;
}
}
else
{
@@ -311,7 +340,7 @@ static int _read_emmc_pkg1(launch_ctxt_t *ctxt)
ctxt->pkg1_id = pkg1_identify(ctxt->pkg1);
if (!ctxt->pkg1_id)
{
EPRINTF("Unknown pkg1 version.");
EHPRINTF("Unknown pkg1 version.");
goto out;
}
gfx_printf("Identified pkg1 and Keyblob %d\n\n", ctxt->pkg1_id->kb);
@@ -375,7 +404,6 @@ out:;
static void _free_launch_components(launch_ctxt_t *ctxt)
{
ini_free_section(ctxt->cfg);
free(ctxt->keyblob);
free(ctxt->pkg1);
free(ctxt->pkg2);
@@ -411,13 +439,22 @@ int hos_launch(ini_sec_t *cfg)
// Try to parse config if present.
if (ctxt.cfg && !parse_boot_config(&ctxt))
{
EPRINTF("Wrong ini cfg or missing files!");
EHPRINTF("Wrong ini cfg or missing files!");
return 0;
}
// Enable emummc patching.
if (emu_cfg.enabled && !h_cfg.emummc_force_disable)
{
if (ctxt.stock)
{
EHPRINTF("Stock emuMMC is not supported yet!");
return 0;
}
ctxt.atmosphere = true; // Set atmosphere patching in case of Stock emuMMC and no fss0.
config_kip1patch(&ctxt, "emummc");
}
// Check if fuses lower than 4.0.0 and if yes apply NO Gamecard patch.
if (h_cfg.autonogc && !(fuse_read_odm(7) & ~0xF) && ctxt.pkg1_id->kb >= KB_FIRMWARE_VERSION_400)
@@ -439,7 +476,7 @@ int hos_launch(ini_sec_t *cfg)
return 0;
}
if (!keygen(ctxt.keyblob, ctxt.pkg1_id->kb, &tsec_ctxt))
if (!keygen(ctxt.keyblob, ctxt.pkg1_id->kb, &tsec_ctxt, &ctxt))
return 0;
DPRINTF("Generated keys\n");
if (ctxt.pkg1_id->kb <= KB_FIRMWARE_VERSION_600)
@@ -452,14 +489,14 @@ int hos_launch(ini_sec_t *cfg)
if (ctxt.pkg1_id->kb <= KB_FIRMWARE_VERSION_600)
pkg1_decrypt(ctxt.pkg1_id, ctxt.pkg1);
if (ctxt.pkg1_id->kb <= KB_FIRMWARE_VERSION_620)
if (ctxt.pkg1_id->kb <= KB_FIRMWARE_VERSION_620 && !(emu_cfg.enabled && !h_cfg.emummc_force_disable))
{
pkg1_unpack((void *)ctxt.pkg1_id->warmboot_base, (void *)ctxt.pkg1_id->secmon_base, NULL, ctxt.pkg1_id, ctxt.pkg1);
gfx_printf("Decrypted & unpacked pkg1\n");
}
else
{
EPRINTF("No mandatory secmon or warmboot provided!");
EHPRINTF("No mandatory secmon or warmboot provided!");
return 0;
}
}
@@ -471,7 +508,7 @@ int hos_launch(ini_sec_t *cfg)
{
if (ctxt.pkg1_id->kb >= KB_FIRMWARE_VERSION_700)
{
EPRINTF("No warmboot provided!");
EHPRINTF("No warmboot provided!");
return 0;
}
// Else we patch it to allow downgrading.
@@ -537,7 +574,7 @@ int hos_launch(ini_sec_t *cfg)
ctxt.pkg2_kernel_id = pkg2_identify(kernel_hash);
if (!ctxt.pkg2_kernel_id)
{
EPRINTF("Failed to identify kernel!");
EHPRINTF("Failed to identify kernel!");
return 0;
}
@@ -576,7 +613,7 @@ int hos_launch(ini_sec_t *cfg)
const char* unappliedPatch = pkg2_patch_kips(&kip1_info, ctxt.kip1_patches);
if (unappliedPatch != NULL)
{
EPRINTFARGS("Failed to apply '%s'!", unappliedPatch);
EHPRINTFARGS("Failed to apply '%s'!", unappliedPatch);
sd_unmount(); // Just exiting is not enough until pkg2_patch_kips stops modifying the string passed into it.
_free_launch_components(&ctxt);

View File

@@ -74,6 +74,6 @@ typedef struct _merge_kip_t
} merge_kip_t;
int hos_launch(ini_sec_t *cfg);
int keygen(u8 *keyblob, u32 kb, tsec_ctxt_t *tsec_ctxt);
int keygen(u8 *keyblob, u32 kb, tsec_ctxt_t *tsec_ctxt, launch_ctxt_t *hos_ctxt);
#endif

View File

@@ -72,15 +72,15 @@ PATCHSET_DEF(_secmon_6_patchset,
{ 0xDC8 + 0x820, _NOP() }, //package2 structure.
{ 0xDC8 + 0x82C, _NOP() }, //Version.
{ 0xDC8 + 0xE90, _NOP() }, //Header signature.
{ 0xDC8 + 0x112C, _NOP() }, //Sections SHA2.
{ 0xDC8 + 0x112C, _NOP() } //Sections SHA2.
// Fix sleep mode for debug.
{ 0x1A68 + 0x3854, 0x94000E45 }, //gpio_config_for_uart.
{ 0x1A68 + 0x3858, 0x97FFFC0F }, //clkrst_reboot_uarta.
{ 0x1A68 + 0x385C, 0x52A00021 }, //MOV W1, #0x10000 ; baudrate.
{ 0x1A68 + 0x3860, 0x2A1F03E0 }, //MOV W0, WZR ; uart_port -> A.
{ 0x1A68 + 0x3864, 0x72984001 }, //MOVK W1, #0xC200 ; baudrate.
{ 0x1A68 + 0x3868, 0x94000C8C }, //uart_configure.
{ 0x1A68 + 0x3A6C, _NOP() } // warmboot UARTA cfg.
// { 0x1A68 + 0x3854, 0x94000E45 }, //gpio_config_for_uart.
// { 0x1A68 + 0x3858, 0x97FFFC0F }, //clkrst_reboot_uarta.
// { 0x1A68 + 0x385C, 0x52A00021 }, //MOV W1, #0x10000 ; baudrate.
// { 0x1A68 + 0x3860, 0x2A1F03E0 }, //MOV W0, WZR ; uart_port -> A.
// { 0x1A68 + 0x3864, 0x72984001 }, //MOVK W1, #0xC200 ; baudrate.
// { 0x1A68 + 0x3868, 0x94000C8C }, //uart_configure.
// { 0x1A68 + 0x3A6C, _NOP() } // warmboot UARTA cfg.
);
PATCHSET_DEF(_secmon_620_patchset,
@@ -88,15 +88,15 @@ PATCHSET_DEF(_secmon_620_patchset,
{ 0xDC8 + 0x604, _NOP() }, //package2 structure.
{ 0xDC8 + 0x610, _NOP() }, //Version.
{ 0xDC8 + 0xC74, _NOP() }, //Header signature.
{ 0xDC8 + 0xF10, _NOP() }, //Sections SHA2.
{ 0xDC8 + 0xF10, _NOP() } //Sections SHA2.
// Fix sleep mode for debug.
{ 0x2AC8 + 0x3854, 0x94000F42 }, //gpio_config_for_uart.
{ 0x2AC8 + 0x3858, 0x97FFFC0F }, //clkrst_reboot_uarta.
{ 0x2AC8 + 0x385C, 0x52A00021 }, //MOV W1, #0x10000 ; baudrate.
{ 0x2AC8 + 0x3860, 0x2A1F03E0 }, //MOV W0, WZR ; uart_port -> A.
{ 0x2AC8 + 0x3864, 0x72984001 }, //MOVK W1, #0xC200 ; baudrate.
{ 0x2AC8 + 0x3868, 0x94000D89 }, //uart_configure.
{ 0x2AC8 + 0x3A6C, _NOP() } // warmboot UARTA cfg.
// { 0x2AC8 + 0x3854, 0x94000F42 }, //gpio_config_for_uart.
// { 0x2AC8 + 0x3858, 0x97FFFC0F }, //clkrst_reboot_uarta.
// { 0x2AC8 + 0x385C, 0x52A00021 }, //MOV W1, #0x10000 ; baudrate.
// { 0x2AC8 + 0x3860, 0x2A1F03E0 }, //MOV W0, WZR ; uart_port -> A.
// { 0x2AC8 + 0x3864, 0x72984001 }, //MOVK W1, #0xC200 ; baudrate.
// { 0x2AC8 + 0x3868, 0x94000D89 }, //uart_configure.
// { 0x2AC8 + 0x3A6C, _NOP() } // warmboot UARTA cfg.
);
PATCHSET_DEF(_warmboot_1_patchset,

View File

@@ -547,8 +547,15 @@ static kip1_id_t _kip_ids[] =
static void parse_external_kip_patches()
{
u32 curr_kip_idx = 0;
char path[64];
strcpy(path, "bootloader/patches.ini");
// If patches.ini not found, try to load from template.
if (f_stat(path, NULL))
strcpy(path, "bootloader/patches_template.ini");
LIST_INIT(ini_kip_sections);
if (ini_patch_parse(&ini_kip_sections, "bootloader/patches.ini"))
if (ini_patch_parse(&ini_kip_sections, path))
{
// Parse patchsets and glue them together.
LIST_FOREACH_ENTRY(ini_kip_sec_t, ini_psec, &ini_kip_sections, link)
@@ -1031,7 +1038,7 @@ const char* pkg2_patch_kips(link_t *info, char* patchNames)
emu_cfg.fs_ver = currKipIdx;
if (currKipIdx)
emu_cfg.fs_ver--;
if (currKipIdx > 19)
if (currKipIdx > 17)
emu_cfg.fs_ver -= 2;
gfx_printf("Injecting emuMMC. FS ver: %d\n", emu_cfg.fs_ver);

View File

@@ -132,7 +132,6 @@ typedef struct _atm_fatal_error_ctx
// Exosphère mailbox defines.
#define EXO_CFG_ADDR 0x8000F000
#define EXO_MAGIC_VAL 0x304F5845
#define EXO_FLAG_620_KGN (1 << 0)
#define EXO_FLAG_DBG_PRIV (1 << 1)
#define EXO_FLAG_DBG_USER (1 << 2)
@@ -163,9 +162,6 @@ void config_exosphere(const char *id, u32 kb, void *warmboot, bool stock)
break;
}
if (kb == KB_FIRMWARE_VERSION_620)
exoFlags |= EXO_FLAG_620_KGN;
// To avoid problems, make private debug mode always on if not semi-stock.
if (!stock || (emu_cfg.enabled && !h_cfg.emummc_force_disable))
exoFlags |= EXO_FLAG_DBG_PRIV;
@@ -216,8 +212,10 @@ void config_exosphere(const char *id, u32 kb, void *warmboot, bool stock)
else
strcpy((char *)exo_cfg->emummc_cfg.file_cfg.path, emu_cfg.path);
if (emu_cfg.nintendo_path)
if (emu_cfg.nintendo_path && !stock)
strcpy((char *)exo_cfg->emummc_cfg.nintendo_path, emu_cfg.nintendo_path);
else if (stock)
strcpy((char *)exo_cfg->emummc_cfg.nintendo_path, "Nintendo");
else
exo_cfg->emummc_cfg.nintendo_path[0] = 0;
}

View File

@@ -76,10 +76,14 @@ extern sdmmc_storage_t sd_storage;
void check_sept()
{
// Check if non-hekate payload is used for sept and restore it.
if (h_cfg.sept_run && !f_stat("sept/payload.bak", NULL))
if (h_cfg.sept_run)
{
f_unlink("sept/payload.bin");
f_rename("sept/payload.bak", "sept/payload.bin");
if (!f_stat("sept/payload.bak", NULL))
{
f_unlink("sept/payload.bin");
f_rename("sept/payload.bak", "sept/payload.bin");
}
return;
}

View File

@@ -445,7 +445,6 @@ void ini_list_launcher()
u8 max_entries = 61;
char *payload_path = NULL;
ini_sec_t *cfg_tmp = NULL;
ini_sec_t *cfg_sec = NULL;
LIST_INIT(ini_list_sections);
@@ -485,9 +484,9 @@ void ini_list_launcher()
ments, "Launch ini configurations", 0, 0
};
cfg_tmp = (ini_sec_t *)tui_do_menu(&menu);
cfg_sec = (ini_sec_t *)tui_do_menu(&menu);
if (cfg_tmp)
if (cfg_sec)
{
u32 non_cfg = 1;
for (int j = 2; j < i; j++)
@@ -495,7 +494,7 @@ void ini_list_launcher()
if (ments[j].type != INI_CHOICE)
non_cfg++;
if (ments[j].data == cfg_tmp)
if (ments[j].data == cfg_sec)
{
b_cfg.boot_cfg = BOOT_CFG_FROM_LAUNCH;
b_cfg.autoboot = j - non_cfg;
@@ -506,17 +505,14 @@ void ini_list_launcher()
}
}
payload_path = ini_check_payload_section(cfg_tmp);
payload_path = ini_check_payload_section(cfg_sec);
if (cfg_tmp && !payload_path)
if (cfg_sec && !payload_path)
check_sept();
cfg_sec = ini_clone_section(cfg_tmp);
if (!cfg_sec)
{
free(ments);
ini_free(&ini_list_sections);
return;
}
@@ -524,7 +520,6 @@ void ini_list_launcher()
else
EPRINTF("No extra configs found.");
free(ments);
ini_free(&ini_list_sections);
}
else
EPRINTF("Could not find any ini\nin bootloader/ini!");
@@ -535,7 +530,6 @@ void ini_list_launcher()
if (payload_path)
{
ini_free_section(cfg_sec);
if (launch_payload(payload_path, false))
{
EPRINTF("Failed to launch payload.");
@@ -549,7 +543,6 @@ void ini_list_launcher()
}
out:
ini_free_section(cfg_sec);
btn_wait();
}
@@ -559,7 +552,6 @@ void launch_firmware()
u8 max_entries = 61;
char *payload_path = NULL;
ini_sec_t *cfg_tmp = NULL;
ini_sec_t *cfg_sec = NULL;
LIST_INIT(ini_sections);
@@ -613,16 +605,16 @@ void launch_firmware()
ments, "Launch configurations", 0, 0
};
cfg_tmp = (ini_sec_t *)tui_do_menu(&menu);
cfg_sec = (ini_sec_t *)tui_do_menu(&menu);
if (cfg_tmp)
if (cfg_sec)
{
u8 non_cfg = 4;
for (int j = 5; j < i; j++)
{
if (ments[j].type != INI_CHOICE)
non_cfg++;
if (ments[j].data == cfg_tmp)
if (ments[j].data == cfg_sec)
{
b_cfg.boot_cfg = BOOT_CFG_FROM_LAUNCH;
b_cfg.autoboot = j - non_cfg;
@@ -633,31 +625,28 @@ void launch_firmware()
}
}
payload_path = ini_check_payload_section(cfg_tmp);
payload_path = ini_check_payload_section(cfg_sec);
if (cfg_tmp)
if (cfg_sec)
{
LIST_FOREACH_ENTRY(ini_kv_t, kv, &cfg_tmp->kvs, link)
LIST_FOREACH_ENTRY(ini_kv_t, kv, &cfg_sec->kvs, link)
{
if (!strcmp("emummc_force_disable", kv->key))
h_cfg.emummc_force_disable = atoi(kv->val);
}
}
if (cfg_tmp && !payload_path)
if (cfg_sec && !payload_path)
check_sept();
cfg_sec = ini_clone_section(cfg_tmp);
if (!cfg_sec)
{
free(ments);
ini_free(&ini_sections);
sd_unmount();
return;
}
free(ments);
ini_free(&ini_sections);
}
else
EPRINTF("Could not open 'bootloader/hekate_ipl.ini'.\nMake sure it exists!");
@@ -675,7 +664,6 @@ void launch_firmware()
if (payload_path)
{
ini_free_section(cfg_sec);
if (launch_payload(payload_path, false))
{
EPRINTF("Failed to launch payload.");
@@ -686,7 +674,6 @@ void launch_firmware()
EPRINTF("Failed to launch firmware.");
out:
ini_free_section(cfg_sec);
sd_unmount();
h_cfg.emummc_force_disable = false;
@@ -722,7 +709,7 @@ void nyx_load_run()
nyx_str->version = ipl_ver.version - 0x303030;
memcpy((u8 *)nyx_str->irama, (void *)IRAM_BASE, 0x8000);
//memcpy((u8 *)nyx_str->irama, (void *)IRAM_BASE, 0x8000);
volatile reloc_meta_t *reloc = (reloc_meta_t *)(IPL_LOAD_ADDR + RELOC_META_OFF);
memcpy((u8 *)nyx_str->hekate, (u8 *)reloc->start, reloc->end - reloc->start);
@@ -730,17 +717,22 @@ void nyx_load_run()
bpmp_mmu_disable();
bpmp_clk_rate_set(BPMP_CLK_NORMAL);
msleep(100);
minerva_periodic_training();
// Some cards (Sandisk U1), do not like a fast power cycle. Wait min 100ms.
u32 sd_poweroff_time = (u32)get_tmr_ms() - h_cfg.sd_timeoff;
if (sd_poweroff_time < 100)
msleep(100 - sd_poweroff_time);
(*nyx_ptr)();
}
void auto_launch_firmware()
{
if(!h_cfg.sept_run && (b_cfg.extra_cfg & EXTRA_CFG_NYX_DUMP))
if(b_cfg.extra_cfg & EXTRA_CFG_NYX_DUMP)
{
EMC(EMC_SCRATCH0) |= EMC_HEKA_UPD;
if (!h_cfg.sept_run)
EMC(EMC_SCRATCH0) |= EMC_HEKA_UPD;
check_sept();
}
@@ -837,7 +829,7 @@ void auto_launch_firmware()
if (h_cfg.autoboot == boot_entry_id && configEntry)
{
cfg_sec = ini_clone_section(ini_sec);
cfg_sec = ini_sec;
LIST_FOREACH_ENTRY(ini_kv_t, kv, &cfg_sec->kvs, link)
{
if (!strcmp("logopath", kv->key))
@@ -856,7 +848,6 @@ void auto_launch_firmware()
if (h_cfg.autoboot_list)
{
ini_free_section(cfg_sec);
boot_entry_id = 1;
bootlogoCustomEntry = NULL;
@@ -872,7 +863,7 @@ void auto_launch_firmware()
if (h_cfg.autoboot == boot_entry_id)
{
h_cfg.emummc_force_disable = false;
cfg_sec = ini_clone_section(ini_sec_list);
cfg_sec = ini_sec_list;
LIST_FOREACH_ENTRY(ini_kv_t, kv, &cfg_sec->kvs, link)
{
if (!strcmp("logopath", kv->key))
@@ -970,15 +961,13 @@ void auto_launch_firmware()
free(BOOTLOGO);
}
ini_free(&ini_sections);
if (h_cfg.autoboot_list)
ini_free(&ini_list_sections);
if (!h_cfg.sept_run && h_cfg.bootwait)
if (b_cfg.boot_cfg & BOOT_CFG_FROM_LAUNCH)
display_backlight_brightness(h_cfg.backlight, 0);
else if (!h_cfg.sept_run && h_cfg.bootwait)
display_backlight_brightness(h_cfg.backlight, 1000);
// Wait before booting. If VOL- is pressed go into bootloader menu.
if (!h_cfg.sept_run)
if (!h_cfg.sept_run && !(b_cfg.boot_cfg & BOOT_CFG_FROM_LAUNCH))
{
btn = btn_wait_timeout(h_cfg.bootwait * 1000, BTN_VOL_DOWN);
@@ -990,7 +979,6 @@ void auto_launch_firmware()
if (payload_path)
{
ini_free_section(cfg_sec);
if (launch_payload(payload_path, false))
free(payload_path);
}
@@ -1001,11 +989,6 @@ void auto_launch_firmware()
}
out:
ini_free(&ini_sections);
if (h_cfg.autoboot_list)
ini_free(&ini_list_sections);
ini_free_section(cfg_sec);
gfx_con.mute = false;
b_cfg.boot_cfg &= ~(BOOT_CFG_AUTOBOOT_EN | BOOT_CFG_FROM_LAUNCH);
@@ -1210,7 +1193,7 @@ ment_t ment_top[] = {
MDEF_END()
};
menu_t menu_top = { ment_top, "hekate - CTCaer mod v5.0.0", 0, 0 };
menu_t menu_top = { ment_top, "hekate - CTCaer mod v5.0.1", 0, 0 };
#define IPL_STACK_TOP 0x90010000
#define IPL_HEAP_START 0x90020000

View File

@@ -1,5 +1,5 @@
/*
* BPMP-Lite Cache/MMU driver for Tegra X1
* BPMP-Lite Cache/MMU and Frequency driver for Tegra X1
*
* Copyright (c) 2019 CTCaer
*
@@ -83,15 +83,15 @@ void bpmp_mmu_maintenance(u32 op)
if (!(BPMP_CACHE_CTRL(BPMP_CACHE_CONFIG) & CFG_ENABLE))
return;
//BPMP_CACHE_CTRL(BPMP_CACHE_INT_CLEAR) = INT_CLR_MAINT_DONE;
BPMP_CACHE_CTRL(BPMP_CACHE_INT_CLEAR) = INT_CLR_MAINT_DONE;
// This is a blocking operation.
BPMP_CACHE_CTRL(BPMP_CACHE_MAINT_REQ) = MAINT_REQ_WAY_BITMAP(0xF) | op;
//while(!(BPMP_CACHE_CTRL(BPMP_CACHE_INT_RAW_EVENT) & INT_RAW_EVENT_MAINT_DONE))
// ;
while(!(BPMP_CACHE_CTRL(BPMP_CACHE_INT_RAW_EVENT) & INT_RAW_EVENT_MAINT_DONE))
;
//BPMP_CACHE_CTRL(BPMP_CACHE_INT_CLEAR) = BPMP_CACHE_CTRL(BPMP_CACHE_INT_RAW_EVENT);
BPMP_CACHE_CTRL(BPMP_CACHE_INT_CLEAR) = BPMP_CACHE_CTRL(BPMP_CACHE_INT_RAW_EVENT);
}
void bpmp_mmu_set_entry(int idx, bpmp_mmu_entry_t *entry, bool apply)
@@ -156,11 +156,12 @@ void bpmp_mmu_disable()
bpmp_mmu_maintenance(BPMP_MMU_MAINT_INVALID_WAY);
}
static u8 pllc4_divn[] = {
const u8 pllc4_divn[] = {
0, // BPMP_CLK_NORMAL: 408MHz 0% - 136MHz APB.
85, // BPMP_CLK_LOW_BOOST: 544MHz 33% - 136MHz APB.
90, // BPMP_CLK_MID_BOOST: 576MHz 41% - 144MHz APB.
95 // BPMP_CLK_SUPER_BOOST: 608MHz 49% - 152MHz APB.
94 // BPMP_CLK_SUPER_BOOST: 602MHz 48% - 150MHz APB.
//95 // BPMP_CLK_SUPER_BOOST: 608MHz 49% - 152MHz APB.
};
bpmp_freq_t bpmp_clock_set = BPMP_CLK_NORMAL;

View File

@@ -1,5 +1,5 @@
/*
* BPMP-Lite Cache/MMU driver for Tegra X1
* BPMP-Lite Cache/MMU and Frequency driver for Tegra X1
*
* Copyright (c) 2019 CTCaer
*

View File

@@ -12,7 +12,7 @@ NYX_STORAGE_ADDR := 0xED000000
NYX_MAGIC := 0x43544347 #"GCTC"
BLVERSION_MAJOR := 0
BLVERSION_MINOR := 8
BLVERSION_HOTFX := 0
BLVERSION_HOTFX := 1
BL_RESERVED := 0

View File

@@ -31,6 +31,9 @@ extern hekate_config h_cfg;
extern bool sd_mount();
extern void sd_unmount(bool deinit);
#pragma GCC push_options
#pragma GCC target ("thumb")
void set_default_configuration()
{
h_cfg.autoboot = 0;
@@ -158,8 +161,7 @@ int create_config_entry()
f_close(&fp);
sd_unmount(false);
if (mainIniFound)
ini_free(&ini_sections);
return 0;
}
#pragma GCC pop_options

View File

@@ -178,64 +178,6 @@ int ini_parse(link_t *dst, char *ini_path, bool is_dir)
return 1;
}
void ini_free(link_t *dst)
{
if (!dst->prev || !dst->next)
return;
LIST_FOREACH_ENTRY(ini_sec_t, ini_sec, dst, link)
{
if (ini_sec->type == INI_CHOICE)
{
LIST_FOREACH_ENTRY(ini_kv_t, kv, &ini_sec->kvs, link)
{
free(kv->key);
free(kv->val);
//free(kv);
}
}
free(ini_sec->name);
//free(ini_sec);
}
list_init(dst);
}
ini_sec_t *ini_clone_section(ini_sec_t *cfg)
{
if (cfg == NULL)
return NULL;
ini_sec_t *csec = (ini_sec_t *)malloc(sizeof(ini_sec_t));
list_init(&csec->kvs);
LIST_FOREACH_ENTRY(ini_kv_t, kv, &cfg->kvs, link)
{
ini_kv_t *kvcfg = (ini_kv_t *)malloc(sizeof(ini_kv_t));
kvcfg->key = _strdup(kv->key);
kvcfg->val = _strdup(kv->val);
list_append(&csec->kvs, &kvcfg->link);
}
return csec;
}
void ini_free_section(ini_sec_t *cfg)
{
if (cfg == NULL)
return;
LIST_FOREACH_ENTRY(ini_kv_t, kv, &cfg->kvs, link)
{
free(kv->key);
free(kv->val);
//free(kv);
}
//free(cfg);
cfg = NULL;
}
char *ini_check_payload_section(ini_sec_t *cfg)
{
char *path = NULL;

View File

@@ -44,9 +44,6 @@ typedef struct _ini_sec_t
} ini_sec_t;
int ini_parse(link_t *dst, char *ini_path, bool is_dir);
void ini_free(link_t *dst);
ini_sec_t *ini_clone_section(ini_sec_t *cfg);
void ini_free_section(ini_sec_t *cfg);
char *ini_check_payload_section(ini_sec_t *cfg);
#endif

View File

@@ -71,7 +71,7 @@ static void get_valid_partition(u32 *sector_start, u32 *sector_size, u32 *part_i
curr_part_size = *(u32 *)&mbr[0x0C + (0x10 * i)];
*sector_start = *(u32 *)&mbr[0x08 + (0x10 * i)];
u8 type = mbr[0x04 + (0x10 * i)];
if ((curr_part_size >= *sector_size) && *sector_start && type != 0x83 && (!backup || type == 0xEE))
if ((curr_part_size >= *sector_size) && *sector_start && type != 0x83 && (!backup || type == 0xE0))
break;
}
if (i < 4)
@@ -132,6 +132,19 @@ static lv_obj_t *create_mbox_text(char *text, bool button_ok)
return dark_bg;
}
static void _update_filename(char *outFilename, u32 sdPathLen, u32 numSplitParts, u32 currPartIdx)
{
if (numSplitParts >= 10 && currPartIdx < 10)
{
outFilename[sdPathLen] = '0';
itoa(currPartIdx, &outFilename[sdPathLen + 1], 10);
}
else
itoa(currPartIdx, &outFilename[sdPathLen], 10);
}
#pragma GCC pop_options
static int _dump_emmc_verify(emmc_tool_gui_t *gui, sdmmc_storage_t *storage, u32 lba_curr, char *outFilename, emmc_part_t *part)
{
FIL fp;
@@ -188,7 +201,7 @@ static int _dump_emmc_verify(emmc_tool_gui_t *gui, sdmmc_storage_t *storage, u32
lv_bar_set_style(gui->bar, LV_BAR_STYLE_BG, gui->bar_teal_bg);
lv_bar_set_style(gui->bar, LV_BAR_STYLE_INDIC, lv_theme_get_current()->bar.indic);
s_printf(gui->txt_buf, " "SYMBOL_DOT" %d%%", pct);
lv_label_set_text(gui->label_pct, gui->txt_buf);
lv_label_set_array_text(gui->label_pct, gui->txt_buf, 32);
manual_system_maintenance(true);
clmt = f_expand_cltbl(&fp, 0x400000, 0);
@@ -280,7 +293,7 @@ static int _dump_emmc_verify(emmc_tool_gui_t *gui, sdmmc_storage_t *storage, u32
{
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);
lv_label_set_array_text(gui->label_pct, gui->txt_buf, 32);
manual_system_maintenance(true);
prevPct = pct;
}
@@ -312,7 +325,7 @@ static int _dump_emmc_verify(emmc_tool_gui_t *gui, sdmmc_storage_t *storage, u32
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);
lv_label_set_array_text(gui->label_pct, gui->txt_buf, 32);
manual_system_maintenance(true);
return 0;
@@ -327,19 +340,6 @@ static int _dump_emmc_verify(emmc_tool_gui_t *gui, sdmmc_storage_t *storage, u32
}
}
static void _update_filename(char *outFilename, u32 sdPathLen, u32 numSplitParts, u32 currPartIdx)
{
if (numSplitParts >= 10 && currPartIdx < 10)
{
outFilename[sdPathLen] = '0';
itoa(currPartIdx, &outFilename[sdPathLen + 1], 10);
}
else
itoa(currPartIdx, &outFilename[sdPathLen], 10);
}
#pragma GCC pop_options
bool partial_sd_full_unmount = false;
static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_storage_t *storage, emmc_part_t *part)
@@ -417,7 +417,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_storage_t
if (!maxSplitParts)
{
s_printf(gui->txt_buf, "#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);
@@ -580,7 +580,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_storage_t
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);
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);
@@ -598,7 +598,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_storage_t
while (!sdmmc_storage_read(storage, lba_curr, num, buf))
{
s_printf(gui->txt_buf,
"#FFDD00 Error reading %d blocks @ LBA %08X,#\n"
"\n#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);
@@ -629,7 +629,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_storage_t
if (res)
{
s_printf(gui->txt_buf, "#FF0000 Fatal error (%d) when writing to SD Card#\nPlease try again...\n", res);
s_printf(gui->txt_buf, "\n#FF0000 Fatal error (%d) when writing to 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);
@@ -644,7 +644,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_storage_t
{
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);
lv_label_set_array_text(gui->label_pct, gui->txt_buf, 32);
manual_system_maintenance(true);
prevPct = pct;
@@ -720,23 +720,24 @@ void dump_emmc_selected(emmcPartType_t dumpType, emmc_tool_gui_t *gui)
{
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);
lv_label_set_static_text(gui->label_info, "Checking for available free space...");
manual_system_maintenance(true);
// Do a reinit to refresh tuning.
sd_unmount(true);
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);
@@ -891,13 +892,16 @@ out:
if (!partial_sd_full_unmount)
sd_unmount(false);
else
{
partial_sd_full_unmount = false;
sd_unmount(true);
}
}
static int _restore_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part, sdmmc_storage_t *storage, emmc_part_t *part, bool allow_multi_part)
{
const u32 SECTORS_TO_MIB_COEFF = 11;
//! TODO switch to 800MHz
u32 totalSectors = part->lba_end - part->lba_start + 1;
u32 currPartIdx = 0;
u32 numSplitParts = 0;
@@ -953,7 +957,7 @@ static int _restore_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_pa
if (f_stat(outFilename, &fno) && !gui->raw_emummc)
{
s_printf(gui->txt_buf, "#FFDD00 Error (%d) file not found '%s'. Aborting...#\n", res, outFilename);
s_printf(gui->txt_buf, "#FFDD00 Error (%d) file not found#\n#FFDD00 %s.#\n#FFDD00 Aborting...#", res, outFilename);
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
@@ -1194,7 +1198,7 @@ static int _restore_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_pa
{;
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);
lv_label_set_array_text(gui->label_pct, gui->txt_buf, 32);
manual_system_maintenance(true);
prevPct = pct;
}
@@ -1252,14 +1256,14 @@ void restore_emmc_selected(emmcPartType_t restoreType, emmc_tool_gui_t *gui)
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);
manual_system_maintenance(true);
sd_unmount(true);
s_printf(txt_buf,
"#FFDD00 This may render your device inoperative!#\n\n"
"#FFDD00 Are you really sure?#");

View File

@@ -50,6 +50,9 @@ extern hekate_config h_cfg;
extern bool sd_mount();
extern void sd_unmount(bool deinit);
#pragma GCC push_options
#pragma GCC target ("thumb")
void save_emummc_cfg(u32 part_idx, u32 sector_start, const char *path)
{
sd_mount();
@@ -98,6 +101,8 @@ void save_emummc_cfg(u32 part_idx, u32 sector_start, const char *path)
f_close(&fp);
}
#pragma GCC pop_options
static void _update_emummc_base_folder(char *outFilename, u32 sdPathLen, u32 currPartIdx)
{
if (currPartIdx < 10)
@@ -255,7 +260,7 @@ static int _dump_emummc_file_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_sto
if (res)
{
s_printf(gui->txt_buf, "#FF0000 Fatal error (%d) when writing to SD Card#\nPlease try again...\n", res);
s_printf(gui->txt_buf, "\n#FF0000 Fatal error (%d) when writing to 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);
@@ -270,7 +275,7 @@ static int _dump_emummc_file_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_sto
{
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);
lv_label_set_array_text(gui->label_pct, gui->txt_buf, 32);
manual_system_maintenance(true);
prevPct = pct;
@@ -300,18 +305,19 @@ static int _dump_emummc_file_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_sto
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);
manual_system_maintenance(true);
sd_unmount(true);
if (!sd_mount())
{
lv_label_set_static_text(gui->label_info, "#FFDD00 Failed to init SD!#");
@@ -343,7 +349,7 @@ void dump_emummc_file(emmc_tool_gui_t *gui)
for (int j = 0; j < 100; j++)
{
_update_emummc_base_folder(sdPath, base_len, j);
if(f_stat(sdPath, &fno) == FR_NO_FILE)
if(f_stat(sdPath, NULL) == FR_NO_FILE)
break;
}
@@ -489,7 +495,7 @@ static int _dump_emummc_raw_part(emmc_tool_gui_t *gui, int active_part, int part
while (!sdmmc_storage_read(storage, lba_curr, num, buf))
{
s_printf(gui->txt_buf,
"#FFDD00 Error reading %d blocks @LBA %08X,#\n"
"\n#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);
@@ -517,7 +523,7 @@ static int _dump_emummc_raw_part(emmc_tool_gui_t *gui, int active_part, int part
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"
"\n#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);
@@ -544,7 +550,7 @@ static int _dump_emummc_raw_part(emmc_tool_gui_t *gui, int active_part, int part
{
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);
lv_label_set_array_text(gui->label_pct, gui->txt_buf, 32);
manual_system_maintenance(true);
prevPct = pct;
@@ -562,7 +568,7 @@ static int _dump_emummc_raw_part(emmc_tool_gui_t *gui, int active_part, int part
{
u8 *mbr = (u8 *)malloc(0x200);
sdmmc_storage_read(&sd_storage, 0, 1, mbr);
mbr[MBR_1ST_PART_TYPE_OFF + (0x10 * part_idx)] = 0xEE;
mbr[MBR_1ST_PART_TYPE_OFF + (0x10 * part_idx)] = 0xE0;
sdmmc_storage_write(&sd_storage, 0, 1, mbr);
free(mbr);
}
@@ -574,14 +580,16 @@ 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);
manual_system_maintenance(true);
sd_unmount(true);
if (!sd_mount())
{
lv_label_set_static_text(gui->label_info, "#FFDD00 Failed to init SD!#");

View File

@@ -55,6 +55,7 @@ void *sd_file_read(const char *path, u32 *fsize);
int sd_save_to_file(void *buf, u32 size, const char *filename);
static bool disp_init_done = false;
static bool do_reload = false;
typedef struct _gui_status_bar_ctx
{
@@ -77,6 +78,9 @@ static void _nyx_disp_init()
static void _save_fb_to_bmp()
{
if (do_reload)
return;
const u32 file_size = 0x384000 + 0x36;
u8 *bitmap = malloc(file_size);
u32 *fb = malloc(0x384000);
@@ -444,9 +448,13 @@ lv_obj_t *nyx_create_standard_window(const char *win_title)
return win;
}
static bool launch_logs_enable = false;
static void _launch_hos(u8 autoboot, u8 autoboot_list)
{
b_cfg->boot_cfg = BOOT_CFG_AUTOBOOT_EN;
if (launch_logs_enable)
b_cfg->boot_cfg |= BOOT_CFG_FROM_LAUNCH;
b_cfg->autoboot = autoboot;
b_cfg->autoboot_list = autoboot_list;
@@ -739,11 +747,26 @@ static lv_res_t reload_action(lv_obj_t *btns, const char *txt)
return mbox_action(btns, txt);
}
static bool do_reload = false;
static lv_res_t _removed_sd_action(lv_obj_t *btns, const char *txt)
{
u32 btnidx = lv_btnm_get_pressed(btns);
switch (btnidx)
{
case 0:
reboot_rcm();
break;
case 1:
power_off();
break;
}
return mbox_action(btns, txt);
}
static void _check_sd_card_removed(void *params)
{
// The following checks if sdmmc_1 is initialized.
// 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_reload && get_sd_card_removed())
@@ -752,11 +775,13 @@ static void _check_sd_card_removed(void *params)
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[] = { "\221Reboot (RCM)", "\221Power Off", "" };
lv_obj_t *mbox = lv_mbox_create(dark_bg, NULL);
lv_mbox_set_recolor_text(mbox, true);
lv_obj_set_width(mbox, LV_HOR_RES * 4 / 9);
lv_mbox_set_text(mbox, "\n#FF8000 SD card was removed!#\n\n#96FF00 Nyx will reload after inserting it.#\n");
lv_mbox_add_btns(mbox, mbox_btn_map, _removed_sd_action);
lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_top(mbox, true);
@@ -1421,6 +1446,50 @@ static lv_res_t _launch_action(lv_obj_t *btn)
return LV_RES_OK;
}
static lv_res_t logs_onoff_toggle(lv_obj_t *btn)
{
launch_logs_enable = !launch_logs_enable;
lv_obj_t *label_btn = lv_obj_get_child(btn, NULL);
char label_text[64];
strcpy(label_text, lv_label_get_text(label_btn));
label_text[strlen(label_text) - 12] = 0;
if (!launch_logs_enable)
{
strcat(label_text, "#D0D0D0 OFF#");
lv_label_set_array_text(label_btn, label_text, 64);
}
else
{
strcat(label_text, "#00FFC9 ON #");
lv_label_set_array_text(label_btn, label_text, 64);
}
return LV_RES_OK;
}
typedef struct _launch_button_pos_t
{
u16 btn_x;
u16 btn_y;
u16 lbl_x;
u16 lbl_y;
} launch_button_pos_t;
static const launch_button_pos_t launch_button_pos[8] = {
{ 19, 36, 0, 245 },
{ 340, 36, 321, 245 },
{ 661, 36, 642, 245 },
{ 982, 36, 963, 245 },
{ 19, 313, 0, 522 },
{ 340, 313, 321, 522 },
{ 661, 313, 642, 522 },
{ 982, 313, 963, 522 }
};
static lv_res_t _create_window_home_launch(lv_obj_t *btn)
{
char *icon_path;
@@ -1428,6 +1497,7 @@ static lv_res_t _create_window_home_launch(lv_obj_t *btn)
static lv_style_t btn_home_transp_rel;
lv_style_copy(&btn_home_transp_rel, lv_theme_get_current()->btn.rel);
btn_home_transp_rel.body.opa = LV_OPA_0;
btn_home_transp_rel.body.border.width = 4;
static lv_style_t btn_home_transp_pr;
lv_style_copy(&btn_home_transp_pr, lv_theme_get_current()->btn.pr);
@@ -1446,6 +1516,9 @@ static lv_res_t _create_window_home_launch(lv_obj_t *btn)
else
win = create_window_launch(SYMBOL_GPS" More Configurations");
lv_win_add_btn(win, NULL, SYMBOL_LIST" Logs #D0D0D0 OFF#", logs_onoff_toggle);
launch_logs_enable = false;
lv_cont_set_fit(lv_page_get_scrl(lv_win_get_content(win)), false, false);
lv_page_set_scrl_height(lv_win_get_content(win), 572);
@@ -1457,17 +1530,14 @@ static lv_res_t _create_window_home_launch(lv_obj_t *btn)
u32 max_entries = 8;
lv_btn_ext_t * ext;
//! TODO: Use an array/loop for the initialization.
// Create CFW buttons.
btn_boot_entry = lv_btn_create(win, NULL);
launch_ctxt[0] = btn_boot_entry;
// Buttons are 200 x 200 with 4 pixel borders.
// Icons must be <= 192 x 192.
// Button 0.
// Create first Button.
btn_boot_entry = lv_btn_create(win, NULL);
launch_ctxt[0] = btn_boot_entry;
lv_obj_set_size(btn_boot_entry, 200, 200);
lv_obj_set_pos(btn_boot_entry, 19, 36);
lv_obj_set_pos(btn_boot_entry, launch_button_pos[0].btn_x, launch_button_pos[0].btn_y);
lv_obj_set_opa_scale(btn_boot_entry, LV_OPA_0);
lv_obj_set_opa_scale_enable(btn_boot_entry, true);
lv_btn_set_layout(btn_boot_entry, LV_LAYOUT_OFF);
@@ -1481,77 +1551,20 @@ static lv_res_t _create_window_home_launch(lv_obj_t *btn)
lv_cont_set_fit(boot_entry_lbl_cont, false, false);
lv_cont_set_layout(boot_entry_lbl_cont, LV_LAYOUT_CENTER);
lv_obj_set_size(boot_entry_lbl_cont, 238, 20);
lv_obj_set_pos(boot_entry_lbl_cont, 0, 245);
lv_obj_set_pos(boot_entry_lbl_cont, launch_button_pos[0].lbl_x, launch_button_pos[0].lbl_y);
// Button 1.
btn_boot_entry = lv_btn_create(win, btn_boot_entry);
launch_ctxt[2] = btn_boot_entry;
lv_obj_set_pos(btn_boot_entry, 340, 36);
// Create the rest of the buttons.
for (u32 btn_idx = 2; btn_idx < 16; btn_idx += 2)
{
btn_boot_entry = lv_btn_create(win, btn_boot_entry);
launch_ctxt[btn_idx] = btn_boot_entry;
lv_obj_set_pos(btn_boot_entry, launch_button_pos[btn_idx >> 1].btn_x, launch_button_pos[btn_idx >> 1].btn_y);
boot_entry_lbl_cont = lv_cont_create(win, boot_entry_lbl_cont);
boot_entry_label = lv_label_create(boot_entry_lbl_cont, boot_entry_label);
lv_obj_set_pos(boot_entry_lbl_cont, 321, 245);
launch_ctxt[3] = boot_entry_label;
// Button 2.
btn_boot_entry = lv_btn_create(win, btn_boot_entry);
launch_ctxt[4] = btn_boot_entry;
lv_obj_set_pos(btn_boot_entry, 661, 36);
boot_entry_lbl_cont = lv_cont_create(win, boot_entry_lbl_cont);
boot_entry_label = lv_label_create(boot_entry_lbl_cont, boot_entry_label);
lv_obj_set_pos(boot_entry_lbl_cont, 642, 245);
launch_ctxt[5] = boot_entry_label;
// Button 3.
btn_boot_entry = lv_btn_create(win, btn_boot_entry);
launch_ctxt[6] = btn_boot_entry;
lv_obj_set_pos(btn_boot_entry, 982, 36);
boot_entry_lbl_cont = lv_cont_create(win, boot_entry_lbl_cont);
boot_entry_label = lv_label_create(boot_entry_lbl_cont, boot_entry_label);
lv_obj_set_pos(boot_entry_lbl_cont, 963, 245);
launch_ctxt[7] = boot_entry_label;
// Button 4.
btn_boot_entry = lv_btn_create(win, btn_boot_entry);
launch_ctxt[8] = btn_boot_entry;
lv_obj_set_pos(btn_boot_entry, 19, 313);
boot_entry_lbl_cont = lv_cont_create(win, boot_entry_lbl_cont);
boot_entry_label = lv_label_create(boot_entry_lbl_cont, boot_entry_label);
lv_obj_set_pos(boot_entry_lbl_cont, 0, 522);
launch_ctxt[9] = boot_entry_label;
// Button 5.
btn_boot_entry = lv_btn_create(win, btn_boot_entry);
launch_ctxt[10] = btn_boot_entry;
lv_obj_set_pos(btn_boot_entry, 340, 313);
boot_entry_lbl_cont = lv_cont_create(win, boot_entry_lbl_cont);
boot_entry_label = lv_label_create(boot_entry_lbl_cont, boot_entry_label);
lv_obj_set_pos(boot_entry_lbl_cont, 321, 522);
launch_ctxt[11] = boot_entry_label;
// Button 6.
btn_boot_entry = lv_btn_create(win, btn_boot_entry);
launch_ctxt[12] = btn_boot_entry;
lv_obj_set_pos(btn_boot_entry, 661, 313);
boot_entry_lbl_cont = lv_cont_create(win, boot_entry_lbl_cont);
boot_entry_label = lv_label_create(boot_entry_lbl_cont, boot_entry_label);
lv_obj_set_pos(boot_entry_lbl_cont, 642, 522);
launch_ctxt[13] = boot_entry_label;
// Button 7.
btn_boot_entry = lv_btn_create(win, btn_boot_entry);
launch_ctxt[14] = btn_boot_entry;
lv_obj_set_pos(btn_boot_entry, 982, 313);
boot_entry_lbl_cont = lv_cont_create(win, boot_entry_lbl_cont);
boot_entry_label = lv_label_create(boot_entry_lbl_cont, boot_entry_label);
lv_obj_set_pos(boot_entry_lbl_cont, 963, 522);
launch_ctxt[15] = boot_entry_label;
boot_entry_lbl_cont = lv_cont_create(win, boot_entry_lbl_cont);
boot_entry_label = lv_label_create(boot_entry_lbl_cont, boot_entry_label);
lv_obj_set_pos(boot_entry_lbl_cont, launch_button_pos[btn_idx >> 1].lbl_x, launch_button_pos[btn_idx >> 1].lbl_y);
launch_ctxt[btn_idx + 1] = boot_entry_label;
}
// Parse ini boot entries and set buttons/icons.
char *tmp_path = calloc(0x80, 1);
@@ -1577,6 +1590,7 @@ static lv_res_t _create_window_home_launch(lv_obj_t *btn)
icon_path = NULL;
bool payload = false;
lv_img_dsc_t *bmp = NULL;
lv_obj_t *img = NULL;
// Check for icons.
LIST_FOREACH_ENTRY(ini_kv_t, kv, &ini_sec->kvs, link)
@@ -1613,31 +1627,38 @@ static lv_res_t _create_window_home_launch(lv_obj_t *btn)
if (!bmp)
bmp = icon_switch;
//Set icon and border/radius mask.
//Set icon.
if (bmp)
{
lv_obj_t *img = lv_img_create(launch_ctxt[x], NULL);
img = lv_img_create(launch_ctxt[x], NULL);
lv_img_set_src(img, bmp);
lv_obj_t *btn = lv_btn_create(launch_ctxt[x], NULL);
lv_obj_set_size(btn, 200, 200);
lv_btn_set_style(btn, LV_BTN_STYLE_REL, &btn_home_transp_rel);
lv_btn_set_style(btn, LV_BTN_STYLE_PR, &btn_home_transp_pr);
lv_obj_align(img, NULL, LV_ALIGN_CENTER, 0, 0);
ext = lv_obj_get_ext_attr(btn);
ext->idx = i;
if (!more_cfg)
lv_btn_set_action(btn, LV_BTN_ACTION_CLICK, _launch_action);
else
lv_btn_set_action(btn, LV_BTN_ACTION_CLICK, _launch_more_cfg_action);
}
// Add button mask/radius and align icon.
lv_obj_t *btn = lv_btn_create(launch_ctxt[x], NULL);
lv_obj_set_size(btn, 200, 200);
lv_btn_set_style(btn, LV_BTN_STYLE_REL, &btn_home_transp_rel);
lv_btn_set_style(btn, LV_BTN_STYLE_PR, &btn_home_transp_pr);
if (img)
lv_obj_align(img, NULL, LV_ALIGN_CENTER, 0, 0);
// Set autoboot index.
ext = lv_obj_get_ext_attr(btn);
ext->idx = i;
// Set action.
if (!more_cfg)
lv_btn_set_action(btn, LV_BTN_ACTION_CLICK, _launch_action);
else
lv_btn_set_action(btn, LV_BTN_ACTION_CLICK, _launch_more_cfg_action);
// Set button's label text.
lv_label_set_array_text(launch_ctxt[x + 1], ini_sec->name, strlen(ini_sec->name));
lv_obj_set_opa_scale(launch_ctxt[x + 1], LV_OPA_COVER);
//! TODO: Check strlen and decide on rolling text
//lv_label_set_long_mode(boot_entry_label, LV_LABEL_LONG_ROLL);
// Set rolling text if name is big.
if (strlen(ini_sec->name) > 22)
lv_label_set_long_mode(boot_entry_label, LV_LABEL_LONG_ROLL);
i++;
x += 2;
@@ -2089,6 +2110,9 @@ void nyx_load_and_run()
lv_indev_drv_register(&indev_drv);
touchpad.touch = false;
// Initialize temperature sensor.
tmp451_init();
//Set the theme.
//! TODO: Finish theme support.
lv_theme_t *th = lv_theme_hekate_init(167, NULL);

View File

@@ -61,7 +61,11 @@ static void _create_window_backup_restore(emmcPartType_t type, const char* win_l
emmc_tool_gui_ctxt.raw_emummc = emmc_btn_ctxt.raw_emummc;
lv_obj_t *win = nyx_create_standard_window(win_label);
char win_label_full[80];
s_printf(win_label_full, "%s%s", emmc_btn_ctxt.restore ? SYMBOL_DOWNLOAD" Restore " : SYMBOL_UPLOAD" Backup ", win_label+3);
lv_obj_t *win = nyx_create_standard_window(win_label_full);
//Disable buttons.
nyx_window_toggle_buttons(win, true);
@@ -108,20 +112,18 @@ 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;
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));
static lv_style_t bar_teal_bg, 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);
bar_teal_bg->body.grad_color = bar_teal_bg->body.main_color;
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;
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;
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);
@@ -154,9 +156,6 @@ static void _create_window_backup_restore(emmcPartType_t type, const char* win_l
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)

View File

@@ -178,7 +178,7 @@ static void _create_mbox_emummc_raw()
u32 curr_part_size = *(u32 *)&mbr[0x0C + (0x10 * i)];
sector_start = *(u32 *)&mbr[0x08 + (0x10 * i)];
u8 type = mbr[0x04 + (0x10 * i)];
if ((curr_part_size > storage.sec_cnt) && sector_start && type != 0x83) //! TODO: For now it skips linux partitions.
if ((curr_part_size >= (storage.sec_cnt + 0x8000)) && sector_start && type != 0x83) //! TODO: For now it skips linux partitions.
{
part_idx = i;
sector_start += 0x8000;
@@ -191,7 +191,7 @@ static void _create_mbox_emummc_raw()
if (part_idx)
{
s_printf(txt_buf,
"#C7EA46 Found applicable partition [%d]!#\n"
"#C7EA46 Found applicable partition: [Part %d]!#\n"
"#FF8000 Do you want to continue?#\n\n", part_idx);
}
else
@@ -276,14 +276,14 @@ static void _change_raw_emummc_part_type()
{
u8 *mbr = (u8 *)malloc(0x200);
sdmmc_storage_read(&sd_storage, 0, 1, mbr);
mbr[MBR_1ST_PART_TYPE_OFF + (0x10 * part_idx)] = 0xEE;
mbr[MBR_1ST_PART_TYPE_OFF + (0x10 * part_idx)] = 0xE0;
sdmmc_storage_write(&sd_storage, 0, 1, mbr);
free(mbr);
}
static void _migrate_sd_raw_based()
{
sector_start += 2;
sector_start = 2;
sd_mount();
f_mkdir("emuMMC");
@@ -295,8 +295,6 @@ static void _migrate_sd_raw_based()
f_write(&fp, &sector_start, 4, NULL);
f_close(&fp);
_change_raw_emummc_part_type();
save_emummc_cfg(1, sector_start, "emuMMC/ER00");
sd_unmount(false);
}
@@ -391,9 +389,7 @@ static void _migrate_sd_backup_file_based()
bool multipart = false;
s_printf(path2, "%s/rawnand.bin", path);
FILINFO fno;
if(f_stat(path2, &fno))
if(f_stat(path2, NULL))
multipart = true;
if (!multipart)
@@ -520,6 +516,7 @@ static lv_res_t _create_mbox_emummc_migrate(lv_obj_t *btn)
char *txt_buf = (char *)malloc(0x500);
u8 *mbr = (u8 *)malloc(0x200);
u8 *efi_part = (u8 *)malloc(0x200);
sd_mount();
sdmmc_storage_read(&sd_storage, 0, 1, mbr);
@@ -533,63 +530,62 @@ static lv_res_t _create_mbox_emummc_migrate(lv_obj_t *btn)
bool backup = false;
bool emummc = false;
bool file_based = false;
bool em = false;
sector_start = 0;
part_idx = 0;
for (int i = 1; i < 4; i++)
{
u32 curr_part_size = *(u32 *)&mbr[0x0C + (0x10 * i)];
sector_start = *(u32 *)&mbr[0x08 + (0x10 * i)];
if ((curr_part_size > storage.sec_cnt) && sector_start)
if (sector_start)
{
part_idx = i;
break;
sdmmc_storage_read(&sd_storage, sector_start + 0xC001, 1, efi_part);
if (!memcmp(efi_part, "EFI PART", 8))
{
sector_start += 0x8000;
emummc = true;
part_idx = i;
break;
}
else
{
sdmmc_storage_read(&sd_storage, sector_start + 0x4001, 1, efi_part);
if (!memcmp(efi_part, "EFI PART", 8))
{
emummc = true;
part_idx = i;
break;
}
}
}
}
//! TODO: What about unallocated
if (part_idx)
if (!part_idx)
{
sdmmc_storage_read(&sd_storage, sector_start + 0xC001, 1, mbr);
if (!memcmp(mbr, "EFI PART", 8))
{
sector_start += 0x8000;
emummc = true;
}
else
{
sdmmc_storage_read(&sd_storage, sector_start + 0x4001, 1, mbr);
if (!memcmp(mbr, "EFI PART", 8))
emummc = true;
}
if (!emummc)
{
sdmmc_storage_read(&sd_storage, sector_start + 0x4003, 1, mbr);
if (memcmp(mbr, "EFI PART", 8))
part_idx = 0;
}
sdmmc_storage_read(&sd_storage, 0x4003, 1, efi_part);
if (!memcmp(efi_part, "EFI PART", 8))
em = true;
}
FILINFO fno;
s_printf(txt_buf, "%c%c%c%c%s", 's', 'x', 'o','s', "/emunand/boot0.bin");
if(!f_stat(txt_buf, &fno))
if(!f_stat(txt_buf, NULL))
file_based = true;
bool rawnand_backup_found = false;
emmcsn_path_impl(txt_buf, "", "BOOT0", &storage);
if(!f_stat(txt_buf, &fno))
if(!f_stat(txt_buf, NULL))
backup = true;
emmcsn_path_impl(txt_buf, "", "rawnand.bin", &storage);
if(!f_stat(txt_buf, &fno))
if(!f_stat(txt_buf, NULL))
rawnand_backup_found = true;
emmcsn_path_impl(txt_buf, "", "rawnand.bin.00", &storage);
if(!f_stat(txt_buf, &fno))
if(!f_stat(txt_buf, NULL))
rawnand_backup_found = true;
if (backup && rawnand_backup_found)
@@ -614,21 +610,21 @@ static lv_res_t _create_mbox_emummc_migrate(lv_obj_t *btn)
"#FF8000 Do you want to repair the config for it?#\n\n");
lv_mbox_add_btns(mbox, mbox_btn_map, _create_emummc_mig3_action);
}
else if (part_idx && !file_based)
else if (em && !file_based)
{
s_printf(txt_buf,
"#C7EA46 Found foreign SD Partition emunand!#\n"
"#FF8000 Do you want to migrate it?#\n\n");
lv_mbox_add_btns(mbox, mbox_btn_map, _create_emummc_mig2_action);
}
else if (!part_idx && file_based)
else if (!em && file_based)
{
s_printf(txt_buf,
"#C7EA46 Found foreign SD File emunand!#\n"
"#FF8000 Do you want to migrate it?#\n\n");
lv_mbox_add_btns(mbox, mbox_btn_map, _create_emummc_mig0_action);
}
else if (part_idx && file_based)
else if (em && file_based)
{
s_printf(txt_buf,
"#C7EA46 Found both foreign SD File and Partition emunand!#\n"
@@ -637,13 +633,14 @@ static lv_res_t _create_mbox_emummc_migrate(lv_obj_t *btn)
}
else
{
s_printf(txt_buf, "No foreign emunand or emuMMC found!\n\n");
s_printf(txt_buf, "No emuMMC or foreign emunand found!\n\n");
lv_mbox_add_btns(mbox, mbox_btn_map3, mbox_action);
}
lv_mbox_set_text(mbox, txt_buf);
free(txt_buf);
free(mbr);
free(efi_part);
lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_top(mbox, true);
@@ -656,8 +653,8 @@ typedef struct _emummc_images_t
char *dirlist;
u32 part_sector[3];
u32 part_type[3];
u32 part_size[3];
char part_path[3 * 32];
u32 part_end[3];
char part_path[3 * 128];
lv_obj_t *win;
} emummc_images_t;
@@ -711,10 +708,10 @@ static lv_res_t _save_raw_emummc_cfg_action(lv_obj_t * btn)
save_emummc_cfg(1, emummc_img->part_sector[0], &emummc_img->part_path[0]);
break;
case 1:
save_emummc_cfg(2, emummc_img->part_sector[1], &emummc_img->part_path[32]);
save_emummc_cfg(2, emummc_img->part_sector[1], &emummc_img->part_path[128]);
break;
case 2:
save_emummc_cfg(3, emummc_img->part_sector[2], &emummc_img->part_path[64]);
save_emummc_cfg(3, emummc_img->part_sector[2], &emummc_img->part_path[256]);
break;
}
@@ -759,12 +756,12 @@ static lv_res_t _create_change_emummc_window()
sdmmc_storage_read(&sd_storage, 0, 1, mbr);
memcpy(mbr, mbr + 0x1BE, 0x40);
memset(emummc_img->part_path, 0, 3 * 32);
memset(emummc_img->part_path, 0, 3 * 128);
for (int i = 1; i < 4; i++)
{
emummc_img->part_size[i - 1] = *(u32 *)&mbr[0x0C + (0x10 * i)];
emummc_img->part_sector[i - 1] = *(u32 *)&mbr[0x08 + (0x10 * i)];
emummc_img->part_end[i - 1] = emummc_img->part_sector[i - 1] + *(u32 *)&mbr[0x0C + (0x10 * i)] - 1;
emummc_img->part_type[i - 1] = mbr[0x04 + (0x10 * i)];
}
free(mbr);
@@ -775,7 +772,7 @@ static lv_res_t _create_change_emummc_window()
goto out0;
u32 emummc_idx = 0;
FILINFO fno;
FIL fp;
// Check for sd raw partitions, based on the folders in /emuMMC.
@@ -783,7 +780,7 @@ static lv_res_t _create_change_emummc_window()
{
s_printf(path, "emuMMC/%s/raw_based", &emummc_img->dirlist[emummc_idx * 256]);
if(!f_stat(path, &fno))
if(!f_stat(path, NULL))
{
f_open(&fp, path, FA_READ);
u32 curr_list_sector = 0;
@@ -791,32 +788,27 @@ static lv_res_t _create_change_emummc_window()
f_close(&fp);
// Check if there's a HOS image there.
if (emummc_img->part_sector[0] && curr_list_sector >= emummc_img->part_sector[0] && emummc_img->part_type[0] != 0x83)
if ((curr_list_sector == 2) || (emummc_img->part_sector[0] && curr_list_sector >= emummc_img->part_sector[0] &&
curr_list_sector < emummc_img->part_end[0] && emummc_img->part_type[0] != 0x83))
{
if (emummc_img->part_sector[1] && curr_list_sector >= emummc_img->part_sector[1] && emummc_img->part_type[1] != 0x83)
{
if (emummc_img->part_sector[2] && curr_list_sector >= emummc_img->part_sector[2] && emummc_img->part_type[2] != 0x83)
{
s_printf(path, "emuMMC/%s", &emummc_img->dirlist[emummc_idx * 256]);
strcpy(&emummc_img->part_path[2 * 32], path);
emummc_img->part_sector[2] = curr_list_sector;
}
else
{
s_printf(path, "emuMMC/%s", &emummc_img->dirlist[emummc_idx * 256]);
strcpy(&emummc_img->part_path[1 * 32], path);
emummc_img->part_sector[1] = curr_list_sector;
}
}
else
{
s_printf(path, "emuMMC/%s", &emummc_img->dirlist[emummc_idx * 256]);
strcpy(&emummc_img->part_path[0], path);
emummc_img->part_sector[0] = curr_list_sector;
}
s_printf(&emummc_img->part_path[0], "emuMMC/%s", &emummc_img->dirlist[emummc_idx * 256]);
emummc_img->part_sector[0] = curr_list_sector;
emummc_img->part_end[0] = 0;
}
else if (emummc_img->part_sector[1] && curr_list_sector >= emummc_img->part_sector[1] &&
curr_list_sector < emummc_img->part_end[1] && emummc_img->part_type[1] != 0x83)
{
s_printf(&emummc_img->part_path[1 * 128], "emuMMC/%s", &emummc_img->dirlist[emummc_idx * 256]);
emummc_img->part_sector[1] = curr_list_sector;
emummc_img->part_end[1] = 0;
}
else if (emummc_img->part_sector[2] && curr_list_sector >= emummc_img->part_sector[2] &&
curr_list_sector < emummc_img->part_end[2] && emummc_img->part_type[2] != 0x83)
{
s_printf(&emummc_img->part_path[2 * 128], "emuMMC/%s", &emummc_img->dirlist[emummc_idx * 256]);
emummc_img->part_sector[2] = curr_list_sector;
emummc_img->part_end[2] = 0;
}
}
emummc_idx++;
}
@@ -829,7 +821,7 @@ static lv_res_t _create_change_emummc_window()
{
s_printf(path, "emuMMC/%s/file_based", &emummc_img->dirlist[emummc_idx * 256]);
if(!f_stat(path, &fno))
if(!f_stat(path, NULL))
{
strcpy(&emummc_img->dirlist[file_based_idx * 256], &emummc_img->dirlist[emummc_idx * 256]);
file_based_idx++;
@@ -867,79 +859,58 @@ out0:;
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 RAW 1 button.
lv_obj_t *btn = lv_btn_create(h1, NULL);
lv_btn_ext_t *ext = lv_obj_get_ext_attr(btn);
ext->idx = 0;
lv_obj_t *btn_label = lv_label_create(btn, NULL);
if (emummc_img->part_type[0] != 0x83)
lv_label_set_static_text(btn_label, "SD RAW 1");
else
lv_label_set_static_text(btn_label, "Linux");
if (!emummc_img->part_sector[0] || emummc_img->part_type[0] == 0x83 || !emummc_img->part_path[0])
{
lv_btn_set_state(btn, LV_BTN_STATE_INA);
lv_obj_set_click(btn, false);
}
lv_btn_set_fit(btn, false, true);
lv_obj_set_width(btn, LV_DPI * 3);
lv_obj_align(btn, line_sep, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI / 2, LV_DPI / 5);
lv_btn_set_action(btn, LV_BTN_ACTION_CLICK, _save_raw_emummc_cfg_action);
lv_obj_t *lv_desc = lv_label_create(h1, NULL);
lv_label_set_recolor(lv_desc, true);
lv_obj_t *btn = NULL;
lv_btn_ext_t *ext;
lv_obj_t *btn_label = NULL;
lv_obj_t *lv_desc = NULL;
char *txt_buf = malloc(0x500);
s_printf(txt_buf, "Sector start: 0x%08X\nFolder: %s", emummc_img->part_sector[0], &emummc_img->part_path[0]);
lv_label_set_array_text(lv_desc, txt_buf, 0x500);
lv_obj_set_style(lv_desc, &hint_small_style);
lv_obj_align(lv_desc, btn, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 5);
// Create RAW 2 button.
btn = lv_btn_create(h1, btn);
ext = lv_obj_get_ext_attr(btn);
ext->idx = 1;
btn_label = lv_label_create(btn, btn_label);
if (emummc_img->part_type[1] != 0x83)
lv_label_set_static_text(btn_label, "SD RAW 2");
else
lv_label_set_static_text(btn_label, "Linux");
if (!emummc_img->part_sector[1] || emummc_img->part_type[1] == 0x83 || !emummc_img->part_path[32])
// Create RAW buttons.
for (u32 raw_btn_idx = 0; raw_btn_idx < 3; raw_btn_idx++)
{
lv_btn_set_state(btn, LV_BTN_STATE_INA);
lv_obj_set_click(btn, false);
btn = lv_btn_create(h1, btn);
ext = lv_obj_get_ext_attr(btn);
ext->idx = raw_btn_idx;
btn_label = lv_label_create(btn, btn_label);
lv_btn_set_state(btn, LV_BTN_STATE_REL);
lv_obj_set_click(btn, true);
if (emummc_img->part_type[raw_btn_idx] != 0x83)
{
s_printf(txt_buf, "SD RAW %d", raw_btn_idx + 1);
lv_label_set_array_text(btn_label, txt_buf, 32);
}
if (!emummc_img->part_sector[raw_btn_idx] || emummc_img->part_type[raw_btn_idx] == 0x83 || !emummc_img->part_path[raw_btn_idx * 128])
{
lv_btn_set_state(btn, LV_BTN_STATE_INA);
lv_obj_set_click(btn, false);
if (emummc_img->part_type[raw_btn_idx] == 0x83)
lv_label_set_static_text(btn_label, "Linux");
}
if (!raw_btn_idx)
{
lv_btn_set_fit(btn, false, true);
lv_obj_set_width(btn, LV_DPI * 3);
lv_obj_align(btn, line_sep, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI / 2, LV_DPI / 5);
}
else
lv_obj_align(btn, lv_desc, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 3);
lv_btn_set_action(btn, LV_BTN_ACTION_CLICK, _save_raw_emummc_cfg_action);
lv_desc = lv_label_create(h1, lv_desc);
lv_label_set_recolor(lv_desc, true);
lv_obj_set_style(lv_desc, &hint_small_style);
s_printf(txt_buf, "Sector start: 0x%08X\nFolder: %s", emummc_img->part_sector[raw_btn_idx], &emummc_img->part_path[raw_btn_idx * 128]);
lv_label_set_array_text(lv_desc, txt_buf, 0x500);
lv_obj_align(lv_desc, btn, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 5);
}
lv_obj_align(btn, lv_desc, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 3);
lv_btn_set_action(btn, LV_BTN_ACTION_CLICK, _save_raw_emummc_cfg_action);
lv_desc = lv_label_create(h1, lv_desc);
s_printf(txt_buf, "Sector start: 0x%08X\nFolder: %s", emummc_img->part_sector[1], &emummc_img->part_path[32]);
lv_label_set_array_text(lv_desc, txt_buf, 0x500);
lv_obj_align(lv_desc, btn, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 5);
// Create RAW 3 button.
btn = lv_btn_create(h1, btn);
ext = lv_obj_get_ext_attr(btn);
ext->idx = 2;
btn_label = lv_label_create(btn, btn_label);
if (emummc_img->part_type[2] != 0x83)
lv_label_set_static_text(btn_label, "SD RAW 3");
else
lv_label_set_static_text(btn_label, "Linux");
if (!emummc_img->part_sector[2] || emummc_img->part_type[2] == 0x83 || !emummc_img->part_path[64])
{
lv_btn_set_state(btn, LV_BTN_STATE_INA);
lv_obj_set_click(btn, false);
}
lv_obj_align(btn, lv_desc, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 3);
lv_btn_set_action(btn, LV_BTN_ACTION_CLICK, _save_raw_emummc_cfg_action);
lv_desc = lv_label_create(h1, lv_desc);
s_printf(txt_buf, "Sector start: 0x%08X\nFolder: %s", emummc_img->part_sector[2], &emummc_img->part_path[64]);
lv_label_set_array_text(lv_desc, txt_buf, 0x500);
lv_obj_align(lv_desc, btn, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 5);
// Create SD File Based container.
lv_obj_t *h2 = lv_cont_create(win, NULL);

View File

@@ -275,11 +275,7 @@ static lv_res_t _create_window_fuses_info_status(lv_obj_t *btn)
{
case 0:
case 4:
memcpy(dram_man, "Samsung ", 9);
if (!dram_id)
memcpy(dram_man + strlen(dram_man), "4GB", 4);
else
memcpy(dram_man + strlen(dram_man), "6GB", 4);
s_printf(dram_man, "Samsung %s", (!dram_id) ? "4GB" : "6GB");
break;
case 1:
memcpy(dram_man, "Hynix 4GB", 10);
@@ -1078,7 +1074,7 @@ void create_tab_info(lv_theme_t *th, lv_obj_t *parent)
lv_line_set_style(line_sep, &line_style);
// Create Fuses button.
lv_obj_t *btn3 = lv_btn_create(h1, NULL);
lv_obj_t *btn3 = lv_btn_create(h1, btn);
label_btn = lv_label_create(btn3, NULL);
lv_btn_set_fit(btn3, true, true);
lv_label_set_static_text(label_btn, SYMBOL_CIRCUIT" Fuses ");

View File

@@ -121,7 +121,7 @@ static lv_res_t _create_mbox_autorcm_status(lv_obj_t *btn)
{
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");
"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);
@@ -611,17 +611,14 @@ 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)
static lv_obj_t *_create_container(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);
@@ -629,6 +626,16 @@ static void _create_tab_tools_emmc_pkg12(lv_theme_t *th, lv_obj_t *parent)
lv_obj_set_click(h1, false);
lv_cont_set_layout(h1, LV_LAYOUT_OFF);
return h1;
}
static void _create_tab_tools_emmc_pkg12(lv_theme_t *th, lv_obj_t *parent)
{
lv_page_set_scrl_layout(parent, LV_LAYOUT_PRETTY);
// Create Backup & Restore container.
lv_obj_t *h1 = _create_container(parent);
lv_obj_t *label_sep = lv_label_create(h1, NULL);
lv_label_set_static_text(label_sep, "");
@@ -675,19 +682,14 @@ static void _create_tab_tools_emmc_pkg12(lv_theme_t *th, lv_obj_t *parent)
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"
"Allows you to restore your eMMC/emuMMC partitions individually\n"
"or as a whole raw image from 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_t *h2 = _create_container(parent);
lv_obj_align(h2, h1, LV_ALIGN_OUT_RIGHT_TOP, 0, 0);
label_sep = lv_label_create(h2, NULL);
@@ -731,19 +733,8 @@ 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 *h1 = _create_container(parent);
lv_obj_t *label_sep = lv_label_create(h1, NULL);
lv_label_set_static_text(label_sep, "");
@@ -798,12 +789,7 @@ static void _create_tab_tools_arc_autorcm(lv_theme_t *th, lv_obj_t *parent)
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_t *h2 = _create_container(parent);
lv_obj_align(h2, h1, LV_ALIGN_OUT_RIGHT_TOP, 0, 0);
label_sep = lv_label_create(h2, NULL);

View File

@@ -145,12 +145,13 @@ int touch_power_on()
gpio_write(GPIO_PORT_J, GPIO_PIN_7, GPIO_HIGH);
// IRQ and more.
// PINMUX_AUX(PINMUX_AUX_TOUCH_INT) = PINMUX_TRISTATE | PINMUX_PULL_UP | 3;
// PINMUX_AUX(PINMUX_AUX_TOUCH_INT) = PINMUX_INPUT_ENABLE | PINMUX_TRISTATE | PINMUX_PULL_UP | 3;
// gpio_config(GPIO_PORT_X, GPIO_PIN_1, GPIO_MODE_GPIO);
// gpio_write(GPIO_PORT_X, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3, GPIO_LOW);
// gpio_write(GPIO_PORT_X, GPIO_PIN_1, GPIO_LOW);
// Configure Touscreen and GCAsic shared GPIO.
PINMUX_AUX(PINMUX_AUX_CAM_I2C_SDA) = PINMUX_TRISTATE | PINMUX_INPUT_ENABLE | PINMUX_PULL_UP | 3;
PINMUX_AUX(PINMUX_AUX_CAM_I2C_SCL) = PINMUX_INPUT_ENABLE | 1;
gpio_config(GPIO_PORT_S, GPIO_PIN_3, GPIO_MODE_GPIO);
// Initialize I2C3.
@@ -159,8 +160,9 @@ int touch_power_on()
i2c_init(I2C_3);
// Enables LDO6 for touchscreen VDD/AVDD supply
i2c_send_byte(I2C_5, MAX77620_I2C_ADDR, MAX77620_REG_LDO6_CFG, 0xEA);
i2c_send_byte(I2C_5, MAX77620_I2C_ADDR, MAX77620_REG_LDO6_CFG2, 0xDA);
max77620_regulator_set_volt_and_flags(REGULATOR_LDO6, 2900000, MAX77620_POWER_MODE_NORMAL);
i2c_send_byte(I2C_5, MAX77620_I2C_ADDR, MAX77620_REG_LDO6_CFG2,
MAX77620_LDO_CFG2_ADE_ENABLE | (3 << 3) | (MAX77620_POWER_MODE_NORMAL << MAX77620_LDO_POWER_MODE_SHIFT));
msleep(20);
@@ -193,14 +195,13 @@ void touch_power_off()
{
touch_command(STMFTS_SLEEP_IN);
// Disables LDO6 for touchscreen VDD, AVDD supply
i2c_send_byte(I2C_5, MAX77620_I2C_ADDR, MAX77620_REG_LDO6_CFG, 0x28);
i2c_send_byte(I2C_5, MAX77620_I2C_ADDR, MAX77620_REG_LDO6_CFG2, 0xD2);
clock_disable_i2c(I2C_3);
// Disable touchscreen power.
gpio_write(GPIO_PORT_J, GPIO_PIN_7, GPIO_LOW);
pinmux_config_i2c(I2C_3);
// Disables LDO6 for touchscreen VDD, AVDD supply
max77620_regulator_enable(REGULATOR_LDO6, 0);
i2c_send_byte(I2C_5, MAX77620_I2C_ADDR, MAX77620_REG_LDO6_CFG2,
MAX77620_LDO_CFG2_ADE_ENABLE | (2 << 3) | (MAX77620_POWER_MODE_NORMAL << MAX77620_LDO_POWER_MODE_SHIFT));
clock_disable_i2c(I2C_3);
}

View File

@@ -163,7 +163,7 @@
* LV_LOG_LEVEL_WARN Log if something unwanted happened but didn't caused problem
* LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail
*/
# define LV_LOG_LEVEL LV_LOG_LEVEL_TRACE
# define LV_LOG_LEVEL LV_LOG_LEVEL_ERROR
/* 1: Print the log with 'printf'; 0: user need to register a callback*/
# define LV_LOG_PRINTF 1
#endif /*USE_LV_LOG*/

View File

@@ -201,6 +201,7 @@ lv_obj_t * lv_win_add_btn(lv_obj_t * win, const void * img_src, const char * lab
else if (label_src)
{
lv_obj_t *label = lv_label_create(btn, NULL);
lv_label_set_recolor(label, true);
lv_label_set_text(label, label_src);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 77 KiB

View File

@@ -85,7 +85,11 @@ bool sd_mount()
int res = 0;
if (!sd_init_done)
{
res = !sdmmc_storage_init_sd(&sd_storage, &sd_sdmmc, SDMMC_1, SDMMC_BUS_WIDTH_4, 11);
if (!res)
sd_init_done = true;
}
if (res)
{
@@ -93,11 +97,10 @@ bool sd_mount()
}
else
{
sd_init_done = true;
int res = f_mount(&sd_fs, "", 1);
if (res == FR_OK)
{
sd_mounted = 1;
sd_mounted = true;
return true;
}
else
@@ -111,7 +114,7 @@ bool sd_mount()
void sd_unmount(bool deinit)
{
if (sd_mounted)
if (sd_init_done && sd_mounted)
{
f_mount(NULL, "", 1);
sd_mounted = false;
@@ -290,8 +293,6 @@ lv_res_t launch_payload(lv_obj_t *list)
void (*ext_payload_ptr)() = (void *)EXT_PAYLOAD_ADDR;
msleep(100);
// Launch our payload.
(*ext_payload_ptr)();
}
@@ -326,7 +327,11 @@ void load_saved_configuration()
else if (!strcmp("verification", kv->key))
h_cfg.verification = atoi(kv->val);
else if (!strcmp("backlight", kv->key))
{
h_cfg.backlight = atoi(kv->val);
if (h_cfg.backlight <= 20)
h_cfg.backlight = 30;
}
else if (!strcmp("autohosoff", kv->key))
h_cfg.autohosoff = atoi(kv->val);
else if (!strcmp("autonogc", kv->key))
@@ -398,9 +403,6 @@ extern void pivot_stack(u32 stack_top);
void ipl_main()
{
//Pivot the stack so we have enough space.
pivot_stack(IPL_STACK_TOP);
//Tegra/Horizon configuration goes to 0x80000000+, package2 goes to 0xA9800000, we place our heap in between.
heap_init(IPL_HEAP_START);

View File

@@ -23,6 +23,9 @@
#define REGULATOR_SD 0
#define REGULATOR_LDO 1
#pragma GCC push_options
#pragma GCC target ("thumb")
typedef struct _max77620_regulator_t
{
u8 type;
@@ -163,3 +166,5 @@ void max77620_low_battery_monitor_config()
i2c_send_byte(I2C_5, MAX77620_I2C_ADDR, MAX77620_REG_CNFGGLBL1,
MAX77620_CNFGGLBL1_LBDAC_EN | MAX77620_CNFGGLBL1_LBHYST_N | MAX77620_CNFGGLBL1_LBDAC_N);
}
#pragma GCC pop_options

View File

@@ -72,6 +72,9 @@
#define MMU_EN_READ (1 << 2)
#define MMU_EN_WRITE (1 << 3)
#pragma GCC push_options
#pragma GCC target ("thumb")
bpmp_mmu_entry_t mmu_entries[] =
{
{ 0x80000000, 0xFFFFFFFF, MMU_EN_READ | MMU_EN_WRITE | MMU_EN_EXEC | MMU_EN_CACHED, true },
@@ -83,15 +86,15 @@ void bpmp_mmu_maintenance(u32 op)
if (!(BPMP_CACHE_CTRL(BPMP_CACHE_CONFIG) & CFG_ENABLE))
return;
//BPMP_CACHE_CTRL(BPMP_CACHE_INT_CLEAR) = INT_CLR_MAINT_DONE;
BPMP_CACHE_CTRL(BPMP_CACHE_INT_CLEAR) = INT_CLR_MAINT_DONE;
// This is a blocking operation.
BPMP_CACHE_CTRL(BPMP_CACHE_MAINT_REQ) = MAINT_REQ_WAY_BITMAP(0xF) | op;
//while(!(BPMP_CACHE_CTRL(BPMP_CACHE_INT_RAW_EVENT) & INT_RAW_EVENT_MAINT_DONE))
// ;
while(!(BPMP_CACHE_CTRL(BPMP_CACHE_INT_RAW_EVENT) & INT_RAW_EVENT_MAINT_DONE))
;
//BPMP_CACHE_CTRL(BPMP_CACHE_INT_CLEAR) = BPMP_CACHE_CTRL(BPMP_CACHE_INT_RAW_EVENT);
BPMP_CACHE_CTRL(BPMP_CACHE_INT_CLEAR) = BPMP_CACHE_CTRL(BPMP_CACHE_INT_RAW_EVENT);
}
void bpmp_mmu_set_entry(int idx, bpmp_mmu_entry_t *entry, bool apply)
@@ -160,7 +163,8 @@ const u8 pllc4_divn[] = {
0, // BPMP_CLK_NORMAL: 408MHz 0% - 136MHz APB.
85, // BPMP_CLK_LOW_BOOST: 544MHz 33% - 136MHz APB.
90, // BPMP_CLK_MID_BOOST: 576MHz 41% - 144MHz APB.
95 // BPMP_CLK_SUPER_BOOST: 608MHz 49% - 152MHz APB.
94 // BPMP_CLK_SUPER_BOOST: 602MHz 48% - 150MHz APB.
//95 // BPMP_CLK_SUPER_BOOST: 608MHz 49% - 152MHz APB.
};
bpmp_freq_t bpmp_clock_set = BPMP_CLK_NORMAL;
@@ -215,3 +219,4 @@ void bpmp_clk_rate_set(bpmp_freq_t fid)
}
}
#pragma GCC pop_options

View File

@@ -19,6 +19,9 @@
#include "../utils/util.h"
#include "../storage/sdmmc.h"
#pragma GCC push_options
#pragma GCC target ("thumb")
/* clock_t: reset, enable, source, index, clk_src, clk_div */
static const clock_t _clock_uart[] = {
@@ -527,3 +530,5 @@ void clock_sdmmc_disable(u32 id)
_clock_sdmmc_clear_enable(id);
_clock_sdmmc_is_reset(id);
}
#pragma GCC pop_options

View File

@@ -23,6 +23,9 @@
#include "../power/max77620.h"
#include "../power/max7762x.h"
#pragma GCC push_options
#pragma GCC target ("thumb")
void _cluster_enable_power()
{
u8 tmp = i2c_recv_byte(I2C_5, MAX77620_I2C_ADDR, MAX77620_REG_AME_GPIO); // Get current pinmuxing
@@ -131,3 +134,5 @@ void cluster_boot_cpu0(u32 entry)
// < 5.x: 0x411F000F, Clear CPU{0,1,2,3} POR and CORE, CX0, L2, and DBG reset.
CLOCK(CLK_RST_CONTROLLER_RST_CPUG_CMPLX_CLR) = 0x41010001;
}
#pragma GCC pop_options

View File

@@ -22,6 +22,9 @@
#include "../soc/fuse.h"
#include "../soc/t210.h"
#pragma GCC push_options
#pragma GCC target ("thumb")
#define ARRAYSIZE(x) (sizeof(x) / sizeof(*x))
static const u32 evp_thunk_template[] = {
@@ -347,3 +350,5 @@ bool fuse_check_patched_rcm()
return false;
}
#pragma GCC pop_options

View File

@@ -41,6 +41,7 @@
#define PINMUX_AUX_SATA_LED_ACTIVE 0x4C
#define PINMUX_AUX_DMIC3_CLK 0xB4
#define PINMUX_AUX_DMIC3_DAT 0xB8
#define PINMUX_AUX_CAM_I2C_SCL 0xD4
#define PINMUX_AUX_CAM_I2C_SDA 0xD8
#define PINMUX_AUX_UART2_TX 0xF4
#define PINMUX_AUX_UART3_TX 0x104

View File

@@ -36,7 +36,7 @@ _start:
/* If we are not in the right location already, copy a relocator to upper IRAM. */
ADR R2, _reloc_ipl
LDR R3, =0x4003FF00
LDR R3, =0x4003FFE0
MOV R4, #(_real_start - _reloc_ipl)
_copy_loop:
LDMIA R2!, {R5}
@@ -48,7 +48,7 @@ _copy_loop:
LDR R2, =__ipl_end
SUB R2, R2, R1
LDR R3, =_real_start
LDR R4, =0x4003FF00
LDR R4, =0x4003FFE0
BX R4
_reloc_ipl:
@@ -61,7 +61,7 @@ _reloc_ipl:
_real_start:
/* Initially, we place our stack in IRAM but will move it to SDRAM later. */
LDR SP, =0x4003FF00
LDR SP, =0x90010000
LDR R0, =__bss_start
EOR R1, R1, R1
LDR R2, =__bss_end

View File

@@ -29,6 +29,9 @@
extern hekate_config h_cfg;
#pragma GCC push_options
#pragma GCC target ("thumb")
static inline u32 unstuff_bits(u32 *resp, u32 start, u32 size)
{
const u32 mask = (size < 32 ? 1 << size : 0) - 1;
@@ -1199,3 +1202,5 @@ int sdmmc_storage_init_gc(sdmmc_storage_t *storage, sdmmc_t *sdmmc)
return 1;
}
#pragma GCC pop_options

View File

@@ -50,3 +50,16 @@ u16 tmp451_get_pcb_temp(bool intenger)
return temp;
}
void tmp451_init()
{
// Disable ALARM.
i2c_send_byte(I2C_1, TMP451_I2C_ADDR, TMP451_CONFIG_REG, 0x80);
// Set conversion rate to 32/s and make a read to update the reg.
i2c_send_byte(I2C_1, TMP451_I2C_ADDR, TMP451_CNV_RATE_REG, 9);
tmp451_get_soc_temp(false);
// Set rate to every 4 seconds.
i2c_send_byte(I2C_1, TMP451_I2C_ADDR, TMP451_CNV_RATE_REG, 2);
}

View File

@@ -25,6 +25,10 @@
#define TMP451_PCB_TEMP_REG 0x00
#define TMP451_SOC_TEMP_REG 0x01
#define TMP451_CONFIG_REG 0x09
#define TMP451_CNV_RATE_REG 0x0A
#define TMP451_SOC_TMP_DEC_REG 0x10
#define TMP451_PCB_TMP_DEC_REG 0x15
@@ -33,5 +37,6 @@
// Otherwise it's an integer oC.
u16 tmp451_get_soc_temp(bool integer);
u16 tmp451_get_pcb_temp(bool integer);
void tmp451_init();
#endif /* __TMP451_H_ */

View File

Before

Width:  |  Height:  |  Size: 144 KiB

After

Width:  |  Height:  |  Size: 144 KiB

View File

Before

Width:  |  Height:  |  Size: 144 KiB

After

Width:  |  Height:  |  Size: 144 KiB

View File

Before

Width:  |  Height:  |  Size: 144 KiB

After

Width:  |  Height:  |  Size: 144 KiB