Skip to content

Commit

Permalink
Wipe the EmuNAND NCSD magic upon format
Browse files Browse the repository at this point in the history
  • Loading branch information
d0k3 committed Sep 6, 2016
1 parent ea8bd48 commit 19724f4
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions source/emunand9.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ u32 FormatSdCard(u32 param)
{
MbrInfo* mbr_info = (MbrInfo*) 0x20316000;
MbrPartitionInfo* part_info = mbr_info->partitions;
u8* zeroes = (u8*) 0x20316200;
u8* buffer = (u8*) 0x21000000;

bool setup_emunand = (param & SD_SETUP_EMUNAND);
Expand Down Expand Up @@ -640,6 +641,14 @@ u32 FormatSdCard(u32 param)
Debug("SD card i/o failure");
return 1;
}
Debug("Wiping earlier NCSD EmuNAND magic...");
memset(zeroes, 0x00, 0x200);
if ((!setup_emunand && (sdmmc_sdcard_writesectors(1, 1, zeroes) != 0)) ||
((sd_size_sectors > getMMCDevice(0)->total_size) && (fat_offset_sectors <= getMMCDevice(0)->total_size) &&
(sdmmc_sdcard_writesectors(getMMCDevice(0)->total_size, 1, zeroes) != 0))) {
Debug("SD card i/o failure");
return 1;
}
InitFS();
Debug("Formatting FAT partition...");
if (!PartitionFormat("EMUNAND9SD")) {
Expand Down

0 comments on commit 19724f4

Please sign in to comment.