Hello everyone,
Last week I received my slim node board designed by m26872 and begun the process of burning the 1Mhz bootloader. I faced some problems for a couple of hours and google helped me to successfully burn it and uploading the sketch.
Please correct me if I missed something. I tried to re-do the steps now before writing the post to make sure it works.
I am using Arduino IDE 1.6.5-r5 with Arduino UNO board.
I used some photos from arduino.cc
I will explain flashing both 8Mhz and 1Mhz configurations.
1- You will need the following
- Arduino UNO ( didn't test using other boards)
- Atmega328p chip ( with preloaded bootloader or without )
- Breadboard
- Wires
- Crystal ( optional )
2-
- Connect your arduino UNO to your laptop.
- Open Arduino IDE.
- Go to File > Examples > Arduino ISP
- Go to Tools and make sure you choose Arduino/Genuino Uno and you COM port.
Your COM port may be different than mine
Note: The following step solved my problem when I failed to upload the bootloader at the beginning.
- Go to Tools > Programmer > Arduino as ISP
Make sure to choose "Arduino as ISP" not "ArduinoISP"
Then upload your ArduinoISP sketch.
- It will take less than a minute.
- Close the sketch ArduinoISP adter uploading successfully.
*********************************** . ***********************************
*********************** Burning the bootloader ***********************
*********************************** . ***********************************
3- For burning the bootloader you have to set your environment as shown in the figure below:
Remove the arduino usb cable and begin wiring.
Double check your wires and make sure they are connected in the correct pin.
*********************************** . ***********************************
********************** Burning 8Mhz bootloader **********************
*********************************** . ***********************************
Quoted from Arduino.cc :
- Download this hardware configuration archive: breadboard-1-6-x.zip
- Extract the zip file. A folder with name "breadboard" will appear.
- Open your Arduino folder path and move the breadboard folder from the zip archive to the "hardware" folder of your Arduino sketchbook.
- Restart the Arduino software.
You should see "ATmega328 on a breadboard (8 MHz internal clock)" in the Tools > Board menu. - Be sure to select "ATmega328 on a breadboard (8 MHz internal clock)" when burning the bootloader.(If you select the wrong item and configure the microcontroller to use an external clock, it won't work unless you connect one.)
- Once you've done this, you can burn the bootloader and upload programs onto your ATmega328p. To burn the bootloader go to Tools > Burn bootloader
It will take less than a minute and leds will flash. Wait until bootloader is burned.
*********************************** . ***********************************
********************** Burning 1Mhz bootloader **********************
*********************************** . ***********************************
-
I followed m26872 guides in his project My Slim 2AA Battery Node to get the 1Mhz bootloader. I'll copy some of his instructions.
-
I use this precompiled bootloader from here. It's an Optiboot with 1MHz internal clock and 9600 baud serial communication. Fuse changed to BOD disable.
-
Rename your .hex to atmega328_1a.hex
-
Move it to "ARDUINO_PATH" > hardware > arduino > avr > bootloaders
- We need to add the new board to the boards.txt file located at "ARDUINO_PATH" > hardware > arduino > avr
- Open boards.txt
- Go to this link.
- Copy the content of the link and paste it at the end of boards.txt
- Restart you Arduino IDE.
- You should see "APM Optiboot internal 1Mhz noBOD 9600baud" in the Tools > Board menu.
- Once you've done this, you can burn the bootloader and upload programs onto your ATmega328p. To burn the bootloader go to Tools > Burn bootloader
Tips about burning the bootloader if it failed:
1- I faced the following issues and was solved as follows:
avrdude: Yikes! Invalid device signature.
Double check connections and try again, or use -F to override
- Maybe your chip is configured to run on an external crystal clock. I tested with two values and it succeeded. I used 10Mhz and 20Mhz as I didn't have 16 Mhz.
- Connect the crystal to pin 9 and 10
- Note: You won't need the crystal except for the first time as the new bootloader is configured to run on internal 1Mhz or 8Mhz.
2-
avrdude: Error: Could not find USBtiny device (0x2341/0x49)
Make sure you chose "Arduino as ISP" not "ArduinoISP" from the programmer list. You will find it in Tools menu.
3-
avrdude: can't open input file D:\arduino-1.6.5-r5\hardware\arduino\avr/bootloaders/atmega328_1a.hex: No such file or directory
avrdude: read from file 'D:\arduino-1.6.5-r5\hardware\arduino\avr/bootloaders/atmega328_1a.hex' failed
Error while burning bootloader.
Your .hex file is not in the correct path.
- According to the .boards file, the path is configured to be in the default path arduino-1.6.5-r5\hardware\arduino\avr\bootloaders
You can find this configuration in the boards.txt as follows:
apm96.bootloader.file=atmega328_1a.hex
If you wish to put the .hex file in a folder, so you will have to edit the path above in the boards.txt
Example:You put the .hex file in > arduino-1.6.5-r5\hardware\arduino\avr\bootloaders\MyOneMhz
So change the line to this: apm96.bootloader.file=MyOneMhz/atmega328_1a.hex
*********************************** . ***********************************
********************** End of burning bootloader **********************
*********************************** . ***********************************
*********************************** . ***********************************
************************ Uploading the sketch *************************
*********************************** . ***********************************
4- Once your ATmega328p has the Arduino bootloader on it, you can upload programs to it using the USB-to-serial convertor (FTDI chip) on an Arduino board. To do so, you remove the microcontroller from the Arduino board so the FTDI chip can talk to the microcontroller on the breadboard instead.
- Set the environment as follows:
The picture at the bottom shows how to connect the RX and TX lines from the Arduino UNO board to the ATmega on the breadboard.
After finishing wiring and recheck connections:
- Choose your desired board which we have added before and burned the atmega328p with it.
- Upload your sketch normally.
- Leds will flash in the Arduino UNO board.
- Sketch will take some time with 1Mhz and it is faster with 8Mhz because of the baud rate chosen in 1Mhz.
*********************************** . ***********************************
*************************** ** References ** **************************
*********************************** . ***********************************
- How To Load Bootloader onto Arduino
- Re: Burning bootloader on standalone Atmega328(internal clock 8MHz)
- From Arduino to a Microcontroller on a Breadboard
*********************************** . ***********************************
*************************** ** THE END ** *****************************
*********************************** . ***********************************
I hope it was clear enough and doesn't contain mistakes. Please let me know if something was missing.
I encourage you to add your tips and tricks so that we can learn.
Thanks.