Arduino Nano CH340 Chinese-Build OPTIBOOT BOOTLOADER HACK !
by offtherails2010 in Circuits > Microcontrollers
4515 Views, 18 Favorites, 0 Comments
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 - 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 - 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