Projects/Minimus32

MINIMUS AVR USB V1 Board(AT90USB162) and AVR USB 32K(ATMEGA32U2)

Introduction
The Minimus AVR USB V1 board and the Minimus AVR USB 32K boards are tiny Atmel 8 bit processor boards with USB interface and all I/O brought out to .1" pitch solder pads. The V1 and the 32K boards are identical except for the processor fitted.

The board has a large amount of open source and free software already available.

The origins and low cost of the hardware are from the PS3 hack at the end of 2010 called PSGroove.

Thanks to members of the London, Manchester, and Reading Hackspaces, we got a quantity of the V1 boards at £2.63 each in April 2012 and a quantity of the 32K boards for £3 in October 2012.

Hardware Description
Minimus suppliers data provides a description, useful links, and some sample code.

AT90USB162 Datasheet describes the V1 Processor in more detail.

ATMEGA32U2 Datasheet describes the 32K Processor in more detail.

The key additions over other small Atmel AtMega processors are:
 * USB Full speed device interface capable of offering different device types and classes(serial CDC, HID, ...)
 * Onboard voltage regulator providing 5V or 3.3V operation and interface
 * Retains USART, so offering USART plus virtual serial ports simultaneously

The key limitations are:
 * No I2C
 * No analogue to digital converters, analogue comparator might be used with PWM DAC
 * Limited Memory, only 12K of remains when bootloader presenton the AT90USB162. RAM is also only 512 bytes on the AT90USB162. So avoid too many text strings or at least keep them in program space!

Minimus do not publish the Schematic, though it has been reverse engineered with other useful hardware information here by Talpa Schematic and Hardware Information

Reading using ISP the Minimus is shipped with the lock bits of the AT90USB162 and the ATMEAG32U2 is set to:

LB = PROG_VER_DISABLED, BLB0 = NO_LOCK, BLB1 = SPM_DISABLE

LOCKBIT = 0xEC (valid)

And the fuse bits are:

BODLEVEL = 3V0, HWBE = [X], DWEN = [ ]. RSTDISBL = [ ] SPIEN = [X], WDTON = [ ], EESAVE = [ ], BOOTSZ = 2048W_1800 BOOTRST = [ ], CKDIV8 = [X], CKOUT = [ ], SUT_CKSEL = EXTXOSC_8MHZ_XX_258CK_65MS

EXTENDED = 0xF4 (valid)

HIGH = 0xD9 (valid)

LOW = 0x5E (valid)

Note: the Watchdog timer reset and the clock prescaler are set. Change this in application if you want different.

Programming Minimus
A new Minimus board has the Atmel DFU USB bootloader already installed and no application program present. To communicate to the DFU bootloader, the USB drivers for Atmel DFU must be correctly installed, and a compatible programmer application run under Windows or Linux. For Windows the GUI programmer is FLIP, and the FLIP package also includes BatchISB a command line version. For Linux the programmer is dfu-programmer. The role of the programmer application in conjuction with the Minimus bootloader is to program a .hex file into the flash memory of the AT90USB162 chip. Installing these programming applications and drivers does not interfere with other loaders and drivers such as those for Arduino.

You can get a detailed setup guide for the Atmel FLIP software and drivers here: setup PDF


 * Tools and Utilities for Windows
 * Tools for Utilities for Linux
 * Libraries

Can we use Arduino IDE and run Arduino code direct on the Minimus ?
Yes, but some modifications are required first.

You will have to replace the bootloader of the Minimus with one that has been modified to mimic an Arduino Leonardo. PBrook of the Leeds HackSpace has the files available on his github page and it will require a programmer or an Arduino acting as one. There is also an informative wiki.

The github repository also houses the sketchbook files necessary for the Arduino IDE (min version 1.0.1) to have the correct board profile for talking with the modified Minimus32.

Further to this, there is also a modified OneWire library which takes advantage of the on-board pull up resistor.

The Leeds HackSpace also has a wiki on the Minimus32 which is still in development.

Projects
And an example program which flash's the LED's and responds to the buttons here: led_test.hex and src. This hex file worked OK on my Minimus, but the source project files were not compatible with the latest AVR Studio 5 from Atmel, and also a hex file made from the provided source file had continual watchdog timeouts. A new AVR studio project and a fix to the watchdog disable code quickly fixes that, so you can now build you own hex files based on this using the available documentation and snippets of Atmega code from Arduino or elsewhere.
 * Blink Demo Program

To create .hex files you need a compiler or development environment. The best is probably the AVR Studio 5 from Atmel. The Arduino IDE does not support the Minimus board.

I have put an AVRStudio 5.1 project here with the changes I made: avr-usb-162_led.zip

The latest Arduino Uno uses an ATMega8U2 for the USB to serial interface in conjunction with the ATMega328 used for th Arduino code. The UNO USB to serial code is small enough to fit easily in the AT90USB162. The Minimus can therefore be used to provide an alternative to a USB serial cable to download to Arduino Pro Mini and similar boards. The link on the Minimus board allows it to be used with either 5V or 3.3V Arduinos.
 * USB to Serial

The hardware configuration simply requires a 6 way .1" IDC female connector to go to the Arduino board as follows:

Arduino_Pin    Function   Colour    Minimus_Pin 1              Ground      Black    Gnd 2              Unused      Brown    None 3              Vcc         Red      Vcc      Wire may be left off if Arduino is self powered 4              Txd         Orange   PD3 5              Rxd         Yellow   PD2 6              DTR(Reset)  Green    PD4      Add 1K resistor to ground

The AVRStudio 5.1 Project is here: MinimusUno.zip. The USB to serial worked fie on my Arduino Pro Mini (5V/16MHz), but failed initially to work on an Arduino based board I built myself. The problem was with the automatic reset, and I added the 1K resistor from Reset(PD4) to ground as fitted on the Uno, this fixed the problem.

The interface uses the Lufa USB library, the project only contains part of the library.

The code is derived from Uno Loader sources from Arduino.


 * AVR-ISP

I recently built an arduino based board and needed to load the bootloader into the ATMega168 I used. The board had a 6 pin ICSP connector, so I built an AVR ISP MkII clone.

Don't cut the USB pin as the blog describes leave out the Vcc wire in the cable so USB powers the Minimus.

The firmware is available within the lufa projects. Change the makefile to use the Minimus board so the LEDS work properly.

For the 6 pin ICSP connector, I wired as follows:

ICSP_Pin       Function    Colour   Minimus_Pin 1              MISO        Black    PB3 2              Vcc         Brown    None     May connect to Minimus Vcc if you want to power the board you are programming 3              SCK         Red      PB1 4              MOSI        Orange   PB2 5              RESET       Yellow   PB4 6              Ground      Green    Gnd

You can use this ISP programmer to change the bootloader in another minimus AVR.

Board is recognised as AVR ISP MkII by AVR studio. It may not be recognised by the Arduino IDE or AVRdude, because the AVR STudio USB drivers when installed override the Arduino drivers. You need to delete the USB drivers and use the Arduino supplied ones.


 * Bus Ninja

Bus Ninja


 * Arduino and Bitlash

I have not found a ready made solution to load Arduino sketches into the Minimus from the IDE. The Teensy product V1.0 was based on the AT90USB162 and does acheive this goal, however it uses a closed source HID bootloader(Halfkay). Dean Camera from Lufa made an version called TeesnyHID which uses conforms to the Teensy protocol, though larger. Teensy changed their software to not recognise TeensyHID so now a dead end.

Dean also has a CDC serial bootloader which works on the Minimus, but it conforms to AVR109 bootloader specification and not STK500 used by Arduino, so cannot be used with Arduino IDE. Works with AVRdude though.

The new Arduino Leonardo product will use the ATMega32u4 which has a higher spec. than the AT90USB162. This is not supporting the AT90USB162 and not yet completely working in the Beta. While it might be adapted it is probably better to wait until Leonardo is stable.

For now, I am personally happy to use AVR Studio and existing avr 8 bit libraries. If anyone wants to start a project to use Leonardo on Minimus, I might help.

As an example of a project to use the Minimus, I am posting notes from Barnaby about how to use the Minimus for this rather specialist application. The TVRR is based on the RepRap 3D printer with specially designed electronics. Much of the build has been undertaken at RHS - MikeTheBee
 * Using the Minimus as an AVR Firmware loader for the TVRR Controller

Barnaby Shearer	- Posted on TVRRUG Google Group on Apr 16 2012

Here are some provisional firmware steps to get you going.

First clone Michel's git repository:

git clone https://github.com/buserror-uk/Marlin.git curl http://arduino.googlecode.com/files/arduino-0022-64-2.tgz | tar -xz cd Marlin/Marlin git checkout -b local origin/dev-michel

Then build. You will need a working version of avr-gcc on your path, then:

make

Then you need to know if your AVR has been programed with a bootloader. If so you should be able to upload strait away, though you may need to change PORT=/dev/arduino in the Makefile to PORT=/dev/ttyUSB0 or whatever your printer has been detected as.

make upload

If you don't have a bootloader you will need a AVR ISP to flash the firmware. If you have a Minimus they can be easily made into an ISP. Simply get LUFA:

svn checkout http://lufa-lib.googlecode.com/svn/trunk/ lufa-lib cd lufa-lib/Projects/AVRISP-MKII

Change the BOARD=USBTINYMKII to BOARD=MINIMUS in the makefile and build and upload using flip etc.

You then need to wire the Minimus to the 6-pin IDC header on the OMCA. http://www.batsocks.co.uk/readme/isp_headers.htm:

1 MISO  = PB3 2 Vcc   = Vcc 2 Sck   = PB1 4 MOSI  = PB2 5 RESET = PB4 6 Ground = Gnd

Then back in Marlin change the Makefile to:

AVRDUDE_PROGRAMMER = avrispmkII PORT = usb

and run:

make upload

I had best results also removing the -D from the AVRDUDE_FLAGS in the Makefile so that I got a full erase on each flash.

- Barnaby

Other useful links
Project YACC is a project from the London Hackspace for a AT90USB162 board and describes some Arduino integration.

Teensy is a product based on the Atmel USB devices including the AT90USB162 in early versions. It is the most integrated to Arduino, but the loader used is product specific and not open source. Some useful libraries and ideas.

DFU Programmer is a Linux command line loader program. Seems to be able to set fuses in AT90USB162, so more options, but higher risk.

Jamie Lentin provides some useful programming tips under Linux and an Arcade Joystick project.

YouTube Link Video of workshop held 1st April 2012, in 3 Parts.