mirror of
https://github.com/wiiu-env/wiiu-nanddumper-payload.git
synced 2024-11-25 12:46:55 +01:00
Fixed some tab/spaces confusion
This commit is contained in:
parent
1d7fb42aa3
commit
7513886800
@ -154,14 +154,14 @@ int slcWrite2_patch(void *physical_device_info, u32 offset_high, u32 offset_low,
|
|||||||
|
|
||||||
int eccCheck_patch(void *buffer, char* spare_ecc, char* calculated_ecc, int ecc_length)
|
int eccCheck_patch(void *buffer, char* spare_ecc, char* calculated_ecc, int ecc_length)
|
||||||
{
|
{
|
||||||
if (io_buffer_spare_status || io_buffer_spare_pos > sizeof(io_buffer_spare) || io_buffer_spare_pos+0x840 > sizeof(io_buffer_spare)) {
|
if (io_buffer_spare_status || io_buffer_spare_pos > sizeof(io_buffer_spare) || io_buffer_spare_pos+0x840 > sizeof(io_buffer_spare)) {
|
||||||
io_buffer_spare_status = -1;
|
io_buffer_spare_status = -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
memcpy(io_buffer_spare+io_buffer_spare_pos, buffer, 0x800);
|
memcpy(io_buffer_spare+io_buffer_spare_pos, buffer, 0x800);
|
||||||
io_buffer_spare_pos += 0x800;
|
io_buffer_spare_pos += 0x800;
|
||||||
memcpy(io_buffer_spare+io_buffer_spare_pos, spare_ecc - 0x30, 0x40);
|
memcpy(io_buffer_spare+io_buffer_spare_pos, spare_ecc - 0x30, 0x40);
|
||||||
io_buffer_spare_pos += 0x40;
|
io_buffer_spare_pos += 0x40;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ static int srcRead(void* deviceHandle, void *data_ptr, u32 offset, u32 sectors,
|
|||||||
|
|
||||||
int slc_dump(void *deviceHandle, const char* device, const char* filename, int y_offset)
|
int slc_dump(void *deviceHandle, const char* device, const char* filename, int y_offset)
|
||||||
{
|
{
|
||||||
//also create a mutex for synchronization with end of operation...
|
//also create a mutex for synchronization with end of operation...
|
||||||
int sync_mutex = FS_SVC_CREATEMUTEX(1, 1);
|
int sync_mutex = FS_SVC_CREATEMUTEX(1, 1);
|
||||||
FS_SVC_ACQUIREMUTEX(sync_mutex, 0);
|
FS_SVC_ACQUIREMUTEX(sync_mutex, 0);
|
||||||
|
|
||||||
@ -59,76 +59,76 @@ int slc_dump(void *deviceHandle, const char* device, const char* filename, int y
|
|||||||
FS_SLEEP(1000);
|
FS_SLEEP(1000);
|
||||||
|
|
||||||
FL_FILE *file = fl_fopen(filename, "w");
|
FL_FILE *file = fl_fopen(filename, "w");
|
||||||
if (!file) {
|
if (!file) {
|
||||||
_printf(20, y_offset, "Failed to open %s for writing", filename);
|
_printf(20, y_offset, "Failed to open %s for writing", filename);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
_printf(20, y_offset, "%s = %05X / 40000", device, offset);
|
_printf(20, y_offset, "%s = %05X / 40000", device, offset);
|
||||||
|
|
||||||
//! set flash erased byte to buffer
|
//! set flash erased byte to buffer
|
||||||
FS_MEMSET(io_buffer_spare, 0xff, IO_BUFFER_SPARE_SIZE);
|
FS_MEMSET(io_buffer_spare, 0xff, IO_BUFFER_SPARE_SIZE);
|
||||||
io_buffer_spare_status = 0;
|
io_buffer_spare_status = 0;
|
||||||
io_buffer_spare_pos = 0;
|
io_buffer_spare_pos = 0;
|
||||||
//readResult = readSlc(io_buffer, offset, (sizeof(io_buffer) / SLC_BYTES_PER_SECTOR), deviceHandle);
|
//readResult = readSlc(io_buffer, offset, (sizeof(io_buffer) / SLC_BYTES_PER_SECTOR), deviceHandle);
|
||||||
readResult = srcRead(deviceHandle, io_buffer, offset, readSize, result_array);
|
readResult = srcRead(deviceHandle, io_buffer, offset, readSize, result_array);
|
||||||
|
|
||||||
if (readResult || io_buffer_spare_status || io_buffer_spare_pos != IO_BUFFER_SPARE_SIZE) {
|
if (readResult || io_buffer_spare_status || io_buffer_spare_pos != IO_BUFFER_SPARE_SIZE) {
|
||||||
|
|
||||||
_printf(20, y_offset+10, "Failed to read flash block. read result: 0x%08X spare status: 0x%08X spare pos: 0x%08X", readResult, io_buffer_spare_status, io_buffer_spare_pos);
|
_printf(20, y_offset+10, "Failed to read flash block. read result: 0x%08X spare status: 0x%08X spare pos: 0x%08X", readResult, io_buffer_spare_status, io_buffer_spare_pos);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
//FS_SLEEP(10);
|
//FS_SLEEP(10);
|
||||||
writeResult = fl_fwrite(io_buffer_spare, 1, readSize * SLC_BYTES_PER_SECTOR, file);
|
writeResult = fl_fwrite(io_buffer_spare, 1, readSize * SLC_BYTES_PER_SECTOR, file);
|
||||||
if (writeResult != readSize * SLC_BYTES_PER_SECTOR) {
|
if (writeResult != readSize * SLC_BYTES_PER_SECTOR) {
|
||||||
_printf(20, y_offset + 10, "%s: Failed to write %d bytes to file %s (result: %d)!", device, readSize * SLC_BYTES_PER_SECTOR, file, filename, writeResult);
|
_printf(20, y_offset + 10, "%s: Failed to write %d bytes to file %s (result: %d)!", device, readSize * SLC_BYTES_PER_SECTOR, file, filename, writeResult);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
offset += readSize;
|
offset += readSize;
|
||||||
}
|
}
|
||||||
while (offset < SLC_SECTOR_COUNT);
|
while (offset < SLC_SECTOR_COUNT);
|
||||||
|
|
||||||
result = 0;
|
result = 0;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
FS_SVC_DESTROYMUTEX(sync_mutex);
|
FS_SVC_DESTROYMUTEX(sync_mutex);
|
||||||
|
|
||||||
if (file) {
|
if (file) {
|
||||||
fl_fclose(file);
|
fl_fclose(file);
|
||||||
}
|
}
|
||||||
// last print to show "done"
|
// last print to show "done"
|
||||||
_printf(20, y_offset, "%s = %05X / 40000", device, offset);
|
_printf(20, y_offset, "%s = %05X / 40000", device, offset);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mlc_dump(u32 mlc_end, int y_offset)
|
int mlc_dump(u32 mlc_end, int y_offset)
|
||||||
{
|
{
|
||||||
u32 offset = 0;
|
u32 offset = 0;
|
||||||
|
|
||||||
int result = -1;
|
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;
|
int current_file_index = 0;
|
||||||
|
|
||||||
|
|
||||||
char filename[40];
|
char filename[40];
|
||||||
FL_FILE *file = NULL;
|
FL_FILE *file = NULL;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (!file) {
|
if (!file) {
|
||||||
FS_SNPRINTF(filename, sizeof(filename), "/mlc.bin.part%02d", ++current_file_index);
|
FS_SNPRINTF(filename, sizeof(filename), "/mlc.bin.part%02d", ++current_file_index);
|
||||||
file = fl_fopen(filename, "w");
|
file = fl_fopen(filename, "w");
|
||||||
if (!file) {
|
if (!file) {
|
||||||
_printf(20, y_offset, "Failed to open %s for writing", filename);
|
_printf(20, y_offset, "Failed to open %s for writing", filename);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//! print only every 4th time
|
//! print only every 4th time
|
||||||
if(print_counter == 0)
|
if(print_counter == 0)
|
||||||
{
|
{
|
||||||
@ -158,30 +158,30 @@ int mlc_dump(u32 mlc_end, int y_offset)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
write_result = fl_fwrite(io_buffer, 1, IO_BUFFER_SIZE, file);
|
write_result = fl_fwrite(io_buffer, 1, IO_BUFFER_SIZE, file);
|
||||||
if (write_result != IO_BUFFER_SIZE) {
|
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);
|
_printf(20, y_offset + 10, "mlc: Failed to write %d bytes to file %s (result: %d)!", IO_BUFFER_SIZE, file, filename, write_result);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
offset += (IO_BUFFER_SIZE / MLC_BYTES_PER_SECTOR);
|
offset += (IO_BUFFER_SIZE / MLC_BYTES_PER_SECTOR);
|
||||||
if ((offset % 0x400000) == 0) {
|
if ((offset % 0x400000) == 0) {
|
||||||
fl_fclose(file);
|
fl_fclose(file);
|
||||||
file = NULL;
|
file = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while(offset < mlc_end); //! TODO: make define MLC32_SECTOR_COUNT:
|
while(offset < mlc_end); //! TODO: make define MLC32_SECTOR_COUNT:
|
||||||
|
|
||||||
result = 0;
|
result = 0;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
if (file) {
|
if (file) {
|
||||||
fl_fclose(file);
|
fl_fclose(file);
|
||||||
}
|
}
|
||||||
// last print to show "done"
|
// last print to show "done"
|
||||||
_printf(20, y_offset, "mlc = %08X / %08X, mlc res %08X, retry %d", offset, mlc_end, mlc_result, retry);
|
_printf(20, y_offset, "mlc = %08X / %08X, mlc res %08X, retry %d", offset, mlc_end, mlc_result, retry);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int check_nand_type(void)
|
int check_nand_type(void)
|
||||||
@ -227,31 +227,31 @@ int check_nand_type(void)
|
|||||||
|
|
||||||
void dump_nand_complete()
|
void dump_nand_complete()
|
||||||
{
|
{
|
||||||
int offset_y = 30;
|
int offset_y = 30;
|
||||||
_printf(20, offset_y, "Init SD card....");
|
_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, offset_y, "Init SD card.... Success!");
|
_printf(20, offset_y, "Init SD card.... Success!");
|
||||||
offset_y += 10;
|
offset_y += 10;
|
||||||
|
|
||||||
//wait_format_confirmation();
|
//wait_format_confirmation();
|
||||||
|
|
||||||
u32 mlc_sector_count = 0;
|
u32 mlc_sector_count = 0;
|
||||||
if (dumper_config.dump_mlc) {
|
if (dumper_config.dump_mlc) {
|
||||||
mlc_init();
|
mlc_init();
|
||||||
FS_SLEEP(1000);
|
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];
|
||||||
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, offset_y, "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;
|
||||||
}
|
}
|
||||||
offset_y += 10;
|
offset_y += 10;
|
||||||
|
|
||||||
/*if(sdio_sector_count < fat32_partition_offset)
|
/*if(sdio_sector_count < fat32_partition_offset)
|
||||||
{
|
{
|
||||||
@ -266,58 +266,58 @@ void dump_nand_complete()
|
|||||||
svcShutdown(SHUTDOWN_TYPE_REBOOT);
|
svcShutdown(SHUTDOWN_TYPE_REBOOT);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
if (dumper_config.dump_otp) {
|
if (dumper_config.dump_otp) {
|
||||||
_printf(20, offset_y, "Writing otp...");
|
_printf(20, offset_y, "Writing otp...");
|
||||||
FL_FILE *file = fl_fopen("/otp.bin", "w");
|
FL_FILE *file = fl_fopen("/otp.bin", "w");
|
||||||
if (!file) {
|
if (!file) {
|
||||||
_printf(20, offset_y+10, "Failed to open /otp.bin for writing!");
|
_printf(20, offset_y+10, "Failed to open /otp.bin for writing!");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
// It doesn't work if we try write directly this buffer, does it try to access too much?
|
// It doesn't work if we try write directly this buffer, does it try to access too much?
|
||||||
memcpy(io_buffer, dumper_config.otp_buffer, sizeof(dumper_config.otp_buffer));
|
memcpy(io_buffer, dumper_config.otp_buffer, sizeof(dumper_config.otp_buffer));
|
||||||
if (fl_fwrite(io_buffer, 1, sizeof(dumper_config.otp_buffer), file) != sizeof(dumper_config.otp_buffer)) {
|
if (fl_fwrite(io_buffer, 1, sizeof(dumper_config.otp_buffer), file) != sizeof(dumper_config.otp_buffer)) {
|
||||||
fl_fclose(file);
|
fl_fclose(file);
|
||||||
_printf(20, offset_y+10, "Failed to write otp to file!");
|
_printf(20, offset_y+10, "Failed to write otp to file!");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
fl_fclose(file);
|
fl_fclose(file);
|
||||||
_printf(20, offset_y, "Writing otp... Success!");
|
_printf(20, offset_y, "Writing otp... Success!");
|
||||||
offset_y += 10;
|
offset_y += 10;
|
||||||
}
|
}
|
||||||
if (dumper_config.dump_seeprom) {
|
if (dumper_config.dump_seeprom) {
|
||||||
_printf(20, offset_y, "Writing seeprom...");
|
_printf(20, offset_y, "Writing seeprom...");
|
||||||
FL_FILE *file = fl_fopen("/seeprom.bin", "w");
|
FL_FILE *file = fl_fopen("/seeprom.bin", "w");
|
||||||
if (!file) {
|
if (!file) {
|
||||||
_printf(20, offset_y+10, "Failed to open /seeprom.bin for writing!");
|
_printf(20, offset_y+10, "Failed to open /seeprom.bin for writing!");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
// It doesn't work if we try write directly this buffer, does it try to access too much?
|
// It doesn't work if we try write directly this buffer, does it try to access too much?
|
||||||
memcpy(io_buffer, dumper_config.seeprom_buffer, sizeof(dumper_config.seeprom_buffer));
|
memcpy(io_buffer, dumper_config.seeprom_buffer, sizeof(dumper_config.seeprom_buffer));
|
||||||
if (fl_fwrite(io_buffer, 1, sizeof(dumper_config.seeprom_buffer), file) != sizeof(dumper_config.seeprom_buffer)) {
|
if (fl_fwrite(io_buffer, 1, sizeof(dumper_config.seeprom_buffer), file) != sizeof(dumper_config.seeprom_buffer)) {
|
||||||
fl_fclose(file);
|
fl_fclose(file);
|
||||||
_printf(20, offset_y+10, "Failed to write seeprom to file!");
|
_printf(20, offset_y+10, "Failed to write seeprom to file!");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
fl_fclose(file);
|
fl_fclose(file);
|
||||||
_printf(20, offset_y, "Writing seeprom... Success!");
|
_printf(20, offset_y, "Writing seeprom... Success!");
|
||||||
offset_y += 10;
|
offset_y += 10;
|
||||||
}
|
}
|
||||||
if (dumper_config.dump_slc) {
|
if (dumper_config.dump_slc) {
|
||||||
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 (dumper_config.dump_slccmpt) {
|
if (dumper_config.dump_slccmpt) {
|
||||||
if (slc_dump(FS_SLCCMPT_PHYS_DEV_STRUCT, "slccmpt", "/slccmpt.bin", offset_y))
|
if (slc_dump(FS_SLCCMPT_PHYS_DEV_STRUCT, "slccmpt", "/slccmpt.bin", offset_y))
|
||||||
goto error;
|
goto error;
|
||||||
offset_y += 10;
|
offset_y += 10;
|
||||||
}
|
}
|
||||||
if (dumper_config.dump_mlc) {
|
if (dumper_config.dump_mlc) {
|
||||||
if (mlc_dump(mlc_sector_count, offset_y))
|
if (mlc_dump(mlc_sector_count, offset_y))
|
||||||
goto error;
|
goto error;
|
||||||
offset_y += 10;
|
offset_y += 10;
|
||||||
}
|
}
|
||||||
offset_y += 20;
|
offset_y += 20;
|
||||||
|
|
||||||
_printf(20, offset_y, "Complete! -> rebooting into sysNAND...");
|
_printf(20, offset_y, "Complete! -> rebooting into sysNAND...");
|
||||||
|
|
||||||
@ -325,7 +325,7 @@ void dump_nand_complete()
|
|||||||
svcShutdown(SHUTDOWN_TYPE_REBOOT);
|
svcShutdown(SHUTDOWN_TYPE_REBOOT);
|
||||||
|
|
||||||
error:
|
error:
|
||||||
offset_y += 20;
|
offset_y += 20;
|
||||||
_printf(20, offset_y, "Error! -> rebooting into sysNAND...");
|
_printf(20, offset_y, "Error! -> rebooting into sysNAND...");
|
||||||
|
|
||||||
FS_SLEEP(3000);
|
FS_SLEEP(3000);
|
||||||
|
@ -630,12 +630,12 @@ static uint32 _read_sectors(FL_FILE* file, uint32 offset, uint8 *buffer, uint32
|
|||||||
void fl_init(void)
|
void fl_init(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
memset(_files, 0, sizeof(_files));
|
memset(_files, 0, sizeof(_files));
|
||||||
memset(&_filelib_init, 0, sizeof(_filelib_init));
|
memset(&_filelib_init, 0, sizeof(_filelib_init));
|
||||||
memset(&_filelib_valid, 0, sizeof(_filelib_valid));
|
memset(&_filelib_valid, 0, sizeof(_filelib_valid));
|
||||||
memset(&_fs, 0, sizeof(_fs));
|
memset(&_fs, 0, sizeof(_fs));
|
||||||
memset(&_open_file_list, 0, sizeof(_open_file_list));
|
memset(&_open_file_list, 0, sizeof(_open_file_list));
|
||||||
memset(&_free_file_list, 0, sizeof(_free_file_list));
|
memset(&_free_file_list, 0, sizeof(_free_file_list));
|
||||||
|
|
||||||
fat_list_init(&_free_file_list);
|
fat_list_init(&_free_file_list);
|
||||||
fat_list_init(&_open_file_list);
|
fat_list_init(&_open_file_list);
|
||||||
|
@ -337,7 +337,7 @@ int fatfs_find_blank_cluster(struct fatfs *fs, uint32 start_cluster, uint32 *fre
|
|||||||
while (nextcluster != 0x0);
|
while (nextcluster != 0x0);
|
||||||
|
|
||||||
// Found blank entry
|
// Found blank entry
|
||||||
fs->last_free_cluster = current_cluster + 1;
|
fs->last_free_cluster = current_cluster + 1;
|
||||||
*free_cluster = current_cluster;
|
*free_cluster = current_cluster;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -25,10 +25,10 @@ void createDevThread_entry(int initialization_type)
|
|||||||
{
|
{
|
||||||
//if(check_nand_dump() == 0)
|
//if(check_nand_dump() == 0)
|
||||||
//{
|
//{
|
||||||
clearScreen(0x000000FF);
|
clearScreen(0x000000FF);
|
||||||
_printf(20, 20, "welcome to NAND dumper!");
|
_printf(20, 20, "welcome to NAND dumper!");
|
||||||
|
|
||||||
dump_nand_complete();
|
dump_nand_complete();
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,86 +9,86 @@
|
|||||||
unsigned char sd_io_buffer[0x40000] __attribute__((aligned(0x40))) __attribute__((section(".io_buffer")));
|
unsigned char sd_io_buffer[0x40000] __attribute__((aligned(0x40))) __attribute__((section(".io_buffer")));
|
||||||
unsigned int fat_sector = 0;
|
unsigned int fat_sector = 0;
|
||||||
|
|
||||||
#define PARTITION_TYPE_FAT32 0x0c
|
#define PARTITION_TYPE_FAT32 0x0c
|
||||||
#define PARTITION_TYPE_FAT32_CHS 0x0b
|
#define PARTITION_TYPE_FAT32_CHS 0x0b
|
||||||
|
|
||||||
#define MBR_SIGNATURE 0x55AA
|
#define MBR_SIGNATURE 0x55AA
|
||||||
#define EBR_SIGNATURE MBR_SIGNATURE
|
#define EBR_SIGNATURE MBR_SIGNATURE
|
||||||
|
|
||||||
#define PARTITION_BOOTABLE 0x80 /* Bootable (active) */
|
#define PARTITION_BOOTABLE 0x80 /* Bootable (active) */
|
||||||
#define PARTITION_NONBOOTABLE 0x00 /* Non-bootable */
|
#define PARTITION_NONBOOTABLE 0x00 /* Non-bootable */
|
||||||
#define PARTITION_TYPE_GPT 0xEE /* Indicates that a GPT header is available */
|
#define PARTITION_TYPE_GPT 0xEE /* Indicates that a GPT header is available */
|
||||||
|
|
||||||
typedef struct _PARTITION_RECORD {
|
typedef struct _PARTITION_RECORD {
|
||||||
u8 status; /* Partition status; see above */
|
u8 status; /* Partition status; see above */
|
||||||
u8 chs_start[3]; /* Cylinder-head-sector address to first block of partition */
|
u8 chs_start[3]; /* Cylinder-head-sector address to first block of partition */
|
||||||
u8 type; /* Partition type; see above */
|
u8 type; /* Partition type; see above */
|
||||||
u8 chs_end[3]; /* Cylinder-head-sector address to last block of partition */
|
u8 chs_end[3]; /* Cylinder-head-sector address to last block of partition */
|
||||||
u32 lba_start; /* Local block address to first sector of partition */
|
u32 lba_start; /* Local block address to first sector of partition */
|
||||||
u32 block_count; /* Number of blocks in partition */
|
u32 block_count; /* Number of blocks in partition */
|
||||||
} __attribute__((__packed__)) PARTITION_RECORD;
|
} __attribute__((__packed__)) PARTITION_RECORD;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _MASTER_BOOT_RECORD {
|
typedef struct _MASTER_BOOT_RECORD {
|
||||||
u8 code_area[446]; /* Code area; normally empty */
|
u8 code_area[446]; /* Code area; normally empty */
|
||||||
PARTITION_RECORD partitions[4]; /* 4 primary partitions */
|
PARTITION_RECORD partitions[4]; /* 4 primary partitions */
|
||||||
u16 signature; /* MBR signature; 0xAA55 */
|
u16 signature; /* MBR signature; 0xAA55 */
|
||||||
} __attribute__((__packed__)) MASTER_BOOT_RECORD;
|
} __attribute__((__packed__)) MASTER_BOOT_RECORD;
|
||||||
|
|
||||||
int sd_fat_read(unsigned long sector, unsigned char *buffer, unsigned long sector_count)
|
int sd_fat_read(unsigned long sector, unsigned char *buffer, unsigned long sector_count)
|
||||||
{
|
{
|
||||||
// It seems that sdcard_readwrite overwrite more bytes than requested with 0xff.... So I use io_buffer to read it.
|
// It seems that sdcard_readwrite overwrite more bytes than requested with 0xff.... So I use io_buffer to read it.
|
||||||
if (sector_count * SDIO_BYTES_PER_SECTOR > sizeof(sd_io_buffer)) return 0;
|
if (sector_count * SDIO_BYTES_PER_SECTOR > sizeof(sd_io_buffer)) return 0;
|
||||||
int result = sdcard_readwrite(SDIO_READ, sd_io_buffer, sector_count, SDIO_BYTES_PER_SECTOR, fat_sector + sector, NULL, DEVICE_ID_SDCARD_PATCHED);
|
int result = sdcard_readwrite(SDIO_READ, sd_io_buffer, sector_count, SDIO_BYTES_PER_SECTOR, fat_sector + sector, NULL, DEVICE_ID_SDCARD_PATCHED);
|
||||||
if (result) return 0;
|
if (result) return 0;
|
||||||
memcpy(buffer, sd_io_buffer, sector_count * SDIO_BYTES_PER_SECTOR);
|
memcpy(buffer, sd_io_buffer, sector_count * SDIO_BYTES_PER_SECTOR);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sd_fat_write(unsigned long sector, unsigned char *buffer, unsigned long sector_count)
|
int sd_fat_write(unsigned long sector, unsigned char *buffer, unsigned long sector_count)
|
||||||
{
|
{
|
||||||
if (sector_count * SDIO_BYTES_PER_SECTOR > sizeof(sd_io_buffer)) return 0;
|
if (sector_count * SDIO_BYTES_PER_SECTOR > sizeof(sd_io_buffer)) return 0;
|
||||||
int result = sdcard_readwrite(SDIO_WRITE, buffer, sector_count, SDIO_BYTES_PER_SECTOR, fat_sector + sector, NULL, DEVICE_ID_SDCARD_PATCHED);
|
int result = sdcard_readwrite(SDIO_WRITE, buffer, sector_count, SDIO_BYTES_PER_SECTOR, fat_sector + sector, NULL, DEVICE_ID_SDCARD_PATCHED);
|
||||||
return result ? 0 : 1;
|
return result ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int InitSDCardFAT32()
|
int InitSDCardFAT32()
|
||||||
{
|
{
|
||||||
MASTER_BOOT_RECORD *mbr = (MASTER_BOOT_RECORD*)sd_io_buffer;
|
MASTER_BOOT_RECORD *mbr = (MASTER_BOOT_RECORD*)sd_io_buffer;
|
||||||
memset(mbr, 0, SDIO_BYTES_PER_SECTOR);
|
memset(mbr, 0, SDIO_BYTES_PER_SECTOR);
|
||||||
|
|
||||||
int result = sdcard_readwrite(SDIO_READ, mbr, 1, SDIO_BYTES_PER_SECTOR, 0, NULL, DEVICE_ID_SDCARD_PATCHED);
|
int result = sdcard_readwrite(SDIO_READ, mbr, 1, SDIO_BYTES_PER_SECTOR, 0, NULL, DEVICE_ID_SDCARD_PATCHED);
|
||||||
if(result != 0)
|
if(result != 0)
|
||||||
{
|
{
|
||||||
_printf(20, 40, "SD card read failed %i", result);
|
_printf(20, 40, "SD card read failed %i", result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mbr->signature != MBR_SIGNATURE) {
|
if (mbr->signature != MBR_SIGNATURE) {
|
||||||
_printf(20, 40, "SD not MBR");
|
_printf(20, 40, "SD not MBR");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mbr->partitions[0].status != PARTITION_BOOTABLE && mbr->partitions[0].status != PARTITION_NONBOOTABLE) {
|
if (mbr->partitions[0].status != PARTITION_BOOTABLE && mbr->partitions[0].status != PARTITION_NONBOOTABLE) {
|
||||||
_printf(20, 40, "Invalid paritition status");
|
_printf(20, 40, "Invalid paritition status");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mbr->partitions[0].type != PARTITION_TYPE_FAT32 && mbr->partitions[0].type != PARTITION_TYPE_FAT32_CHS) {
|
if (mbr->partitions[0].type != PARTITION_TYPE_FAT32 && mbr->partitions[0].type != PARTITION_TYPE_FAT32_CHS) {
|
||||||
_printf(20, 40, "First paritition not FAT32");
|
_printf(20, 40, "First paritition not FAT32");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fat_sector = le32(mbr->partitions[0].lba_start);
|
fat_sector = le32(mbr->partitions[0].lba_start);
|
||||||
|
|
||||||
fl_init();
|
fl_init();
|
||||||
|
|
||||||
result = fl_attach_media(sd_fat_read, sd_fat_write);
|
result = fl_attach_media(sd_fat_read, sd_fat_write);
|
||||||
if (result != FAT_INIT_OK)
|
if (result != FAT_INIT_OK)
|
||||||
{
|
{
|
||||||
_printf(20, 40, "FAT32 attach failed %i", result);
|
_printf(20, 40, "FAT32 attach failed %i", result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ u32 fs_get_phys_code_base(void)
|
|||||||
|
|
||||||
void fs_run_patches(u32 ios_elf_start)
|
void fs_run_patches(u32 ios_elf_start)
|
||||||
{
|
{
|
||||||
fs_config config;
|
fs_config config;
|
||||||
|
|
||||||
// write wupserver code and bss
|
// write wupserver code and bss
|
||||||
section_write(ios_elf_start, _text_start, (void*)fs_get_phys_code_base(), _text_end - _text_start);
|
section_write(ios_elf_start, _text_start, (void*)fs_get_phys_code_base(), _text_end - _text_start);
|
||||||
@ -85,15 +85,15 @@ void fs_run_patches(u32 ios_elf_start)
|
|||||||
|
|
||||||
section_write_word(ios_elf_start, FS_SLC_ECC_CHECK, ARM_B(FS_SLC_ECC_CHECK, eccCheck_patch));
|
section_write_word(ios_elf_start, FS_SLC_ECC_CHECK, ARM_B(FS_SLC_ECC_CHECK, eccCheck_patch));
|
||||||
|
|
||||||
config.dump_slc = cfw_config.dumpSlc;
|
config.dump_slc = cfw_config.dumpSlc;
|
||||||
config.dump_slccmpt = cfw_config.dumpSlccmpt;
|
config.dump_slccmpt = cfw_config.dumpSlccmpt;
|
||||||
config.dump_mlc = cfw_config.dumpMlc;
|
config.dump_mlc = cfw_config.dumpMlc;
|
||||||
config.dump_otp = cfw_config.dumpOtp;
|
config.dump_otp = cfw_config.dumpOtp;
|
||||||
config.dump_seeprom = cfw_config.dumpSeeprom;
|
config.dump_seeprom = cfw_config.dumpSeeprom;
|
||||||
if (cfw_config.dumpOtp)
|
if (cfw_config.dumpOtp)
|
||||||
kernel_memcpy(config.otp_buffer, otp_buffer, sizeof(config.otp_buffer));
|
kernel_memcpy(config.otp_buffer, otp_buffer, sizeof(config.otp_buffer));
|
||||||
if (cfw_config.dumpSeeprom)
|
if (cfw_config.dumpSeeprom)
|
||||||
kernel_memcpy(config.seeprom_buffer, seeprom_buffer, sizeof(config.seeprom_buffer));
|
kernel_memcpy(config.seeprom_buffer, seeprom_buffer, sizeof(config.seeprom_buffer));
|
||||||
section_write(ios_elf_start, dumper_config, &config, sizeof(config));
|
section_write(ios_elf_start, dumper_config, &config, sizeof(config));
|
||||||
|
|
||||||
//section_write_word(ios_elf_start, FS_USB_READ, ARM_B(FS_USB_READ, usbRead_patch));
|
//section_write_word(ios_elf_start, FS_USB_READ, ARM_B(FS_USB_READ, usbRead_patch));
|
||||||
|
@ -326,9 +326,9 @@ static void uhs_exploit_init(int dev_uhs_0_handle, cfw_config_t * config)
|
|||||||
|
|
||||||
//if(config->redNAND)
|
//if(config->redNAND)
|
||||||
//{
|
//{
|
||||||
payloads->size = sizeof(ios_fs_bin);
|
payloads->size = sizeof(ios_fs_bin);
|
||||||
memcpy(payloads->data, ios_fs_bin, payloads->size);
|
memcpy(payloads->data, ios_fs_bin, payloads->size);
|
||||||
payloads = (payload_info_t*)( ((char*)payloads) + ALIGN4(sizeof(payload_info_t) + payloads->size) );
|
payloads = (payload_info_t*)( ((char*)payloads) + ALIGN4(sizeof(payload_info_t) + payloads->size) );
|
||||||
|
|
||||||
// if(config->seeprom_red)
|
// if(config->seeprom_red)
|
||||||
// {
|
// {
|
||||||
|
12
src/main.c
12
src/main.c
@ -25,9 +25,9 @@ static int exitToHBLOnLaunch = 0;
|
|||||||
|
|
||||||
int Menu_Main(void)
|
int Menu_Main(void)
|
||||||
{
|
{
|
||||||
//!---------INIT---------
|
//!---------INIT---------
|
||||||
InitOSFunctionPointers();
|
InitOSFunctionPointers();
|
||||||
InitSysFunctionPointers();
|
InitSysFunctionPointers();
|
||||||
InitFSFunctionPointers();
|
InitFSFunctionPointers();
|
||||||
InitSocketFunctionPointers();
|
InitSocketFunctionPointers();
|
||||||
InitVPadFunctionPointers();
|
InitVPadFunctionPointers();
|
||||||
@ -83,9 +83,9 @@ int Menu_Main(void)
|
|||||||
{
|
{
|
||||||
//if(config.noIosReload == 0)
|
//if(config.noIosReload == 0)
|
||||||
//{
|
//{
|
||||||
OSForceFullRelaunch();
|
OSForceFullRelaunch();
|
||||||
SYSLaunchMenu();
|
SYSLaunchMenu();
|
||||||
returnCode = EXIT_RELAUNCH_ON_LOAD;
|
returnCode = EXIT_RELAUNCH_ON_LOAD;
|
||||||
//}
|
//}
|
||||||
//else if(config.launchSysMenu)
|
//else if(config.launchSysMenu)
|
||||||
//{
|
//{
|
||||||
|
Loading…
Reference in New Issue
Block a user