{"id":276,"date":"2018-01-14T14:03:31","date_gmt":"2018-01-14T14:03:31","guid":{"rendered":"https:\/\/elephantandchicken.co.uk\/stuffandnonsense\/?p=276"},"modified":"2018-12-13T10:59:25","modified_gmt":"2018-12-13T10:59:25","slug":"using-avrprog2-and-an-easyavr5a-with-the-arduino-ide","status":"publish","type":"post","link":"https:\/\/elephantandchicken.co.uk\/stuffandnonsense\/?p=276","title":{"rendered":"Using AVRprog2 and an EasyAVR5A with the Arduino IDE"},"content":{"rendered":"<h3>Using AVRprog2 and an EasyAVR5A with the Arduino IDE<\/h3>\n<p>A few years back I bought myself a mikroe EasyAVR5A from the discount bin of an online store. Sadly, at the time, there was no way to use the built in USB programmer from any OS other than Windows, so I resorted to programming the board through a USBasp.<\/p>\n<div id=\"attachment_285\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/elephantandchicken.co.uk\/stuffandnonsense\/wp-content\/uploads\/2018\/01\/IMG_20180114_140811.jpg\"><img aria-describedby=\"caption-attachment-285\" loading=\"lazy\" class=\"size-medium wp-image-285\" src=\"https:\/\/elephantandchicken.co.uk\/stuffandnonsense\/wp-content\/uploads\/2018\/01\/IMG_20180114_140811-300x252.jpg\" alt=\"The mikroe EasyAVR5A\" width=\"300\" height=\"252\" srcset=\"https:\/\/elephantandchicken.co.uk\/stuffandnonsense\/wp-content\/uploads\/2018\/01\/IMG_20180114_140811-300x252.jpg 300w, https:\/\/elephantandchicken.co.uk\/stuffandnonsense\/wp-content\/uploads\/2018\/01\/IMG_20180114_140811-1024x859.jpg 1024w, https:\/\/elephantandchicken.co.uk\/stuffandnonsense\/wp-content\/uploads\/2018\/01\/IMG_20180114_140811.jpg 1455w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-285\" class=\"wp-caption-text\">The mikroe EasyAVR5A<\/p><\/div>\n<p>Jump forwards a while and a helpful university produced a Linux (and Mac) program compatible with the built in USB programmer. <a href=\"https:\/\/github.com\/avrprog2\/avrprog2-code\/\">This can be found here<\/a>. I have been using this software for a while and am very happy that it exists. To use it with the Arduino IDE, you need to add the MCUs you&#8217;re using (if you use an ATMega328p you can skip this as it is the standard chip in an Arduino Uno, although you will need to add it to the list of xml files which describe chips for the AVRprog2 software, described later for the ATMega32), build the project with &#8220;verbose&#8221; turned on in preferences, copy the path to the final mentioned .hex file, and paste it into the command line with the command to program the board. A little bit of a faff.<\/p>\n<div id=\"attachment_284\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/elephantandchicken.co.uk\/stuffandnonsense\/wp-content\/uploads\/2018\/01\/IMG_20180114_140704.jpg\"><img aria-describedby=\"caption-attachment-284\" loading=\"lazy\" class=\"size-medium wp-image-284\" src=\"https:\/\/elephantandchicken.co.uk\/stuffandnonsense\/wp-content\/uploads\/2018\/01\/IMG_20180114_140704-300x206.jpg\" alt=\"The mikroe AVRprog2\" width=\"300\" height=\"206\" srcset=\"https:\/\/elephantandchicken.co.uk\/stuffandnonsense\/wp-content\/uploads\/2018\/01\/IMG_20180114_140704-300x206.jpg 300w, https:\/\/elephantandchicken.co.uk\/stuffandnonsense\/wp-content\/uploads\/2018\/01\/IMG_20180114_140704-1024x703.jpg 1024w, https:\/\/elephantandchicken.co.uk\/stuffandnonsense\/wp-content\/uploads\/2018\/01\/IMG_20180114_140704.jpg 1629w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-284\" class=\"wp-caption-text\">The mikroe AVRprog2<\/p><\/div>\n<p>Messing about today I set myself a little challenge to see if I could add the avrprog2 program as a programmer within the Arduino IDE &#8211; I managed to get it working, so here are the directions on how. This should apply to other boards that use the mikroe AVRprog2 interface (labelled as AVRprog on the board, which causes confusion as there is a parallel interface programmer called the same).<\/p>\n<p>1. Download, compile and install the github avrprog2 project. You can mostly follow their instructions, except you have to run autogen.sh before anything else (otherwise the configure script doesn&#8217;t exist). The listed dependencies are not helpfully named (some aren&#8217;t the package names), but a bit of googling gets it working. For reference, I ran the following commands to install :<\/p>\n<pre class=\"lang:sh highlight:0 decode:true\">sudo apt-get install libusb-1.0-0-dev\r\nsudo apt-get install binutils-dev\r\nsudo apt-get install libboost-all-dev\r\nsudo apt-get install doxygen\r\nsudo apt-get install graphviz-dev\r\nsudo apt-get install graphviz\r\n.\/autogen.sh\r\n.\/configure\r\nmake\r\nsudo make install\r\n<\/pre>\n<p>2. Open the folder called &#8220;config&#8221;. Copy, then edit the file &#8220;atmega16.xml&#8221; to a file called &#8220;atmega32.xml&#8221; and then replace the contents with the following :<\/p>\n<pre class=\"lang:default decode:true\">&lt;device&gt;\r\n\t&lt;name&gt;ATmega 32&lt;\/name&gt;\r\n\t&lt;signature&gt;0x1e9502&lt;\/signature&gt;\r\n\t&lt;flashSize&gt;32768&lt;\/flashSize&gt;\r\n\t&lt;flashPageSize&gt;128&lt;\/flashPageSize&gt;\r\n\t&lt;eepromSize&gt;1024&lt;\/eepromSize&gt;\r\n\t&lt;numOfFuses&gt;2&lt;\/numOfFuses&gt;\r\n&lt;\/device&gt;<\/pre>\n<p>You don&#8217;t need to do this if you don&#8217;t plan to use the ATMega32A part, but I did and might as well include it. Once edited, save and copy to the folder &#8220;\/usr\/local\/share\/avrprog2\/&#8221;. You&#8217;ll need super user permissions to do this.<\/p>\n<p>I&#8217;ve uploaded a few more config files in <a href=\"https:\/\/elephantandchicken.co.uk\/stuffandnonsense\/?p=323\">this post<\/a>. Note that I&#8217;ve included the default ones for reference. I&#8217;ll add more with time as I test more chips.<\/p>\n<p>3. Install <a href=\"https:\/\/github.com\/MCUdude\/MightyCore\">MightyCore<\/a> as per the instructions on the github page.<\/p>\n<p>4. Add the following to the MightyCore platform.txt file (mine was located in &#8220;~\/.arduino15\/packages\/MightyCore\/hardware\/avr\/1.0.8&#8221; &#8211; you can find the correct folder by going to Preferences in the IDE, then clicking on the link under &#8220;More preferences can be edited directly in the file&#8230;&#8221;, then navigating through .\/packages\/MightyCore\/hardware\/avr\/1.0.8) :<\/p>\n<pre class=\"lang:default decode:true\"># avrprog2 entry\r\ntools.avrprog2.cmd.path=\/usr\/local\/bin\/avrprog2\r\ntools.avrprog2.cmd.path.linux=\/usr\/local\/bin\/avrprog2\r\n\r\ntools.avrprog2.upload.params.verbose=-d\r\ntools.avrprog2.upload.params.quiet=\r\ntools.avrprog2.upload.pattern=\"{cmd.path}\" -m {build.mcu} -f {build.f_cpu} --flash w:{build.path}\/{build.project_name}.hex\r\n\r\ntools.avrprog2.program.params.verbose=-d\r\ntools.avrprog2.program.params.quiet=\r\ntools.avrprog2.program.pattern=\"{cmd.path}\" -m {build.mcu} -f {build.f_cpu} --flash w:{build.path}\/{build.project_name}.hex<\/pre>\n<p>I placed it above the line &#8220;# USB Default Flags&#8221;.<\/p>\n<p>5. Add the following to the top of the MightyCore programmers.txt file :<\/p>\n<pre class=\"lang:default decode:true\"># avrprog2 entry\r\navrprog2.name=avrprog2\r\navrprog2.communication=usb\r\navrprog2.protocol=avrprog2\r\navrprog2.program.protocol=avrprog2\r\navrprog2.program.tool=avrprog2<\/pre>\n<p>6. Save both modified files, restart the Arduino IDE and&#8230; you should see a new entry called &#8220;avrprog2&#8221; in the Tools&gt;Programmer menu.<\/p>\n<p>7. Load your program, select the correct MightyCore chip (the board comes with an ATMega16), select the avrprog2 and other various settings for the MCU then&#8230;<\/p>\n<p>8. Shift click the Upload button. If all goes well you should see the compile and then your program loading into the chip. I find I can&#8217;t program the board twice without powercycling between, and sometimes it doesn&#8217;t find the board for some reason (but that is the same when using the programming software from the command line.<\/p>\n<p>Hope someone finds these instructions useful &#8211; they have been written at speed because I have somewhere to be. I may return to clean them up and add some pictures at a later date!<\/p>\n<p>Note that I&#8217;ve not currently made modifications which allow you to flash the bootloader (I&#8217;ve not done anything that writes the fuses). The following two commands seem to work for Internal 8mhz and external crystal respectively :<\/p>\n<pre class=\"lang:default decode:true \">8mhz Internal Clock :\r\navrprog2 -m atmega32 --fuses w:f4,d6\r\n\r\n16mhz External Crystal :\r\navrprog2 -m atmega32 --fuses w:c0,d6<\/pre>\n<p>Good luck!<\/p>\n<p>I found this page useful while making this modification : https:\/\/github.com\/arduino\/Arduino\/wiki\/Arduino-IDE-1.5-3rd-party-Hardware-specification<\/p>\n<p>As well as looking at the Digistump platform.txt and programmer.txt files (started by making a copy of their platform.txt contents).<\/p>\n<p>I&#8217;m also thankful for a point in the right direction from blathijs on the Arduino IRC.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Using AVRprog2 and an EasyAVR5A with the Arduino IDE A few years back I bought myself a mikroe EasyAVR5A from the discount bin of an online store. Sadly, at the time, there was no way to use the built in USB programmer from any OS other than Windows, so I resorted to programming the board [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":283,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[24,13,42,12],"tags":[28,86,85,84,83,82,80,81,87,79,89,88],"jetpack_featured_media_url":"https:\/\/elephantandchicken.co.uk\/stuffandnonsense\/wp-content\/uploads\/2018\/01\/IMG_20180114_140752.jpg","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p7g9vY-4s","_links":{"self":[{"href":"https:\/\/elephantandchicken.co.uk\/stuffandnonsense\/index.php?rest_route=\/wp\/v2\/posts\/276"}],"collection":[{"href":"https:\/\/elephantandchicken.co.uk\/stuffandnonsense\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elephantandchicken.co.uk\/stuffandnonsense\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elephantandchicken.co.uk\/stuffandnonsense\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/elephantandchicken.co.uk\/stuffandnonsense\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=276"}],"version-history":[{"count":18,"href":"https:\/\/elephantandchicken.co.uk\/stuffandnonsense\/index.php?rest_route=\/wp\/v2\/posts\/276\/revisions"}],"predecessor-version":[{"id":397,"href":"https:\/\/elephantandchicken.co.uk\/stuffandnonsense\/index.php?rest_route=\/wp\/v2\/posts\/276\/revisions\/397"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/elephantandchicken.co.uk\/stuffandnonsense\/index.php?rest_route=\/wp\/v2\/media\/283"}],"wp:attachment":[{"href":"https:\/\/elephantandchicken.co.uk\/stuffandnonsense\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=276"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elephantandchicken.co.uk\/stuffandnonsense\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=276"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elephantandchicken.co.uk\/stuffandnonsense\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=276"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}