mirror of
https://github.com/wiiu-env/wiiu-nanddumper-payload.git
synced 2024-11-22 03:19:17 +01:00
add option to dump mlc
This commit is contained in:
parent
7396fe9009
commit
31658bbb04
@ -89,7 +89,7 @@ int slc_dump(void *deviceHandle, const char* device, const char* filename, int y
|
|||||||
|
|
||||||
result = 0;
|
result = 0;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
FS_SVC_DESTROYMUTEX(sync_mutex);
|
FS_SVC_DESTROYMUTEX(sync_mutex);
|
||||||
|
|
||||||
if (file) {
|
if (file) {
|
||||||
@ -100,23 +100,37 @@ int slc_dump(void *deviceHandle, const char* device, const char* filename, int y
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mlc_dump(u32 base_sector, u32 mlc_end)
|
int mlc_dump(u32 mlc_end, int y_offset)
|
||||||
{
|
{
|
||||||
u32 offset = 0;
|
u32 offset = 0;
|
||||||
|
|
||||||
|
int result = -1;
|
||||||
int retry = 0;
|
int retry = 0;
|
||||||
int mlc_result = 0;
|
int mlc_result = 0;
|
||||||
int callback_result = 0;
|
int callback_result = 0;
|
||||||
int write_result = 0;
|
int write_result = 0;
|
||||||
int print_counter = 0;
|
int print_counter = 0;
|
||||||
|
int current_file_index = 0;
|
||||||
|
|
||||||
|
|
||||||
|
char filename[40];
|
||||||
|
FL_FILE *file = NULL;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
if (!file) {
|
||||||
|
FS_SNPRINTF(filename, sizeof(filename), "/mlc.bin.part%02d", ++current_file_index);
|
||||||
|
file = fl_fopen(filename, "w");
|
||||||
|
if (!file) {
|
||||||
|
_printf(20, y_offset, "Failed to open %s for writing", filename);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
}
|
||||||
//! print only every 4th time
|
//! print only every 4th time
|
||||||
if(print_counter == 0)
|
if(print_counter == 0)
|
||||||
{
|
{
|
||||||
print_counter = 4;
|
print_counter = 4;
|
||||||
_printf(20, 70, "mlc = %08X / %08X, mlc res %08X, sd res %08X, retry %d", offset, mlc_end, mlc_result, write_result, retry);
|
_printf(20, y_offset, "mlc = %08X / %08X, mlc res %08X, retry %d", offset, mlc_end, mlc_result, retry);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -141,24 +155,30 @@ void mlc_dump(u32 base_sector, u32 mlc_end)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
write_result = sdcard_readwrite(SDIO_WRITE, io_buffer, (IO_BUFFER_SIZE / MLC_BYTES_PER_SECTOR), SDIO_BYTES_PER_SECTOR, base_sector + offset, NULL, DEVICE_ID_SDCARD_PATCHED);
|
write_result = fl_fwrite(io_buffer, 1, IO_BUFFER_SIZE, file);
|
||||||
if((write_result == 0) || (retry >= 5))
|
if (write_result != IO_BUFFER_SIZE) {
|
||||||
{
|
_printf(20, y_offset + 10, "mlc: Failed to write %d bytes to file %s (result: %d)!", IO_BUFFER_SIZE, file, filename, write_result);
|
||||||
retry = 0;
|
goto error;
|
||||||
offset += (IO_BUFFER_SIZE / MLC_BYTES_PER_SECTOR);
|
}
|
||||||
}
|
offset += (IO_BUFFER_SIZE / MLC_BYTES_PER_SECTOR);
|
||||||
else
|
if ((offset % 0x400000) == 0) {
|
||||||
{
|
fl_fclose(file);
|
||||||
FS_SLEEP(100);
|
file = NULL;
|
||||||
retry++;
|
}
|
||||||
print_counter = 0; // print errors directly
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while(offset < mlc_end); //! TODO: make define MLC32_SECTOR_COUNT
|
while(offset < mlc_end); //! TODO: make define MLC32_SECTOR_COUNT:
|
||||||
|
|
||||||
|
result = 0;
|
||||||
|
|
||||||
|
error:
|
||||||
|
if (file) {
|
||||||
|
fl_fclose(file);
|
||||||
|
}
|
||||||
// last print to show "done"
|
// last print to show "done"
|
||||||
_printf(20, 70, "mlc = %08X / %08X, mlc res %08X, sd res %08X, retry %d", offset, mlc_end, mlc_result, write_result, retry);
|
_printf(20, y_offset, "mlc = %08X / %08X, mlc res %08X, retry %d", offset, mlc_end, mlc_result, retry);
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int check_nand_type(void)
|
int check_nand_type(void)
|
||||||
@ -204,26 +224,38 @@ int check_nand_type(void)
|
|||||||
|
|
||||||
void dump_nand_complete()
|
void dump_nand_complete()
|
||||||
{
|
{
|
||||||
_printf(20, 30, "Init SD card....");
|
int offset_y = 30;
|
||||||
|
_printf(20, offset_y, "Init SD card....");
|
||||||
if ( InitSDCardFAT32() != 0 ) {
|
if ( InitSDCardFAT32() != 0 ) {
|
||||||
FS_SLEEP(3000);
|
FS_SLEEP(3000);
|
||||||
svcShutdown(SHUTDOWN_TYPE_REBOOT);
|
svcShutdown(SHUTDOWN_TYPE_REBOOT);
|
||||||
}
|
}
|
||||||
_printf(20, 30, "Init SD card.... Success!");
|
_printf(20, offset_y, "Init SD card.... Success!");
|
||||||
|
offset_y += 10;
|
||||||
|
|
||||||
|
int * dumpSlc = (int *)(0x107f8200 - 4);
|
||||||
|
int * dumpSlccmpt = (int *)(0x107f8200 - 8);
|
||||||
|
int * dumpMlc = (int *)(0x107f8200 - 12);
|
||||||
|
|
||||||
|
|
||||||
//wait_format_confirmation();
|
//wait_format_confirmation();
|
||||||
|
|
||||||
//mlc_init();
|
u32 mlc_sector_count = 0;
|
||||||
FS_SLEEP(1000);
|
if (*dumpMlc) {
|
||||||
|
mlc_init();
|
||||||
|
FS_SLEEP(1000);
|
||||||
|
|
||||||
/*int nand_type = check_nand_type();
|
int nand_type = check_nand_type();
|
||||||
u32 sdio_sector_count = FS_MMC_SDCARD_STRUCT[0x30/4];
|
//u32 sdio_sector_count = FS_MMC_SDCARD_STRUCT[0x30/4];
|
||||||
u32 mlc_sector_count = FS_MMC_MLC_STRUCT[0x30/4];
|
mlc_sector_count = FS_MMC_MLC_STRUCT[0x30/4];
|
||||||
u32 fat32_partition_offset = (MLC_BASE_SECTORS + mlc_sector_count);
|
//u32 fat32_partition_offset = (MLC_BASE_SECTORS + mlc_sector_count);
|
||||||
|
|
||||||
_printf(20, 30, "Detected %d GB MLC NAND type.", (nand_type == MLC_NAND_TYPE_8GB) ? 8 : 32);
|
_printf(20, offset_y, "Detected %d GB MLC NAND type.", (nand_type == MLC_NAND_TYPE_8GB) ? 8 : 32);
|
||||||
|
offset_y += 10;
|
||||||
|
}
|
||||||
|
offset_y += 10;
|
||||||
|
|
||||||
if(sdio_sector_count < fat32_partition_offset)
|
/*if(sdio_sector_count < fat32_partition_offset)
|
||||||
{
|
{
|
||||||
_printf(20, 40, "SD card too small! Required sectors %u > available %u.", fat32_partition_offset, sdio_sector_count);
|
_printf(20, 40, "SD card too small! Required sectors %u > available %u.", fat32_partition_offset, sdio_sector_count);
|
||||||
FS_SLEEP(3000);
|
FS_SLEEP(3000);
|
||||||
@ -236,33 +268,31 @@ void dump_nand_complete()
|
|||||||
svcShutdown(SHUTDOWN_TYPE_REBOOT);
|
svcShutdown(SHUTDOWN_TYPE_REBOOT);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
int * dumpSlc = (int *)(0x107f8200 - 4);
|
|
||||||
int * dumpSlccmpt = (int *)(0x107f8200 - 8);
|
|
||||||
int * dumpMlc = (int *)(0x107f8200 - 12);
|
|
||||||
int offset_y = 50;
|
|
||||||
if (*dumpSlc) {
|
if (*dumpSlc) {
|
||||||
if (slc_dump(FS_SLC_PHYS_DEV_STRUCT, "slc ", "/slc.bin", offset_y))
|
if (slc_dump(FS_SLC_PHYS_DEV_STRUCT, "slc ", "/slc.bin", offset_y))
|
||||||
goto error;
|
goto error;
|
||||||
offset_y += 10;
|
offset_y += 10;
|
||||||
}
|
}
|
||||||
if (*dumpSlccmpt) {
|
if (*dumpSlccmpt) {
|
||||||
if (slc_dump(FS_SLCCMPT_PHYS_DEV_STRUCT, "slccmpt", "/slccmpt.bin", 60))
|
if (slc_dump(FS_SLCCMPT_PHYS_DEV_STRUCT, "slccmpt", "/slccmpt.bin", offset_y))
|
||||||
goto error;
|
goto error;
|
||||||
offset_y += 10;
|
offset_y += 10;
|
||||||
}
|
}
|
||||||
if (*dumpMlc) {
|
if (*dumpMlc) {
|
||||||
// TODO
|
if (mlc_dump(mlc_sector_count, offset_y))
|
||||||
//mlc_dump(MLC_BASE_SECTORS, mlc_sector_count);
|
goto error;
|
||||||
offset_y += 10;
|
offset_y += 10;
|
||||||
}
|
}
|
||||||
|
offset_y += 20;
|
||||||
|
|
||||||
_printf(20, 80, "Complete! -> rebooting into sysNAND...");
|
_printf(20, offset_y, "Complete! -> rebooting into sysNAND...");
|
||||||
|
|
||||||
FS_SLEEP(3000);
|
FS_SLEEP(3000);
|
||||||
svcShutdown(SHUTDOWN_TYPE_REBOOT);
|
svcShutdown(SHUTDOWN_TYPE_REBOOT);
|
||||||
|
|
||||||
error:
|
error:
|
||||||
_printf(20, 80, "Error! -> rebooting into sysNAND...");
|
offset_y += 20;
|
||||||
|
_printf(20, offset_y, "Error! -> rebooting into sysNAND...");
|
||||||
|
|
||||||
FS_SLEEP(3000);
|
FS_SLEEP(3000);
|
||||||
svcShutdown(SHUTDOWN_TYPE_REBOOT);
|
svcShutdown(SHUTDOWN_TYPE_REBOOT);
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
int check_nand_type(void);
|
int check_nand_type(void);
|
||||||
void slc_dump(int deviceId, const char* format, char* filename);
|
void slc_dump(int deviceId, const char* format, char* filename);
|
||||||
void mlc_dump(u32 base_sector, u32 mlc_end);
|
void mlc_dump(u32 mlc_end, int y_offset);
|
||||||
void dump_nand_complete();
|
void dump_nand_complete();
|
||||||
|
|
||||||
#endif // _DUMPER_H_
|
#endif // _DUMPER_H_
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
#include "dynamic_libs/socket_functions.h"
|
#include "dynamic_libs/socket_functions.h"
|
||||||
#include "cfw_config.h"
|
#include "cfw_config.h"
|
||||||
|
|
||||||
#define MAX_CONFIG_SETTINGS 2
|
#define MAX_CONFIG_SETTINGS 3
|
||||||
//#define MAX_CONFIG_SETTINGS_EXPERT 9
|
//#define MAX_CONFIG_SETTINGS_EXPERT 9
|
||||||
//#define MAX_CONFIG_SETTINGS_DEFAULT (MAX_CONFIG_SETTINGS_EXPERT - 3)
|
//#define MAX_CONFIG_SETTINGS_DEFAULT (MAX_CONFIG_SETTINGS_EXPERT - 3)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user