diff --git a/Makefile.arm11 b/Makefile.arm11 index ff12027..e5806b9 100644 --- a/Makefile.arm11 +++ b/Makefile.arm11 @@ -31,17 +31,18 @@ ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=soft -CFLAGS := -Wall -Wextra -Wcast-align -Wcast-qual -Wdisabled-optimization \ +DBGWARM := -Wextra -Wcast-align -Wcast-qual -Wdisabled-optimization \ -Wformat=2 -Wlogical-op -Wmissing-include-dirs -Wredundant-decls \ -Wshadow -Wsign-conversion -fstrict-overflow -Wstrict-overflow=5 \ - -Wswitch-default -Wundef -fstrict-aliasing -Wstrict-aliasing \ - -std=c11 -O2 -flto -mword-relocations -fomit-frame-pointer \ - -ffast-math -ffunction-sections $(ARCH) + -Wswitch-default -Wundef + +CFLAGS := -Wall $(DBGWARM) -fstrict-aliasing -Wstrict-aliasing -std=c11 -O2 -flto \ + -mword-relocations -fomit-frame-pointer -ffast-math -ffunction-sections $(ARCH) CFLAGS += $(INCLUDE) -DARM11 -D_3DS $(DEFINES) CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=c++11 -ASFLAGS := $(INCLUDE) $(ARCH) $(DEFINES) +ASFLAGS := -g $(INCLUDE) $(ARCH) -DARM11 -D_3DS $(DEFINES) LDFLAGS = -nostartfiles -T../$(LDNAME) $(CFLAGS) -Wl,-Map,$(notdir $*.map),--use-blx,--gc-sections #--------------------------------------------------------------------------------- diff --git a/Makefile.arm9 b/Makefile.arm9 index f3a5de6..96f31a2 100644 --- a/Makefile.arm9 +++ b/Makefile.arm9 @@ -31,17 +31,18 @@ ARCH := -march=armv5te -mtune=arm946e-s -mfloat-abi=soft -CFLAGS := -Wall -Wextra -Wcast-align -Wcast-qual -Wdisabled-optimization \ +DBGWARM := -Wextra -Wcast-align -Wcast-qual -Wdisabled-optimization \ -Wformat=2 -Wlogical-op -Wmissing-include-dirs -Wredundant-decls \ -Wshadow -Wsign-conversion -fstrict-overflow -Wstrict-overflow=5 \ - -Wswitch-default -Wundef -fstrict-aliasing -Wstrict-aliasing \ - -std=c11 -Og -mword-relocations -fomit-frame-pointer \ - -ffast-math -ffunction-sections $(ARCH) + -Wswitch-default -Wundef + +CFLAGS := -Wall $(DBGWARM) -fstrict-aliasing -Wstrict-aliasing -std=c11 -Og \ + -mword-relocations -fomit-frame-pointer -ffast-math -ffunction-sections $(ARCH) CFLAGS += $(INCLUDE) -DARM9 $(DEFINES) CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=c++11 -ASFLAGS := -g $(INCLUDE) $(ARCH) $(DEFINES) +ASFLAGS := -g $(INCLUDE) $(ARCH) -DARM9 $(DEFINES) LDFLAGS = -nostartfiles -T../$(LDNAME) $(CFLAGS) -Wl,-Map,$(notdir $*.map),--use-blx,--gc-sections #--------------------------------------------------------------------------------- diff --git a/include/arm9/console.h b/include/arm9/console.h index 100303b..ce216c6 100644 --- a/include/arm9/console.h +++ b/include/arm9/console.h @@ -14,7 +14,6 @@ */ -#include #include "types.h" #define SCREEN_TOP 1 diff --git a/include/arm9/crypto.h b/include/arm9/crypto.h index d312c3e..e708498 100644 --- a/include/arm9/crypto.h +++ b/include/arm9/crypto.h @@ -39,34 +39,34 @@ #define AES_WRITE_FIFO_COUNT ((REG_AESCNT>>0) & 0x1F) #define AES_READ_FIFO_COUNT ((REG_AESCNT>>5) & 0x1F) -#define AES_BUSY ((u32)1<<31) +#define AES_BUSY (1u<<31) -#define AES_FLUSH_READ_FIFO (1<<10) -#define AES_FLUSH_WRITE_FIFO (1<<11) -#define AES_BIT12 (1<<12) -#define AES_BIT13 (1<<13) -#define AES_MAC_SIZE(n) ((n & 7)<<16) -#define AES_MAC_REGISTER_SOURCE (1<<20) -#define AES_MAC_STATUS (1<<21) // AES_UNKNOWN_21 -#define AES_OUTPUT_BIG (1<<22) -#define AES_OUTPUT_LITTLE (0) -#define AES_INPUT_BIG (1<<23) -#define AES_INPUT_LITTLE (0) -#define AES_OUTPUT_NORMAL_ORDER (1<<24) -#define AES_OUTPUT_REVERSED_ORDER (0) -#define AES_INPUT_NORMAL_ORDER (1<<25) -#define AES_INPUT_REVERSED_ORDER (0) -#define AES_UPDATE_KEYSLOT (1<<26) // AES_UNKNOWN_26 -#define AES_INTERRUPT_ENABLE (1<<30) -#define AES_ENABLE ((u32)1<<31) +#define AES_FLUSH_READ_FIFO (1u<<10) +#define AES_FLUSH_WRITE_FIFO (1u<<11) +#define AES_BIT12 (1u<<12) +#define AES_BIT13 (1u<<13) +#define AES_MAC_SIZE(n) ((n & 7u)<<16) +#define AES_MAC_REGISTER_SOURCE (1u<<20) +#define AES_MAC_STATUS (1u<<21) // AES_UNKNOWN_21 +#define AES_OUTPUT_BIG (1u<<22) +#define AES_OUTPUT_LITTLE (0u) +#define AES_INPUT_BIG (1u<<23) +#define AES_INPUT_LITTLE (0u) +#define AES_OUTPUT_NORMAL_ORDER (1u<<24) +#define AES_OUTPUT_REVERSED_ORDER (0u) +#define AES_INPUT_NORMAL_ORDER (1u<<25) +#define AES_INPUT_REVERSED_ORDER (0u) +#define AES_UPDATE_KEYSLOT (1u<<26) // AES_UNKNOWN_26 +#define AES_INTERRUPT_ENABLE (1u<<30) +#define AES_ENABLE (1u<<31) -#define AES_MODE_CCM_DECRYPT (0) -#define AES_MODE_CCM_ENCRYPT (1<<27) -#define AES_MODE_CTR (2<<27) -#define AES_MODE_CBC_DECRYPT (4<<27) -#define AES_MODE_CBC_ENCRYPT (5<<27) -#define AES_MODE_ECB_DECRYPT (6<<27) -#define AES_MODE_ECB_ENCRYPT (7<<27) +#define AES_MODE_CCM_DECRYPT (0u) +#define AES_MODE_CCM_ENCRYPT (1u<<27) +#define AES_MODE_CTR (2u<<27) +#define AES_MODE_CBC_DECRYPT (4u<<27) +#define AES_MODE_CBC_ENCRYPT (5u<<27) +#define AES_MODE_ECB_DECRYPT (6u<<27) +#define AES_MODE_ECB_ENCRYPT (7u<<27) typedef enum @@ -169,16 +169,16 @@ #define REG_SHA_HASH ( ((u32*) 0x1000A040)) #define REG_SHA_INFIFO ( 0x1000A080) -#define SHA_ENABLE (1) // Also used as busy flag -#define SHA_PAD_INPUT (1<<1) -#define SHA_INPUT_BIG (1<<3) -#define SHA_INPUT_LITTLE (0) +#define SHA_ENABLE (1u) // Also used as busy flag +#define SHA_PAD_INPUT (1u<<1) +#define SHA_INPUT_BIG (1u<<3) +#define SHA_INPUT_LITTLE (0u) #define SHA_OUTPUT_BIG SHA_INPUT_BIG #define SHA_OUTPUT_LITTLE SHA_INPUT_LITTLE -#define SHA_MODE_256 (0) -#define SHA_MODE_224 (1<<4) -#define SHA_MODE_1 (1<<5) +#define SHA_MODE_256 (0u) +#define SHA_MODE_224 (1u<<4) +#define SHA_MODE_1 (1u<<5) /** diff --git a/include/arm9/dev.h b/include/arm9/dev.h index eede02a..86a866b 100644 --- a/include/arm9/dev.h +++ b/include/arm9/dev.h @@ -1,6 +1,8 @@ - #pragma once +#include "types.h" + + typedef struct { char *name; diff --git a/include/arm9/mpu.h b/include/arm9/mpu.h index aad6237..bfbf27b 100644 --- a/include/arm9/mpu.h +++ b/include/arm9/mpu.h @@ -2,5 +2,4 @@ -void setupMpu(void); void disableMpu(void); diff --git a/include/arm9/ndma.h b/include/arm9/ndma.h index d89985f..948ff60 100644 --- a/include/arm9/ndma.h +++ b/include/arm9/ndma.h @@ -78,26 +78,26 @@ // This bit has no effect it seems. -#define NDMA_GLOBAL_ENABLE (1) +#define NDMA_GLOBAL_ENABLE (1u) -#define NDMA_BLOCK_SYS_FREQ (0) +#define NDMA_BLOCK_SYS_FREQ (0u) -#define NDMA_DST_UPDATE_INC (0) -#define NDMA_DST_UPDATE_DEC (1<<10) -#define NDMA_DST_UPDATE_FIXED (2<<10) -#define NDMA_DST_ADDR_RELOAD (1<<12) -#define NDMA_SRC_UPDATE_INC (0) -#define NDMA_SRC_UPDATE_DEC (1<<13) -#define NDMA_SRC_UPDATE_FIXED (2<<13) -#define NDMA_SRC_UPDATE_FILL (3<<13) -#define NDMA_SRC_ADDR_RELOAD (1<<15) +#define NDMA_DST_UPDATE_INC (0u) +#define NDMA_DST_UPDATE_DEC (1u<<10) +#define NDMA_DST_UPDATE_FIXED (2u<<10) +#define NDMA_DST_ADDR_RELOAD (1u<<12) +#define NDMA_SRC_UPDATE_INC (0u) +#define NDMA_SRC_UPDATE_DEC (1u<<13) +#define NDMA_SRC_UPDATE_FIXED (2u<<13) +#define NDMA_SRC_UPDATE_FILL (3u<<13) +#define NDMA_SRC_ADDR_RELOAD (1u<<15) // The block length is 2^n words (Example: 2^15 = 32768 words = 0x20000 bytes) #define NDMA_BLK_TRANS_WORD_COUNT(n) (n<<16) -#define NDMA_IMMEDIATE_MODE (1<<28) -#define NDMA_REPEATING_MODE (1<<29) -#define NDMA_INTERRUPT_ENABLE (1<<30) -#define NDMA_ENABLE ((u32)1<<31) +#define NDMA_IMMEDIATE_MODE (1u<<28) +#define NDMA_REPEATING_MODE (1u<<29) +#define NDMA_INTERRUPT_ENABLE (1u<<30) +#define NDMA_ENABLE (1u<<31) @@ -108,7 +108,7 @@ * @param source Pointer to source data. Must be 4 bytes aligned. * @param[in] num The size of the data. Must be a multiple of 4. */ -void NDMA_copy(void *dest, const void *source, u32 num); +void NDMA_copy(u32 *dest, const u32 *source, u32 num); /** * @brief Fills memory with the given value using the NDMA engine. @@ -117,4 +117,4 @@ * @param[in] value The value each 32-bit word will be set to. * @param[in] num The size of the memory to fill. Must be a multiple of 4. */ -void NDMA_fill(void *dest, u32 value, u32 num); +void NDMA_fill(u32 *dest, u32 value, u32 num); diff --git a/include/arm9/sdmmc.h b/include/arm9/sdmmc.h index cb2bf72..d29536e 100644 --- a/include/arm9/sdmmc.h +++ b/include/arm9/sdmmc.h @@ -2,7 +2,7 @@ #define __SDMMC_H__ #include -#include +#include "types.h" #define SDMMC_BASE 0x10006000 diff --git a/include/types.h b/include/types.h index 37358bb..2880c12 100644 --- a/include/types.h +++ b/include/types.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include diff --git a/source/arm9/console.c b/source/arm9/console.c index a5e7402..86804ee 100644 --- a/source/arm9/console.c +++ b/source/arm9/console.c @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include @@ -222,7 +221,7 @@ char chr; int i, count = 0; - char *tmp = (char*)ptr; + const char *tmp = ptr; if(!tmp || len<=0) return -1; diff --git a/source/arm9/crypto.c b/source/arm9/crypto.c index 85d8e00..1dc5bce 100644 --- a/source/arm9/crypto.c +++ b/source/arm9/crypto.c @@ -3,7 +3,6 @@ */ -#include #include #include "types.h" #include "crypto.h" diff --git a/source/arm9/debug.c b/source/arm9/debug.c index 1900211..c94d7a4 100644 --- a/source/arm9/debug.c +++ b/source/arm9/debug.c @@ -4,13 +4,41 @@ #include "mem_map.h" #include "console.h" -static bool exceptionTriggered = false; + static u32 debugHash = 0; -void NORETURN guruMeditation(u8 type, unsigned int *excStack, unsigned int *stackPointer) + +void hashCodeRoData() +{ + extern u32 *__text_start; + extern u32 *__exidx_start; + + u32 *start = __text_start; + u32 *end = __exidx_start; + + debugHash = 0; + + for(u32 *ptr = start; ptr < end; ptr++) + debugHash += *ptr; +} + +void NORETURN panic() +{ + consoleInit(0, NULL); + + printf("\x1b[41m\x1b[0J\x1b[9CGPANIC!!!\n"); + + unmount_fs(); + devs_close(); + + while(1); +} + +void NORETURN guruMeditation(u8 type, u32 *excStack, u32 *stackPointer) { const char *typeStr[3] = {"Undefined instruction", "Prefetch abort", "Data abort"}; + static bool exceptionTriggered = false; u32 realPc, instSize = 4; bool codeChanged = false; @@ -31,31 +59,33 @@ if(type == 2) realPc = excStack[15] - (instSize * 2); // Data abort else realPc = excStack[15] - instSize; // Other - printf("\x1b[41m\x1b[0J\x1b[9CGuru Meditation Error!\n\n%s:\nCPSR: 0x%X\n", typeStr[type], excStack[1]); - printf("r0 = 0x%08X r8 = 0x%08X\n" - "r1 = 0x%08X r9 = 0x%08X\n" - "r2 = 0x%08X r10 = 0x%08X\n" - "r3 = 0x%08X r11 = 0x%08X\n" - "r4 = 0x%08X r12 = 0x%08X\n" - "r5 = 0x%08X sp = 0x%08X\n" - "r6 = 0x%08X lr = 0x%08X\n" - "r7 = 0x%08X pc = 0x%08X\n\n", + printf("\x1b[41m\x1b[0J\x1b[9CGuru Meditation Error!\n\n%s:\n", typeStr[type]); + printf("CPSR: 0x%08"PRIX32"\n" + "r0 = 0x%08"PRIX32" r8 = 0x%08"PRIX32"\n" + "r1 = 0x%08"PRIX32" r9 = 0x%08"PRIX32"\n" + "r2 = 0x%08"PRIX32" r10 = 0x%08"PRIX32"\n" + "r3 = 0x%08"PRIX32" r11 = 0x%08"PRIX32"\n" + "r4 = 0x%08"PRIX32" r12 = 0x%08"PRIX32"\n" + "r5 = 0x%08"PRIX32" sp = 0x%08"PRIX32"\n" + "r6 = 0x%08"PRIX32" lr = 0x%08"PRIX32"\n" + "r7 = 0x%08"PRIX32" pc = 0x%08"PRIX32"\n\n", + excStack[1], excStack[2], excStack[10], excStack[3], excStack[11], excStack[4], excStack[12], excStack[5], excStack[13], excStack[6], excStack[14], - excStack[7], (unsigned int)stackPointer, + excStack[7], (u32)stackPointer, excStack[8], excStack[0], excStack[9], realPc); // make sure we can actually dump the stack without triggering another fault. - if((stackPointer >= (unsigned int*)A9_RAM_BASE) && (stackPointer < (unsigned int*)(A9_RAM_BASE + A9_RAM_SIZE))) + if((stackPointer >= (u32*)A9_RAM_BASE) && (stackPointer < (u32*)(A9_RAM_BASE + A9_RAM_SIZE))) { puts("Stack dump:"); for(u32 i = 0; i < 15; i++) { - printf("0x%08X: %08X %08X\n", (unsigned int)stackPointer, stackPointer[0], stackPointer[1]); + printf("0x%08"PRIX32": %08"PRIX32" %08"PRIX32"\n", (u32)stackPointer, stackPointer[0], stackPointer[1]); stackPointer += 2; } } @@ -68,29 +98,3 @@ while(1); } - -void NORETURN panic() -{ - consoleInit(0, NULL); - - printf("\x1b[41m\x1b[0J\x1b[9CGPANIC!!!\n"); - - unmount_fs(); - devs_close(); - - while(1); -} - -void hashCodeRoData() -{ - extern u32 *__text_start; - extern u32 *__exidx_start; - - u32 *start = __text_start; - u32 *end = __exidx_start; - - debugHash = 0; - - for(u32 *ptr = start; ptr < end; ptr++) - debugHash += *ptr; -} diff --git a/source/arm9/firm.c b/source/arm9/firm.c index 34605db..8a33384 100644 --- a/source/arm9/firm.c +++ b/source/arm9/firm.c @@ -1,6 +1,5 @@ #include #include -#include #include #include "types.h" #include "arm9/firm.h" @@ -55,8 +54,8 @@ bool retval = true; u32 hash[8]; - printf("ARM9 entry: 0x%X\n", (unsigned int)firm_hdr->entrypointarm9); - printf("ARM11 entry: 0x%X\n", (unsigned int)firm_hdr->entrypointarm11); + printf("ARM9 entry: 0x%"PRIX32"\n", firm_hdr->entrypointarm9); + printf("ARM11 entry: 0x%"PRIX32"\n", firm_hdr->entrypointarm11); for(int i=0; i<4; i++) { @@ -65,8 +64,8 @@ if(section->size == 0) continue; - printf("Section %i:\noffset: 0x%X, addr: 0x%X, size 0x%X\n", i, - (unsigned int)section->offset, (unsigned int)section->address, (unsigned int)section->size); + printf("Section %i:\noffset: 0x%"PRIX32", addr: 0x%"PRIX32", size 0x%"PRIX32"\n", + i, section->offset, section->address, section->size); sha((u32*)(FIRM_LOAD_ADDR + section->offset), section->size, hash, SHA_INPUT_BIG | SHA_MODE_256, SHA_OUTPUT_BIG); isValid = memcmp(hash, section->hash, 32) == 0; @@ -86,7 +85,7 @@ while(*((vu32*)CORE_SYNC_ID) != 0x4F4B4F4B); //printf("Relocating FIRM launch stub...\n"); - NDMA_copy((void*)A9_STUB_ENTRY, (void*)firmLaunchStub, 0x200>>2); + NDMA_copy((u32*)A9_STUB_ENTRY, (u32*)firmLaunchStub, 0x200>>2); //printf("Starting firm launch...\n"); void (*stub)(void) = (void (*)(void))A9_STUB_ENTRY; diff --git a/source/arm9/main.c b/source/arm9/main.c index e10d6ee..ab0c91e 100644 --- a/source/arm9/main.c +++ b/source/arm9/main.c @@ -110,22 +110,22 @@ printf("Mounting SD card FAT FS... "); res = f_mount(&sd_fs, "sdmc:", 1); if(res == FR_OK) printf("%s\e[0m\n", res_str[1]); - else printf("%s ERROR 0x%X\e[0m\n", res_str[0], res); + else printf("%s ERROR 0x%d\e[0m\n", res_str[0], res); printf("Mounting twln FS... "); res = f_mount(&nand_twlnfs, "twln:", 1); if(res == FR_OK) printf("%s\e[0m\n", res_str[1]); - else printf("%s ERROR 0x%X\e[0m\n", res_str[0], res); + else printf("%s ERROR 0x%d\e[0m\n", res_str[0], res); printf("Mounting twlp FS... "); res = f_mount(&nand_twlpfs, "twlp:", 1); if(res == FR_OK) printf("%s\e[0m\n", res_str[1]); - else printf("%s ERROR 0x%X\e[0m\n", res_str[0], res); + else printf("%s ERROR 0x%d\e[0m\n", res_str[0], res); printf("Mounting CTR NAND FAT FS... "); res = f_mount(&nand_fs, "nand:", 1); if(res == FR_OK) printf("%s\e[0m\n", res_str[1]); - else printf("%s ERROR 0x%X\e[0m\n", res_str[0], res); + else printf("%s ERROR 0x%d\e[0m\n", res_str[0], res); sleep_wait(0x8000000); } @@ -193,4 +193,3 @@ return res; } - diff --git a/source/arm9/ndma.c b/source/arm9/ndma.c index 22d5d3b..405d084 100644 --- a/source/arm9/ndma.c +++ b/source/arm9/ndma.c @@ -9,7 +9,7 @@ -void NDMA_copy(void *dest, const void *source, u32 num) +void NDMA_copy(u32 *dest, const u32 *source, u32 num) { flushDCacheRange(source, num<<2); // Make sure possible writes finished before DMAing. flushDCacheRange(dest, num<<2); @@ -25,7 +25,7 @@ invalidateDCacheRange(dest, num<<2); // Make sure no old data is in cache. } -void NDMA_fill(void *dest, u32 value, u32 num) +void NDMA_fill(u32 *dest, u32 value, u32 num) { flushDCacheRange(dest, num<<2); diff --git a/source/arm9/sdmmc.c b/source/arm9/sdmmc.c index 917382b..bbe231c 100644 --- a/source/arm9/sdmmc.c +++ b/source/arm9/sdmmc.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include diff --git a/source/arm9/util.c b/source/arm9/util.c index fe913b2..3cf3cff 100644 --- a/source/arm9/util.c +++ b/source/arm9/util.c @@ -2,9 +2,9 @@ u32 getleu32(const void* ptr) { - u8* p = (u8*)ptr; + const u8* p = (const u8*)ptr; - return (p[0]<<0) | (p[1]<<8) | (p[2]<<16) | (p[3]<<24); + return (u32)((p[0]<<0) | (p[1]<<8) | (p[2]<<16) | (p[3]<<24)); } u32 swap32(u32 num) diff --git a/source/arm9/util_nand.c b/source/arm9/util_nand.c index 3eb7bbe..14c3a7d 100644 --- a/source/arm9/util_nand.c +++ b/source/arm9/util_nand.c @@ -33,13 +33,13 @@ FIL file; FRESULT fres; UINT bytes_written; - + consoleSelect(&con_bottom); - + printf("\n\t\tPress B to cancel"); - + consoleSelect(&con_top); - + u8 *buf = (u8 *) malloc(chunk_size); if(!buf) { @@ -52,10 +52,10 @@ printf("Not enough space on the SD card!\n"); goto fail; } - + if((fres = f_open(&file, filePath, FA_CREATE_ALWAYS | FA_WRITE)) != FR_OK) { - printf("Failed to create '%s'! Error: %x\n", filePath, fres); + printf("Failed to create '%s'! Error: %X\n", filePath, fres); f_close(&file); goto fail; } @@ -67,7 +67,7 @@ if(!dev_rawnand->read(cur_offset, cur_size, buf)) { - printf("\nFailed to read sector 0x%X!\n", (unsigned int)cur_offset>>9); + printf("\nFailed to read sector 0x%"PRIx32"!\n", cur_offset>>9); f_close(&file); goto fail; } @@ -77,25 +77,25 @@ f_close(&file); goto fail; } - + hidScanInput(); - + if(hidKeysDown() & KEY_B) { printf("\n...canceled!\n"); f_close(&file); goto fail; } - + cur_offset += cur_size; - printf("\r%d/%d MB (Sector 0x%X/0x%X)", (unsigned int)cur_offset>>20, (unsigned int)nand_size>>20, - (unsigned int)cur_offset>>9, (unsigned int)nand_size>>9); + printf("\r%"PRId32"/%"PRId32" MB (Sector 0x%"PRIX32"/0x%"PRIX32")", cur_offset>>20, nand_size>>20, + cur_offset>>9, nand_size>>9); } f_close(&file); free(buf); return true; - + fail: free(buf); sleep_wait(0x8000000); @@ -111,13 +111,13 @@ const u32 nand_size = dev_rawnand->get_size(); const u32 chunk_size = 0x80000; u8 *buf; - + consoleSelect(&con_bottom); - + printf("\n\t\tPress B to cancel"); - + consoleSelect(&con_top); - + buf = (u8 *) malloc(chunk_size); if(!buf) { @@ -163,20 +163,20 @@ } if(!dev_rawnand->write(cur_offset, cur_size, buf)) { - printf("\nFailed to write sector 0x%X!\n", (unsigned int)cur_offset>>9); + printf("\nFailed to write sector 0x%"PRIX32"!\n", cur_offset>>9); f_close(&file); goto fail; } cur_offset += cur_size; - printf("\r%d/%d MB (Sector 0x%X/0x%X)", (unsigned int)cur_offset>>20, (unsigned int)nand_size>>20, - (unsigned int)cur_offset>>9, (unsigned int)nand_size>>9); + printf("\r%"PRId32"/%"PRId32" MB (Sector 0x%"PRIX32"/0x%"PRIX32")", cur_offset>>20, nand_size>>20, + cur_offset>>9, nand_size>>9); } f_close(&file); free(buf); return true; - + fail: free(buf); sleep_wait(0x8000000);