User Tools

Site Tools


arduino:arduino_without_a_bootloader

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
arduino:arduino_without_a_bootloader [2020/02/27 18:23] – [Hardware] mithatarduino:arduino_without_a_bootloader [2022/05/30 05:46] (current) – [Case 2: Pro Mini 5V/16MHz with USBtinyISP] mithat
Line 16: Line 16:
 Another reason to not use a bootloader is that the startup time is critical. The Arduino bootloader introduces about a second and a half delay between power-up/reset and running your program. Without the bootloader, your code starts running almost instantaneously. Another reason to not use a bootloader is that the startup time is critical. The Arduino bootloader introduces about a second and a half delay between power-up/reset and running your program. Without the bootloader, your code starts running almost instantaneously.
  
-Yet another situation where you might not want a bootloader is if you have lowered or disabled the [[https://microchipdeveloper.com/8avr:bod|Brown-Out Detection]] so you can use every last ounce of battery juice in a portable application.((Disabling brown-out detection or lowering the threshold of detection involves [[arduino:atmega328p_arduinos_and_custom_fuse_settings|custom fuse settings]] and is beyond the scope of this article.)) Without brown-out detection, the erratic system behavior you can expect at very low voltages could cause a program jump to an arbitrary part of the code in flash storage. If you use a bootloader, this could be a jump into bootloader code. This then has the potential to start a cascade of events that leads to the bootloader overwriting your program code. If you're not using a bootloader, the code you have programmed can't be corrupted this way.((Not using a bootloader in this situation will keep the program memory form becoming corrupted, but EEPROM and other things can still be battered when the voltage falls below the minimum for a given clock frequency. The risks are described more completely in the [[http://ww1.microchip.com/downloads/en/Appnotes/doc1051.pdf|AVR180: External Brown-out Protection]] application note.))+Yet another situation where you might not want a bootloader is if you have lowered or disabled the [[https://microchipdeveloper.com/8avr:bod|Brown-Out Detection]] so you can use every last ounce of battery juice in a portable application.((Disabling brown-out detection or lowering the threshold of detection involves [[arduino:atmega328p_arduinos_and_custom_fuse_settings|custom fuse settings]] and is beyond the scope of this article.)) Without brown-out detection, the erratic system behavior you can expect at very low voltages could cause a program jump to an arbitrary part of the code in flash storage. This could be a jump into bootloader code if the micro is using a bootloader. This then has the potential to start a cascade of events that leads to the bootloader overwriting your program code. If you're not using a bootloader, the code you have programmed can't be corrupted this way.((Not using a bootloader in this scenario will keep the program memory form becoming corrupted, but EEPROM and other things can still be corrupted when the voltage falls below the minimum for a given clock frequency. The risks are described more completely in the [[http://ww1.microchip.com/downloads/en/Appnotes/doc1051.pdf|AVR180: External Brown-out Protection]] application note.))
  
 There are situations apart from these where you wouldn't want to use a bootloader that you might discover as you become more experienced with Arduino and microcontroller programming. For whatever reason, if you want to explore how to upload programs to ATmega-based Arduinos without a bootloader, then read on. There are situations apart from these where you wouldn't want to use a bootloader that you might discover as you become more experienced with Arduino and microcontroller programming. For whatever reason, if you want to explore how to upload programs to ATmega-based Arduinos without a bootloader, then read on.
Line 27: Line 27:
 That's a lot of options! That's a lot of options!
  
-Below, I cover a few cases to get you started. Most of these use the USBtinyISP.((As near as I can tell, the original source of the USBtinyISP design is Dick Streefland's [[https://dicks.home.xs4all.nl/avr/usbtiny/|USBtiny]]. Additional development and refinement leading to the [[https://learn.adafruit.com/usbtinyisp|USBtinyISP]] was done by Limor Fried. The software and hardware are open source (GPL and CC BY-SA 2.5), leading to many clones and derivatives.)) Owing to its low cost and wide availability, the USBtinyISP is one of the most popular options. The [[https://learn.adafruit.com/usbtinyisp|original USBtinyISP]] is available sporadically through Adafruit, and clones derived from its open source design along the lines of [[https://www.ebay.com/itm/USBTiny-USBtinyISP-AVR-ISP-programmer-for-Arduino-bootloader-Meag2560-uno-r3/382580265905|this one]] are widely available at auction sites, Amazon, Banggood, etc. All my testing was done using USBtinyISP clones from two different suppliers.+==== USBtinyISP ====
  
-The original USBtinyISP has a built-in 3x2 IDC cable that carries the signals needed for ISP (in-system programming). It also has a 5x2 IDC cable that carries the same signals but in a different layout.+Below, I cover a few cases to get you started. Most of these use the USBtinyISP.((As near as I can tell, the original source of the USBtinyISP design is Dick Streefland's [[https://dicks.home.xs4all.nl/avr/usbtiny/|USBtiny]]. Additional development and refinement leading to the [[https://learn.adafruit.com/usbtinyisp|USBtinyISP]] was done by Limor Fried. The software and hardware are open source (GPL and CC BY-SA 2.5), leading to many clones and derivatives.)) Owing to its low cost and wide availability, the USBtinyISP is one of the most popular options. The [[https://learn.adafruit.com/usbtinyisp|original USBtinyISP]] is available sporadically through Adafruit, and clones derived from its open source design along the lines of [[https://www.ebay.com/itm/400368767664|this one]] are widely available at auction sites, Amazon, Banggood, etc. All my testing was done using USBtinyISP clones from two different suppliers.
  
-If you are using a USBtinyISP clone, there's a good chance it has a keyed 3x2 ISP header in addition to a keyed 5x2 ISP header. The following assumes this is the case and that you have a 3x2 keyed IDC cable. Such a cable is often included with USBtinyISP clone purchases. Finally, I'm assuming it works at 5VDC, which is the defacto standard.+The original USBtinyISP has a built-in 3x2 IDC cable that carries the signals needed for ISP (in-system programming) and a 5x2 IDC cable that carries the same signals but in a different layout. If you're using a USBtinyISP clone, there's a good chance it has a keyed 3x2 and 5x2 headers instead of build-in cables. The following assumes this is the case and that you are using a 3x2 keyed IDC cable. Such a cable is often included with USBtinyISP clone purchases. Finally, I'm assuming the USBtinyISP works at 5VDC, which is the defacto standard.
  
-Depending on the board you are programming, you may need to use Dupont wires (M to F or F to F depending on your USBtinyISP) instead of the IDC cable.+Depending on the board you are programming, you may find it easier to use Dupont wires (M to F or F to F) instead of the IDC cable.
  
 <WRAP center round tip 80%> <WRAP center round tip 80%>
Line 39: Line 39:
 </WRAP> </WRAP>
 ===== Procedures ===== ===== Procedures =====
-As is the case when uploading a program to your Arduino using a bootloader, when uploading a program using a programmer you must specify what the target board is. So when doing any of the following, make sure //Tools > Board// and //Tools > Processor// (or other board options) are set correctly for your board.+As is the case when uploading a program to your Arduino using a bootloader, when uploading a program using a programmer you must specify what the target board is. So when doing the following, make sure //Tools > Board// and //Tools > Processor// (or other board options) are set correctly for your board.
  
 Now is also a good time to mention a significant caveat about using a programmer as described here. <WRAP center round important 80%> Now is also a good time to mention a significant caveat about using a programmer as described here. <WRAP center round important 80%>
-Using a programmer involves making connections between the programmer and the Arduino's RST, SCK, MOSI, and MISO pins. If these pins are not used in your application, then programming should be a breeze. +Using a programmer involves making connections between the programmer and the Arduino's RST, SCK, MOSI, and MISO pins. If these pins are not used in your application, then programming should be a breeze. However, if these pins //are// used (e.g. for SPI), then you will probably need to disconnect those connections when you are uploading programs.
- +
-However, //if these pins are used (e.g. for SPI), then you will probably need to disconnect those connections when you are uploading programs!//+
 </WRAP> </WRAP>
-Yes, this is yet another way the bootloader makes your life simpler. +This can be bit of a drag and is yet another way the bootloader makes your life simpler.
  
 With that out of the way, let's move on to some specific cases. With that out of the way, let's move on to some specific cases.
Line 62: Line 59:
   - Unplug the USBtinyISP from the computer if it's connected and power down the Uno/Nano if it's powered up.   - Unplug the USBtinyISP from the computer if it's connected and power down the Uno/Nano if it's powered up.
   - Connect USBtinyISP's ISP interface to the Uno/Nano's ICSP header.   - Connect USBtinyISP's ISP interface to the Uno/Nano's ICSP header.
-    * The ICSP header is the 3x2 header on the end of the board opposite the USB jack. Connect the USBtinyISP's IDC cable to that header, but make sure it's the right way around. The easiest way to confirm the orientation is to connect it one way, and then test that the two boards' GNDs are connected with a multimeter. If not, flip the plug around and test again.+    * The ICSP header is the 3x2 header on the end of the board opposite the USB jack. Connect the USBtinyISP's IDC cable to that header, but make sure it's the right way around. The easiest way to confirm the orientation is with all power off to connect the cable one way, and then test that the two boards' GNDs are connected with a multimeter. If not, flip the plug around and test again.
   - Plug the USBtinyISP into your computer. This will power the Uno/Nano (and everything else) from the USBtinyISP's 5V VCC.   - Plug the USBtinyISP into your computer. This will power the Uno/Nano (and everything else) from the USBtinyISP's 5V VCC.
   - Use the Arduino IDE to //Sketch > Upload Using Programmer//.   - Use the Arduino IDE to //Sketch > Upload Using Programmer//.
Line 69: Line 66:
   - To re-program, power down the Uno/Nano and go back to **step 3**.   - To re-program, power down the Uno/Nano and go back to **step 3**.
  
-caveat about power is in order. The 5V VCC supplied from the USBtinyISP to the Arduino is good for about 100mA. This is enough for many situations, but if you have peripherals or other things sucking down a lot of power, it may not be. In this case, be prepared to do a fair amount of hoop-jumping to disconnect the power sucking devices during programming or power the Arduino from a source other than the USBtinyISP during programming.+caution about power is in order. The 5V VCC supplied from the USBtinyISP to the Arduino is good for about 100mA. This is enough for many situations, but if you have peripherals or other things sucking a lot of power, it may not be. In this case, be prepared to do a fair amount of hoop-jumping to disconnect the power sucking devices during programming or power the Arduino from a source other than the USBtinyISP during programming.
  
 ==== Case 2: Pro Mini 5V/16MHz with USBtinyISP ==== ==== Case 2: Pro Mini 5V/16MHz with USBtinyISP ====
- +<WRAP center round info 60%> 
-<WRAP center round important 60%> +Tested.
-I have not tested this case yet.+
 </WRAP> </WRAP>
  
Line 115: Line 111:
  
 <WRAP center round important 80%> <WRAP center round important 80%>
-**Be careful!**  +**Make sure your USBtinyISP level shifts the I/O before attempting this method.** 
- +
-Version 1 of the Adafruit USBtinyISP has a jumper that disconnects the internal VCC from the programming headers, but it does //not// level-shift the I/O. +
- +
-All the thrid-party USBtinyISP clones I've seen have the VCC jumper as well as the needed circuitry to level shift the I/O. But it's entirely likely that there are some old or bargain-basement versions that don't. +
  
-Make sure your USBtinyISP level shifts the I/O before attempting this approach.+Version 1 of the Adafruit USBtinyISP has a jumper that disconnects the internal VCC from the programming headers, but it does //not// level-shift the I/O. All the thrid-party USBtinyISP clones I've encountered have the VCC jumper as well as the needed circuitry to level shift the I/O. But it's entirely likely that there are some that don't.
 </WRAP> </WRAP>
  
arduino/arduino_without_a_bootloader.1582827818.txt.gz · Last modified: 2020/02/27 18:23 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki