mirror of
https://github.com/freitz85/AppleIISd.git
synced 2024-11-25 02:32:14 +00:00
Verification added
This commit is contained in:
parent
88b075357a
commit
7aaa9e9e18
@ -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
|
||||||
|
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user