Boot Cloner

Not rated 31,411

Circuit Image

The boot-cloner is a program compiled and burned using the Arduino IDE that copies part of its flash memory onto another microcontroller. The bootloader can be written to a new microcontroller by the Arduino, eliminating the need for a separate device to burn the bootloader onto new ATmega8s. For those requiring multiple microcontrollers, this tool facilitates quick preparation of dozens of new ATmega8s. The program utilizes an implementation of the ISP protocol and manages tables stored in program flash without occupying RAM. A functioning Arduino is necessary to write programs, and if there is no ATmega8 with a bootloader, a separate device like a parallel port burner is required. The setup includes three LEDs and current-limiting resistors appropriate for the device's voltage, such as 220 Ohm resistors for 20mA when using a 5V Arduino. For a 2.4V battery-powered device, lower resistors should be used to maintain 20mA. Additionally, two ceramic disc capacitors of 10pF (non-polarized) and a 2 to 16MHz crystal oscillator for the target microcontroller are needed. A minimum of 1MHz is required for the crystal, as its speed determines the maximum command and data transfer rate to the target IC via ISP. The target ATmega8 must be oriented correctly, with the notch facing up. The In-System Programming (ISP) protocol, developed by Atmel, serves as the primary means for programming their microcontrollers. This three-wire serial protocol allows for writing fuse bits, programming memory, and EEPROM. The initial command issued through ISP, while holding the RESET pin low, is called program enable. Following this, various commands can be issued serially, including reading/writing flash memory, erasing flash memory, and more. The Boot-Cloner sketch implements the ISP protocol for an ATmega8, encapsulating commands in functions for ease of use. These functions are compatible with many other Atmel microcontrollers but have not been extensively tested. The bootloader for the new ATmega8 is stored in a large array due to default fuse bits preventing reading of the boot section. This challenge, however, opens up new possibilities. In summary, the Boot-Cloner can write any program to any Atmel microcontroller, but the program size is limited by the source memory, making it suitable mainly for small programs like bootloaders. The ISP protocol is detailed in the Atmel ATmega8 datasheet, with additional comments in the sketch's source code explaining command parameters and the flash write process. The Arduino supplies power to the entire circuit, and it is advised to unplug the Arduino before connecting +5V and GND to the target microcontroller to prevent potential shorts that could damage the hardware.

The boot-cloner circuit is designed to facilitate the programming of ATmega8 microcontrollers efficiently. The circuit includes an Arduino, which serves as the programming interface and power supply. The Arduino is connected to the target ATmega8 microcontroller via three specific wires that correspond to the ISP protocol: MOSI (Master Out Slave In), MISO (Master In Slave Out), and SCK (Serial Clock).

Three LEDs are incorporated into the circuit for visual feedback during the programming process. These LEDs are connected through current-limiting resistors, calculated based on the voltage supply and desired current. For a 5V system, 220 Ohm resistors are used to allow for 20mA of current through each LED. For a lower voltage system, such as a 2.4V battery, the resistors must be adjusted accordingly to maintain the same current.

The circuit also requires two ceramic capacitors of 10pF to stabilize the oscillator circuit, which is essential for the timing of the ISP commands. A crystal oscillator, rated between 2 to 16MHz, is connected to the target microcontroller to provide the necessary clock signal. Care must be taken to ensure the crystal oscillator is rated appropriately, as using a lower frequency than 1MHz can hinder the programming speed.

The target ATmega8 microcontroller must be positioned correctly in the circuit board, with the notch on the chip aligned to indicate the correct orientation. This is crucial to prevent miswiring, although the circuit design is robust enough that incorrect orientation may not cause immediate damage.

The ISP protocol, as specified by Atmel, allows for comprehensive control over the microcontroller's programming features. The Boot-Cloner sketch implements this protocol effectively, allowing for operations such as reading and writing memory, programming fuse bits, and managing EEPROM data. The commands are encapsulated in functions that simplify their usage, making the boot-cloner accessible even for those with limited experience in microcontroller programming.

In conclusion, the boot-cloner circuit is a versatile and efficient solution for programming multiple ATmega8 microcontrollers, significantly reducing the time and effort required compared to traditional methods. By leveraging the ISP protocol and the Arduino's capabilities, users can streamline their microcontroller setup process and enhance their project development efficiency.The boot-cloner is a program compiled and burnt with the Arduino IDE, that copies part of it`s flash memory onto another microcontroller. The bootloader can be written to a new microcontroller by the Arduino, instead of burning the bootloader onto new ATmega8`s with a separate device.

If you`re like me, then you need more than one microcontroller, so you can put the IC into a circuit and leave it there permanently. Unfortunately, burning multiple bootloaders can be a very involved, time consuming process. The cloner will help you get dozens of new ATmega8`s ready to use, in seconds. The program gives you access to an implementation of the ISP protocol and declaring and using tables stored in program flash, which don`t occupy ram. You need a functioning Arduino that you can already write programs to. If you don`t have at least one ATmega8 with a bootloader on it, you`ll need to burn it using a separate device, like the parallel port burner.

three leds and current limiting resistors appropriate for the voltage of the device. If you`re working from the Arduino, you`ve got 5V which means 220 Ohm resistors for 20mA. If you build a 2. 4V battery powered device, use lower resistors to get 20mA. (Voltage divided by current tells you resistance, so 2. 4/. 02=12 Ohms, 10 approx) two ceramic disc capacitors of 10pF (with no polarity) and a 2 to 16MHz crystal oscillator for the target microcontroller. Don`t use less than 1MHz; the speed of this crystal determines the maximum rate you can issue commands and send data to the target IC, with ISP.

16MHz was convenient for me, but use whatever you`ve got on hand. Make sure you have the notch on the target ATmega8 facing up. I can`t tell you how many times I`ve accidentally tried wiring the microcontroller upside-down. The good news is doing that doesn`t seem to hurt anything. In-System Programming (ISP) is a protocol developed by Atmel to be used as the primary means of programming their microcontrollers. The three wire serial protocol can be used to write the fuse bits, program memory and eeprom. It`s a bit of a language by itself, and varys slightly from one microcontroller to another - mostly by chip architecture differences.

(i. e. flash/eeprom size and fuse bit features) While holding the RESET pin of the microcontroller at a low level, the first command issued through ISP is called program enable. After those special 32 bits are sent, the microcontroller begins communicating. There`s several commands that can be issued after program enable, which are sent serially at any rate: reading the flash memory, writing the flash memory page-by-page, erasing the flash memory, reading/writing the fuse bits or eeprom, reading device codes and more.

In the Boot-Cloner sketch is an implementation of the ISP protocol for an ATmega8, complete with functions that encapsulate the protocol`s commands - making them easier to use. These functions are compatible with many of the other atmel microcontrollers as-is, but haven`t been tested yet.

The bootloader written to the new ATmega8 is stored in a large array - because default fuse bits of your Arduino prevent reading the boot section. This was a problem I ran into, but the table that had to be added also provides new possibilities. To sum it all up, this means the Boot-Cloner could write any program to any atmel microcontroller. But, because the target`s program must be stored in the source`s memory (which limits the maximum size of the program) it`s only possible to write small programs like bootloaders.

The ISP protocol is detailed in the Atmel ATmega8 datasheet, towards the end. Additional comments in the sketch`s source code describe command parameters and the flash write process. The Arduino will provide power to the entire circuit. Unplug your Arduino before wiring +5V and GND from it, to the target microcontroller. This avoids potential shorts which could damage your hardware. Based on 🔗 External reference