SMB ATmega32u4

IDEAL INTERACTION:

This is the ideal final product I intend to develop. A USB fake pen drive. Once you connect this device to your computer it will open a blog note and write "You are being observed, turn around slowly".The project invite people to question: How vulne…

This is the ideal final product I intend to develop. A USB fake pen drive. Once you connect this device to your computer it will open a blog note and write "You are being observed, turn around slowly".

The project invite people to question: How vulnerable are we? 

I found Adafruit developed an ATmega32u4 adding a couple of extra security features which is good news for our project. I was able to get their eagle file and redesign the board without all the pins I won't use. As a reminder we just want the ISP and USB interface to program and connect to the computer respectively. 

Adafruit ATmega32u4 breakout board.

Adafruit ATmega32u4 breakout board.

Solder Jumpers

Screen Shot 2018-03-22 at 11.31.14 AM.png

There are two solder joints on the breakout board from Adafruit. According to  its documentation, they are:

VCC solder jumper
The board is powered by the USB port at 5V. There is a 500mA polyfuse to protect your computer from a shorted circuit. If you'd like to run the board off of another voltage, you can do that by cutting the VCC solder jumper bridge underneath and connecting an external voltage to pin #2 of the ISP header. Note that running the board at 3.3v @16mhz is considered overclocking. We do it for prototypes and it seems to work fine but it's out of spec!

HWB solder jumper
If you ever want to disable the bootloader you can cut the bottom 'HWB' jumper trace. This will disconnect the 'hardware bootloader' pin, you can then use the button as a plain reset button. For the first few runs of this board we set the fuses to still use the bootloader even with the HWB jumper cut, if you want to get rid of the bootloader, please set the fuses to remove the BOOTRST fuse. Sorry!

This is important being that our board does not have a bootloader and we will be connecting this guy via USB and ISP 

PROTOTYPING:
BOM:

1 - LP2985-33DBVR
1 - USB 2.0 SOCKET/male
2 - 18pF capacitors
2 - 22R RN3D/2 Resistors
1 - 16MHz KX-7/1 Crystal
1 - ATmega32u4
1 - RN1D 10K/1 Resistor
1 - CAPACITOR 0.1u/4
1 - CAPACITOR 10u/1

All the parts are available at Digikey.com
Fortunately, I had just to buy the Atmega microcontroller. I bought 2 just in case.
https://www.digikey.com/product-detail/en/microchip-technology/ATMEGA32U4-AUR/ATMEGA32U4-AURCT-ND/3440960

DESIGN

I decided to design one-sided board in order to check all the connections just in one look. I was using 14 components which can be arranged without air cables. If I want to make the board smaller I can try to make it double - sided but as long as I decided to acid etching this will make it more complicated.

I decided to get off the solder jumpers (connecting them completely) which will represent a problem in the future, as long as the HWB jumper allows to power up the board via ISP.

FABRICATION:

 

I did acid etching in order to subtract the copper that I wasn't interested in using. Fortunately, all my connections were working without any short cut.

My only issue was that the rubbering acid didn't work for me (It took too long and I had to manipulate the board a lot). I used acetone instead which is stronger

Once I checked this I printed a stencil to put all the solder paste in just one go because I tremble a lot. This work just fine as well. Once I put my parts I used the oven to heat the solder up. The temperature reached 340 degrees Celsius.

I decided to check my connections again and I found several issues:

  1. Some paths were broken. I suppose I manipulated too much the board with the rubber alcohol. Next time acetone as first try.
  2. The crystal 16MHZ is huge and is touching another path which is not supposed to. Getting this crystal out I take off the copper as well so I had to repair manually with some paste and wire. I had to use the microscope because the path is way too thin. I changed the crystal to a smaller one.
  3. All the routes were too thin and easy to break in general.

BURN THE BOOTLOADER

Being that the ATmega32u4 is new, it does not have a bootloader. We have to put it via ISP with the Arduino as Programmer. So we prepare the next set up:

This schematic represents the Arduino connected as programmer to a 6 pin header.

This schematic represents the Arduino connected as programmer to a 6 pin header.

Current status

 

 

 

USB host - Homemade hardware

Have you ever receive a free USB? or maybe pick one up from the street?

CAREFUL. This devices will have access to your hardware with your authorization, sending and receiving data and if you are careless, It might be more data than you intended.

My device will take advantage of its size to camouflage as USB device and work as tool to make people aware of their vulnerabilities. Think it twice you receive an USB from me.

I will use the Keyboard.h library for Arduino. This library allows us to send data from an Arduino to our computer in order to simulate keyboard's keys or even mouse actions. This library just works fine with Leonardo, Esplora, Zero, Due and MKR Family, due to the microcontroller in these boards supports USB host i/o.

https://www.arduino.cc/reference/en/language/functions/usb/keyboard/

The board is the ATMEGA32U4

https://www.digikey.com/product-detail/en/microchip-technology/ATMEGA32U4-AUR/ATMEGA32U4-AURCT-ND/3440960

We ordered two just in case.
Getting the Eagle file from the Arduino Leonardo. We got off all the unnecessary hardware (more of it security measures and I/O pins I won't use). We got this board:

 

arduino.JPG

And this schematic:

 

schematic.JPG

This Microcontroller has (ATMEGA32U4) 44 pins and make a boards in its current state will demand a double-sided copper board which I wont use. The idea is to keep it as simple as possible. So, in the next iteration we will get off of more parts.

What I notice is that Leonardo board does not have a second microcontroller to convert USB to Serial which are good news, meaning that in some way we can connect the USB socket directly to the microcontroller without any middleware. I will keep the 6 headers ISCP to program the ATMEGA32U4 in the future.

So far the list of parts are:

LP2985-33DBVR/1
USB 2.0 SOCKET/1
CG0603MLC-05E/2
22R RN3D/1
22R RN3A/1
MF-MSMFMF050-2 500mA/1
16MHz KX-7/1
CD1206-S01575/1
RN1D 10K/1
CAPACITOR 100n/4
CAPACITOR 1u/4
CAPACITOR 10u/1

Let's hope to make it smaller.

PCB Design.

With the help of our new homemade shield for programming the ATTiny85, we will design a board to host the previous sketch (a little catch up simple analogue input controlling an analogue output).

 

shield.jpeg

The tool used is EAGLE: a software to design circuits and was bought by Autodesk few time ago with many new features according to Andy Sigler, so let's believe in him and these new features. As you can imagine, The software comes with two views to understand the schematic and the real world which I found pretty intuitive. You can appreciate those below:

 

Homemade01-01.JPG
Homemade01.JPG

These two images represent the same circuit:

-ATTiny85
-LED
-Capacitor to decoupling
-Press sensor represented by another resistor
-Resistor to pull down the force sensor
-Resistor for the LED
-Header to provide power

As you can see all the pieces were arranged in a board of 5 * 3 cm approximately with holes of 1 mm to be reached with a bit mill of the same size. The circuit is almost ready to be printed.

 

 

ATTiny85

This is a first experiment burning an Arduino sketch into an ATTiny85 microcontroller. This time we will have an analog input which will control an analog output.

Step by step you should:

  1. Upload Arduino as ISP sketch into your Arduino UNO or similar
  2. Connect everything
  3. "Burn Arduino"
    1. Fuses are set
    2. flash ArduinoBootloader
    3. Select programmer "Arduino as ISP"
    4. Upload using programmer
  4. Upload your sketch using programmer.

According with the ATTiny85's pinout schematic

 

download.png

We have 5 digital pins (blue ones) and 3 analog pin (red ones) which is enough for our little example. Let put a force resistor (analog input 0 - 1023) in order to control a fading LED (which receives 0 - 255).

 

WhatsApp Image 2018-02-01 at 9.18.17 AM.jpeg
//ARDUINO CODE
int led = 1;           // the PWM pin the LED is attached to
int forceR = A1;        // Pin 2 = A1 according to pinout
int force;
// the setup routine runs once when you press reset:
void setup() {
  // declare pin 9 to be an output:
  pinMode(led, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  force = analogRead(forceR);
  brightness = map(force, 0, 1023, 0, 255);
  // LED gets brighter the harder you press
  analogWrite(led, brightness);

}