Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
avr_bootloader:bootloader [2020/03/23 16:37]
admin [Burning the Bootloader with the AVRdude]
avr_bootloader:bootloader [2020/06/11 22:13] (current)
Line 1: Line 1:
 ===== Burning the Bootloader ===== ===== Burning the Bootloader =====
  
-Everything about the Arduino ​bootloader ​one can find here:  +If one uses an Atmega328 chip in his Arduino ​or Paperduino project ​one needs to burn a bootloaderThat program allows later for an easy upload of programs. For the Paper-Arduino-Clones we have to burn the Arduino UNO bootloader on our ATmega chip. Depending on the burning device there are a lot of different technics ​to do so.
-[[https://​www.arduino.cc/​en/​Hacking/​Bootloader?​from=Tutorial.Bootloader]]\\ +
-For the Paper-Arduino-Clones we have to burn the bootloader on our ATmega chip. There are differnet ways to do so:+
  
 ---- ----
 ==== Burning the Bootloader with the Arduino IDE ==== ==== Burning the Bootloader with the Arduino IDE ====
 +
 For burning the bootloader on the Paperduino-UNO,​ or on the Paper-Leonardo you need to connect the following pins on your Paperduino-UNO with your ISP programmer (in-system programmer):​ For burning the bootloader on the Paperduino-UNO,​ or on the Paper-Leonardo you need to connect the following pins on your Paperduino-UNO with your ISP programmer (in-system programmer):​
   * 11 - MOSI   * 11 - MOSI
Line 14: Line 13:
   * Ground   * Ground
   * + 5V   * + 5V
-After connecting the programmer to your computer select in the Arduino IDE in Tools/​Programmer your programmer and than klick Tools/Burn Bootloader.+After connecting the programmer to your computer select in the Arduino IDE in Tools/​Programmer your programmer and than click Tools/Burn Bootloader.
  
 === ... and an AVR programmer === === ... and an AVR programmer ===
 {{ :​arduino_clones:​isp_adapter.jpg?​direct&​300 |}} {{ :​arduino_clones:​isp_adapter.jpg?​direct&​300 |}}
  
-On the foto you see the ISP programmer with an ISP adapter board. But you could also build your own modified wire like that on the [[http://​arduino.cc/​en/​Hacking/​MiniBootloader|Mini Bootloader project]]. Anyway here are the connection of an original ISP header.+On the photo one sees the ISP programmer with an ISP adapter board. But you could also build your own modified wire like that on the [[http://​arduino.cc/​en/​Hacking/​MiniBootloader|Mini Bootloader project]]. Anyway here are the connection of an original ISP header.
  
 {{:​arduino_clones:​isp-header.jpg?​nolink|}} {{:​arduino_clones:​isp-header.jpg?​nolink|}}
  
-Cause my ISP programmer has a different ​protokoll as the originale ​AVR-ISP programmer I had to modifie ​the programmers.txt file.\\ +Cause my ISP programmer has a different ​protocol than the original ​AVR ISP programmer I had to modifier ​the programmers.txt file.\\ 
-In that folder(on Linux):+In that folder (on Linux):
   /​usr/​share/​arduino/​hardware/​arduino   /​usr/​share/​arduino/​hardware/​arduino
 The third line has to change to: The third line has to change to:
Line 30: Line 29:
  
 === ... and the Paper-USBasp Programmer === === ... and the Paper-USBasp Programmer ===
- +A [[https://​www.fischl.de/​usbasp/​|USBasp]] programmer will be used similar than the AVR ISP programmer, just select the USBasp programmer and burn.
-It is simelar to the AVR ISP programmer, just select the USBasp programmer and burn.+
  
 {{ :​avr_bootloader:​paper_usbasp_1274.jpg?​300 |}} {{ :​avr_bootloader:​paper_usbasp_1274.jpg?​300 |}}
Line 40: Line 38:
 === ... and a Paperduino-UNO === === ... and a Paperduino-UNO ===
  
-The Paperduino-UNO was designed for cloneing ​and that's why you can use your Paperduino-UNO ​fot burning bootloder, too. Just load the ArduinoISP ​- in the examples ​on your Paperduino-UNO. After that, **turn off the auto reset by removeing ​the auto reset jumper**. And than connect the pins like that:+The Paperduino-UNO was designed for cloning ​and that's why you can use easiely ​your Paperduino-UNO ​for burning ​the bootloder. Just load the ArduinoISP ​program from the Arduino IDE examples on your Paperduino-UNO. After that, **turn off the auto reset by removing ​the auto reset jumper**. And than connect the pins like that:
   * 13 to 13   * 13 to 13
   * 12 to 12   * 12 to 12
Line 50: Line 48:
  
 {{ :​arduino_clones:​paperduino-uno_as_isp_adapter_wspahn.jpg?​direct&​300 |}} {{ :​arduino_clones:​paperduino-uno_as_isp_adapter_wspahn.jpg?​direct&​300 |}}
 +
 +=== Burning an Atmega328 (without P) ===
 +
 +The Atmega328 chip has a different signature than the Atmega328p (p stands for picoPower). When one wants to burn this chip with the IDE the avrdude.conf file has to be changed.\\
 +Open the file:
 +   /​usr/​share/​arduino/​hardware/​tools/​avrdude.conf
 +or (depends on the Arduino version):
 +   /​usr/​share/​arduino/​hardware/​tools/​avr/​etc/​avrdude.conf
 +search for the Atmega328p signature:​\\
 +   0x1e 0x95 0x0F
 +and replace it with the Atmega328 signature:​\\
 +   0x1e 0x95 0x14
 +Now it should be possible to burn the Atmega328 with the Arduino IDE. Don't forget to change it back for the P version of the Atmega chip.
  
 ---- ----
Line 61: Line 72:
 Go to the folder with the bootloader: Go to the folder with the bootloader:
   $ cd /​usr/​share/​arduino/​hardware/​arduino/​avr/​bootloaders/​optiboot/​   $ cd /​usr/​share/​arduino/​hardware/​arduino/​avr/​bootloaders/​optiboot/​
 +
 +=== Fuse Bits ===
 +In the board.txt file for the Arduino UNO the fuse bits are set like that:
 +  uno.bootloader.low_fuses=0xFF
 +  uno.bootloader.high_fuses=0xDE
 +  uno.bootloader.extended_fuses=0xFD
 +  uno.bootloader.unlock_bits=0x3F
 +  uno.bootloader.lock_bits=0x0F
 +The extended fuse bits settings for the brown-out detection level (BOD) are: 
 +  0xFF (BOD disabled)
 +  0xFC (BOD = 4.3V)
 +  0xFD (BOD = 2.7V)
 +  0xFE (BOD = 1.8V)
 +That is the level where the Arduino resets when underpowered.\\
 +
 +A good manual for calculating the fuse bits one findes here [[https://​www.instructables.com/​id/​How-to-change-fuse-bits-of-AVR-Atmega328p-8bit-mic/​]].
 +
 +=== ... with the Paper-USBasp Programmer ====
 +
 +{{:​avr_bootloader:​paper-usbasp_programming_board.jpg?​400|}}\\
 +
 +If one one want to burn the bootloader with an [[avr_bootloader:​paper_usbasp|Paper-USBasp]] programming board the command to set the fuse bits is:
 +  $ sudo avrdude -p m328p -c usbasp -P usb -U lfuse:​w:​0xFF:​m -U hfuse:​w:​0xDE:​m -U efuse:​w:​0xFD:​m
 +And for the actual bootloader it is:
 +  $ sudo avrdude -p m328p -c usbasp -P usb -U flash:​w:​optiboot_atmega328.hex:​i
 +
  
 === ... with an AVR ISP Programmer ==== === ... with an AVR ISP Programmer ====
  
-For setting ​the fuse bits one has to type+If one uses an AVR ISP Programmer to set the fuse bits one has to use this command
-  $ sudo avrdude -p m328p -c stk500v2 -P /​dev/​ttyACM0 -U lfuse:​w:​0xFF:​m -U hfuse:​w:​0xDE:​m -U efuse:w:0x05:m +  $ sudo avrdude -p m328p -c stk500v2 -P /​dev/​ttyACM0 -U lfuse:​w:​0xFF:​m -U hfuse:​w:​0xDE:​m -U efuse:w:0xFD:m 
-And for the bootloader:+And for the bootloader ​this one:
   $ sudo avrdude -p m328p -c stk500v2 -P /​dev/​ttyACM0 -U flash:​w:​optiboot_atmega328.hex:​i   $ sudo avrdude -p m328p -c stk500v2 -P /​dev/​ttyACM0 -U flash:​w:​optiboot_atmega328.hex:​i
-Depending on the AVR ISP Programmer it could be that one needs the stk500v1 protocol.+Depending on the AVR ISP Programmer it could be that one needs the stk500v1 protocol ​instead of the version 2 (stk500v2).
  
 === ... with the Paper-AVRISP mkII === === ... with the Paper-AVRISP mkII ===
 +
 +{{:​avr_bootloader:​paper-avrisp_mkii_programming_board.jpg?​400|}}\\
  
 If one has a [[avr_bootloader:​paper-avrisp_mk2|Paper-AVRISP mkII]] one hast to type in the terminal the following. For setting the fuse bits: If one has a [[avr_bootloader:​paper-avrisp_mk2|Paper-AVRISP mkII]] one hast to type in the terminal the following. For setting the fuse bits:
-  $ sudo avrdude -p m328p -c avrispmkII -P usb -U lfuse:​w:​0xFF:​m -U hfuse:​w:​0xDE:​m -U efuse:w:0x05:m+  $ sudo avrdude -p m328p -c avrispmkII -P usb -U lfuse:​w:​0xFF:​m -U hfuse:​w:​0xDE:​m -U efuse:w:0xFD:m
 And for the actual bootloader: And for the actual bootloader:
   $ sudo avrdude -p m328p -c avrispmkII -P usb -U flash:​w:​optiboot_atmega328.hex:​i   $ sudo avrdude -p m328p -c avrispmkII -P usb -U flash:​w:​optiboot_atmega328.hex:​i
  
 +=== Problem Solving ===
 +To erase all fuse bits one can use the attribute: -e\\
 +or even: -e -F\\
 +Sometimes a specific Baud rate helps, too: -b 19200\\
 +For verbose output use: -v\\
  
-  ​ +=== Burning an Atmega328 (without P) == 
-More information one finds at the [[avr_bootloader:​AVRdude|AVRdude]] page.\\ +  
-When using an Atmega328 (without p) use "-p m238"​.\\+When using an Atmega328 (without p) use "-p m238" instead of "-p m238p".\\
  
 ---- ----
-==== Burning an Atmega328 (without P) ==== +==== Links ==== 
- +[[https://​www.arduino.cc/​en/​Hacking/​Bootloader?​from=Tutorial.Bootloader]]\\ 
-The Atmega328 has a different signature than the Atmega328p (p stands for picoPower)When using the Atmega328 for an Arduino Uno and burn with the IDE one has to change the avrdude.conf file. An other possibility is to burn with the avrdude and use -F for sciping the signature check.\\ +[[https://www.fischl.de/usbasp/]]\\ 
-Open the file: +[[https://​www.nongnu.org/avrdude/]]\\ 
-   $ sudo nano /usr/share/arduino/hardware/tools/avrdude.conf +[[https://www.ladyada.net/learn/​avr/​avrdude.html]]\\
-or (depends on the Arduino version): +
-   $ sudo nano /usr/share/arduino/​hardware/​tools/avr/etc/avrdude.conf +
-search with control W for the Atmega328p signature:\\ +
-   0x1e 0x95 0x0F +
-and replace it with the Atmega328 signature:​\\ +
-   0x1e 0x95 0x14 +
-Save and close (contr O and contr X)\\ +
-Now you can burn the Atmega328 with the Arduino IDE (Arduino Uno).+
  
 ---- ----