17 *(
volatile unsigned int*)(0xea00c000UL | addr) = __builtin_bswap32(
data);
22 return __builtin_bswap32(*(
volatile unsigned int*)(0xea00c000UL | addr));
53 printf(
" ! SFCX: Unknown error at address %08X: %08X. Please worry.\n",
address,
status);
62 for (i = 0; i <
page_sz ; i += 4)
113 printf(
" ! SFCX: Unexpected sfcx_write_page status %08X\n",
status);
188 unsigned int i=0,
val=0;
191 for (i = 0; i < 0x1066; i++)
194 v = ~__builtin_bswap32(*
data++);
205 edc[0] = (
val << 6) & 0xFF;
206 edc[1] = (
val >> 2) & 0xFF;
207 edc[2] = (
val >> 10) & 0xFF;
208 edc[3] = (
val >> 18) & 0xFF;
402 if ((
id == 1) && (
blockbuf[0x4405] == 0xFF))
407 else if ((
blockbuf[0x4405] != 0xFF))
409 printf(
" ! Badblock on block 1 detected! Unable to check for META Type 0/1!\n");
419 if ((
id == 1) && (
blockbuf[0x4405] == 0xFF))
428 printf(
" ! Bad incompatible size");
435 if ((
id == 0) && (
blockbuf[0x4400] == 0xFF))
443 printf(
" ! Incompatible size\n");
446 printf(
" ! Bad meta data for this console type\n");
451 unsigned char ecd[4];
453 if ((ecd[0] == page[0x20C]) && (ecd[1] == page[0x20D]) && (ecd[2] == page[0x20E]) && (ecd[3] == page[0x20F]))
463 while (offset < len / 0x210)
467 printf(
" ! Bad ECD detected on page %i\n", offset / 0x210);
486 printf(
" ! ERROR: unable to allocate 0x%x bytes for a buffer!\n", len);
491 printf(
" ! ERROR: Can't read enough data...");
508 int addr, addrphy,
status, r;
514 printf(
"ERROR: unable to allocate 0x%x bytes for a buffer!\n", readsz);
518 secondPgOffset = 0x1080;
521 printf(
"processing block 0x%04x of 0x%04x \r", i+1, numblocks);
530 printf(
"ERROR: failed to read %d bytes from file\n\n",readsz);
535 printf(
"block 0x%x seems bad, status 0x%08x\n", i,
status);
540 printf(
"Block recovered! (A.K.A The block wasn't bad in the first place...)\n");
544 printf(
"Block cannot be recovered (A.K.A it's really bad)\n");
564 long size = s.st_size;
568 int f =
open(filename, O_RDONLY);
572 printf(
" * rawflash v5 started (by cOz, modified By Swizzy)\n");
578 printf(
"error: %s - size %d is not valid image size!\n", filename,
size);
583 printf(
"\n * found '%s'. press power NOW if you don't want to flash the NAND.\n",filename);
586 printf(
" * Checking NAND File to be of matching type...\n");
589 printf(
" ! Bad Image for this console... Please replace the file and try again...\n");
593 printf(
" * Image matches expected data...\n");
596 f =
open(filename, O_RDONLY);
600 printf(
"%s opened OK, attempting to write 0x%x bytes to flash...\n",filename,
size);
602 printf(
"image written, shut down now!\n");
604 printf(
"failed to write image :(\n");
648 printf(
" ! SFCX: Unsupported Type - PHISON eMMC\n");
665 switch ((config >> 17) & 0x03)
671 switch ((config >> 4) & 0x3)
674 printf(
" ! SFCX: Unsupported Type A-0\n");
712 switch ((config >> 4) & 0x3)
716 if(((config >> 17) & 0x03) == 0x01)
720 printf(
" ! SFCX: Unsupported Type B-0\n");
738 if(((config >> 17) & 0x03) == 0x01)
766 sfc.
size_bytes = 0x1 << (((config >> 19) & 0x3) + ((config >> 21) & 0xF) + 0x17);
776 sfc.
size_bytes = 0x1 << (((config >> 19) & 0x3) + ((config >> 21) & 0xF) + 0x17);
786 printf(
" ! SFCX: Unsupported Type\n");
822 printf(
" config register = %08X\n", config);
int stat(const char *file, struct stat *st)
int read(int fileDesc, void *ptr, size_t len)
int open(const char *file, int flags, int mode)
unsigned int xenon_get_PCIBridgeRevisionID()
unsigned long sfcx_readreg(int addr)
int rawflash_checkImage(int f)
int sfcx_is_pageerased(unsigned char *data)
int sfcx_read_page(unsigned char *data, int address, int raw)
void sfcx_set_pagevalid(unsigned char *data)
int sfcx_write_page(unsigned char *data, int address)
void sfcx_set_pageinvalid(unsigned char *data)
int sfcx_rawaddress_to_block(int address)
int sfcx_block_to_rawaddress(int block)
int sfcx_get_blocknumber(unsigned char *data)
int sfcx_address_to_block(int address)
int sfcx_get_blockversion(unsigned char *data)
void sfcx_set_blockversion(unsigned char *data, int ver)
int sfcx_read_block(unsigned char *data, int address, int raw)
int rawflash_checkImage_ecd_page(unsigned char *page)
void sfcx_calcecc_ex(unsigned int *data, unsigned char *edc)
int rawflash_writeImage(int len, int f)
int sfcx_is_pagezeroed(unsigned char *data)
void sfcx_calcecc(unsigned int *data)
void sfcx_writereg(int addr, unsigned long data)
int rawflash_checkImage_meta(int len)
int rawflash_checkImage_ecd(int len)
int sfcx_is_pagevalid(unsigned char *data)
int try_rawflash(char *filename)
unsigned int sfcx_init(void)
int sfcx_erase_block(int address)
int sfcx_block_to_address(int block)
int sfcx_write_block(unsigned char *data, int address)
void sfcx_set_blocknumber(unsigned char *data, int num)
#define SFCX_SUCCESS(status)
#define WRITE_PAGE_TO_PHY