From b0094f133ca8b070e1976909d911a6acfcb13494 Mon Sep 17 00:00:00 2001 From: "Such Meme, Many Skill" Date: Wed, 4 Dec 2019 17:47:13 +0100 Subject: [PATCH] Partitioning: add 16mb in front --- source/libs/fatfs/ff.c | 4 ++-- source/tegraexplorer/tools.c | 14 ++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/source/libs/fatfs/ff.c b/source/libs/fatfs/ff.c index 3013b4b..3c254a7 100644 --- a/source/libs/fatfs/ff.c +++ b/source/libs/fatfs/ff.c @@ -6134,13 +6134,14 @@ FRESULT f_fdisk ( sz_part = (DWORD)sz_cyl * p_cyl; if (i == 0) { /* Exclude first track of cylinder 0 */ s_hd = 1; - s_part += 63; sz_part -= 63; + s_part += 32831; sz_part -= 32831; } else { s_hd = 0; } e_cyl = b_cyl + p_cyl - 1; /* End cylinder */ if (e_cyl >= tot_cyl) LEAVE_MKFS(FR_INVALID_PARAMETER); + /* Set partition table */ p[1] = s_hd; /* Start head */ p[2] = (BYTE)(((b_cyl >> 2) & 0xC0) | 1); /* Start sector */ @@ -6151,7 +6152,6 @@ FRESULT f_fdisk ( p[7] = (BYTE)e_cyl; /* End cylinder */ st_dword(p + 8, s_part); /* Start sector in LBA */ st_dword(p + 12, sz_part); /* Number of sectors */ - /* Next partition */ b_cyl += p_cyl; } diff --git a/source/tegraexplorer/tools.c b/source/tegraexplorer/tools.c index dcca492..a8ed9c3 100644 --- a/source/tegraexplorer/tools.c +++ b/source/tegraexplorer/tools.c @@ -6,6 +6,7 @@ #include "../soc/gpio.h" #include "../utils/util.h" #include "../utils/types.h" +#include "../libs/fatfs/diskio.h" extern bool sd_mount(); extern void sd_unmount(); @@ -14,7 +15,7 @@ void displayinfo(){ clearscreen(); FATFS *fs; - DWORD fre_clust, fre_sect, tot_sect, temp_sect; + DWORD fre_clust, fre_sect, tot_sect, temp_sect, sz_disk; int res; gfx_printf("Getting storage info: please wait..."); @@ -30,7 +31,12 @@ void displayinfo(){ temp_sect = tot_sect; temp_sect -= 61145088; - gfx_printf("\n1st part: %d\n2nd part: 61145088", temp_sect); + gfx_printf("\n1st part: %d\n2nd part: 61145088\n\n", temp_sect); + + disk_initialize(0); + disk_ioctl(0, GET_SECTOR_COUNT, &sz_disk); + + gfx_printf("total sectors: %d", sz_disk); btn_wait(); } @@ -74,14 +80,14 @@ void format(){ gfx_printf("Getting free cluster info from 1st partition"); if (res = f_getfree("sd:", &fre_clust, &fs)) - gfx_printf("%kGetfree failed! errcode %d", COLOR_RED, res); + gfx_printf("%kGetfree failed! errcode %d", COLOR_ORANGE, res); else { tot_sect = (fs->n_fatent - 2) * fs->csize; temp_sect = tot_sect; temp_sect -= 61145089; gfx_printf("Total sectors: %d\nFree after emummc: %d\n\n", tot_sect, temp_sect); if (temp_sect < 0) - gfx_printf("%kNot enough space free!\n", COLOR_RED); + gfx_printf("%kNot enough space free!\n", COLOR_ORANGE); else { gfx_printf("Partitioning sd...\nPartition1 size: %d\nPartition2 size: %d\n", plist[0], plist[1]); plist[0] = temp_sect;