vdudouyt / stm8flash

program your stm8 devices with SWIM/stlinkv(1,2)
GNU General Public License v2.0
403 stars 183 forks source link

Verify option for ihx is broken #81

Closed rumpeltux closed 6 years ago

rumpeltux commented 7 years ago

I’m not sure exactly how though. But this seems to already have been spotted in #14 Verify for binary files works.

welash commented 6 years ago

Issue #14 was reported before intel hex format was supported. I will try to take a look at this later, but just to make sure, the file that you are verifying from is an intel hex file, and it has an extension of either ".hex" or ".ihx", correct. Any other extension will be treated as a binary file. We probably should use a command line option or other method for determining the file type, but we don't/

rumpeltux commented 6 years ago

Yes, I had the correct extension, verifing .bin or any other works fine.

welash commented 6 years ago

Ok, I think I see the problem. the call to ihex_read is passing in buf instead of buf2. The fix should be:

diff --git a/main.c b/main.c
index df3b0db..2728cee 100644
--- a/main.c
+++ b/main.c
@@ -371,7 +371,7 @@ int main(int argc, char **argv) {
                int bytes_to_verify;
                /* reading bytes to RAM */
                if(is_ext(filename, ".ihx") || is_ext(filename, ".hex")) {
-                       bytes_to_verify = ihex_read(f, buf, start, start + bytes_count);
+                       bytes_to_verify = ihex_read(f, buf2, start, start + bytes_count);
                } else {
                        fseek(f, 0L, SEEK_END);
                        bytes_to_verify = ftell(f);

But I haven't had a chance to test it.

rumpeltux commented 6 years ago

I tested it. Seems to work :) Thanks.

welash commented 6 years ago

Great, I'll submit a pull request when I get a chance.

On Tue, Dec 5, 2017 at 2:39 AM, Hagen Fritsch notifications@github.com wrote:

I tested it. Seems to work :) Thanks.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/vdudouyt/stm8flash/issues/81#issuecomment-349233945, or mute the thread https://github.com/notifications/unsubscribe-auth/AGQvNKITYPg2SU97En27pPgXm8Y6u9vjks5s9QEsgaJpZM4QF8Gm .

spth commented 6 years ago

Clsoing the issue, since the fix has been merged and tested.

Philipp