This project is a clone "rip-off" of the Adafruit Pro Trinket bootloader project. Without this clever code and the underlying V-USB codebase by Objective Development, this project could not be possible. Thanks to Frank Zhao (USnoobie fame) for this bootloader implementation!
Now, what we have in this project is essentially a bootloader that mimics the USBtiny AVR programming dongle. For our purposes, this means that we can use some rather simple hardware tricks to make the Atmega328P microcontroller appear to be connected to a USBtiny for the purposes of programming. Yes, that is cool - and all done by the bootloader. If that was not enough, the bootloader also contains the Optiboot bootloader, too - so you can program the microcontroller over a serial TTL interface.
Adafruit supplies a full schematic for their product here. My implementation may (or may not) use the exact same parts value for resistors, the values I use have been found to work acceptably over numerous V-USB projects. I make no representation as to how "compatible" this project is with Arduino; however I have tested several sketches on GUI version 1.0.6 and have had only success.
Adafruit has created an installable signed driver package for Windows! This package must be downloaded and installed per Adafruit's instructions.
I would encourage non-experts who like the idea of the Pro Trinket to purchase from Adafruit since they support the Open Source movement and Arduino by licensing the brand. Supporting vendors that support us is just good business. However, if you are a true hacker... continue below!
The parts required are minimal - the same used on my Chachka project on Hackster.io - therefore, I refer you to that project for a list of parts and possible vendors of same. I warned in the Chachka project about the 3.6V Zener diodes and I will issue that warning here: you must use low-wattage zener diodes because of the junction capacitance - I recommend IN5227B-TAP. The two zeners and the 68 Ohm resistors are critical values. The authoritative information is here.
In my opinion, this is an advanced Arduino project. Mistakes made in the construction of this project may render you USB port and/or entire computer inoperative because the power and data lines of the USB port are exposed. Proceed at your own risk.
In Chachka, Attiny85P-PU pins D3 and D4 were utilized for the USB interface. In this project, D2 and D6 will be used: Atmega328P-PU physical pins 4 and 12.
Adafruit has two versions of schematics and you can construct either version. However, I am only addressing the 5 Volt version in my Windows batch script - you can easily edit the script to upload the 3.3V firmware - note that this version is not 16MHz, but is 12MHz.
Finally! To proceed with the upload of the HEX files and the setting of the three (3) required fuses, you need to have access to an ArduinoISP (software+UNO) or other device for uploading HEX to the Arduino. You device must be supported by AVRDUDE, a utility that is installed with the Arduino GUI and it is this utility that the GUI calls after a successful compile to upload your Arduino board.
I cannot make you read the following link, but I strongly recommend that you do... the knowledge gained will be of great value to you, READ THIS!
When the Arduino GUI software and tools are installed, they reside in the Windows Programs directory. Different versions of Windows have a different name for this location. Depending upon your version of Windows and Arduino, you will likely need to edit line 3. Line 4 and line 5 will also require a little editing as most readers will have their Arduino home directory on drive C: and the path will most likely be: CD C:\Documents\Arduino\hardware\ProTrinket
The name of this script file is: MAKE328.CMD
I would prefer that you go to the Adafruit Github and download the latest files, but the ZIP above has that archive bound with a 20150113 date. There is also a board.txt file in the ZIP that is required for the Arduino GUI 1.0.6. At present, Adafruit has not issued a file that will support Arduino GUI 1.6.0rc1, but the edits are simple for those individuals that wish a bit of a challenge. For now, I'm only providing nothing more or less that what Adafruit does.
- The ZIP must be installed in your Documents directory and subordinate to the Arduino home folder: for most users, this will be C:\Documents\Arduino\hardware
- Create a folder named ProTrinket and unzip the files. Make certain that Arduino is not running at the time. When the files have all be uncompressed, go to the next step.
- Navigate to the folder: C:\Documents\Arduino\hardware\ProTrinket
- Right-click on the filename MAKE328.CMD
- Select "Edit" from the menu. If asked, select Notepad as the editor.
- Locate lines 3, 4, and 5 and edit the environment to match your PC.
- DO NOT close the file yet.
At this time, you need to set-up your AVR chip programmer. As stated, this can be an UNO running ArduinoISP software, an AVRtiny or TinyISP, or STK500 type of device. These are USB connected peripherals and some will enumerate as virtual communications ports (Ex: com8) and other will enumerate as custom types (Ex: usbasp).
- In lines 17, 19, 21, and 23 you will need to change com9 (and maybe -b 19200) to match the requirements of your programmer. Unfortunately, this will require you to read and understand your reference documentations. IF you are using ArduinoISP, then you only need to change the com9 to whatever port your OS picked. This link may be useful to owners of other programmers.
- Now, close the editor and confirm the overwriting of the file.
- Connect your programmer or UNO acting as ArduinoISP.
- Insert a blank (or previously used) Atmega328P-PU.
- Double-click on the filename MAKE328.CMD
- Press ENTER to start the process.
Before using your newly programmed chip in your V-USB design, please read Adafruit's description of normal use here.
Here is a summary of how I do it, however.
- I open Arduino 1.0.6
- I select Pro Trinket 5V/16MHz (USB)
- I load or write my script
- I ensure the Pro Trinket is plugged into USB
- I press the Reset button
- I use the menu option File / Upload Using Programmer Ctrl+Shift+U
That is a wrap. I did notice that the very first time that I used the system, that pressing the Reset button was not necessary (no program in Flash!) After the 1st programming, pressing Reset was necessary.
Now you can Print Over USB (kind of!) The magic is a project from RAYHOBBY.NET (No relationship) which was modified by Frank Zhao of Adafruit (before he left for Sony) to provide a great way to do diagnostic printouts over USB to a dedicated Java console - provided as both executable for Windows and source code. Get this library here. Frank explains serial over USB here. And I have a working test in this pix:
I hope you have fun with your new Tchotchke! Be sure to read about the update to my prototype below!
Below is my logfile:
I got crazy and decided I wanted to craft a Tchotchke the size of a USB storage stick. I had a dead 8G drive and I pried open the case, removed the dead stuff, and proceeded to measure. Just barely enough space for a 16MHz Atmega328P-PU, small breadboard, crystal, USB male connector, 3 resistors, and 2 zener diodes. Tight.
Caveat: The copper tape in my design acts as a ground plane and "adds" enough capacitance to avoid the need of using crystal load caps. Because this concept is not inline with accepted practice, I cannot promise that you will be as fortunate as I. The two caps "may" fit underneath the chip on the bottom of the circuit board and again, they may not. Caps "could" be built with copper tape and Kapton tape.
Here is my new prototype in pictures: