<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ntsdt.net &#187; avrdude</title>
	<atom:link href="http://ntsdt.net/tag/avrdude/feed/" rel="self" type="application/rss+xml" />
	<link>http://ntsdt.net</link>
	<description>never the same day twice</description>
	<lastBuildDate>Wed, 02 Jun 2010 16:35:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Burning the Arduino Bootloader</title>
		<link>http://ntsdt.net/2009/08/22/burning-the-arduino-bootloader/</link>
		<comments>http://ntsdt.net/2009/08/22/burning-the-arduino-bootloader/#comments</comments>
		<pubDate>Sat, 22 Aug 2009 15:02:01 +0000</pubDate>
		<dc:creator>lukus</dc:creator>
				<category><![CDATA[arduino]]></category>
		<category><![CDATA[hardware]]></category>
		<category><![CDATA[avrdude]]></category>
		<category><![CDATA[bootloader]]></category>
		<category><![CDATA[electronics]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://ntsdt.net/?p=245</guid>
		<description><![CDATA[The Arduino bootloader is a small program burnt into the ATmega&#8217;s flash memory, which enables sketches to be uploaded without the use of an external programming board.  Any new ATmega8/168/328p microprocessor needs to be programmed with a version of the Arduino bootloader firmware before it can be used with the Arduino IDE.
Many places sell ATmega [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://arduino.cc/en/Tutorial/Bootloader" target="_blank">Arduino bootloader </a>is a small program burnt into the ATmega&#8217;s flash memory, which enables sketches to be uploaded without the use of an external programming board.  Any new ATmega8/168/328p microprocessor needs to be programmed with a version of the Arduino bootloader firmware before it can be used with the Arduino IDE.</p>
<p>Many places sell ATmega chips with the Arduino bootloader pre-loaded. To actually burn the bootloader yourself, you <strong>do need</strong> an external programmer.  Fear not though &#8211; in a previous post, I discovered how to use an Arduino board (together with the mega-isp project) as a make-shift external programmer -&gt; <a href="http://ntsdt.net/2009/08/07/programming-an-atmega8-using-arduino/" target="_blank">see this post for details</a>.</p>
<p><span id="more-245"></span></p>
<h3>Putting the Boot-in..</h3>
<p>The version of the bootloader that you need to use, depends on the type of hardware that you intend to program.  The Arduino IDE supplies versions of the bootloader for a range of ATmega / Arduino combinations .. see the &#8216;./hardware/bootloaders/&#8217; sub-directory within your arduino installation directory for more info.</p>
<p>There are also custom versions of the bootloader created by third-parties -&gt; ladyada has produced some <a href="http://www.ladyada.net/library/arduino/bootloader.html" target="_blank">bootloader hacks</a> and another <a href="http://www.wulfden.org/TheShoppe/freeduino/ADABOOT.shtml" target="_blank">unified version of the bootloader can be found here</a>.</p>
<div id="attachment_246" class="wp-caption alignright" style="width: 310px"><img class="size-medium wp-image-246 " title="atmega8" src="http://ntsdt.net/wp-content/uploads/2009/08/atmega8-300x225.jpg" alt="Atmel's ATmega8 microprocessor" width="300" height="225" /><p class="wp-caption-text">Atmel&#39;s ATmega8 microprocessor</p></div>
<p>Once you&#8217;ve decided which bootloader you want to use, you can use AVRdude to upload the code.</p>
<h3>Steps Required to Burn the Bootloader</h3>
<ol>
<li>Unlock the bootloader segment</li>
<li>Upload the bootloader code</li>
<li>Relock the bootloader segment</li>
</ol>
<h4>Step 1: Unlock</h4>
<p>First of all, it&#8217;s a good idea to make sure that you can communicate with your programmer successfully.  To do so, you can issue a simple command via AVRdude, which will give you a nice &#8216;all clear&#8217; status message as long as everything is set-up correctly.</p>
<p>The parameters that you use might vary according to your system settings and the external programmer you&#8217;re using.</p>
<pre class="code">avrdude -p m8 -P /dev/ttyUSB0 -c avrisp -b 19200</pre>
<p>Briefly,<em> &#8216;-p&#8217;</em> defines the chip I&#8217;m programming, <em>&#8216;-P&#8217;</em> is the port that my programmer is connected to, <em>&#8216;-c&#8217;</em> is the programmer type and the baud-rate is specified by <em>&#8216;-b&#8217;</em>.  You can run <em>&#8216;avrdude &#8211;help&#8217;</em> to discover the full range of options.</p>
<p>This returned:</p>
<pre class="code">avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.13s

avrdude: Device signature = 0x1e9307

avrdude: safemode: Fuses OK

avrdude done.  Thank you.</pre>
<p>.. which is good.  This means that the stage is set for programming and we can begin to set the fuses to unlock the bootloader segment of the AVRdude.</p>
<p>Each ATmega chip has a number of Fuses which can be set.  I think of the fuses as configuration bits -&gt; they define the way that the chip is going to function on a very low level.  I&#8217;ve been using a <a href="http://fusecalc.engbedded.com/" target="_blank">fuse-calculator</a> to simplify the process, and I&#8217;d suggest that you do the same.</p>
<pre class="code">avrdude -p m8 -P /dev/ttyUSB0 -c avrisp -b 19200 -e -U lock:w:0x3F:m -U lfuse:w:0xc4:m -U hfuse:w:0xd9:m</pre>
<p>The <em>&#8216;-U lock:w:0&#215;3F:m&#8217;</em> performs the unlock and <em>&#8216;-U lfuse:w:0xc4:m -U hfuse:w:0xd9:m&#8217;</em> is used to set the chip&#8217;s low and high fuse values.</p>
<p>I want to use this particular ATmega chip as a minimal Arduino, so I&#8217;ve set the fuses to instruct the chip to use it&#8217;s own internal 8 MHz oscillator rather than an external crystal oscillator.</p>
<pre class="code">avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.13s

avrdude: Device signature = 0x1e9307
avrdude: erasing chip
avrdude: reading input file "0xc4"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.04s

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xc4:
avrdude: load data lfuse data from input file 0xc4:
avrdude: input file 0xc4 contains 1 bytes
avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.04s

avrdude: verifying ...
avrdude: 1 bytes of lfuse verified
avrdude: reading input file "0xd9"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.04s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xd9:
avrdude: load data hfuse data from input file 0xd9:
avrdude: input file 0xd9 contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.04s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified

avrdude: safemode: Fuses OK

avrdude done.  Thank you.</pre>
<h4>Step 2: The Burn</h4>
<p>The chip has now been set up &#8211; the next stage involves uploading the new firmware.</p>
<pre class="code">avrdude -p m8 -P /dev/ttyUSB0 -c avrisp -b 19200 -D -U flash:w:/opt/arduino/hardware/bootloaders/atmega8/ATmegaBOOT.hex</pre>
<p>&#8230; which produces &#8230;</p>
<h4>Step 3: Re-lock</h4>
<p>The final stage involves re-setting the lock fuse:</p>
<pre class="code">avrdude -p m8 -P /dev/ttyUSB0 -c avrisp -b 19200 -U lock:w:0x0F:m</pre>
<p>And that&#8217;s it!</p>
]]></content:encoded>
			<wfw:commentRss>http://ntsdt.net/2009/08/22/burning-the-arduino-bootloader/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>programming an atmega8 using arduino</title>
		<link>http://ntsdt.net/2009/08/07/programming-an-atmega8-using-arduino/</link>
		<comments>http://ntsdt.net/2009/08/07/programming-an-atmega8-using-arduino/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 20:44:42 +0000</pubDate>
		<dc:creator>lukus</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[atmega]]></category>
		<category><![CDATA[avrdude]]></category>
		<category><![CDATA[electronics]]></category>
		<category><![CDATA[programmer]]></category>

		<guid isPermaLink="false">http://ntsdt.net/?p=184</guid>
		<description><![CDATA[The ATmega8/168/328 are a range of microprocessors at the heart of the Arduino.  Rather than having to include an external Arduino board with my projects, I&#8217;d like to be able to create self-contained devices which have the ATmega chip embedded.
Programming the ATmega
It&#8217;s possible to program Atmel microprocessors using an Arduino board and the megaISP [...]]]></description>
			<content:encoded><![CDATA[<p>The ATmega8/168/328 are a range of microprocessors at the heart of the Arduino.  Rather than having to include an external Arduino board with my projects, I&#8217;d like to be able to create self-contained devices which have the ATmega chip embedded.</p>
<h3>Programming the ATmega</h3>
<p>It&#8217;s possible to program Atmel microprocessors using an Arduino board and the megaISP project.  This post documents my attempt.</p>
<p><span id="more-184"></span></p>
<p>Before starting of got hold of a copy of the datasheet for the ATmega8 (<a href="http://www.atmel.com/dyn/resources/prod_documents/doc2486.pdf)" target="_blank">http://www.atmel.com/dyn/resources/prod_documents/doc2486.pdf</a>)</p>
<h3>Step 1: Upload mega-isp to Arduino</h3>
<p>I downloaded the mega-isp source, and uploaded it to my Arduino board.  The source can be found at google code (<a href="http://code.google.com/p/mega-isp/" target="_blank">http://code.google.com/p/mega-isp/</a>).</p>
<h3>Step 2: Set up breadboard</h3>
<div class="wp-caption alignleft" style="width: 510px"><img title="mega-isp: programming an atmega8 with arduino" src="http://farm3.static.flickr.com/2447/3798709025_dc18d9e25a.jpg" alt="mega-isp: programming an atmega8 with arduino" width="500" height="375" /><p class="wp-caption-text">mega-isp: programming an atmega8 with arduino</p></div>
<p>First of all, I set up the breadboard according the advice given at <a href="http://www.uchobby.com/index.php/2007/11/04/arduino-avr-in-system-programmer-isp/" target="_blank">http://www.uchobby.com/index.php/2007/11/04/arduino-avr-in-system-programmer-isp/</a></p>
<p>The article mentions something called a bypass capacitor .. which is something I hadn&#8217;t come across before.  Basically, it&#8217;s a small capacitor that&#8217;s used to smooth out small changes in voltage &#8211; and should be used whenever you set up a microprocessor in a circuit.  I learnt about them here (<a href="http://www.seattlerobotics.org/Encoder/jun97/basics.html" target="_blank">http://www.seattlerobotics.org/Encoder/jun97/basics.html</a>)</p>
<p>Because I&#8217;m trying to program an ATmega8 (and not the Tiny18 mentioned in the  article) I needed to adjust the pins.  I also added another LED to signal when megaisp is actually programming (which was mentioned in the Arduino source code).</p>
<div id="attachment_232" class="wp-caption alignright" style="width: 310px"><img class="size-medium wp-image-232 " title="ATMEGA8.pinconfig" src="http://ntsdt.net/wp-content/uploads/2009/08/ATMEGA8.pinconfig-300x273.png" alt="ATmega8/168/328p pinout diagram" width="300" height="273" /><p class="wp-caption-text">ATmega8/168/328p pinout diagram</p></div>
<p>The only pins that I needed to consider were:</p>
<table border="0">
<tbody>
<tr>
<th colspan="3"><strong>The SPI interface</strong></th>
</tr>
<tr>
<td>ATMEGA-PIN19</td>
<td>⇔</td>
<td>ARDUINO-PIN13(SCK)</td>
</tr>
<tr>
<td>ATMEGA-PIN18</td>
<td>⇔</td>
<td>ARDUINO-PIN12(MISO)</td>
</tr>
<tr>
<td>ATMEGA-PIN17</td>
<td>⇔</td>
<td>ARDUINO-PIN11(MOSI)</td>
</tr>
<tr>
<th colspan="3"><strong>Power / Gnd</strong><br />
(I added a bypass capacitor between 7/22 on the atmega)</th>
</tr>
<tr>
<td>ATMEGA-PIN8</td>
<td>⇔</td>
<td>ARDUINO-GND</td>
</tr>
<tr>
<td>ATMEGA-PIN22</td>
<td>⇔</td>
<td>ARDUINO-GND</td>
</tr>
<tr>
<td>ATMEGA-PIN7</td>
<td>⇔</td>
<td>ARDUINO-5V</td>
</tr>
<tr>
<td>ATMEGA-PIN20</td>
<td>⇔</td>
<td>ARDUINO-5V</td>
</tr>
<tr>
<th colspan="3"><strong>Reset</strong></th>
</tr>
<tr>
<td>ATMEGA-PIN1</td>
<td>⇔</td>
<td>ARDUINO-PIN10</td>
</tr>
<tr>
<th colspan="3"><strong>Status LEDs</strong><br />
(each connected to ground via a resistor)</th>
</tr>
<tr>
<td>heartbeat LED</td>
<td>⇔</td>
<td>ARDUINO-PIN9</td>
</tr>
<tr>
<td>error LED</td>
<td>⇔</td>
<td>ARDUINO-PIN8</td>
</tr>
<tr>
<td>programming LED</td>
<td>⇔</td>
<td>ARDUINO-PIN7</td>
</tr>
</tbody>
</table>
<h3>Step 3: Connecting via AVRdude</h3>
<p><a href="http://savannah.nongnu.org/projects/avrdude/" target="_blank">AVRdude</a> is an open-source utility for programming Atmel AVR Microcontrollers.</p>
<p>Running the following from a terminal</p>
<pre class="code">avrdude -p atmega8 -c avrisp -P /dev/ttyUSB0 -b 19200</pre>
<p>produced</p>
<pre class="code">avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.13s

avrdude: Device signature = 0x1e9307

avrdude: safemode: Fuses OK

avrdude done.  Thank you.</pre>
<p>Which indicated that AVRdude had communicated  with the mega-isp successfully.</p>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 684px; width: 1px; height: 1px;">&amp;hArr;</div>
]]></content:encoded>
			<wfw:commentRss>http://ntsdt.net/2009/08/07/programming-an-atmega8-using-arduino/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
