Introduction: Arduino Nano CH340 Chinese-Build OPTIBOOT BOOTLOADER HACK !
Brief Intro;
WHY do i need the Optiboot Bootloader ?
The Optiboot bootloader is a Quarter the size of the normal bootloader
1.5K instead of 6K and with the programming space on the Atmel Atmega328P-AU being just 32K:-
32K - 6K = 26K
So just 26K worth of code space to write.
Optiboot provides 30.5K worth of code space :)
TheThinker (cheers :})
I'm currently working on combining 4-5 different Arduino sketches to become one (re-writing) and so i need the extra space as all pins are used, many devices on the I2C line and using SPI lol
As i had found just googling, many in my circumstances would find this very useful to extending their code too :)
Google-Fu Failed
I've searched like crazy online and my Google-Fu failed me as there wasnt a solution i could easily find to get Optiboot Bootloader burnt onto these really cheap Arduino-Nano Compatible Boards that use the CH340 IC for the USB TTL to RS232...
This is real simple and took me like 10-15 minutes as im heavily sedated most of the darn time, will take the average joe less time lol
The Solution;
What i did was to FOOL the Bootloader burner i made a few years ago with the help of msuzuki777, its one of my very first PCB Home-Brew Shield's i made so its really crude but i havent got around to replacing it with a shiny professional made PCB because it still works perfectly & i had kinda future-proofed it by adding a switch to select between using "Optiboot Bootloading Process" or 'Arduino As ISP'
Mainly thanks to msuzuki777 !! lol
Here goes, what you do is have the setup on breadboard, a ZIF socket (Zero Insertion Force) would make life real easy but can do it without by breadboard'ing the components from the eagle schematic also supplied.
Step 1: Step 1 - Have a Breadboard Optiboot Circuit Setup
msuzuki777 designed this board, i just added a switch to select between "Optiboot Bootloading Process" or 'Arduino As ISP', included the Eagle Files below so you can make one yourselves or just use the schematic to breadboard it, eaither way, this will last you a lifetime and a hell of a lot LESS headaches and DEAD-END google searching for hours and hours lol
~ Eagle Schematic & Board Attached ~
So 1 - breadboard or make the PCB homebrew style, the SMD components are EASY to solder by hand so dont worry about those, they are a comforatble 1206 Side and pretty large compared to the heat and size of a standard soldering iron tip, which is what i use lol
nothing fancy like hot air SMD reword station - i wish lol
Step 2: Step 2 - FOOL the Optiboot ZIF Socket/Breadboard Setup !
This is where the magic happens, lol
it only takes SIX (YES ~ 6 !!!!) Pins to do this
See in the pic there ive circled in the Sketch of the Optiboot loader, the "TARGET" pins that the sketch will search for, now all we need to do is match up those 6 pins to the ZIF Socket and convert from the ATMEGA328P-AU to ATMEGA328P-PU pinout, which really doesnt take long, keep referring to Photo 2 and Photo 3 back and forth and youll get the idea !!
So in the 'TARGET' List we got these pins only;
#define SCK 13
#define MISO 12
#define MOSI 11
#define RESET 10
So thats 4 Pins plus GND & +5v
~ i added GND from the NANO to Pin 8 of the Thru-hole
~ added VCC (+5v) from the NANO to Pin 7 of the Thru-Hole
Thus making only 6 pins used, a little setup time, GUARANTEED RESULT - (SOLVED)
SOLVED !!!!
So we got the SMD version of the Atmega328P Microcontroller (Uc) on the Nano and the Through-Hole uC being sought after in the sketch - but wait, the sketch is intelligent enough to know that once it detects the SMD version of the ATMEGA328P - it will use the SMD.HEX file for its Optiboot Bootloader !
So for example,
Sketch Pins Thru-Hole Pins SMD-Pins Equivalent
SCK 13 19 17
MISO 12 18 16
MOSI 11 17 15
RESET 10 1 29
So now We've Deciphered which pins to target on the NANO board, stick it into a breadboard and wire the pins directly into the Optiboot setup in previous step, which are;
SMD Pins;
15, 16, 17 & 29 (29 is RST {RESET})
More Pictures Coming Soon :)
Major thanks to;
msuzuki777 for making the Optiboot Bootloading Shield,
The Arduino Team for keeping everything open source (almost lol),
http://pighixxx.com for the awesome pinout Picturres
Caretaker/s of Optiboot
& China for Awesome Mass Produced TECHNOLOGY !!!! lol hehehe
muhahahahahaha :)
Aaaaaand apologies in advance for;
~Anyone ive left out to thank :)
~Apologies if there "WAS" a solution to get an Optiboot Bootloader onto the New China-Mass produced Arduino-Nano Compatible CH340 TTL to Serial boards - it just wasnt obvious or clear and with a wealth of DEAD-ENDS to sift and read thru, apologies ive missed it, it was burried deep as i searched for over 8 hrs straight LOL
NEVER AGAIN :P

Participated in the
Microcontroller Contest 2017
10 Comments
5 years ago
You should be able to burn optiboot just by changing code in boards.txt
http://playground.arduino.cc/Main/CustomizeArduino...
Just copy upload.maximum_size and bootloader.file path from Uno and paste to Nano and burn bootlaoder with another Arduino as ISP or other AVR programmer.
Reply 5 years ago
Wow thats awesome ! thanks for the tip, will give that a try too, always fun getting right into the files to see how it all works, much appreciated :)
Reply 5 years ago
Just remember: do not mess with fuses, unless you know what you change. Fuses keep info about clock source, memory access, etc. Wrong selection may brick uC.
I used that method to burn Optinoot to ATmega328P-AU (Nano's uC), but it used different xtal: 4MHz, so fuses was different. This way it works on single CR2032 3V battery. uC dies when voltage goes lower than approx. 1.6V.
If you want to change fuses for eg. Different clock xtal and different minimum volrage called BOD level you can use some online AVR fuses calculators. They should have fuses description, which allow to understand what fuses do.
Reply 5 years ago
WOW DUDE-MAN ~ !!!
This info is GOLDEN !
Please can you make an instructable for it, i know its a bit more work for you, but this method really deserves an instructable of its own due to the methodology and intricate detail, id love to also link it in my instructable - if you get time, please do let me know when you've done one, the detail about fuses alone really begs for a step by step instruction-dialogue, plus id love to see it laid out too :)
Thanks loads once again, this is what makes instructables and the community great :))
Reply 5 years ago
You also have to cange upload speed to 115200.
I tried it at home and it works well. On other system boards.txt was in C:\Program Files (x86)\Arduino\hardware\arduino\avr.
Heres code for new CPU for Nano board, screenshot shows where to paste it:
## Arduino Nano w/ ATmega328 w/Optiboot
## -------------------------
nano.menu.cpu.atmega328opti=ATmega328 optiboot
nano.menu.cpu.atmega328opti.upload.maximum_size=32256
nano.menu.cpu.atmega328opti.upload.maximum_data_size=2048
nano.menu.cpu.atmega328opti.upload.speed=115200
nano.menu.cpu.atmega328opti.bootloader.low_fuses=0xFF
nano.menu.cpu.atmega328opti.bootloader.high_fuses=0xDA
nano.menu.cpu.atmega328opti.bootloader.extended_fuses=0xFD
nano.menu.cpu.atmega328opti.bootloader.file=optiboot/optiboot_atmega328.hex
nano.menu.cpu.atmega328opti.build.mcu=atmega328p
Reply 5 years ago
I forgot about fuses (they keep info aboat bootloader max size, which is reserved for bootloader only), here's updated code:
## Arduino Nano w/ ATmega328 w/Optiboot
## -------------------------
nano.menu.cpu.atmega328opti=ATmega328 optiboot
nano.menu.cpu.atmega328opti.upload.maximum_size=32256
nano.menu.cpu.atmega328opti.upload.maximum_data_size=2048
nano.menu.cpu.atmega328opti.upload.speed=115200
nano.menu.cpu.atmega328opti.bootloader.low_fuses=0xFF
nano.menu.cpu.atmega328opti.bootloader.high_fuses=0xDE
nano.menu.cpu.atmega328opti.bootloader.extended_fuses=0xFD
nano.menu.cpu.atmega328opti.bootloader.file=optiboot/optiboot_atmega328.hex
nano.menu.cpu.atmega328opti.build.mcu=atmega328p
5 years ago
So an optiboot bootloader is just the same as a normal bootloader for atmel chips but just takes less room in memory . Most would not need it.
Reply 5 years ago
Agreed, not for the beginner, a beginner wouldnt need the extra space, as i commented below, the bootloader being a Quarter the size of the normal bootloader, 1.5K instead of 6K and with the programming space on the Atmel Atmega328P-AU being just 32K:-
32K - 6K = 26K
So just 26K worth of code space to write.
Optiboot provides 30.5K worth of code space :)
5 years ago
Thanks for sharing! I would be helpful to many I imagine if you added an introduction explaining why one would want to do this?
Reply 5 years ago
Most welcome & thx for the encouraging words & good idea, i shall put it into the intro as to why this would be wanted/needed :)
Basically, Optiboot, is a quarter of the size of the default bootloader, freeing 1.5k of extra space to write more code.
I'm currently working on combining 4-5 different Arduino sketches to become one (re-writing) and so i need the extra space as all pins are used, many devices on the I2C line and using SPI lol
As i had found just googling, many in my circumstances would find this very useful to extending their code too :)