Compare commits

...

11 Commits
1.0.0 ... 1.1.1

Author SHA1 Message Date
Such Meme, Many Skill
697fc3a086 Do partition alignment, bump version to v1.1.1 2019-12-26 23:07:18 +01:00
Such Meme, Many Skill
6518f37b1c Bump version 2019-12-22 21:44:03 +01:00
Such Meme, Many Skill
81e97fa820 Mount other emmc parts 2019-12-22 12:10:59 +01:00
Such Meme, Many Skill
12802bf371 Make the user able to format without a valid partition 2019-12-20 21:00:47 +01:00
Such Meme, Many Skill
d1678be654 Make format options more clear 2019-12-18 16:14:14 +01:00
Such Meme, Many Skill
2a78d3c924 Fix folder scrolling issues 2019-12-18 16:02:45 +01:00
Such Meme, Many Skill
d4010ba04d Update Readme with support discords 2019-12-17 13:53:49 +01:00
Such Meme, Many Skill
7b6c19f820 Add check for <32gb sd cards for partitioning 2019-12-17 13:50:02 +01:00
Such Meme, Many Skill
3274d18b83 Add boot safety check, Add payload launching safety check
+ Add version info
2019-12-17 13:43:32 +01:00
Such Meme, Many Skill
472c0e293a Spice up Console Info menu 2019-12-16 23:31:29 +01:00
Such Meme, Many Skill
2e61413627 Reformat to 32k clusters instead of 8k clusters 2019-12-12 18:46:27 +01:00
12 changed files with 128 additions and 57 deletions

View File

@@ -10,7 +10,7 @@ include $(DEVKITARM)/base_rules
IPL_LOAD_ADDR := 0x40003000
LPVERSION_MAJOR := 2
LPVERSION_MINOR := 0
LPVERSION_MINOR := 1
LPVERSION_BUGFX := 0
################################################################################

View File

@@ -17,6 +17,12 @@ Navigate around the menu's using the vol+, vol- and power buttons
- Dumping your current firmware to sd
- Formatting the sd card
## Support
For general CFW support, go to the [Nintendo Homebrew](https://discord.gg/C29hYvh) discord
For question specifically for TegraExplorer, go to [my discord](https://discord.gg/aH9rsuP)
# Credits
Based on [Lockpick_RCM](https://github.com/shchmue/Lockpick_RCM), and thus based on [Hekate](https://github.com/CTCaer/hekate)

View File

@@ -151,7 +151,7 @@ DRESULT disk_read (
__attribute__ ((aligned (16))) static u64 prev_cluster = -1;
__attribute__ ((aligned (16))) static u32 prev_sector = 0;
bool needs_cache_sector = false;
/*
if (secindex == 0 || clear_sector_cache) {
if (!sector_cache)
sector_cache = (sector_cache_t *)malloc(sizeof(sector_cache_t) * MAX_SEC_CACHE_ENTRIES);
@@ -179,6 +179,7 @@ DRESULT disk_read (
secindex++;
}
}
*/
//system_part (pdrv == 1) ? system_part_sys : system_part_usr
if (nx_emmc_part_read(&storage, system_part, sector, count, buff)) {
u32 tweak_exp = 0;
@@ -195,10 +196,12 @@ DRESULT disk_read (
// fatfs will never pull more than a cluster
_emmc_xts(9, 8, 0, tweak, regen_tweak, tweak_exp, prev_cluster, buff, buff, count * 0x200);
/*
if (needs_cache_sector) {
memcpy(sector_cache[s].cached_sector, buff, 0x200);
memcpy(sector_cache[s].tweak, tweak, 0x10);
}
*/
prev_sector = sector + count - 1;
return RES_OK;
}

View File

@@ -6105,10 +6105,10 @@ FRESULT f_fdisk (
void* work /* Pointer to the working buffer (null: use heap memory) */
)
{
UINT i, n, sz_cyl, tot_cyl, b_cyl, e_cyl, p_cyl;
UINT i, n, sz_cyl, tot_cyl, e_cyl;
BYTE s_hd, e_hd, *p, *buf = (BYTE*)work;
DSTATUS stat;
DWORD sz_disk, sz_part, s_part;
DWORD sz_disk, sz_part, s_part, p_cyl, b_cyl;
FRESULT res;
@@ -6134,17 +6134,17 @@ FRESULT f_fdisk (
mem_set(buf, 0, FF_MAX_SS);
p = buf + MBR_Table; b_cyl = 0;
for (i = 0; i < 4; i++, p += SZ_PTE) {
p_cyl = (szt[i] <= 100U) ? (DWORD)tot_cyl * (szt[i] / 100) : szt[i] / sz_cyl; /* Number of cylinders */
p_cyl = (szt[i] <= 100U) ? (DWORD)tot_cyl * (szt[i] / 100) : szt[i]; // sz_cyl; /* Number of cylinders */
if (p_cyl == 0) continue;
s_part = (DWORD)sz_cyl * b_cyl;
sz_part = (DWORD)sz_cyl * p_cyl;
s_part = /*(DWORD)sz_cyl * */ b_cyl;
sz_part = /* (DWORD)sz_cyl * */ p_cyl;
if (i == 0) { /* Exclude first track of cylinder 0 */
s_hd = 1;
s_part += 32768; sz_part -= 32768;
} else {
s_hd = 0;
}
e_cyl = b_cyl + p_cyl - 1; /* End cylinder */
e_cyl = (b_cyl + p_cyl - 1) / sz_cyl; /* End cylinder */
if (e_cyl >= tot_cyl) LEAVE_MKFS(FR_INVALID_PARAMETER);

View File

@@ -45,11 +45,20 @@
sdmmc_t sd_sdmmc;
sdmmc_storage_t sd_storage;
__attribute__ ((aligned (16))) FATFS sd_fs;
static bool sd_mounted;
static bool sd_mounted, sd_inited;
volatile nyx_storage_t *nyx_str = (nyx_storage_t *)NYX_STORAGE_ADDR;
hekate_config h_cfg;
boot_cfg_t __attribute__((section ("._boot_cfg"))) b_cfg;
bool return_sd_mounted(int value){
switch(value){
case 1:
return sd_mounted;
case 7:
return sd_inited;
}
}
bool sd_mount()
{
if (sd_mounted)
@@ -58,9 +67,11 @@ bool sd_mount()
if (!sdmmc_storage_init_sd(&sd_storage, &sd_sdmmc, SDMMC_1, SDMMC_BUS_WIDTH_4, 11))
{
EPRINTF("Failed to init SD card.\nMake sure that it is inserted.\nOr that SD reader is properly seated!");
sd_inited = false;
}
else
{
sd_inited = true;
int res = 0;
res = f_mount(&sd_fs, "sd:", 1);
if (res == FR_OK)
@@ -84,6 +95,7 @@ void sd_unmount()
f_mount(NULL, "sd:", 1);
sdmmc_storage_end(&sd_storage);
sd_mounted = false;
sd_inited = false;
}
}

View File

@@ -28,7 +28,7 @@ __attribute__ ((aligned (16))) FATFS emmc;
LIST_INIT(gpt);
u8 bis_key[4][32];
short pkg1ver;
short pkg1ver = -1;
static bool _key_exists(const void *data) { return memcmp(data, zeros, 0x10); };
@@ -44,9 +44,11 @@ static void _generate_kek(u32 ks, const void *key_source, void *master_key, cons
}
void print_biskeys(){
gfx_printf("\n");
gfx_printf("Bis_Key_00\n");
gfx_hexdump(0, bis_key[0], 32);
gfx_printf("Bis_Key_01\n");
gfx_hexdump(0, bis_key[1], 32);
gfx_printf("Bis_Key_02 & 03\n");
gfx_hexdump(0, bis_key[2], 32);
}
@@ -75,6 +77,7 @@ short returnpkg1ver(){
}
void disconnect_emmc(){
f_unmount("emmc:");
sdmmc_storage_end(&storage);
}

View File

@@ -320,6 +320,10 @@ int delfile(const char *path, const char *filename){
void filemenu(const char *startpath){
int amount, res, tempint;
char temp[100];
if (!strcmp(rootpath, "emmc:/") && !strcmp(startpath, "emmc:/"))
clipboardhelper = 0;
strcpy(rootpath, startpath);
writecurpath(startpath);
amount = readfolder(currentpath);
@@ -363,8 +367,9 @@ void filemenu(const char *startpath){
sprintf(temp, "\nSize: %d %s", fileobjects[res - 1].size, sizevalues[tempint - 4]);
strcpy(explfilemenu[2].name, temp);
if (strstr(fileobjects[res - 1].name, ".bin") != NULL)
if (strstr(fileobjects[res - 1].name, ".bin") != NULL && fileobjects[res - 1].size & ISKB){
explfilemenu[7].property = 1;
}
else
explfilemenu[7].property = -1;

View File

@@ -26,7 +26,7 @@ void clearscreen(){
gfx_clear_grey(0x1B);
gfx_box(0, 0, 719, 15, COLOR_WHITE);
gfx_con_setpos(0, 0);
gfx_printf("%k%KTegraexplorer%k%K\n", COLOR_DEFAULT, COLOR_WHITE, COLOR_WHITE, COLOR_DEFAULT);
gfx_printf("%k%KTegraexplorer v1.1.1%k%K\n", COLOR_DEFAULT, COLOR_WHITE, COLOR_WHITE, COLOR_DEFAULT);
}
int message(char* message, u32 color){
@@ -127,26 +127,33 @@ void printfsentry(fs_entry file, bool highlight, bool refresh){
if (highlight)
gfx_printf("%K%k", COLOR_WHITE, COLOR_DEFAULT);
else
gfx_printf("%K%k", COLOR_DEFAULT, COLOR_WHITE);
RESETCOLOR;
if (file.property & ISDIR)
gfx_printf("%s\n", display);
gfx_printf("%s", display);
else {
for (size = 4; size < 8; size++)
if ((file.property & (1 << size)))
break;
gfx_printf("%k%s%K", COLOR_VIOLET, display, COLOR_DEFAULT);
SWAPCOLOR(COLOR_VIOLET);
gfx_printf("%s", display);
}
RESETCOLOR;
if (refresh){
length = strlen(display);
for (int i = 0; i < (42 - length); i++)
gfx_printf(" ");
}
if (!(file.property & ISDIR))
if (file.property & ISDIR)
gfx_printf("\n");
else {
SWAPCOLOR(COLOR_BLUE);
gfx_printf("\a%d\e%s", file.size, sizevalues[size - 4]);
}
free(display);
}

View File

@@ -2,6 +2,9 @@
#include "te.h"
#include "fs.h"
#define SWAPCOLOR(color) gfx_printf("%k", color)
#define RESETCOLOR gfx_printf("%k%K", COLOR_WHITE, COLOR_DEFAULT)
int makemenu(menu_item menu[], int menuamount);
int message(char* message, u32 color);
void clearscreen();

View File

@@ -10,12 +10,14 @@
extern bool sd_mount();
extern void sd_unmount();
extern bool return_sd_mounted(int value);
extern int launch_payload(char *path);
bool sd_mounted;
menu_item mainmenu[MAINMENU_AMOUNT] = {
{"[SD:/] SD CARD", COLOR_GREEN, SD_CARD, 1},
{"[SYSTEM:/] EMMC", COLOR_GREEN, EMMC_SYS, 1},
{"[SD:/] SD CARD\n", COLOR_GREEN, SD_CARD, 1},
{"[SYSTEM:/] EMMC", COLOR_ORANGE, EMMC_SYS, 1},
{"[USER:/] EMMC", COLOR_ORANGE, EMMC_USR, 1},
{"[SAFE:/] EMMC", COLOR_ORANGE, EMMC_SAF, 1},
{"\nMount/Unmount SD", COLOR_WHITE, MOUNT_SD, 1},
{"Tools", COLOR_VIOLET, TOOLS, 1},
{"SD format", COLOR_VIOLET, SD_FORMAT, 1},
@@ -44,8 +46,14 @@ menu_item toolsmenu[5] = {
menu_item formatmenu[4] = {
{"-- FORMAT SD --\n", COLOR_RED, -1, 0},
{"Back\n", COLOR_WHITE, -1, 1},
{"Format to FAT32", COLOR_RED, FORMAT_ALL_FAT32, 1},
{"Format for EmuMMC setup", COLOR_RED, FORMAT_EMUMMC, 1}
{"Format entire SD to FAT32", COLOR_RED, FORMAT_ALL_FAT32, 1},
{"Format for EmuMMC setup (FAT32/RAW)", COLOR_RED, FORMAT_EMUMMC, 1}
};
const char emmc_entries[3][8] = {
"SAFE",
"SYSTEM",
"USER"
};
void fillmainmenu(){
@@ -54,14 +62,14 @@ void fillmainmenu(){
for (i = 0; i < MAINMENU_AMOUNT; i++){
switch (i + 1) {
case 1:
case 5:
if (sd_mounted)
case 7:
if (return_sd_mounted(i + 1))
mainmenu[i].property = 1;
else
mainmenu[i].property = -1;
break;
case 3:
if (sd_mounted){
case 5:
if (return_sd_mounted(1)){
mainmenu[i].property = 2;
strcpy(mainmenu[i].name, "\nUnmount SD");
}
@@ -77,10 +85,12 @@ void fillmainmenu(){
void te_main(){
int res;
dump_biskeys();
mount_emmc("SYSTEM", 2);
sd_mounted = sd_mount();
if (dump_biskeys() == -1){
message("Biskeys failed to dump!\nEmmc will not be mounted!", COLOR_RED);
mainmenu[1].property = -1;
mainmenu[2].property = -1;
mainmenu[3].property = -1;
}
while (1){
fillmainmenu();
@@ -90,23 +100,26 @@ void te_main(){
case SD_CARD:
filemenu("SD:/");
break;
case EMMC_SAF:
case EMMC_SYS:
if (makewaitmenu("You're about to enter EMMC\nModifying anything here\n can result in a BRICK!\n\nPlease only continue\n if you know what you're doing\n\nPress Vol+/- to return\n", "Press Power to enter", 4))
filemenu("emmc:/");
break;
/*
case EMMC_USR:
mount_emmc("USER", 2);
filemenu("emmc:/");
break;
*/
case MOUNT_SD:
if (sd_mounted){
sd_mounted = false;
sd_unmount();
if (makewaitmenu("You're about to enter EMMC\nModifying anything here\n can result in a BRICK!\n\nPlease only continue\n if you know what you're doing\n\nPress Vol+/- to return\n", "Press Power to enter", 4)){
if (!mount_emmc(emmc_entries[res - 2], res - 1)){
filemenu("emmc:/");
}
else
sd_mounted = sd_mount();
message("EMMC failed to mount!", COLOR_RED);
}
break;
case MOUNT_SD:
if (return_sd_mounted(1))
sd_unmount();
else
sd_mount();
break;
@@ -133,7 +146,6 @@ void te_main(){
if(makewaitmenu("Are you sure you want to format your sd?\nThis will delete everything on your SD card\nThis action is irreversible!\n\nPress Vol+/- to cancel\n", "Press Power to continue", 10)){
if (format(res)){
sd_unmount();
sd_mounted = false;
}
}
}
@@ -145,7 +157,7 @@ void te_main(){
break;
case EXIT:
if (sd_mounted){
if (return_sd_mounted(1)){
if (checkfile("/bootloader/update.bin"))
shutdownmenu[5].property = 1;
else

View File

@@ -1,7 +1,7 @@
#pragma once
#include "../utils/types.h"
#define MAINMENU_AMOUNT 7
#define MAINMENU_AMOUNT 9
#define CREDITS_MESSAGE "\nTegraexplorer, made by:\nSuch Meme, Many Skill\n\nProject based on:\nLockpick_RCM\nHekate\n\nCool people:\nshchmue\ndennthecafebabe\nDax"
typedef struct _menu_item {
@@ -13,6 +13,7 @@ typedef struct _menu_item {
enum mainmenu_return {
SD_CARD = 1,
EMMC_SAF,
EMMC_SYS,
EMMC_USR,
MOUNT_SD,

View File

@@ -9,6 +9,7 @@
#include "../libs/fatfs/diskio.h"
#include "../storage/sdmmc.h"
#include "../utils/sprintf.h"
#include "../soc/fuse.h"
#include "emmc.h"
#include "fs.h"
@@ -22,11 +23,24 @@ void displayinfo(){
FATFS *fs;
DWORD fre_clust, fre_sect, tot_sect;
u32 capacity;
u8 fuse_count = 0;
int res;
gfx_printf("Biskeys:\n");
for (u32 i = 0; i < 32; i++){
if ((fuse_read_odm(7) >> i) & 1)
fuse_count++;
}
SWAPCOLOR(COLOR_ORANGE);
gfx_printf("Fuse count: %d\nPKG1 version: %d\n\n", fuse_count, returnpkg1ver());
print_biskeys();
RESETCOLOR;
gfx_printf("\n-----\n\n");
SWAPCOLOR(COLOR_BLUE);
if (!sd_mount()){
gfx_printf("SD mount failed!\nFailed to display SD info\n");
}
@@ -44,6 +58,7 @@ void displayinfo(){
gfx_printf("First partition on SD:\nSectors: %d\nSpace total: %d MB\nSpace free: %d MB\n\n", tot_sect, tot_sect / 2048, fre_sect / 2048);
}
RESETCOLOR;
gfx_printf("Press any key to continue");
btn_wait();
}
@@ -51,7 +66,7 @@ void displayinfo(){
void displaygpio(){
int res;
clearscreen();
gfx_printf("Updates gpio pins ever 50ms:\nPress power to exit");
gfx_printf("Updates gpio pins every 50ms:\nPress power to exit");
msleep(200);
while (1){
msleep(10);
@@ -82,6 +97,7 @@ int dumpfirmware(){
u32 timer = get_tmr_s();
clearscreen();
mount_emmc("SYSTEM", 2);
gfx_printf("PKG1 version: %d\n", pkg1ver);
@@ -129,9 +145,9 @@ int format(int mode){
int res;
bool fatalerror = false;
DWORD plist[] = {666, 61145088};
u32 timer, totalsectors;
u32 timer, totalsectors, alignedsectors, extrasectors;
BYTE work[FF_MAX_SS];
DWORD clustsize = 16 * 512;
DWORD clustsize = 32768;
BYTE formatoptions = 0;
formatoptions |= (FM_FAT32);
//formatoptions |= (FM_SFD);
@@ -142,14 +158,17 @@ int format(int mode){
totalsectors = sd_storage.csd.capacity;
if (mode == 0){
if (totalsectors < 61145088){
gfx_printf("%k\nNot enough free space for emummc!", COLOR_RED);
if (totalsectors < 83886080){
gfx_printf("%kYou seem to be running this on a <=32GB SD\nNot enough free space for emummc!", COLOR_RED);
fatalerror = true;
}
if (!fatalerror){
plist[0] = totalsectors - 61145088;
gfx_printf("\nStarting SD partitioning:\nTotalSectors: %d\nPartition1 (SD): %d\nPartition2 (EMUMMC): %d\n", totalsectors, plist[0], plist[1]);
else {
totalsectors -= plist[1];
alignedsectors = (totalsectors / 2048) * 2048;
extrasectors = totalsectors - alignedsectors;
plist[0] = alignedsectors;
plist[1] += extrasectors;
gfx_printf("\nStarting SD partitioning:\nTotalSectors: %d\nPartition1 (SD): %d\nPartition2 (EMUMMC): %d\n", plist[0] + plist[1], plist[0], plist[1]);
}
}
else {