{"id":188,"date":"2011-06-02T08:22:44","date_gmt":"2011-06-02T08:22:44","guid":{"rendered":"http:\/\/www.martyndavis.com\/?p=188"},"modified":"2022-04-10T08:56:54","modified_gmt":"2022-04-10T07:56:54","slug":"veroboarduino-last-part-burning-a-bootloader-and-uploading-programs","status":"publish","type":"post","link":"https:\/\/www.martyndavis.com\/?p=188","title":{"rendered":"VeroBoardUino &#8211; Last Part &#8211; Burning a Bootloader and Uploading Programs"},"content":{"rendered":"<p>In which we burn an arduino boot loader onto the ATMega, and then upload our own programs.<\/p>\n<p><!--more--><\/p>\n<p><em>Note: this is the final part of a series of posts describing how to create an arduino-compatible board from scratch for very little money. You can find the previous posts here:<\/em><\/p>\n<p><em> <a href=\"http:\/\/www.martyndavis.com\/?p=105\">Part 1<\/a><br \/>\n<a href=\"http:\/\/www.martyndavis.com\/?p=133\">Part 2<\/a><br \/>\n<a href=\"http:\/\/www.martyndavis.com\/?p=150\">Part 2.5 (circuit and parts list)<\/a><br \/>\n<a href=\"http:\/\/www.martyndavis.com\/?p=168\">Part 3<\/a> <\/em><\/p>\n<h3>BURNING THE BOOTLOADER<\/h3>\n<p>This section describes how you can easily burn a bootloader onto the stock ATMega chip in your new circuit using nothing more than your existing Arduino Uno (or older board), a few wires and one component. You do <strong>not <\/strong>need an external programmer device.<\/p>\n<p><strong>Wait, what IS a bootloader??<\/strong> &#8211; Good question. The bootloader is a small program that is run whenever the chip starts up, and, for a few seconds, it waits and listens to see if you want to upload a new sketch. If it doesn&#8217;t get an upload, it just runs the sketch that&#8217;s already resident on the chip.<\/p>\n<p><strong>N.B. it is possible to buy ATMega chips with the arduino bootloader already burned onto them (obviously they cost more). If you have one of these, you can skip down to &#8220;Uploading a Sketch to the Board&#8221;<\/strong><\/p>\n<p>So, grab your &#8220;real&#8221; arduino and load up the normal arduino IDE on your computer. Load the ArduinoISP &#8220;sketch&#8221; from the <span style=\"color: #333399;\"><span style=\"color: #993300;\">File -&gt; Examples<\/span> <\/span>menu option and upload it. Now connect up your new circuit to your arduino according to the image below (click to show larger in a new window).<\/p>\n<p><a href=\"http:\/\/martyndavis.com\/wp-content\/uploads\/2011\/06\/step8.jpg\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-247\" title=\"Bootloading\" src=\"http:\/\/martyndavis.com\/wp-content\/uploads\/2011\/06\/step8-300x240.jpg\" alt=\"\" width=\"300\" height=\"240\" srcset=\"https:\/\/www.martyndavis.com\/wp-content\/uploads\/2011\/06\/step8-300x240.jpg 300w, https:\/\/www.martyndavis.com\/wp-content\/uploads\/2011\/06\/step8.jpg 988w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>The picture might not be as clear as it might be with all those wires floating about, so here are the connections:<\/p>\n<table>\n<tbody>\n<tr>\n<td style=\"vertical-align: top; padding-right: 20px;\"><strong>Arduino Pin<\/strong><\/td>\n<td style=\"vertical-align: top;\"><strong>New Board<\/strong><\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align: top;\">13<\/td>\n<td style=\"vertical-align: top;\">row 17, right hand side, on the stripboard (i.e. connects to pin 13)<\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align: top;\">12<\/td>\n<td style=\"vertical-align: top;\">row 16, right hand side, on the stripboard (i.e. connects to pin 12)<\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align: top;\">11<\/td>\n<td style=\"vertical-align: top;\">row 15, right hand side, on the stripboard (i.e. connects to pin 11)<\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align: top;\">10<\/td>\n<td style=\"vertical-align: top;\">hold this wire against the RESET pin when burning the bootloader (i.e. row 8, left-hand side)<\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align: top;\">5V<\/td>\n<td style=\"vertical-align: top;\">take to an external breadboard, and take another wire from the same breadboard track to the female header on the left side of the new board, row 8 (i.e. +5V)<\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align: top;\">GND<\/td>\n<td style=\"vertical-align: top;\">connect to the header on the left of the new board, row 6 (i.e. GND)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Finally we need to add a component to defeat the &#8220;real&#8221; arduino&#8217;s auto-reset feature as this gets in the way of the bootloader-burning sketch. For an Arduino Uno (which I&#8217;m using), you&#8217;ll need to take a &nbsp;capacitor (electrolytic, so make sure you have the polarity right) from the +5V we&#8217;ve got on the <strong>BREADboard<\/strong> (not the stripboard). Connect the other end of this to the Uno&#8217;s RESET socket. If you&#8217;re using an older arduino, I understand a 120 ohm resistor will work in place of the capacitor.<\/p>\n<p>Once you&#8217;re all hooked up, and you&#8217;ve got the ArduinoISP sketch loaded on your &#8220;real&#8221; arduino, change the board on the IDE to the one you&#8217;re burning <strong>TO<\/strong> &#8211; I&#8217;m burning an ATMega 168 so I select &#8220;<span style=\"color: #993300;\">Arduino Diecimila, Duemilanova or Nano w\/ ATMega 168<\/span>&#8221; from the <span style=\"color: #800000;\"><span style=\"color: #993300;\">Tools -&gt; Board<\/span> <\/span>menu.<\/p>\n<p>Then make sure you&#8217;re holding the reset wire (the white wire that&#8217;s labelled in the picture)&nbsp;against the RESET pin on your new board, and select <span style=\"color: #993300;\">Tools -&gt; Burn Bootloader -&gt; w\/ Arduino as ISP <\/span>from the menu.<\/p>\n<p>If all is connected correctly, you should see the TX\/RX lights on your &#8220;real&#8221; Arduino flash for a couple of minutes, then the IDE should report &#8220;<span style=\"color: #993300;\">Done burning bootloader<\/span>&#8220;.<\/p>\n<p><span style=\"color: #ff0000;\">NOTE (30-JUN-2012) &#8211; if you hit errors like &#8220;avrdude: stk500_getsync(): not in sync: resp=0x15&#8221; at this step, try using the Arduino 1.0.1 version IDE &#8211; this cured it for me.<\/span><\/p>\n<p>Congratulations &#8211; we&#8217;ve made an Arduino! Next step will be programming the thing.<\/p>\n<h3>UPLOADING A SKETCH TO THE BOARD<\/h3>\n<p>&#8220;Real&#8221; arduinos normally have a USB socket on them to allow you to connect the board to your computer to allow you to upload &#8220;sketches&#8221; (i.e. your programs). As this is a designed to be a dedicated circuit, adding extra USB circuitry would be a waste and an unnecessary complication.<\/p>\n<p>Therefore we are going to need to use something to convert USB to serial (which is what the chip &#8220;speaks&#8221; natively). Here are a couple of suggestions:<\/p>\n<p><a href=\"http:\/\/www.sparkfun.com\/products\/10008\" target=\"_blank\" rel=\"noopener\">http:\/\/www.sparkfun.com\/products\/10008<\/a> &#8211; this is the one I&#8217;m using, I&#8217;ve soldered male header pins onto it so it plugs directly into the serial header on the circuit we&#8217;ve made.<\/p>\n<p>Alternatively there are complete cables, e.g.:<br \/>\n<a href=\"http:\/\/www.sparkfun.com\/products\/9718\" target=\"_blank\" rel=\"noopener\"> http:\/\/www.sparkfun.com\/products\/9718<\/a><br \/>\nor<br \/>\n<a href=\"http:\/\/www.oomlout.co.uk\/usb-serial-cable-33v-p-232.html\" target=\"_blank\" rel=\"noopener\">http:\/\/www.oomlout.co.uk\/usb-serial-cable-33v-p-232.html<\/a><\/p>\n<p>Both of the cables mentioned above have <strong>female<\/strong> ends &#8211; when using one of these I usually use a 6 pin male to male adapter I made by soldering two six pin male headers back-to-back to convert it to a male end. You could of course use a male header on the circuit we&#8217;ve just made, but it&#8217;s easier with the female header to connect up for bootloader burning etc. Your choice!<\/p>\n<p>So, with my FTDI Basic Breakout board plugged into the serial connector on our board (note which way round it goes &#8211; &#8220;BLK&#8221; on the breakout board corresponds to row 6 (i.e. GND) and a USB mini cable connecting that to my PC, I should have be able to upload sketches. Note that on the IDE I need to select &#8220;Arduino Diecimila, Duemilanova or Nano w\/ ATMega 168&#8221; as the board type (as I used an ATMega 168) and the serial port is different from the usual one that shows up for the Uno &#8211; it&#8217;s \/dev\/ttyUSB0 (I&#8217;m running this on Linux).<\/p>\n<p>I could now load up the Blink &#8220;sketch&#8221; and upload.&nbsp;<strong>But here&#8217;s a little &#8220;gotcha&#8221;<\/strong> &#8211; we don&#8217;t have any way to automatically reset our new board when uploading &#8211; we&#8217;ve not connected up the required line on the serial connector. I haven&#8217;t bothered with this because, for some reason, I found it very temperamental, and older arduinos didn&#8217;t have an auto-reset anyway. But to upload a sketch the board needs to be reset (because, as I explained earlier, that&#8217;s the only time that the bootloader is listening).<\/p>\n<p>So here&#8217;s how to upload without problems every time&#8230; hold down the reset button on your new circuit, press the upload button on the IDE (or press Ctrl-U), then, <strong>only when you see the message<\/strong> &#8220;<span style=\"color: #993300;\">Binary sketch size: xxx bytes (of a xxxxx byte maximum)<\/span>&#8221; pop up in the bottom black window (indicating it&#8217;s compiled and is about to upload), immediately let go of the reset button. This ensures the board is reset at just the right time. If you timed it correctly, you should soon then see the &#8220;<span style=\"color: #993300;\">Done uploading<\/span>&#8221; message, and you&#8217;re done!<\/p>\n<p>Try testing your board with the Blink program and connecting pin 13 to an LED with suitable resistor.<\/p>\n<p>I hope this little series has been useful &#8211; if you have any comments, suggestions or have spotted any errors then feel free to leave a comment. It&#8217;s been fun &#8211; cheers!<\/p>\n<p>&#8212;<\/p>\n<p><span style=\"color: #000000;\">By the way, &#8220;Vero&#8221; is a trademark of Vero Technologies Ltd, UK.<\/span><\/p>\n<p><span style=\"color: #000000;\"><br \/>\nThe text and images in this series are Creative Commons licensed &#8211; if you wish to use them for non-commercial purposes, go ahead &#8211; please just prominently label what you use with a link back to this site!<br \/>\n<a href=\"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/\" rel=\"license\"><img decoding=\"async\" style=\"border-width: 0;\" src=\"http:\/\/i.creativecommons.org\/l\/by-nc-sa\/3.0\/88x31.png\" alt=\"Creative Commons Licence\"><br \/>\n<\/a> This VeroBoardUino Tutorial is licensed under a <a href=\"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/\" rel=\"license\">Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License<\/a>.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In which we burn an arduino boot loader onto the ATMega, and then upload our own programs.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,1],"tags":[19,10],"_links":{"self":[{"href":"https:\/\/www.martyndavis.com\/index.php?rest_route=\/wp\/v2\/posts\/188"}],"collection":[{"href":"https:\/\/www.martyndavis.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.martyndavis.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.martyndavis.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.martyndavis.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=188"}],"version-history":[{"count":74,"href":"https:\/\/www.martyndavis.com\/index.php?rest_route=\/wp\/v2\/posts\/188\/revisions"}],"predecessor-version":[{"id":850,"href":"https:\/\/www.martyndavis.com\/index.php?rest_route=\/wp\/v2\/posts\/188\/revisions\/850"}],"wp:attachment":[{"href":"https:\/\/www.martyndavis.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.martyndavis.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.martyndavis.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}