Compiling with LTO produces broken binary after upgrading compiler

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

I upgraded avr-gcc to 7.2.0 and now my code does not work properly if I I compile it LTO. It does if I compile it without LTO, but I consider this a workaround and it is not my preferred solution. Are there some other switches I can try playing around with?

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

Around a thousand...

 

http://gcc.gnu.org/onlinedocs/gc...
 

avrfreaks does not support Opera. Profile inactive.

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

I would also consider something in your code, e.g. without LTO a "missed optimization".

 

The thing to do is to track down what in the code that is misbehaving.

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

You can start compiling individual modules without LTO until removing LTO from a further modul will make it work again.  The "irreducible" set you get by that process need not be unique; it might depend on the order in which you drop LTO.

 

avrfreaks does not support Opera. Profile inactive.

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

How do I selectively disable LTO for certain modules? FYI it's a USB device I'm trying to debug. If it is using a binary created using LTO the device will go into an unresponsive state when suspended by the host and never resume operation. In the event that I find the bug, would I have any options aside from waiting for the compiler to be fixed?

Last Edited: Sun. Oct 8, 2017 - 05:12 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just compile the respective module without -flto. Or append -fno-lto to the end of respective compiler invocation to compile a module; it will undo previous -flto.

 

 

avrfreaks does not support Opera. Profile inactive.

Last Edited: Sun. Oct 8, 2017 - 05:31 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

e_l_tang wrote:
Are there some other switches I can try playing around with?
For a different LTO issue in AVR GCC 7.1.1, -fno-devirtualize

Segmentation fault on Serial.begin() #486

https://github.com/sudar/Arduino-Makefile/issues/486

though there's another work-around (near page's bottom; search for archlinux)

 


LTO causes internal compiler error #65

https://github.com/platformio/platform-atmelavr/issues/65

 

Edit : typo

 

"Dare to be naïve." - Buckminster Fuller

Last Edited: Mon. Oct 9, 2017 - 01:01 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I troubleshooted the issue by flashing LEDs and it seems that the chip is going to sleep and never waking up because the watchdog interrupt is not working properly. I dug around the disassembly and I'm seeing some strange stuff. Two ISRs seem to have been squashed together, and jump between each other. __vector_12 is the ISR for the watchdog interrupt.

 

They look like this when I compile without LTO.

00000f6a <__vector_10>:

ISR(USB_GEN_vect, ISR_BLOCK)
{
     f6a:	1f 92       	push	r1
     f6c:	0f 92       	push	r0
     f6e:	0f b6       	in	r0, 0x3f	; 63
     f70:	0f 92       	push	r0
     f72:	11 24       	eor	r1, r1
     f74:	2f 93       	push	r18
     f76:	3f 93       	push	r19
     f78:	4f 93       	push	r20
     f7a:	5f 93       	push	r21
     f7c:	6f 93       	push	r22
     f7e:	7f 93       	push	r23
     f80:	8f 93       	push	r24
     f82:	9f 93       	push	r25
     f84:	af 93       	push	r26
     f86:	bf 93       	push	r27
     f88:	ef 93       	push	r30
     f8a:	ff 93       	push	r31
					case USB_INT_SUSPI:
						return (UDINT  & (1 << SUSPI));
					case USB_INT_EORSTI:
						return (UDINT  & (1 << EORSTI));
					case USB_INT_SOFI:
						return (UDINT  & (1 << SOFI));
     f8c:	80 91 e1 00 	lds	r24, 0x00E1	; 0x8000e1 <__TEXT_REGION_LENGTH__+0x7e00e1>
	#if defined(USB_CAN_BE_DEVICE)
	#if !defined(NO_SOF_EVENTS)
	if (USB_INT_HasOccurred(USB_INT_SOFI) && USB_INT_IsEnabled(USB_INT_SOFI))
     f90:	82 ff       	sbrs	r24, 2
     f92:	0a c0       	rjmp	.+20     	; 0xfa8 <__vector_10+0x3e>
						return (UDIEN  & (1 << SOFE));
     f94:	80 91 e2 00 	lds	r24, 0x00E2	; 0x8000e2 <__TEXT_REGION_LENGTH__+0x7e00e2>
     f98:	82 ff       	sbrs	r24, 2
     f9a:	06 c0       	rjmp	.+12     	; 0xfa8 <__vector_10+0x3e>
						UDINT  &= ~(1 << SOFI);
     f9c:	80 91 e1 00 	lds	r24, 0x00E1	; 0x8000e1 <__TEXT_REGION_LENGTH__+0x7e00e1>
     fa0:	8b 7f       	andi	r24, 0xFB	; 251
     fa2:	80 93 e1 00 	sts	0x00E1, r24	; 0x8000e1 <__TEXT_REGION_LENGTH__+0x7e00e1>
						return (USBINT & (1 << VBUSTI));
     fa6:	37 dc       	rcall	.-1938   	; 0x816 <EVENT_USB_Device_StartOfFrame>
     fa8:	80 91 da 00 	lds	r24, 0x00DA	; 0x8000da <__TEXT_REGION_LENGTH__+0x7e00da>
		EVENT_USB_Device_StartOfFrame();
	}
	#endif

	#if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
	if (USB_INT_HasOccurred(USB_INT_VBUSTI) && USB_INT_IsEnabled(USB_INT_VBUSTI))
     fac:	80 ff       	sbrs	r24, 0
						return (USBCON & (1 << VBUSTE));
     fae:	17 c0       	rjmp	.+46     	; 0xfde <__vector_10+0x74>
     fb0:	80 91 d8 00 	lds	r24, 0x00D8	; 0x8000d8 <__TEXT_REGION_LENGTH__+0x7e00d8>
     fb4:	80 ff       	sbrs	r24, 0
						USBINT &= ~(1 << VBUSTI);
     fb6:	13 c0       	rjmp	.+38     	; 0xfde <__vector_10+0x74>
     fb8:	80 91 da 00 	lds	r24, 0x00DA	; 0x8000da <__TEXT_REGION_LENGTH__+0x7e00da>
     fbc:	8e 7f       	andi	r24, 0xFE	; 254
     fbe:	80 93 da 00 	sts	0x00DA, r24	; 0x8000da <__TEXT_REGION_LENGTH__+0x7e00da>
					return ((USBSTA & (1 << VBUS)) ? true : false);
     fc2:	80 91 d9 00 	lds	r24, 0x00D9	; 0x8000d9 <__TEXT_REGION_LENGTH__+0x7e00d9>
	{
		USB_INT_Clear(USB_INT_VBUSTI);

		if (USB_VBUS_GetStatus())
     fc6:	80 ff       	sbrs	r24, 0
				PLLCSR = USB_PLL_PSC;
     fc8:	8b c0       	rjmp	.+278    	; 0x10e0 <__vector_10+0x176>
     fca:	80 e1       	ldi	r24, 0x10	; 16
				PLLCSR = (USB_PLL_PSC | (1 << PLLE));
     fcc:	89 bd       	out	0x29, r24	; 41
     fce:	82 e1       	ldi	r24, 0x12	; 18
		{
			if (!(USB_Options & USB_OPT_MANUAL_PLL))
			{
				USB_PLL_On();
				while (!(USB_PLL_IsReady()));
     fd0:	89 bd       	out	0x29, r24	; 41
     fd2:	09 b4       	in	r0, 0x29	; 41
     fd4:	00 fe       	sbrs	r0, 0
			}

			USB_DeviceState = DEVICE_STATE_Powered;
     fd6:	fd cf       	rjmp	.-6      	; 0xfd2 <__vector_10+0x68>
			EVENT_USB_Device_Connect();
     fd8:	81 e0       	ldi	r24, 0x01	; 1
     fda:	8e bb       	out	0x1e, r24	; 30
						return (UDINT  & (1 << SUSPI));
     fdc:	ff db       	rcall	.-2050   	; 0x7dc <EVENT_USB_Device_Connect>
     fde:	80 91 e1 00 	lds	r24, 0x00E1	; 0x8000e1 <__TEXT_REGION_LENGTH__+0x7e00e1>
			EVENT_USB_Device_Disconnect();
		}
	}
	#endif

	if (USB_INT_HasOccurred(USB_INT_SUSPI) && USB_INT_IsEnabled(USB_INT_SUSPI))
     fe2:	80 ff       	sbrs	r24, 0
						return (UDIEN  & (1 << SUSPE));
     fe4:	17 c0       	rjmp	.+46     	; 0x1014 <__vector_10+0xaa>
     fe6:	80 91 e2 00 	lds	r24, 0x00E2	; 0x8000e2 <__TEXT_REGION_LENGTH__+0x7e00e2>
     fea:	80 ff       	sbrs	r24, 0
						UDIEN  &= ~(1 << SUSPE);
     fec:	13 c0       	rjmp	.+38     	; 0x1014 <__vector_10+0xaa>
     fee:	80 91 e2 00 	lds	r24, 0x00E2	; 0x8000e2 <__TEXT_REGION_LENGTH__+0x7e00e2>
     ff2:	8e 7f       	andi	r24, 0xFE	; 254
     ff4:	80 93 e2 00 	sts	0x00E2, r24	; 0x8000e2 <__TEXT_REGION_LENGTH__+0x7e00e2>
						UDIEN  |= (1 << WAKEUPE);
     ff8:	80 91 e2 00 	lds	r24, 0x00E2	; 0x8000e2 <__TEXT_REGION_LENGTH__+0x7e00e2>
     ffc:	80 61       	ori	r24, 0x10	; 16
     ffe:	80 93 e2 00 	sts	0x00E2, r24	; 0x8000e2 <__TEXT_REGION_LENGTH__+0x7e00e2>
				USBCON |=  (1 << FRZCLK);
    1002:	80 91 d8 00 	lds	r24, 0x00D8	; 0x8000d8 <__TEXT_REGION_LENGTH__+0x7e00d8>
    1006:	80 62       	ori	r24, 0x20	; 32
    1008:	80 93 d8 00 	sts	0x00D8, r24	; 0x8000d8 <__TEXT_REGION_LENGTH__+0x7e00d8>
		#if defined(USB_SERIES_2_AVR) && !defined(NO_LIMITED_CONTROLLER_CONNECT)
		USB_DeviceState = DEVICE_STATE_Unattached;
		EVENT_USB_Device_Disconnect();
		#else
		USB_DeviceState = DEVICE_STATE_Suspended;
		EVENT_USB_Device_Suspend();
    100c:	19 bc       	out	0x29, r1	; 41
    100e:	85 e0       	ldi	r24, 0x05	; 5
						return (UDINT  & (1 << WAKEUPI));
    1010:	8e bb       	out	0x1e, r24	; 30
    1012:	24 dc       	rcall	.-1976   	; 0x85c <EVENT_USB_Device_Suspend>
		#endif
	}

	if (USB_INT_HasOccurred(USB_INT_WAKEUPI) && USB_INT_IsEnabled(USB_INT_WAKEUPI))
    1014:	80 91 e1 00 	lds	r24, 0x00E1	; 0x8000e1 <__TEXT_REGION_LENGTH__+0x7e00e1>
						return (UDIEN  & (1 << WAKEUPE));
    1018:	84 ff       	sbrs	r24, 4
    101a:	27 c0       	rjmp	.+78     	; 0x106a <__vector_10+0x100>
    101c:	80 91 e2 00 	lds	r24, 0x00E2	; 0x8000e2 <__TEXT_REGION_LENGTH__+0x7e00e2>
				PLLCSR = USB_PLL_PSC;
    1020:	84 ff       	sbrs	r24, 4
    1022:	23 c0       	rjmp	.+70     	; 0x106a <__vector_10+0x100>
				PLLCSR = (USB_PLL_PSC | (1 << PLLE));
    1024:	80 e1       	ldi	r24, 0x10	; 16
    1026:	89 bd       	out	0x29, r24	; 41
	{
		if (!(USB_Options & USB_OPT_MANUAL_PLL))
		{
			USB_PLL_On();
			while (!(USB_PLL_IsReady()));
    1028:	82 e1       	ldi	r24, 0x12	; 18
    102a:	89 bd       	out	0x29, r24	; 41
    102c:	09 b4       	in	r0, 0x29	; 41
				USBCON &= ~(1 << FRZCLK);
    102e:	00 fe       	sbrs	r0, 0
    1030:	fd cf       	rjmp	.-6      	; 0x102c <__vector_10+0xc2>
    1032:	80 91 d8 00 	lds	r24, 0x00D8	; 0x8000d8 <__TEXT_REGION_LENGTH__+0x7e00d8>
    1036:	8f 7d       	andi	r24, 0xDF	; 223
						UDINT  &= ~(1 << WAKEUPI);
    1038:	80 93 d8 00 	sts	0x00D8, r24	; 0x8000d8 <__TEXT_REGION_LENGTH__+0x7e00d8>
    103c:	80 91 e1 00 	lds	r24, 0x00E1	; 0x8000e1 <__TEXT_REGION_LENGTH__+0x7e00e1>
    1040:	8f 7e       	andi	r24, 0xEF	; 239
						UDIEN  &= ~(1 << WAKEUPE);
    1042:	80 93 e1 00 	sts	0x00E1, r24	; 0x8000e1 <__TEXT_REGION_LENGTH__+0x7e00e1>
    1046:	80 91 e2 00 	lds	r24, 0x00E2	; 0x8000e2 <__TEXT_REGION_LENGTH__+0x7e00e2>
    104a:	8f 7e       	andi	r24, 0xEF	; 239
						UDIEN  |= (1 << SUSPE);
    104c:	80 93 e2 00 	sts	0x00E2, r24	; 0x8000e2 <__TEXT_REGION_LENGTH__+0x7e00e2>
    1050:	80 91 e2 00 	lds	r24, 0x00E2	; 0x8000e2 <__TEXT_REGION_LENGTH__+0x7e00e2>
    1054:	81 60       	ori	r24, 0x01	; 1
		USB_INT_Clear(USB_INT_WAKEUPI);

		USB_INT_Disable(USB_INT_WAKEUPI);
		USB_INT_Enable(USB_INT_SUSPI);

		if (USB_Device_ConfigurationNumber)
    1056:	80 93 e2 00 	sts	0x00E2, r24	; 0x8000e2 <__TEXT_REGION_LENGTH__+0x7e00e2>
    105a:	80 91 bb 02 	lds	r24, 0x02BB	; 0x8002bb <USB_Device_ConfigurationNumber>
		  USB_DeviceState = DEVICE_STATE_Configured;
    105e:	88 23       	and	r24, r24
		else
		  USB_DeviceState = (USB_Device_IsAddressSet()) ? DEVICE_STATE_Addressed : DEVICE_STATE_Powered;
    1060:	09 f4       	brne	.+2      	; 0x1064 <__vector_10+0xfa>

		#if defined(USB_SERIES_2_AVR) && !defined(NO_LIMITED_CONTROLLER_CONNECT)
		EVENT_USB_Device_Connect();
		#else
		EVENT_USB_Device_WakeUp();
    1062:	42 c0       	rjmp	.+132    	; 0x10e8 <__vector_10+0x17e>
    1064:	84 e0       	ldi	r24, 0x04	; 4
						return (UDINT  & (1 << EORSTI));
    1066:	8e bb       	out	0x1e, r24	; 30
    1068:	0b dc       	rcall	.-2026   	; 0x880 <EVENT_USB_Device_WakeUp>
		#endif
	}

	if (USB_INT_HasOccurred(USB_INT_EORSTI) && USB_INT_IsEnabled(USB_INT_EORSTI))
    106a:	80 91 e1 00 	lds	r24, 0x00E1	; 0x8000e1 <__TEXT_REGION_LENGTH__+0x7e00e1>
						return (UDIEN  & (1 << EORSTE));
    106e:	83 ff       	sbrs	r24, 3
    1070:	26 c0       	rjmp	.+76     	; 0x10be <__vector_10+0x154>
    1072:	80 91 e2 00 	lds	r24, 0x00E2	; 0x8000e2 <__TEXT_REGION_LENGTH__+0x7e00e2>
						UDINT  &= ~(1 << EORSTI);
    1076:	83 ff       	sbrs	r24, 3
    1078:	22 c0       	rjmp	.+68     	; 0x10be <__vector_10+0x154>
    107a:	80 91 e1 00 	lds	r24, 0x00E1	; 0x8000e1 <__TEXT_REGION_LENGTH__+0x7e00e1>
    107e:	87 7f       	andi	r24, 0xF7	; 247
	{
		USB_INT_Clear(USB_INT_EORSTI);

		USB_DeviceState                = DEVICE_STATE_Default;
    1080:	80 93 e1 00 	sts	0x00E1, r24	; 0x8000e1 <__TEXT_REGION_LENGTH__+0x7e00e1>
		USB_Device_ConfigurationNumber = 0;
    1084:	82 e0       	ldi	r24, 0x02	; 2
    1086:	8e bb       	out	0x1e, r24	; 30
						UDINT  &= ~(1 << SUSPI);
    1088:	10 92 bb 02 	sts	0x02BB, r1	; 0x8002bb <USB_Device_ConfigurationNumber>
    108c:	80 91 e1 00 	lds	r24, 0x00E1	; 0x8000e1 <__TEXT_REGION_LENGTH__+0x7e00e1>
    1090:	8e 7f       	andi	r24, 0xFE	; 254
						UDIEN  &= ~(1 << SUSPE);
    1092:	80 93 e1 00 	sts	0x00E1, r24	; 0x8000e1 <__TEXT_REGION_LENGTH__+0x7e00e1>
    1096:	80 91 e2 00 	lds	r24, 0x00E2	; 0x8000e2 <__TEXT_REGION_LENGTH__+0x7e00e2>
    109a:	8e 7f       	andi	r24, 0xFE	; 254
						UDIEN  |= (1 << WAKEUPE);
    109c:	80 93 e2 00 	sts	0x00E2, r24	; 0x8000e2 <__TEXT_REGION_LENGTH__+0x7e00e2>
    10a0:	80 91 e2 00 	lds	r24, 0x00E2	; 0x8000e2 <__TEXT_REGION_LENGTH__+0x7e00e2>
				uint8_t Number = (Address & ENDPOINT_EPNUM_MASK);

				if (Number >= ENDPOINT_TOTAL_ENDPOINTS)
				  return false;

				return Endpoint_ConfigureEndpoint_Prv(Number,
    10a4:	80 61       	ori	r24, 0x10	; 16
    10a6:	80 93 e2 00 	sts	0x00E2, r24	; 0x8000e2 <__TEXT_REGION_LENGTH__+0x7e00e2>
    10aa:	42 e0       	ldi	r20, 0x02	; 2
						UEIENX |= (1 << RXSTPE);
    10ac:	60 e0       	ldi	r22, 0x00	; 0
    10ae:	80 e0       	ldi	r24, 0x00	; 0
    10b0:	2d de       	rcall	.-934    	; 0xd0c <Endpoint_ConfigureEndpoint_Prv>
    10b2:	80 91 f0 00 	lds	r24, 0x00F0	; 0x8000f0 <__TEXT_REGION_LENGTH__+0x7e00f0>

		#if defined(INTERRUPT_CONTROL_ENDPOINT)
		USB_INT_Enable(USB_INT_RXSTPI);
		#endif

		EVENT_USB_Device_Reset();
    10b6:	88 60       	ori	r24, 0x08	; 8
		USB_ResetInterface();

		EVENT_USB_UIDChange();
	}
	#endif
}
    10b8:	80 93 f0 00 	sts	0x00F0, r24	; 0x8000f0 <__TEXT_REGION_LENGTH__+0x7e00f0>
    10bc:	a9 d1       	rcall	.+850    	; 0x1410 <USB_Event_Stub>
    10be:	ff 91       	pop	r31
    10c0:	ef 91       	pop	r30
    10c2:	bf 91       	pop	r27
    10c4:	af 91       	pop	r26
    10c6:	9f 91       	pop	r25
    10c8:	8f 91       	pop	r24
    10ca:	7f 91       	pop	r23
    10cc:	6f 91       	pop	r22
    10ce:	5f 91       	pop	r21
    10d0:	4f 91       	pop	r20
    10d2:	3f 91       	pop	r19
    10d4:	2f 91       	pop	r18
    10d6:	0f 90       	pop	r0
				PLLCSR = 0;
    10d8:	0f be       	out	0x3f, r0	; 63
			USB_DeviceState = DEVICE_STATE_Unattached;
    10da:	0f 90       	pop	r0
			EVENT_USB_Device_Disconnect();
    10dc:	1f 90       	pop	r1
    10de:	18 95       	reti
    10e0:	19 bc       	out	0x29, r1	; 41
			}

			static inline bool USB_Device_IsAddressSet(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
			static inline bool USB_Device_IsAddressSet(void)
			{
				return (UDADDR & (1 << ADDEN));
    10e2:	1e ba       	out	0x1e, r1	; 30
    10e4:	7c db       	rcall	.-2312   	; 0x7de <EVENT_USB_Device_Disconnect>
		  USB_DeviceState = (USB_Device_IsAddressSet()) ? DEVICE_STATE_Addressed : DEVICE_STATE_Powered;
    10e6:	7b cf       	rjmp	.-266    	; 0xfde <__vector_10+0x74>
    10e8:	80 91 e3 00 	lds	r24, 0x00E3	; 0x8000e3 <__TEXT_REGION_LENGTH__+0x7e00e3>
    10ec:	87 fd       	sbrc	r24, 7
    10ee:	02 c0       	rjmp	.+4      	; 0x10f4 <__vector_10+0x18a>
    10f0:	81 e0       	ldi	r24, 0x01	; 1
    10f2:	b9 cf       	rjmp	.-142    	; 0x1066 <__vector_10+0xfc>
    10f4:	83 e0       	ldi	r24, 0x03	; 3
    10f6:	b7 cf       	rjmp	.-146    	; 0x1066 <__vector_10+0xfc>

0000086c <__vector_12>:
     86c:	1f 92       	push	r1
     86e:	0f 92       	push	r0
     870:	0f b6       	in	r0, 0x3f	; 63
     872:	0f 92       	push	r0
     874:	11 24       	eor	r1, r1
     876:	0f 90       	pop	r0
     878:	0f be       	out	0x3f, r0	; 63
     87a:	0f 90       	pop	r0
     87c:	1f 90       	pop	r1
     87e:	18 95       	reti

 

They look like this when I compile with LTO.

00001fd2 <__vector_10>:
    1fd2:	1f 92       	push	r1
    1fd4:	0f 92       	push	r0
    1fd6:	0f b6       	in	r0, 0x3f	; 63
    1fd8:	0f 92       	push	r0
    1fda:	11 24       	eor	r1, r1
    1fdc:	2f 93       	push	r18
    1fde:	3f 93       	push	r19
    1fe0:	4f 93       	push	r20
    1fe2:	5f 93       	push	r21
    1fe4:	6f 93       	push	r22
    1fe6:	7f 93       	push	r23
    1fe8:	8f 93       	push	r24
    1fea:	9f 93       	push	r25
    1fec:	af 93       	push	r26
    1fee:	bf 93       	push	r27
    1ff0:	ef 93       	push	r30
    1ff2:	ff 93       	push	r31
    1ff4:	80 91 e1 00 	lds	r24, 0x00E1	; 0x8000e1 <__TEXT_REGION_LENGTH__+0x7e00e1>
    1ff8:	82 ff       	sbrs	r24, 2
    1ffa:	3d c0       	rjmp	.+122    	; 0x2076 <__vector_10+0xa4>
    1ffc:	80 91 e2 00 	lds	r24, 0x00E2	; 0x8000e2 <__TEXT_REGION_LENGTH__+0x7e00e2>
    2000:	82 ff       	sbrs	r24, 2
    2002:	39 c0       	rjmp	.+114    	; 0x2076 <__vector_10+0xa4>
    2004:	80 91 e1 00 	lds	r24, 0x00E1	; 0x8000e1 <__TEXT_REGION_LENGTH__+0x7e00e1>
    2008:	8b 7f       	andi	r24, 0xFB	; 251
    200a:	80 93 e1 00 	sts	0x00E1, r24	; 0x8000e1 <__TEXT_REGION_LENGTH__+0x7e00e1>
    200e:	80 91 4a 01 	lds	r24, 0x014A	; 0x80014a <Keyboard_HID_Interface+0xe>
    2012:	90 91 4b 01 	lds	r25, 0x014B	; 0x80014b <Keyboard_HID_Interface+0xf>
    2016:	00 97       	sbiw	r24, 0x00	; 0
    2018:	29 f0       	breq	.+10     	; 0x2024 <__vector_10+0x52>
    201a:	01 97       	sbiw	r24, 0x01	; 1
    201c:	90 93 4b 01 	sts	0x014B, r25	; 0x80014b <Keyboard_HID_Interface+0xf>
    2020:	80 93 4a 01 	sts	0x014A, r24	; 0x80014a <Keyboard_HID_Interface+0xe>
    2024:	80 91 3a 01 	lds	r24, 0x013A	; 0x80013a <Mouse_HID_Interface+0xe>
    2028:	90 91 3b 01 	lds	r25, 0x013B	; 0x80013b <Mouse_HID_Interface+0xf>
    202c:	00 97       	sbiw	r24, 0x00	; 0
    202e:	29 f0       	breq	.+10     	; 0x203a <__vector_10+0x68>
    2030:	01 97       	sbiw	r24, 0x01	; 1
    2032:	90 93 3b 01 	sts	0x013B, r25	; 0x80013b <Mouse_HID_Interface+0xf>
    2036:	80 93 3a 01 	sts	0x013A, r24	; 0x80013a <Mouse_HID_Interface+0xe>
    203a:	80 91 29 01 	lds	r24, 0x0129	; 0x800129 <EnhancedKeyboard_HID_Interface+0xe>
    203e:	90 91 2a 01 	lds	r25, 0x012A	; 0x80012a <EnhancedKeyboard_HID_Interface+0xf>
    2042:	00 97       	sbiw	r24, 0x00	; 0
    2044:	29 f0       	breq	.+10     	; 0x2050 <__vector_10+0x7e>
    2046:	01 97       	sbiw	r24, 0x01	; 1
    2048:	90 93 2a 01 	sts	0x012A, r25	; 0x80012a <EnhancedKeyboard_HID_Interface+0xf>
    204c:	80 93 29 01 	sts	0x0129, r24	; 0x800129 <EnhancedKeyboard_HID_Interface+0xe>
    2050:	80 91 af 01 	lds	r24, 0x01AF	; 0x8001af <count>
    2054:	90 91 b0 01 	lds	r25, 0x01B0	; 0x8001b0 <count+0x1>
    2058:	a0 91 b1 01 	lds	r26, 0x01B1	; 0x8001b1 <count+0x2>
    205c:	b0 91 b2 01 	lds	r27, 0x01B2	; 0x8001b2 <count+0x3>
    2060:	01 96       	adiw	r24, 0x01	; 1
    2062:	a1 1d       	adc	r26, r1
    2064:	b1 1d       	adc	r27, r1
    2066:	80 93 af 01 	sts	0x01AF, r24	; 0x8001af <count>
    206a:	90 93 b0 01 	sts	0x01B0, r25	; 0x8001b0 <count+0x1>
    206e:	a0 93 b1 01 	sts	0x01B1, r26	; 0x8001b1 <count+0x2>
    2072:	b0 93 b2 01 	sts	0x01B2, r27	; 0x8001b2 <count+0x3>
    2076:	80 91 da 00 	lds	r24, 0x00DA	; 0x8000da <__TEXT_REGION_LENGTH__+0x7e00da>
    207a:	80 ff       	sbrs	r24, 0
    207c:	16 c0       	rjmp	.+44     	; 0x20aa <__vector_10+0xd8>
    207e:	80 91 d8 00 	lds	r24, 0x00D8	; 0x8000d8 <__TEXT_REGION_LENGTH__+0x7e00d8>
    2082:	80 ff       	sbrs	r24, 0
    2084:	12 c0       	rjmp	.+36     	; 0x20aa <__vector_10+0xd8>
    2086:	80 91 da 00 	lds	r24, 0x00DA	; 0x8000da <__TEXT_REGION_LENGTH__+0x7e00da>
    208a:	8e 7f       	andi	r24, 0xFE	; 254
    208c:	80 93 da 00 	sts	0x00DA, r24	; 0x8000da <__TEXT_REGION_LENGTH__+0x7e00da>
    2090:	80 91 d9 00 	lds	r24, 0x00D9	; 0x8000d9 <__TEXT_REGION_LENGTH__+0x7e00d9>
    2094:	80 ff       	sbrs	r24, 0
    2096:	9b c0       	rjmp	.+310    	; 0x21ce <__vector_10+0x1fc>
    2098:	80 e1       	ldi	r24, 0x10	; 16
    209a:	89 bd       	out	0x29, r24	; 41
    209c:	82 e1       	ldi	r24, 0x12	; 18
    209e:	89 bd       	out	0x29, r24	; 41
    20a0:	09 b4       	in	r0, 0x29	; 41
    20a2:	00 fe       	sbrs	r0, 0
    20a4:	fd cf       	rjmp	.-6      	; 0x20a0 <__vector_10+0xce>
    20a6:	81 e0       	ldi	r24, 0x01	; 1
    20a8:	8e bb       	out	0x1e, r24	; 30
    20aa:	80 91 e1 00 	lds	r24, 0x00E1	; 0x8000e1 <__TEXT_REGION_LENGTH__+0x7e00e1>
    20ae:	80 ff       	sbrs	r24, 0
    20b0:	1e c0       	rjmp	.+60     	; 0x20ee <__vector_10+0x11c>
    20b2:	80 91 e2 00 	lds	r24, 0x00E2	; 0x8000e2 <__TEXT_REGION_LENGTH__+0x7e00e2>
    20b6:	80 ff       	sbrs	r24, 0
    20b8:	1a c0       	rjmp	.+52     	; 0x20ee <__vector_10+0x11c>
    20ba:	80 91 e2 00 	lds	r24, 0x00E2	; 0x8000e2 <__TEXT_REGION_LENGTH__+0x7e00e2>
    20be:	8e 7f       	andi	r24, 0xFE	; 254
    20c0:	80 93 e2 00 	sts	0x00E2, r24	; 0x8000e2 <__TEXT_REGION_LENGTH__+0x7e00e2>
    20c4:	80 91 e2 00 	lds	r24, 0x00E2	; 0x8000e2 <__TEXT_REGION_LENGTH__+0x7e00e2>
    20c8:	80 61       	ori	r24, 0x10	; 16
    20ca:	80 93 e2 00 	sts	0x00E2, r24	; 0x8000e2 <__TEXT_REGION_LENGTH__+0x7e00e2>
    20ce:	80 91 d8 00 	lds	r24, 0x00D8	; 0x8000d8 <__TEXT_REGION_LENGTH__+0x7e00d8>
    20d2:	80 62       	ori	r24, 0x20	; 32
    20d4:	80 93 d8 00 	sts	0x00D8, r24	; 0x8000d8 <__TEXT_REGION_LENGTH__+0x7e00d8>
    20d8:	19 bc       	out	0x29, r1	; 41
    20da:	85 e0       	ldi	r24, 0x05	; 5
    20dc:	8e bb       	out	0x1e, r24	; 30
    20de:	80 91 60 00 	lds	r24, 0x0060	; 0x800060 <__TEXT_REGION_LENGTH__+0x7e0060>
    20e2:	88 61       	ori	r24, 0x18	; 24
    20e4:	80 93 60 00 	sts	0x0060, r24	; 0x800060 <__TEXT_REGION_LENGTH__+0x7e0060>
    20e8:	80 e4       	ldi	r24, 0x40	; 64
    20ea:	80 93 60 00 	sts	0x0060, r24	; 0x800060 <__TEXT_REGION_LENGTH__+0x7e0060>
    20ee:	80 91 e1 00 	lds	r24, 0x00E1	; 0x8000e1 <__TEXT_REGION_LENGTH__+0x7e00e1>
    20f2:	84 ff       	sbrs	r24, 4
    20f4:	31 c0       	rjmp	.+98     	; 0x2158 <__vector_10+0x186>
    20f6:	80 91 e2 00 	lds	r24, 0x00E2	; 0x8000e2 <__TEXT_REGION_LENGTH__+0x7e00e2>
    20fa:	84 ff       	sbrs	r24, 4
    20fc:	2d c0       	rjmp	.+90     	; 0x2158 <__vector_10+0x186>
    20fe:	80 e1       	ldi	r24, 0x10	; 16
    2100:	89 bd       	out	0x29, r24	; 41
    2102:	82 e1       	ldi	r24, 0x12	; 18
    2104:	89 bd       	out	0x29, r24	; 41
    2106:	09 b4       	in	r0, 0x29	; 41
    2108:	00 fe       	sbrs	r0, 0
    210a:	fd cf       	rjmp	.-6      	; 0x2106 <__vector_10+0x134>
    210c:	80 91 d8 00 	lds	r24, 0x00D8	; 0x8000d8 <__TEXT_REGION_LENGTH__+0x7e00d8>
    2110:	8f 7d       	andi	r24, 0xDF	; 223
    2112:	80 93 d8 00 	sts	0x00D8, r24	; 0x8000d8 <__TEXT_REGION_LENGTH__+0x7e00d8>
    2116:	80 91 e1 00 	lds	r24, 0x00E1	; 0x8000e1 <__TEXT_REGION_LENGTH__+0x7e00e1>
    211a:	8f 7e       	andi	r24, 0xEF	; 239
    211c:	80 93 e1 00 	sts	0x00E1, r24	; 0x8000e1 <__TEXT_REGION_LENGTH__+0x7e00e1>
    2120:	80 91 e2 00 	lds	r24, 0x00E2	; 0x8000e2 <__TEXT_REGION_LENGTH__+0x7e00e2>
    2124:	8f 7e       	andi	r24, 0xEF	; 239
    2126:	80 93 e2 00 	sts	0x00E2, r24	; 0x8000e2 <__TEXT_REGION_LENGTH__+0x7e00e2>
    212a:	80 91 e2 00 	lds	r24, 0x00E2	; 0x8000e2 <__TEXT_REGION_LENGTH__+0x7e00e2>
    212e:	81 60       	ori	r24, 0x01	; 1
    2130:	80 93 e2 00 	sts	0x00E2, r24	; 0x8000e2 <__TEXT_REGION_LENGTH__+0x7e00e2>
    2134:	80 91 80 01 	lds	r24, 0x0180	; 0x800180 <USB_Device_ConfigurationNumber>
    2138:	88 23       	and	r24, r24
    213a:	09 f4       	brne	.+2      	; 0x213e <__vector_10+0x16c>
    213c:	4b c0       	rjmp	.+150    	; 0x21d4 <__vector_10+0x202>
    213e:	84 e0       	ldi	r24, 0x04	; 4
    2140:	8e bb       	out	0x1e, r24	; 30
    2142:	0f b6       	in	r0, 0x3f	; 63
    2144:	f8 94       	cli
    2146:	a8 95       	wdr
    2148:	80 91 60 00 	lds	r24, 0x0060	; 0x800060 <__TEXT_REGION_LENGTH__+0x7e0060>
    214c:	88 61       	ori	r24, 0x18	; 24
    214e:	80 93 60 00 	sts	0x0060, r24	; 0x800060 <__TEXT_REGION_LENGTH__+0x7e0060>
    2152:	10 92 60 00 	sts	0x0060, r1	; 0x800060 <__TEXT_REGION_LENGTH__+0x7e0060>
    2156:	0f be       	out	0x3f, r0	; 63
    2158:	80 91 e1 00 	lds	r24, 0x00E1	; 0x8000e1 <__TEXT_REGION_LENGTH__+0x7e00e1>
    215c:	83 ff       	sbrs	r24, 3
    215e:	26 c0       	rjmp	.+76     	; 0x21ac <__vector_10+0x1da>
    2160:	80 91 e2 00 	lds	r24, 0x00E2	; 0x8000e2 <__TEXT_REGION_LENGTH__+0x7e00e2>
    2164:	83 ff       	sbrs	r24, 3
    2166:	22 c0       	rjmp	.+68     	; 0x21ac <__vector_10+0x1da>
    2168:	80 91 e1 00 	lds	r24, 0x00E1	; 0x8000e1 <__TEXT_REGION_LENGTH__+0x7e00e1>
    216c:	87 7f       	andi	r24, 0xF7	; 247
    216e:	80 93 e1 00 	sts	0x00E1, r24	; 0x8000e1 <__TEXT_REGION_LENGTH__+0x7e00e1>
    2172:	82 e0       	ldi	r24, 0x02	; 2
    2174:	8e bb       	out	0x1e, r24	; 30
    2176:	10 92 80 01 	sts	0x0180, r1	; 0x800180 <USB_Device_ConfigurationNumber>
    217a:	80 91 e1 00 	lds	r24, 0x00E1	; 0x8000e1 <__TEXT_REGION_LENGTH__+0x7e00e1>
    217e:	8e 7f       	andi	r24, 0xFE	; 254
    2180:	80 93 e1 00 	sts	0x00E1, r24	; 0x8000e1 <__TEXT_REGION_LENGTH__+0x7e00e1>
    2184:	80 91 e2 00 	lds	r24, 0x00E2	; 0x8000e2 <__TEXT_REGION_LENGTH__+0x7e00e2>
    2188:	8e 7f       	andi	r24, 0xFE	; 254
    218a:	80 93 e2 00 	sts	0x00E2, r24	; 0x8000e2 <__TEXT_REGION_LENGTH__+0x7e00e2>
    218e:	80 91 e2 00 	lds	r24, 0x00E2	; 0x8000e2 <__TEXT_REGION_LENGTH__+0x7e00e2>
    2192:	80 61       	ori	r24, 0x10	; 16
    2194:	80 93 e2 00 	sts	0x00E2, r24	; 0x8000e2 <__TEXT_REGION_LENGTH__+0x7e00e2>
    2198:	42 e0       	ldi	r20, 0x02	; 2
    219a:	60 e0       	ldi	r22, 0x00	; 0
    219c:	80 e0       	ldi	r24, 0x00	; 0
    219e:	0e 94 7d 06 	call	0xcfa	; 0xcfa <Endpoint_ConfigureEndpoint_Prv>
    21a2:	80 91 f0 00 	lds	r24, 0x00F0	; 0x8000f0 <__TEXT_REGION_LENGTH__+0x7e00f0>
    21a6:	88 60       	ori	r24, 0x08	; 8
    21a8:	80 93 f0 00 	sts	0x00F0, r24	; 0x8000f0 <__TEXT_REGION_LENGTH__+0x7e00f0>
    21ac:	ff 91       	pop	r31
    21ae:	ef 91       	pop	r30
    21b0:	bf 91       	pop	r27
    21b2:	af 91       	pop	r26
    21b4:	9f 91       	pop	r25
    21b6:	8f 91       	pop	r24
    21b8:	7f 91       	pop	r23
    21ba:	6f 91       	pop	r22
    21bc:	5f 91       	pop	r21
    21be:	4f 91       	pop	r20
    21c0:	3f 91       	pop	r19
    21c2:	2f 91       	pop	r18
    21c4:	0f 90       	pop	r0
    21c6:	0f be       	out	0x3f, r0	; 63
    21c8:	0f 90       	pop	r0
    21ca:	1f 90       	pop	r1
    21cc:	18 95       	reti
    21ce:	19 bc       	out	0x29, r1	; 41
    21d0:	1e ba       	out	0x1e, r1	; 30
    21d2:	6b cf       	rjmp	.-298    	; 0x20aa <__vector_10+0xd8>
    21d4:	80 91 e3 00 	lds	r24, 0x00E3	; 0x8000e3 <__TEXT_REGION_LENGTH__+0x7e00e3>
    21d8:	87 fd       	sbrc	r24, 7
    21da:	02 c0       	rjmp	.+4      	; 0x21e0 <__vector_12>
    21dc:	81 e0       	ldi	r24, 0x01	; 1
    21de:	b0 cf       	rjmp	.-160    	; 0x2140 <__vector_10+0x16e>

000021e0 <__vector_12>:
    21e0:	83 e0       	ldi	r24, 0x03	; 3
    21e2:	ae cf       	rjmp	.-164    	; 0x2140 <__vector_10+0x16e>
    21e4:	1f 92       	push	r1
    21e6:	0f 92       	push	r0
    21e8:	0f b6       	in	r0, 0x3f	; 63
    21ea:	0f 92       	push	r0
    21ec:	11 24       	eor	r1, r1
    21ee:	0f 90       	pop	r0
    21f0:	0f be       	out	0x3f, r0	; 63
    21f2:	0f 90       	pop	r0
    21f4:	1f 90       	pop	r1
    21f6:	18 95       	reti

 

Last Edited: Thu. Oct 19, 2017 - 01:51 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Does anyone have any idea as to where the problem is? I unfortunately have only a very limited understanding of AVR assembly.

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

Here is the code which turns on the watchdog timer. Do they both finish within 4 cycles?

 

    20de:	80 91 60 00 	lds	r24, 0x0060	; 0x800060 <__TEXT_REGION_LENGTH__+0x7e0060>
    20e2:	88 61       	ori	r24, 0x18	; 24
    20e4:	80 93 60 00 	sts	0x0060, r24	; 0x800060 <__TEXT_REGION_LENGTH__+0x7e0060>
    20e8:	80 e4       	ldi	r24, 0x40	; 64
    20ea:	80 93 60 00 	sts	0x0060, r24	; 0x800060 <__TEXT_REGION_LENGTH__+0x7e0060>
     85c:	e0 e6       	ldi	r30, 0x60	; 96
     85e:	f0 e0       	ldi	r31, 0x00	; 0
     860:	80 81       	ld	r24, Z
     862:	88 61       	ori	r24, 0x18	; 24
     864:	80 83       	st	Z, r24
     866:	80 e4       	ldi	r24, 0x40	; 64
     868:	80 83       	st	Z, r24