{"id":480,"date":"2020-02-29T16:56:45","date_gmt":"2020-02-29T16:56:45","guid":{"rendered":"https:\/\/immerhax.com\/?p=480"},"modified":"2020-03-01T13:37:50","modified_gmt":"2020-03-01T13:37:50","slug":"boot-time-difference-on-arduino-nano-v3-0-clone-with-and-without-bootloader","status":"publish","type":"post","link":"https:\/\/immerhax.com\/?p=480","title":{"rendered":"Boot time difference on Arduino Nano v3.0 (clone) with and without bootloader"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">So I wanted to see what kind of delay the built-in bootloader of the Nano v3.0 clones I have was causing, so I created a small sketch which basically sets up a pin as output and turns it on. I then attached my logic analyzer and measured the time from reset is released until the pin goes high.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here is the measurement of the sketch,  uploaded through the serial port, meaning through the bootloader, meaning bootloader is active:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/immerhax.com\/wp-content\/uploads\/2020\/02\/nano-w-bootloader.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"174\" src=\"https:\/\/immerhax.com\/wp-content\/uploads\/2020\/02\/nano-w-bootloader-1024x174.png\" alt=\"\" class=\"wp-image-481\" srcset=\"https:\/\/immerhax.com\/wp-content\/uploads\/2020\/02\/nano-w-bootloader-1024x174.png 1024w, https:\/\/immerhax.com\/wp-content\/uploads\/2020\/02\/nano-w-bootloader-300x51.png 300w, https:\/\/immerhax.com\/wp-content\/uploads\/2020\/02\/nano-w-bootloader-768x130.png 768w, https:\/\/immerhax.com\/wp-content\/uploads\/2020\/02\/nano-w-bootloader.png 1167w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption>Nano v3 clone with bootloader active<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">So here, from I release the reset, until the test pin goes high, is a delay of ~1,46 seconds.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">And now, with the sketch uploaded through ISP\/ICSP, meaning bootloader is now destroyed (and board cannot be programmed through serial port unless a new bootloader is added):<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/immerhax.com\/wp-content\/uploads\/2020\/02\/nano-wo-bootloader.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"154\" src=\"https:\/\/immerhax.com\/wp-content\/uploads\/2020\/02\/nano-wo-bootloader-1024x154.png\" alt=\"\" class=\"wp-image-482\" srcset=\"https:\/\/immerhax.com\/wp-content\/uploads\/2020\/02\/nano-wo-bootloader-1024x154.png 1024w, https:\/\/immerhax.com\/wp-content\/uploads\/2020\/02\/nano-wo-bootloader-300x45.png 300w, https:\/\/immerhax.com\/wp-content\/uploads\/2020\/02\/nano-wo-bootloader-768x116.png 768w, https:\/\/immerhax.com\/wp-content\/uploads\/2020\/02\/nano-wo-bootloader.png 1327w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption>Nano v3 clone without bootloader<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">So now, from I release reset, until the test pin goes high, is a delay of 70 ms. Purrty big diffewence!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can verify that the bootloader is now gone by checking the red LED on the board. When power is applied, it will blink once during startup (that&#8217;s the bootloader) and then do whatever your program does afterwards, so if it doesn&#8217;t, the bootloader is gone.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now there are other bootloaders available, much faster ones also, but this is the one built into all clone Nanos I&#8217;ve worked with. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Turning the Arduino Nano clone into a programmer<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">So in case you don&#8217;t have a programmer (ISP) you can turn one of those Arduinos you have in the drawer into one! The Arduino IDE has a sketch that can be uploaded to any Arduino basically and make it act like a programmer, which you can then use to program sketches directly into other Arduinos, thus removing the bootloader, and reducing boot time dramatically. Here&#8217;s how to do it for a Nano:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Start the IDE, press &#8220;<strong>File<\/strong>&#8220;, press &#8220;<strong>Examples<\/strong>&#8220;, choose &#8220;<strong>11. ArduinoISP<\/strong>&#8221; and then &#8220;<strong>ArduinoISP<\/strong>&#8220;. It will then load that sketch. Press &#8220;<strong>Tools<\/strong>&#8220;, press &#8220;<strong>Board<\/strong>&#8220;, select &#8220;<strong>Arduino Nano<\/strong>&#8220;. Press &#8220;<strong>Tools<\/strong>&#8220;, press &#8220;<strong>Processor<\/strong>&#8220;, select &#8220;<strong>ATmega328P (Old bootloader)<\/strong>&#8220;. The &#8220;Old bootloader&#8221; versions have been the ones I needed to select for all clones I&#8217;ve used. You also need to select the serial port it is attached to in &#8220;<strong>Tools<\/strong>&#8220;. Press &#8220;<strong>Upload<\/strong>&#8221; to put the sketch in. You should now have an Arduino ISP. To get a stable connection, it is necessary to add a ~10uF capacitor between the RST and GND pins (negative on GND, positive on RST) on the Arduino ISP. Like this:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/immerhax.com\/wp-content\/uploads\/2020\/02\/IMG_20200229_173222-scaled.jpg\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/immerhax.com\/wp-content\/uploads\/2020\/02\/IMG_20200229_173222-1024x768.jpg\" alt=\"\" class=\"wp-image-487\" srcset=\"https:\/\/immerhax.com\/wp-content\/uploads\/2020\/02\/IMG_20200229_173222-1024x768.jpg 1024w, https:\/\/immerhax.com\/wp-content\/uploads\/2020\/02\/IMG_20200229_173222-300x225.jpg 300w, https:\/\/immerhax.com\/wp-content\/uploads\/2020\/02\/IMG_20200229_173222-768x576.jpg 768w, https:\/\/immerhax.com\/wp-content\/uploads\/2020\/02\/IMG_20200229_173222-1536x1152.jpg 1536w, https:\/\/immerhax.com\/wp-content\/uploads\/2020\/02\/IMG_20200229_173222-2048x1536.jpg 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption>10uF cap between GND and RST on the ISP Nano<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">This is a hardware-hack to circumvent the Arduino from resetting when the serial data from the computer arrives. It is important that this is done <strong>after<\/strong> the ArduinoISP sketch has been uploaded.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now to use your new programmer, open the sketch you want to write, select the correct board of your target (in this case no difference), and in &#8220;<strong>Tools<\/strong>&#8220;, press &#8220;<strong>Programmer<\/strong>&#8220;, select &#8220;<strong>Arduino as ISP<\/strong>&#8221; (note: NOT &#8220;ArduinoISP&#8221;, as that is a separate piece of hardware). The serial port should be the same as your Arduino programmer is connected to. You then need to connect the following with jumper cables (programmer -&gt; target):<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">D10 -&gt; RST<br>D11 -&gt; D11<br>D12 -&gt; D12<br>D13 -&gt; D13<br>5V -&gt; 5V<br>GND -&gt; GND<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So quite easy for Nano -&gt; Nano.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/immerhax.com\/wp-content\/uploads\/2020\/03\/IMG_20200301_101752-scaled.jpg\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/immerhax.com\/wp-content\/uploads\/2020\/03\/IMG_20200301_101752-1024x768.jpg\" alt=\"\" class=\"wp-image-492\" srcset=\"https:\/\/immerhax.com\/wp-content\/uploads\/2020\/03\/IMG_20200301_101752-1024x768.jpg 1024w, https:\/\/immerhax.com\/wp-content\/uploads\/2020\/03\/IMG_20200301_101752-300x225.jpg 300w, https:\/\/immerhax.com\/wp-content\/uploads\/2020\/03\/IMG_20200301_101752-768x576.jpg 768w, https:\/\/immerhax.com\/wp-content\/uploads\/2020\/03\/IMG_20200301_101752-1536x1152.jpg 1536w, https:\/\/immerhax.com\/wp-content\/uploads\/2020\/03\/IMG_20200301_101752-2048x1536.jpg 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption>ISP Nano to the left and the target Nano to the right (and a Mini Pro top left, disregard that)<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Then write the sketch by pressing &#8220;<strong>Sketch<\/strong>&#8220;, select<strong> <\/strong>&#8220;<strong>Upload using programmer<\/strong>&#8220;. It should upload the sketch to the target, which now has zero bootloader, thus boots close to immediately. To reclaim the bootloader (or change it to another), simply press the &#8220;<strong>Burn bootloader<\/strong>&#8221; in &#8220;<strong>Tools<\/strong>&#8220;.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So I wanted to see what kind of delay the built-in bootloader of the Nano v3.0 clones I have was causing, so I created a small sketch which basically sets up a pin as output and turns it on. I then attached my logic analyzer and measured the time from reset is released until the &hellip; <a href=\"https:\/\/immerhax.com\/?p=480\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Boot time difference on Arduino Nano v3.0 (clone) with and without bootloader<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-480","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/immerhax.com\/index.php?rest_route=\/wp\/v2\/posts\/480","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/immerhax.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/immerhax.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/immerhax.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/immerhax.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=480"}],"version-history":[{"count":9,"href":"https:\/\/immerhax.com\/index.php?rest_route=\/wp\/v2\/posts\/480\/revisions"}],"predecessor-version":[{"id":494,"href":"https:\/\/immerhax.com\/index.php?rest_route=\/wp\/v2\/posts\/480\/revisions\/494"}],"wp:attachment":[{"href":"https:\/\/immerhax.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=480"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/immerhax.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=480"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/immerhax.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=480"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}