static FlashType flashType = FLASH_INVALID;
static uint32_t manId = 0;
-static const char trbflash_version[] = "$Revision: 2.28 $";
+static const char trbflash_version[] = "$Revision: 2.29 $";
static uint32_t mdcFlashSelect = 1;
static int programImageBuffer(uint16_t trb_address,
unsigned int size, PMode mode, int infoPage)
{
- int bla = 0;
unsigned int block;
int status;
int errorCtr = 0;
char c;
if ((flashType == FLASH_MDC_OEP_V2) || (flashType == FLASH_MDC_OEP_V3)) {
if (mdcFlashSelect == 0) {
- fprintf(stderr,
+ fprintf(stdout,
"You decided to reprogram the FlashRom(s) #0 of "
"MDC_OEP, the so called 'GoldenImage'. "
"Do you really know what you're about to do [N,y]: ");
}
} else {
- fprintf(stderr,
+ fprintf(stdout,
"You decided to reprogram the FlashRom(s) of "
"%s, are you sure [N,y]: ", FlashTypeStr[flashType]);
}
+ fflush(stdout);
c = getc(stdin);
if (!((c == 'Y') || (c == 'y'))) {
- fprintf(stderr, "\nAborting on user request\n");
+ fprintf(stdout, "\nAborting on user request\n");
+ fflush(stdout);
return -1;
}
}
if (mode != PMODE_VERIFY) {
- fprintf(stderr,
+ fprintf(stdout,
"Programming Endpoint(s) @ Address 0x%04x\n", trb_address);
- fprintf(stderr,
+ fprintf(stdout,
"Symbols:\n"
" E: Erasing\n"
" P: Programming\n" " @: Success\n" " .: Skipped\n\n");
} else {
- fprintf(stderr, "Verifying Endpoint(s) @ Address 0x%04x\n", trb_address);
- fprintf(stderr,
+ fprintf(stdout, "Verifying Endpoint(s) @ Address 0x%04x\n", trb_address);
+ fprintf(stdout,
"Symbols:\n"
" V: Verifying\n"
" X: Failed (see logfile 'trbflash.log' for details)\n"
" @: Success\n" " .: Skipped\n\n");
}
- fprintf(stderr, "Block: 0 1 2 3 4 5 6 7 8 9 A B C D E F");
-
+ fprintf(stdout, "Block: 0 1 2 3 4 5 6 7 8 9 A B C D E F");
+ fflush(stdout);
+
errorCtr = 0;
if ((mode != PMODE_VERIFY) && (manId == 0x1520c2)) {
int error = 0;
int writeInfoPage = (block == NUM_BLOCKS - 1) && (infoPage == 1) ? 1 : 0;
if (block % 16 == 0) {
- fprintf(stderr, "\n%x ", block / 16);
+ fprintf(stdout, "\n%x ", block / 16);
}
- fprintf(stderr, ".\b");
-
+ fprintf(stdout, ".\b");
+ fflush(stdout);
+
if (!(bytesWritten > 0) && (writeInfoPage == 0)) {
- fprintf(stderr, ". ");
+ fprintf(stdout, ". ");
+ fflush(stdout);
continue;
}
}
/* Erase block */
- fprintf(stderr, "E\b");
+ fprintf(stdout, "E\b");
+ fflush(stdout);
if (sendCommand(trb_address, 0xd8 << 24 | (BLOCK_SIZE * block), 3)
== -1) {
fprintf(stderr, "\nError > program: erase block #%d, aborting\n",
}
/* Now write pages */
- fprintf(stderr, "P\b");
+ fprintf(stdout, "P\b");
+ fflush(stdout);
tmp = bytesWritten;
for (i = 0, page = (block * BLOCK_SIZE) / PAGE_SIZE;
(i < (BLOCK_SIZE / PAGE_SIZE)) && (tmp > 0); i++, page++) {
}
} else {
/* Verify pages */
- fprintf(stderr, "V\b");
+ fprintf(stdout, "V\b");
+ fflush(stdout);
tmp = bytesWritten;
- bla++;
for (i = 0, page = (block * BLOCK_SIZE) / PAGE_SIZE;
(i < (BLOCK_SIZE / PAGE_SIZE)) && (tmp > 0); i++, page++) {
unsigned int endPoint;
}
if (error == 0) {
- fprintf(stderr, "@ ");
+ fprintf(stdout, "@ ");
} else {
- fprintf(stderr, "X ");
+ fprintf(stdout, "X ");
}
+ fflush(stdout);
}
if ((mode != PMODE_VERIFY) && (manId == 0x1520c2)) {
}
if (errorCtr == 0) {
- fprintf(stderr, "\n\nSuccess\n\n");
+ fprintf(stdout, "\n\nSuccess\n\n");
} else {
- fprintf(stderr,
+ fprintf(stdout,
"\n\n%d Errors have occured, see logFile %s for details\n\n",
errorCtr, logFileName);
}
+ fflush(stdout);
return errorCtr == 0 ? 0 : -1;
}