-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[bug #51320] linuxgpio and linuxspi problem: 0x00 written as 0xFF when byte count is less than 0x10 in hex file lines #455
Comments
Mike Here is an intel hex file that will return a verification error due to "00" getting written as "FF". |
Mike In further troubleshooting of my issue, I did examine the verbose output during the writing and flashing of the blink-2560-mod hex file. Interestingly, the bitbang_cmd() output shows that it did write "00" for the byte in question. During the read, "FF" is being read. I do know that if I read the firmware with AVR Studio it will also confirm the byte mismatch so even though avrdude bitbang shows "00", it is either not writing it (and FF is a remnant of the initial chip erase) or it is writing FF. I have attached two more images showing the verbose output during this scenario. |
Mike In further testing, the issue is not specific to trying to write "00". I will receive a verification error anytime the data byte count is less than 0x10 AND the last data byte != 0xFF. I have verified this response with numerous .hex files on the Atmega1284 and Atmega 2560 chips. Atmel Studio will write and verify these same .hex files without error. |
Mike After further troubleshooting, I believe I have discovered more precisely what is causing the verification error and in an effort to not bury it below this bug thread, I want to open a new bug. This bug can be closed. |
Andrzej Pietrasiewicz
|
Andrzej Pietrasiewicz Please see https://www.avrfreaks.net/comment/2739451#comment-2739451 The problem is with hex file records containing an odd number of data bytes. |
Andrzej Pietrasiewicz I have a solution - if an ihex record has odd length then mark the missing high byte as allocated and let it contain 0xff: diff --git a/fileio.c b/fileio.c
index 02c50ab..e3c82a4 100644
--- a/fileio.c
+++ b/fileio.c
@@ -334,6 +334,10 @@ static int ihex2b(char * infile, FILE * inf,
mem->buf[nextaddr+i] = ihex.data[i];
mem->tags[nextaddr+i] = TAG_ALLOCATED;
}
+ if (ihex.reclen & 0x1) {
+ mem->buf[nextaddr+i] = 0xff;
+ mem->tags[nextaddr+i] = TAG_ALLOCATED;
+ }
if (nextaddr+ihex.reclen > maxaddr)
maxaddr = nextaddr+ihex.reclen;
break; But why is the record length odd in the first place if flash locations are 2-byte locations? |
Related issue with Mega2560 and linuxgpio. Probably this is the same as #458. |
I will try to test this soon with the above-mentioned hex file for ATmega2560. |
I can confirm that there is a bug here.
|
Not so sure if this has anything similar to the issue mentioned in #825 or #936.
The patch with a bit better formatting. diff --git a/fileio.c b/fileio.c
index 02c50ab..e3c82a4 100644
--- a/fileio.c
+++ b/fileio.c
@@ -334,6 +334,10 @@ static int ihex2b(char * infile, FILE * inf,
mem->buf[nextaddr+i] = ihex.data[i];
mem->tags[nextaddr+i] = TAG_ALLOCATED;
}
+ if (ihex.reclen & 0x1) {
+ mem->buf[nextaddr+i] = 0xff;
+ mem->tags[nextaddr+i] = TAG_ALLOCATED;
+ }
if (nextaddr+ihex.reclen > maxaddr)
maxaddr = nextaddr+ihex.reclen;
break;
`` |
I can confirm that the patch fixed the issue.
|
@stefanrueger
|
I can confirm that linuxspi has the same issue and the same patch works to fix the issue.
|
BTW, there is no issue with an STK500v2 and an AVRISP mkii clone. This is kind of strange since the fix is not specific to the linuxgpio/linuxspi programmer.
Same for a PICKit 2 with the fix for issue #1004 (Pull request #1023).
|
@mcuee I had a look and I am puzzled by the patch. A hex file can piece together an application in whichever way it likes, eg, a 10-byte contiguous input file might well be described in a hex file as one record of 7 bytes followed by another record of 3 bytes. It should not matter how the hex file looks like, what matters is how the resulting file after reading looks like. On that grounds alone I would reject the patch. So, if the patch works in the observed case, it must have been something else that helped... |
I agree. I was puzzled as well because the patch is not really related to linuxgpio and linuxspi. So I guess something in the linuxgpio and linuxspi may be the problem. Therefore I agree the patch is probably not addressing the root cause. |
@stefanrueger |
I can confirm that PR #1265 fixed this issue. Analysis by @stefanrueger |
Mike Brandon smbrandonjr@gmail.com
Mon 26 Jun 2017 08:13:10 PM UTC
Programmer hardware: linuxgpio
Device type: m2650
I have two different .hex files (unfortunately I am unable to share entire .hex files as I do not own them). Both write and verify fine when using AVR Studio and an AVRISP programmer.
When using avrdude with linuxgpio, the write process completes but the verification process returns an error. In both files it occurs on lines of the .hex file where the data byte count is less than 0x10 (this is the only common theme I have been able to identify). When I look at the specific address mentioned by avrdude for the verification error, the original data that SHOULD have been written was 0x00. The data that WAS written was 0xFF.
The attached files only pertain to one of the hex files I have experienced this with.
file #41054: 0x40ca-read.PNG
file #41053: avrdude-write-read.PNG
file #41052: 0x40ca-data.PNG
file #41079: blink-2560-mod.hex
file #41127: blink-mod-bitbang-read.PNG
file #41126: blink-mod-bitbang-write.PNG
This issue was migrated from https://savannah.nongnu.org/bugs/?51320
The text was updated successfully, but these errors were encountered: