<?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/3909" />

	<title>Objective Development Forums</title>
	
	<link href="https://forums.obdev.at/index.php" />
	<updated>2012-05-15T11:15:19+02:00</updated>

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

		<entry>
		<author><name><![CDATA[christian]]></name></author>
		<updated>2012-05-15T11:15:19+02:00</updated>

		<published>2012-05-15T11:15:19+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=3909&amp;p=21609#p21609</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=3909&amp;p=21609#p21609"/>
		<title type="html"><![CDATA[Re: ATtiny85 self programming flash.]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=3909&amp;p=21609#p21609"><![CDATA[
Thanks a lot for this great port to the ATTiny85!<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=8">christian</a> — Tue May 15, 2012 11:15 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[EmbeddedCreations]]></name></author>
		<updated>2012-05-13T23:41:45+02:00</updated>

		<published>2012-05-13T23:41:45+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=3909&amp;p=21593#p21593</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=3909&amp;p=21593#p21593"/>
		<title type="html"><![CDATA[Re: ATtiny85 self programming flash.]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=3909&amp;p=21593#p21593"><![CDATA[
This thread helped me understand why there wasn't a V-USB based bootloader for the ATtiny85 when I went looking for one.  I did figure out how to work around the issues with the ATtiny architecture and updated Christian's USBaspLoader project to have ATtiny85 support.  It's still a work in progress, the main thing I'd like to improve is the program size, it's currently taking up 1/3 of the 8kB flash on the ATtiny85.<br /><br /><!-- m --><a class="postlink" href="http://embedded-creations.com/projects/attiny85-usb-bootloader-overview/">http://embedded-creations.com/projects/ ... -overview/</a><!-- m --><p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=6720">EmbeddedCreations</a> — Sun May 13, 2012 11:41 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[pe0fko]]></name></author>
		<updated>2010-03-30T16:15:38+02:00</updated>

		<published>2010-03-30T16:15:38+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=3909&amp;p=13915#p13915</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=3909&amp;p=13915#p13915"/>
		<title type="html"><![CDATA[Re: ATtiny85 self programming flash.]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=3909&amp;p=13915#p13915"><![CDATA[
<blockquote><div><cite>christian wrote:</cite>This means that not even interrupts (such as the USB interrupt) can execute.</div></blockquote><br />Did try a simulation of the program command with a _delay_ms, did not put the cli() sei() around it  <img class="smilies" src="./../../../images/smilies/icon_confused.gif" alt=":?" title="Confused" /> That did confuse me, that it was running with a long (30ms) delay, but with interrupts on it was still running the low level of usb communication.<br /><br /><blockquote><div><cite>christian wrote:</cite>After the host has read the status, flash the data from the main loop.</div></blockquote><br />Will try that way, need to find a quiet moment in the loop.<br /><br />The program is running if ignoring the error on the program command, it will also depend on the error handling of the PC lib I expect. Not that nice programming if I do it that way  <img class="smilies" src="./../../../images/smilies/icon_sad.gif" alt=":(" title="Sad" /><br /><br />Thanks Christian for the comment!!<br />Fred Krom<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=2772">pe0fko</a> — Tue Mar 30, 2010 4:15 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[christian]]></name></author>
		<updated>2010-03-06T18:16:24+02:00</updated>

		<published>2010-03-06T18:16:24+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=3909&amp;p=13544#p13544</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=3909&amp;p=13544#p13544"/>
		<title type="html"><![CDATA[Re: ATtiny85 self programming flash.]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=3909&amp;p=13544#p13544"><![CDATA[
You keep the interrupts disabled while you do the busy wait. This way you lock out the driver during the write operation. See bootloadHID for an example where to disable interrupts and where to keep them enabled.<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=8">christian</a> — Sat Mar 06, 2010 6:16 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[uchar]]></name></author>
		<updated>2010-03-06T00:27:55+02:00</updated>

		<published>2010-03-06T00:27:55+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=3909&amp;p=13534#p13534</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=3909&amp;p=13534#p13534"/>
		<title type="html"><![CDATA[Re: ATtiny85 self programming flash.]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=3909&amp;p=13534#p13534"><![CDATA[
Excuse, has forgotten to write - I use ATMega8.<br /><br />I use AVRStudio, in project customisations has specified compiler AVR-GCC. Function boot_program_page is placed in area bootloader.<br /><br /><div class="codebox"><p>Code: </p><pre><code>void BOOTLOADER_SECTION  boot_program_page (uint32_t page)<br />    {<br />        uint16_t i;<br /><br />   <br />      uint8_t sreg;<br /><br />      uint8_t ser_1;<br />      uint8_t ser_2;<br /><br />      uint16_t page_offset = 0;<br /><br /><br />       <br /><br />      ser_1 = 0x02; <br />         ser_2 = 0x49; <br />         <br /><br />         DDRC = 1;   //LED OFF<br />         PORTC = 1;<br /><br /> <br />        sreg = SREG;<br />      <br />      <br />       <br />          <br />      cli();<br />         <br />         eeprom_busy_wait ();<br /><br />           boot_page_erase (page);<br /><br />         boot_spm_busy_wait ();<br /><br />         <br />         eeprom_busy_wait ();<br /><br />         boot_page_fill(page + page_offset, ser_1);<br /><br />         boot_spm_busy_wait ();<br /><br />         <br />         eeprom_busy_wait ();<br /><br />         boot_page_write(page);<br /><br />         boot_spm_busy_wait ();<br /><br />         <br />         eeprom_busy_wait ();<br /><br />         boot_rww_enable ();<br /><br />         boot_spm_busy_wait ();<br /><br />         <br /><br />         SREG = sreg;<br /><br /><br /><br />         DDRC = 1;   //LED ON<br />         PORTC = 0;<br /><br /><br /><br /><br />      <br />    }<br />   <br />   <br /><br /><br />   <br />   uchar usbFunctionWrite(uchar *data, uchar len)<br />{<br /><br /><br />      <br />         <br />         DDRC = 1;   //LED ON<br />         PORTC = 0;            <br /><br />            boot_program_page(0x1ff8);<br />            <br />         return 1; <br /><br /><br />}<br /></code></pre></div><br /><br /><br />The host program produces an error - it is returned by function usbhidSetReport.<br /><div class="codebox"><p>Code: </p><pre><code><br />f((err = usbhidSetReport(dev, buffer, sizeof(buffer))) != 0)<br />         {              <br />            fprintf(stderr, &quot;error FLASH-write command: %s\n&quot;, usbErrorMessage(err));<br />         } <br /><br /></code></pre></div><br />Tried to write to area NRWW and in area RWW - the error is always.<br /><br />I hope for your help <img class="smilies" src="./../../../images/smilies/icon_smile.gif" alt=":)" title="Smile" /> <br /><br /><br />P.S. The example from your site (bootloadHID) works for me.<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=3029">uchar</a> — Sat Mar 06, 2010 12:27 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[christian]]></name></author>
		<updated>2010-03-05T18:12:13+02:00</updated>

		<published>2010-03-05T18:12:13+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=3909&amp;p=13529#p13529</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=3909&amp;p=13529#p13529"/>
		<title type="html"><![CDATA[Re: ATtiny85 self programming flash.]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=3909&amp;p=13529#p13529"><![CDATA[
This works on devices which have Read-While-Write capability (probably all devices with a boot loader section). It does NOT work on the ATTiny85.<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=8">christian</a> — Fri Mar 05, 2010 6:12 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[uchar]]></name></author>
		<updated>2010-03-05T18:01:23+02:00</updated>

		<published>2010-03-05T18:01:23+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=3909&amp;p=13527#p13527</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=3909&amp;p=13527#p13527"/>
		<title type="html"><![CDATA[Re: ATtiny85 self programming flash.]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=3909&amp;p=13527#p13527"><![CDATA[
Thanks for the answer, Christian.<br />On your site there is an example - bootloadHID - <!-- m --><a class="postlink" href="http://www.obdev.at/products/vusb/bootloadhid.html">http://www.obdev.at/products/vusb/bootloadhid.html</a><!-- m --><br />I have checked up - it works, but all functions are called from usbFunctionWrite.<br />Explain please why this example works?<br /><br /><div class="codebox"><p>Code: </p><pre><code>uchar usbFunctionWrite(uchar *data, uchar len)<br />{<br />union {<br />    addr_t  l;<br />    uint    s&#91;sizeof(addr_t)/2&#93;;<br />    uchar   c&#91;sizeof(addr_t)&#93;;<br />}       address;<br />uchar   isLast;<br /><br />    address.l = currentAddress;<br />    if(offset == 0){<br />        DBG1(0x30, data, 3);<br />        address.c&#91;0&#93; = data&#91;1&#93;;<br />        address.c&#91;1&#93; = data&#91;2&#93;;<br />#if (FLASHEND) &gt; 0xffff /* we need long addressing */<br />        address.c&#91;2&#93; = data&#91;3&#93;;<br />        address.c&#91;3&#93; = 0;<br />#endif<br />        data += 4;<br />        len -= 4;<br />    }<br />    DBG1(0x31, (void *)&amp;currentAddress, 4);<br />    offset += len;<br />    isLast = offset &amp; 0x80; /* != 0 if last block received */<br />    do{<br />        addr_t prevAddr;<br />#if SPM_PAGESIZE &gt; 256<br />        uint pageAddr;<br />#else<br />        uchar pageAddr;<br />#endif<br />        DBG1(0x32, 0, 0);<br />        pageAddr = address.s&#91;0&#93; &amp; (SPM_PAGESIZE - 1);<br />        if(pageAddr == 0){              /* if page start: erase */<br />            DBG1(0x33, 0, 0);<br />#ifndef TEST_MODE<br />            cli();<br />            boot_page_erase(address.l); /* erase page */<br />            sei();<br />            boot_spm_busy_wait();       /* wait until page is erased */<br />#endif<br />        }<br />        cli();<br />        boot_page_fill(address.l, *(short *)data);<br />        sei();<br />        prevAddr = address.l;<br />        address.l += 2;<br />        data += 2;<br />        /* write page when we cross page boundary */<br />        pageAddr = address.s&#91;0&#93; &amp; (SPM_PAGESIZE - 1);<br />        if(pageAddr == 0){<br />            DBG1(0x34, 0, 0);<br />#ifndef TEST_MODE<br />            cli();<br />            boot_page_write(prevAddr);<br />            sei();<br />            boot_spm_busy_wait();<br />#endif<br />        }<br />        len -= 2;<br />    }while(len);<br />    currentAddress = address.l;<br />    DBG1(0x35, (void *)&amp;currentAddress, 4);<br />    return isLast;<br />}<br /></code></pre></div><p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=3029">uchar</a> — Fri Mar 05, 2010 6:01 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[christian]]></name></author>
		<updated>2010-03-04T16:44:08+02:00</updated>

		<published>2010-03-04T16:44:08+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=3909&amp;p=13506#p13506</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=3909&amp;p=13506#p13506"/>
		<title type="html"><![CDATA[Re: ATtiny85 self programming flash.]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=3909&amp;p=13506#p13506"><![CDATA[
Whey you receive the data in (e.g.) usbFunctionWrite(), the last USB transfer is not complete. The host wants to read a zero byte block as a kind of ACK. The host polls for this reply while you are in usbFunctionWrite(). If you block the CPU during this time, the host won't receive a NAK to its polling and thus produce an error.<br /><br />You must ensure that the transfer is complete before you block the CPU. HID for this purpose is not a good idea because the host polls the interrupt endpoint in any case. I'd recommend a custom class device.<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=8">christian</a> — Thu Mar 04, 2010 4:44 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[uchar]]></name></author>
		<updated>2010-03-04T15:11:26+02:00</updated>

		<published>2010-03-04T15:11:26+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=3909&amp;p=13505#p13505</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=3909&amp;p=13505#p13505"/>
		<title type="html"><![CDATA[Re: ATtiny85 self programming flash.]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=3909&amp;p=13505#p13505"><![CDATA[
Respected Christian!<br /><br />I use an example hid-data and  I too try to write the data in memory of programs - in area NRWW. I use functions boot_page_erase, boot_page_fill and boot_page_write which are in function boot_program_page.<br /><br />Function boot_program_page is placed in bootloader area.<br />It is called from function usbFuctionWrite.<br />But the host program produces an error - Communication error with device. But the microcontroller writes the data in memory of programs successfully.<br /><br />Prompt please in what there can be a reason?<br /><br />I am sorry for my English.<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=3029">uchar</a> — Thu Mar 04, 2010 3:11 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[christian]]></name></author>
		<updated>2010-02-28T18:47:07+02:00</updated>

		<published>2010-02-28T18:47:07+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=3909&amp;p=13448#p13448</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=3909&amp;p=13448#p13448"/>
		<title type="html"><![CDATA[Re: ATtiny85 self programming flash.]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=3909&amp;p=13448#p13448"><![CDATA[
Since the Tiny85 does not have read-while-write capability, the CPU is halted during programming. This means that not even interrupts (such as the USB interrupt) can execute. The host won't receive any responses to USB requests during this time.<br /><br />You might get around the problem if you ensure that all pending USB communication is done before you flash the data. Then wait for 10 ms before you resume USB communication. Note that you must not flash the data from usbFunctionWrite(), only store the data and return with success. After the host has read the status, flash the data from the main loop.<br /><br />You would still get an error if the operating system wants to read descriptors during this time, though.<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=8">christian</a> — Sun Feb 28, 2010 6:47 pm</p><hr />
]]></content>
	</entry>
	</feed>
