Skip to content

Commit

Permalink
Clear text before doing NAND operations
Browse files Browse the repository at this point in the history
ALSO: Do not loop low battery message
  • Loading branch information
RocketRobz committed Dec 3, 2020
1 parent 07bdfbc commit 220609c
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions arm9/source/arm9.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,19 @@ void getConsoleID(u8 *consoleID){
}

int dumpNAND(nocash_footer_t *footer){
consoleClear();

u32 rwTotal=nand_GetSize()*0x200; //240MB or 245.5MB
printf("NAND size: %.2fMB\n", (float)rwTotal/(float)0x100000);

if(rwTotal != 0xF000000 && rwTotal != 0xF580000) death("Unknown NAND size."); //there's no documented nand chip with sizes different from these two.

bool batteryMsgShown=false;
while(getBatteryLevel() < 0x4){
iprintf("Battery low: plug in to proceed\r"); //user can charge to 2 bars or more OR just plug in the charger. charging state adds +0x80 to battery level. low 4 bits are the battery charge level.
wait(60); //don't spam getbatterylevel too much
if(!batteryMsgShown) {
iprintf("Battery low: plug in to proceed\r"); //user can charge to 2 bars or more OR just plug in the charger. charging state adds +0x80 to battery level. low 4 bits are the battery charge level.
batteryMsgShown=true;
}
}

char *filename="nand.bin";
Expand Down Expand Up @@ -146,15 +150,19 @@ int dumpNAND(nocash_footer_t *footer){
}

int restoreNAND(nocash_footer_t *footer){
consoleClear();

u32 rwTotal=nand_GetSize()*0x200; //240MB or 245.5MB
printf("NAND size: %.2fMB\n", (float)rwTotal/(float)0x100000);

if(rwTotal != 0xF000000 && rwTotal != 0xF580000) death("Unknown NAND size."); //there's no documented nand chip with sizes different from these two.

bool batteryMsgShown=false;
while(getBatteryLevel() < 0x4){
iprintf("Battery low: plug in to proceed\r"); //user can charge to 2 bars or more OR just plug in the charger. charging state adds +0x80 to battery level. low 4 bits are the battery charge level.
wait(60); //don't spam getbatterylevel too much
if(!batteryMsgShown) {
iprintf("Battery low: plug in to proceed\r"); //user can charge to 2 bars or more OR just plug in the charger. charging state adds +0x80 to battery level. low 4 bits are the battery charge level.
batteryMsgShown=true;
}
}

int fail=0;
Expand Down

0 comments on commit 220609c

Please sign in to comment.