Closed mrv96 closed 8 months ago
@mrv96 solution fixes the Program
function instead and i think this is the preferred fix for this issue. I tested it on my system, now it works as expected.
You have done a great and good job. But, unfortunately, this problem affects all types of chips and it is much more rational to solve it when loading a file. Please test my changes:
// if ChipSze = 0 IMSProg using at hexeditor only. chipsize -> hexedit.data
// if ChipSize < FileSize - showing error message
// if Filesize <= ChipSize - filling fileArray to hexedit.Data, the end of the array chipData remains filled 0xff
QFile file(fileName);
if ((info.size() > currentChipSize) && (currentChipSize != 0))
{
QMessageBox::about(this, tr("Error"), tr("The file size exceeds the chip size. Please select another chip or file or use block operations to split the file."));
return;
}
if (!file.open(QIODevice::ReadOnly))
{
return;
}
buf.resize(info.size());
buf = file.readAll();
if (currentChipSize == 0)
{
chipData.resize(info.size());
}
for (uint32_t i=0; i < info.size(); i++)
{
chipData[i] = buf[i];
}
hexEdit->setData(chipData);
file.close();
I just tested your solution; generally speaking it works, but I found a case where it doesn't.
Suppose to have a memory of 4 bytes where the value of last byte is 0xAA
. You want to write a file containing three byte (e.g. 0x11
0x22
0x33
) performing the following steps:
The expected memory content is: 0x11 0x22 0x33 0xAA
, but it actually contains: 0x11 0x22 0x33 0xFF
That's normal. If you want to load a file and leave the rest of the buffer contents - use the Load Part
command. (Puzzle with red arrow). This is a special command for assembling multiple files into a buffer.
Fix https://github.com/bigbigmdm/IMSProg/issues/28 for I2C EEPROM