<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forums.obdev.at/app.php/feed/topic/1603" />

	<title>Objective Development Forums</title>
	
	<link href="https://forums.obdev.at/index.php" />
	<updated>2008-09-01T10:57:32+02:00</updated>

	<author><name><![CDATA[Objective Development Forums]]></name></author>
	<id>https://forums.obdev.at/app.php/feed/topic/1603</id>

		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2008-09-01T10:57:32+02:00</updated>

		<published>2008-09-01T10:57:32+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=1603&amp;p=6106#p6106</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=1603&amp;p=6106#p6106"/>
		<title type="html"><![CDATA[question about source code bootloader for atmega32]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=1603&amp;p=6106#p6106"><![CDATA[
hi all. can somebody guide me to build my own bootloader for atmega32??<br /><br />i need to porting avr jtag isp from <!-- m --><a class="postlink" href="http://www.floppyspongeonline.com/automation/isojtagisp/isojtagisp.php">http://www.floppyspongeonline.com/autom ... tagisp.php</a><!-- m --><br /><br />but i would use atmega32<br /><br />thanks<p>Statistics: Posted by Guest — Mon Sep 01, 2008 10:57 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2008-07-29T23:17:58+02:00</updated>

		<published>2008-07-29T23:17:58+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=1603&amp;p=5879#p5879</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=1603&amp;p=5879#p5879"/>
		<title type="html"><![CDATA[USBaspLoader and ATmega32]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=1603&amp;p=5879#p5879"><![CDATA[
Hello again. I discovered that i've made a big mistake. All sizes in datasheet are given in words and word size is 2 bytes. So BOOTLOADER_ADDRESS should be 7800, because this value is given in bytes. I thought that maximum bootloader size is 2048 bytes, but it is 2048 words, or 4096 bytes, So BOOTSZ1 and 0 bits in high fuse byte should be 0 and 1 respectivly. It means that atmega started execution from 4096 byte from flash end, but bootloader was situated at 2048 bytes from flash end. And in this situation bootloader starts ok and only thing that don't work is interrupt handlers. I think atmega startt execution at 4096 from flashend, executes 2048 zeroes(may be they are omitted or treated as nops) and then starts execution of bootloader. <br />So i fixed hfuse byte and my bootloader is detected from pc. Thank you, Christian, for your help!<p>Statistics: Posted by Guest — Tue Jul 29, 2008 11:17 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2008-07-29T22:53:07+02:00</updated>

		<published>2008-07-29T22:53:07+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=1603&amp;p=5878#p5878</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=1603&amp;p=5878#p5878"/>
		<title type="html"><![CDATA[USBaspLoader and ATmega32]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=1603&amp;p=5878#p5878"><![CDATA[
Just made these changes to bootloader code:<br />Makefile:<br />BOOTLOADER_ADDRESS = 0<br /><br />main.c:<br />    //Commented code which moves interrupt table to bootloader section<br />    bootLoaderInit();<br />    odDebugInit();<br />    DBG1(0x00, 0, 0);<br />#ifndef NO_FLASH_WRITE<br />    //GICR = (1 &lt;&lt; IVCE);  /* enable change of interrupt vectors */<br />    //GICR = (1 &lt;&lt; IVSEL); /* move interrupts to boot flash section */<br />#endif<br /><br />So now booloader boots not like bootloader, but like ordinary program. Of course in such state it can't load a program to flash. But it works! It is recognised by laptop. I don't know how to make bootloader to make it to work. I can't see where are interrupt vectors are really situated after movement.<p>Statistics: Posted by Guest — Tue Jul 29, 2008 10:53 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2008-07-29T22:33:37+02:00</updated>

		<published>2008-07-29T22:33:37+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=1603&amp;p=5877#p5877</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=1603&amp;p=5877#p5877"/>
		<title type="html"><![CDATA[USBaspLoader and ATmega32]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=1603&amp;p=5877#p5877"><![CDATA[
Thank you for your advice, Christian. I configured PowerSwitch, flashed by board and it works! I didn't try to use PowerSwitch, but it is detected by my laptop and lsusb -v tells some information. So it works.<br />Then i tried to use INT1 and it works too.<br />Here are interrupt vectors table:<br />00000000 &lt;__vectors&gt;:<br />   0:   0c 94 57 00     jmp     0xae    ; 0xae &lt;__ctors_end&gt;<br />   4:   0c 94 74 00     jmp     0xe8    ; 0xe8 &lt;__bad_interrupt&gt;<br />   8:   0c 94 98 01     jmp     0x330   ; 0x330 &lt;__vector_2&gt;<br />   c:   0c 94 74 00     jmp     0xe8    ; 0xe8 &lt;__bad_interrupt&gt;<br />  10:   0c 94 74 00     jmp     0xe8    ; 0xe8 &lt;__bad_interrupt&gt;<br /><br />You see, that jmp takes 4 bytes, but datasheet tells that jmp in this table must take 2 bytes. I think i don't really understand interrupts or it is an error in datasheet. Anyway, avr-usb driver works perfectly, but USBaspLoader don't.<p>Statistics: Posted by Guest — Tue Jul 29, 2008 10:33 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[christian]]></name></author>
		<updated>2008-07-29T17:51:50+02:00</updated>

		<published>2008-07-29T17:51:50+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=1603&amp;p=5874#p5874</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=1603&amp;p=5874#p5874"/>
		<title type="html"><![CDATA[USBaspLoader and ATmega32]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=1603&amp;p=5874#p5874"><![CDATA[
Please start with a less complex example, something which does not require the boot section and switching the interrupt vectors. When that works, you can at least be sure that the hardware infrastructure is OK.<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=8">christian</a> — Tue Jul 29, 2008 5:51 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2008-07-28T21:27:15+02:00</updated>

		<published>2008-07-28T21:27:15+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=1603&amp;p=5864#p5864</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=1603&amp;p=5864#p5864"/>
		<title type="html"><![CDATA[USBaspLoader and ATmega32]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=1603&amp;p=5864#p5864"><![CDATA[
Tried to use INT0 instead of INT1. Soldered PD3 to PD2 and disabled PD3. Than i modified usbconfig.h to reflect changes. Same behavior. It reboots continuosly when there is some activity on D+. I dont't know what to do. I tried almost everything, but bootloader doesn't work <img class="smilies" src="./../../../images/smilies/icon_sad.gif" alt=":(" title="Sad" /><p>Statistics: Posted by Guest — Mon Jul 28, 2008 9:27 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2008-07-28T12:41:06+02:00</updated>

		<published>2008-07-28T12:41:06+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=1603&amp;p=5857#p5857</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=1603&amp;p=5857#p5857"/>
		<title type="html"><![CDATA[USBaspLoader and ATmega32]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=1603&amp;p=5857#p5857"><![CDATA[
Hello, everybody. I got a trouble with usbasploader and atmega32. I wired D+ to PD3(INT1), D- to PD6, jumper to PD7. My board doen't recognized by pc. I have added some code to main.c, so i can see when controller is rebooting and so on. I see, that after board starts it behaves ok, it recognizes the jumper position and so on. But when PC is sending anything over D+ line - the board reboots. I read MCUCSR register and it is filled by zeroes after such reboot. If i disable interrupt handling board dont reboots, but doesn't work too. I have added some asm code to interrupt handler, but that code never executes.<br />I think that after an interrupt on D+ controller jumps not to INT1 handler, but to 0 or other place. The datasheet says that INT1 vector position is BOOTLOADER_START+0x04, INT0 - +0x02 and so on. But i did avr-objdump -d main.bin and saw that INT1 vector was placed at +0x08 position. <br />I built my project with latest gcc-avr in Gnetoo Linux and with winavr gcc-3.4.6 - results are absolutly same. Also i tried to simulate atmega32 in Proteus, but it reboots after any activity on D+ line.<br />I use 5V power source, tried to solder zener diodes(3V6), pull-down resistor(1M1) to D+, but that didn't help. Tried to use another atmega32, but results stay the same. I googled for a long time, but nothing helps <img class="smilies" src="./../../../images/smilies/icon_sad.gif" alt=":(" title="Sad" /><br />Unfortunatly, i cant debug avr-usb driver, because my usart over max232 don't works too <img class="smilies" src="./../../../images/smilies/icon_smile.gif" alt=":)" title="Smile" />   I'll try to use INT0 tomorrow.<br />Here are relevant parts of my project:<br />usbconfig.h:<br />#define USB_INTR_CFG            MCUCR<br />#define USB_INTR_CFG_SET        ((1 &lt;&lt; ISC10) | (1 &lt;&lt; ISC11))<br />#define USB_INTR_CFG_CLR        0<br />#define USB_INTR_ENABLE         GICR<br />#define USB_INTR_ENABLE_BIT     INT1<br />#define USB_INTR_PENDING        GIFR <br />#define USB_INTR_PENDING_BIT    INTF1<br />#define USB_INTR_VECTORSIG_INTERRUPT1  //tried SIG_INTERRUPT0 to place handler at +0x04 address, but no success<br /><br />bootloaderconfig.h:<br />#define USB_CFG_IOPORTNAME      D<br />#define USB_CFG_DMINUS_BIT      6<br />#define USB_CFG_DPLUS_BIT       3<br />#define JUMPER_BIT  7<br />static inline void  bootLoaderInit(void)<br />{<br />    PORTD |= (1 &lt;&lt; JUMPER_BIT);     /* activate pull-up */<br />    //if(!(MCUCSR &amp; (1 &lt;&lt; EXTRF)))    /* If this was not an external reset, ignore */<br />    //    leaveBootloader();<br />    MCUCSR = 0;                     /* clear all reset flags for next time */<br />}<br /><br />Makefile:<br />F_CPU = 16000000<br />DEVICE = atmega32<br />BOOTLOADER_ADDRESS = 7800<br />FUSEOPT = $(FUSEOPT_168)<br />LOCKOPT = -U lock:w:0x2f:m<br /><br />PROGRAMMER = -c stk500v2 -P avrdoper<br /># PROGRAMMER contains AVRDUDE options to address your programmer<br /><br />FUSEOPT_32 = -U hfuse:w:0xc0:m -U lfuse:w:0x8f:m<br />FUSEOPT_8 = -U hfuse:w:0xc0:m -U lfuse:w:0x9f:m<br />FUSEOPT_88 = -U hfuse:w:0xd6:m -U lfuse:w:0xdf:m -U efuse:w:0x00:m<br />FUSEOPT_168 = -U hfuse:w:0xd6:m -U lfuse:w:0xdf:m -U efuse:w:0x00:m<br /><br />main.c:<br />   /*  DEBUG  */<br />// enable PB1 as output<br />#define LED1_INIT DDRD|=_BV(PD4)<br />// // led on, pin=0<br />#define LED1_OFF PORTD&amp;=~_BV(PD4)<br />// // led off, pin=1<br />#define LED1_ON PORTD|=_BV(PD4)<br />// enable PB1 as output<br />#define LED2_INIT DDRD|=_BV(PD5)<br />// // led on, pin=0<br />#define LED2_OFF PORTD&amp;=~_BV(PD5)<br />// // led off, pin=1<br />#define LED2_ON PORTD|=_BV(PD5)<br /><br />int main(void)<br />{<br />LED1_INIT;<br />LED2_INIT;<br />LED1_ON;<br />LED2_ON;<br />_delay_ms(200);<br /><br />    /* initialize  */<br />    bootLoaderInit();<br />    odDebugInit();<br />    DBG1(0x00, 0, 0);<br />#ifndef NO_FLASH_WRITE<br />    GICR = (1 &lt;&lt; IVCE);  /* enable change of interrupt vectors */<br />    GICR = (1 &lt;&lt; IVSEL); /* move interrupts to boot flash section */<br />#endif<br />    if(bootLoaderCondition()){<br />        uint i = 0;<br />        initForUsbConnectivity();<br />        do{<br />            LED2_OFF;<br />            usbPoll();<br />#if BOOTLOADER_CAN_EXIT<br />            if(requestBootLoaderExit){<br />                if(--i == 0)<br />                    break;<br />            }<br />#endif<br />        }while(bootLoaderCondition());  /* main event loop */<br />    }<br />    LED1_OFF;<br />    _delay_ms(200);<br />    leaveBootloader();<br />    return 0;<br />}<br />/*<br />After start we see 2 leds, wait 200ms. If led2 is on and led1 - off it means that bootloader condition don't met. If led1 is on and led2 is off  - we are in main loop. So if we reboot somewhere during this loop we will see two leds on again.<br />*/<br /><br /><br />main.bin:<br />main.bin:     file format elf32-avr<br /><br />Disassembly of section .text:<br /><br />00007800 &lt;__vectors&gt;:<br />    7800:0c 94 53 3c jmp0x78a6 &lt;__init&gt;<br />    7804:0c 94 6e 3c jmp0x78dc &lt;__bad_interrupt&gt;<br />    7808:0c 94 8d 3c jmp0x791a &lt;__vector_2&gt;<br />    780c:0c 94 6e 3c jmp0x78dc &lt;__bad_interrupt&gt;<br />    7810:0c 94 6e 3c jmp0x78dc &lt;__bad_interrupt&gt;<br />    7814:0c 94 6e 3c jmp0x78dc &lt;__bad_interrupt&gt;<br />    7818:0c 94 6e 3c jmp0x78dc &lt;__bad_interrupt&gt;<br />    781c:0c 94 6e 3c jmp0x78dc &lt;__bad_interrupt&gt;<br />    7820:0c 94 6e 3c jmp0x78dc &lt;__bad_interrupt&gt;<br />    7824:0c 94 6e 3c jmp0x78dc &lt;__bad_interrupt&gt;<br />    7828:0c 94 6e 3c jmp0x78dc &lt;__bad_interrupt&gt;<br />    782c:0c 94 6e 3c jmp0x78dc &lt;__bad_interrupt&gt;<br />    7830:0c 94 6e 3c jmp0x78dc &lt;__bad_interrupt&gt;<br />    7834:0c 94 6e 3c jmp0x78dc &lt;__bad_interrupt&gt;<br />    7838:0c 94 6e 3c jmp0x78dc &lt;__bad_interrupt&gt;<br />    783c:0c 94 6e 3c jmp0x78dc &lt;__bad_interrupt&gt;<br />    7840:0c 94 6e 3c jmp0x78dc &lt;__bad_interrupt&gt;<br />    7844:0c 94 6e 3c jmp0x78dc &lt;__bad_interrupt&gt;<br />    7848:0c 94 6e 3c jmp0x78dc &lt;__bad_interrupt&gt;<br />    784c:0c 94 6e 3c jmp0x78dc &lt;__bad_interrupt&gt;<br />    7850:0c 94 6e 3c jmp0x78dc &lt;__bad_interrupt&gt;<br />   ********************************************<br /><br />0000791a &lt;__vector_2&gt;:<br />    791a:cf 93       pushr28<br />    791c:cf b7       inr28, 0x3f; 63<br />    791e:cf 93       pushr28<br /><br />00007920 &lt;waitForJ&gt;:<br />    7920:86 9b       sbis0x10, 6; 16<br />    7922:fe cf       rjmp.-4      ; 0x7920 &lt;waitForJ&gt;<br /><br />****************************************************<p>Statistics: Posted by Guest — Mon Jul 28, 2008 12:41 pm</p><hr />
]]></content>
	</entry>
	</feed>
