Avrdude: verification error, first mismatch at byte 0x0080..

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello. I program my arduino Uno with assembly and Avr-Studio4.
But when i use the .ORG directive the avrdude gives me:

slaris@deb-hack:~/test/tmp$ avrdude -p atmega328p -c arduino -P /dev/ttyACM1 -U flash:w:timer0.hex:i 

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "timer0.hex"
avrdude: writing flash (1052 bytes):

Writing | ################################################## | 100% 0.06s

avrdude: 1052 bytes of flash written
avrdude: verifying flash memory against timer0.hex:
avrdude: load data flash data from input file timer0.hex:
avrdude: input file timer0.hex contains 1052 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.15s

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0100
         0xff != 0x80
avrdude: verification error; content mismatch

avrdude: safemode: Fuses OK

avrdude done.  Thank you.

Notice the: verification error, first mismatch at byte 0x0100
0xff != 0x80

I check this with the simulator and it doesn't seem a piece of memory to be overlapping with another. Does this error mean that something else is written on the flash that shouldn't been written after checking the checksum?
Also, could it have any relation with the arduino bootloader which i have no idea where it resides?
Nevertheless the program works fine after the upload.
Also the file included in the code is the "m328def.inc", not "m32def.inc". I had just renamed it.

Attachment(s): 

Last Edited: Fri. Sep 26, 2014 - 11:40 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You should not go changing system files like "m32def.inc"

The m328 and m32 have SRAM and SFRs at different addresses.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I included the m328Pdef.inc file (since the mcu is atmega328p-PU) which resides in the "C:\Program Files\Atmel\AVR Tools\AvrAssembler2\Appnotes" directory. I didn't need to put the path in the source file, Avr Studio finds it alone. But the same error occurs.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sure enough, the UNO bootloader does not like a sparse HEX file.

I edited your code to place the main: at the end of the vector table. And the ISR()s follow the foreground code.

Find my edits by search ".kbv"

.INCLUDE	"m328pdef.inc"         //.kbv
.DEF	cou_reg = r20
.DEF	zero_reg = r1
.EQU	COUNT = 64
.ORG 	0
		jmp		MAIN
.ORG 	OC1Aaddr
		jmp		TIMER1_COMPA
.ORG 	OVF0addr
		jmp		TIMER0_OVF
;.kbv .ORG	0x40
.ORG	INT_VECTORS_SIZE           //.kbv
MAIN:
		ldi		cou_reg, COUNT
		ldi		r16, HIGH(RAMEND)
		out		SPH, r16
		ldi		r16, LOW(RAMEND)
		out		SPL, r16
		
		; Zero the zero reg
		ldi		r16, 0x00
		mov		zero_reg, r16
		; Make port D output
		ldi		r16, 0xFF
		out		DDRD, r16
		; Make pin 8 output and low
		sbi		DDRB, 0
		cbi		PORTB, 0
		; Make pin 9 output and low
		sbi		DDRB, 1
		cbi		PORTB, 1
		; SET THE TIMER0
		; Set prescaler to 1024
		in		r16, TCCR0B
		ldi		r17, 0x05
		eor		r16, r17
		out		TCCR0B, R16
		; Set TOIE0 bit
		ldi		r16, 0x01
		sts		TIMSK0, r16

		; SET THE TIMER2


		; SET THE TIMER1
		ldi		r16, 0x0B
		lds		r17, TCCR1B
		eor		r17, r16
		sts		TCCR1B, r17
		ldi		r16, 0x02
		sts		TIMSK1, r16
		ldi		r16, 0xC3
		sts		OCR1AH, r16
		ldi		r16, 0x50
		sts		OCR1AL, r16
		ldi		r16, 0
		sts		TCNT1H, r16
		sts 	TCNT1L, r16
		out		TCNT0, R16	; Initialize TCNT0 too
		; Enable global interrupts
		sei
L1:		
		ldi		r16, 0
L2:		
		inc		r16
		out		PORTD, r16
; ============================= 
;    delay loop generator 
;     2000000 cycles:
; ----------------------------- 
; delaying 1999998 cycles:
          ldi  R17, $12
WGLOOP0:  ldi  R18, $BC
WGLOOP1:  ldi  R19, $C4
WGLOOP2:  dec  R19
          brne WGLOOP2
          dec  R18
          brne WGLOOP1
          dec  R17
          brne WGLOOP0
; ----------------------------- 
; delaying 2 cycles:
          nop
          nop
; ============================= 


		cp 		r16, r1
		breq	L1
		jmp		L2	

;.kbv .ORG	0x200
TIMER0_OVF:
		dec		cou_reg
		cp		cou_reg, zero_reg
		brne	END
		ldi		cou_reg, 64
		in 		r21, PORTB
		ldi		r22, (1<<0)
		eor		r21, r22
		out		PORTB, r21	
END:
		reti
TIMER1_COMPA:
		in		r21, PORTB
		ldi		r22, (1<<1)
		eor		r21, r22
		out		PORTB, r21
		reti

The UNO bootloader was quite happy with a conventional HEX. If you change to the Duemilanove bootloader, you lose memory but gain flexibility.

Untested.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

David it really doesn't produce any error now! I didn't know that the bootloader had problems with "gaps" in the hex file.
I try to understand what is the ".ORG INT_VECTOR_SIZE" for. Is it the maximum size, in words, that the flash has to include data inside for not to be considered a "gap"?
Also i prefer much more flexibility than memory, so i'll maybe try another bootloader sometime.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

saavedra29 wrote:

I try to understand what is the ".ORG INT_VECTOR_SIZE" for. Is it the maximum size, in words, that the flash has to include data inside for not to be considered a "gap"?

I just noticed it. It's just the first 52 words containing the interrupt vectors :D

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The header file contains all the useful information like 'size' of vector table.

I am not sure quite what the problem is with 'gaps' and the Optiboot bootloader. You can always create a non-sparse HEX file.

If you think about it, the start of your HEX file is 'sparse'. The UNO bootloader has no trouble with those short records that describe the ASM vector table.

In practice, a C generated HEX file 'fills in' the unused vectors.

Oh, I have come across this before. The Codevision "Arduino Uploader" will cope when the basic avrdude gives a verify error.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
If you think about it, the start of your HEX file is 'sparse'.

I was about to ask you for that, as my vector table was almost "empty".
Well it's true that i can always create no-sparse HEX files, so no problem. When i buy my first ISP programmer, I'll may be able to learn more about bootloaders, and have some practice :D
Thank you very much for the help David.