Verification added

This commit is contained in:
Florian Reitz 2019-03-05 20:41:36 +01:00
parent 88b075357a
commit 7aaa9e9e18
2 changed files with 39 additions and 15 deletions

View File

@ -4,6 +4,10 @@
typedef unsigned char uint8; typedef unsigned char uint8;
typedef unsigned short uint16; typedef unsigned short uint16;
typedef unsigned long uint32; typedef unsigned long uint32;
typedef unsigned char boolean;
#define TRUE 1
#define FALSE 0
#define SLOT_IO_START (uint8*)0xC080 #define SLOT_IO_START (uint8*)0xC080
#define SLOT_ROM_START (uint8*)0xC000 #define SLOT_ROM_START (uint8*)0xC000

View File

@ -20,7 +20,7 @@ typedef enum
const char state_char[STATE_LAST] = { '|', '/', '-', '\\' }; const char state_char[STATE_LAST] = { '|', '/', '-', '\\' };
void writeChip(const uint8* pSource, uint8* pDest, uint16 length); boolean writeChip(const uint8* pSource, uint8* pDest, uint16 length);
void printStatus(uint8 percentage); void printStatus(uint8 percentage);
// Binary can't be larger than 2k // Binary can't be larger than 2k
@ -28,6 +28,7 @@ uint8 buffer[2048] = { 0 };
int main() int main()
{ {
int retval = 0;
FILE* pFile; FILE* pFile;
char slotNum; char slotNum;
@ -76,49 +77,68 @@ int main()
// write to SLOTROM // write to SLOTROM
cprintf("\r\n\r\nFlashing SLOTROM: "); cprintf("\r\n\r\nFlashing SLOTROM: ");
writeChip(buffer, pSlotRom, 256); if(writeChip(buffer, pSlotRom, 256))
{
// write to EXTROM // write to EXTROM
cprintf("\r\nFlashing EXTROM: "); cprintf("\r\nFlashing EXTROM: ");
writeChip(buffer + 256, pExtRom, fileSize - 256); if(writeChip(buffer + 256, pExtRom, fileSize - 256))
{
cprintf("\r\n\r\nFlashing finished!\n");
}
else
{
retval = 1;
}
}
else
{
retval = 1;
}
// disable write // disable write
pAIISD->status.pgmen = 0; pAIISD->status.pgmen = 0;
cprintf("\r\n\r\nFlashing finished!\n");
} }
else else
{ {
cprintf("\r\nWrong file size: %d\r\n", fileSize); cprintf("\r\nWrong file size: %d\r\n", fileSize);
return 1; retval = 1;
} }
} }
else else
{ {
cprintf("\r\nCan't open %s file\r\n", BIN_FILE_NAME); cprintf("\r\nCan't open %s file\r\n", BIN_FILE_NAME);
return 1; retval = 1;
} }
return 0; // success return retval;
} }
void writeChip(const uint8* pSource, uint8* pDest, uint16 length) boolean writeChip(const uint8* pSource, uint8* pDest, uint16 length)
{ {
uint32 i; uint32 i;
uint8 data = 0;
for(i=0; i<length; i++) for(i=0; i<length; i++)
{ {
// set 0 if no source
if(pSource) if(pSource)
{ {
*pDest = pSource[i]; data = pSource[i];
} }
else
*pDest = data;
if(*pDest != data)
{ {
// erase if no source // verification not successful
*pDest = 0; cprintf("\r\n\r\n!!! Flashing failed at %p !!!\r\n", pDest);
return FALSE;
} }
printStatus((i * 100u / length) + 1); printStatus((i * 100u / length) + 1);
pDest++; pDest++;
} }
return TRUE;
} }
void printStatus(uint8 percentage) void printStatus(uint8 percentage)