Skip to content

INHX32 is not fully supported #5

@marcoNexion

Description

@marcoNexion

Hi,

when read_inhx() function runs it fails in checksum comparison.

e.g.:

line 2530 (35 bytes): ':0B9D20004A943366CC831D3A74E8CBF4\r\n'
byte_count = 0x0B
address = 0x9D20
record_type = 0x00 (data)
data = 0x944A @0x00004E90
data = 0x6633 @0x00004E91
data = 0x83CC @0x00004E92
data = 0x3A1D @0x00004E93
data = 0xE874 @0x00004E94
checksum = 0xCB
Error: checksum does not match. Calculated = 0xBF, Read = 0xCB

In file, checksum is supposed to be 0xF4.
In read_inhx(), checsum is computed as 0xCB.

When byte_count is odd, the for loop ignore the last char :

for(i = 0; i < byte_count/2; i++) {
nread = sscanf(&line[9+4*i], "%4hx", &data);
if (nread != 1) {
	cerr << "Error: cannot read data." << endl;
	return 0;
}
tmp = data;
data = (data >> 8) | (tmp << 8);
if (flags.debug) fprintf(stderr, "  data        = 0x%04X", data);
checksum_calculated += (data >> 8) & 0xFF;
checksum_calculated += data & 0xFF;

extended_address = ( ((uint32_t)base_address << 16) | address);
if (flags.debug)
	fprintf(stderr, " @0x%08X\n", extended_address/2+i);

mem->location[extended_address/2 + i - offset/2] = data;
mem->filled[extended_address/2 + i - offset/2] = 1;
filled_locations++;
}

A part of my hex file is :

:109D1000D4B37DFAEFC5913972E4D3BD61C29F25FA
:0B9D20004A943366CC831D3A74E8CBF4
:049D2C002BD9E150FE
:109D3000F90F23D9000ED880EE54000EED5425E221

May be I can link the code to fill 16bit location. But it does'nt seem possible with MPLAB C18.

Regards,

Marco

Metadata

Metadata

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions