MEAM.Design - MAEVARM - Getting Started in Linux



Ubuntu 12.04

To flash an M2 on Ubuntu 12.04, use the following steps:

From the terminal, install some nifty programs from C compiling and avr flashing:

sudo apt-get install gcc-avr avrdude avr-libc dfu-programmer

Option 1

Download the Makefile and sample C file from the medesign wiki.

Run sudo make flash. The C code will be compiled and then flashed to the M2.

Option 2

1. Download the template code

2. Place your source files (*.c) in atmega/src folder

3. Place your header files (*.h) in atmega/inc folder

4. Navigate terminal to atmega folder and execute:

make

5. You should see some information about your compiled files and memory usage and the last line should be

[>-----Build Successfully-----<]

6. Run sudo make flash. The C code will be flashed to the M2.


Ubuntu 11.10 & 10.04

To flash an M2 using Ubuntu 11.10 & 10.04, use the following steps (based off of Niko's):

From the terminal, install some nifty programs from C compiling and avr flashing:

sudo apt-get install gcc-avr avrdude avr-libc dfu-programmer

Download the Makefile and sample C file from the medesign wiki.

To compile, run make in the directory where you put your main.c and Makefile (if you get an error like "make: Nothing to be done for 'all'." then run make clean to get rid of some of the files created the last time you compile) This will generate a couple of files -- you'll want to make sure you have a "main.hex" file.

Finally, to flash the code, run:

sudo dfu-programmer atmega32u4 erase
sudo dfu-programmer atmega32u4 flash main.hex

And there you go -- you've flashed a board in Ubuntu 11.10 / 10.04!


Running dfu-programmer without sudo

To avoid needing to run dfu-programmer as root:

  • Create a new file in /etc/udev/rules.d, called something like '90-atmega32u4.rules'
  • In that file, add the following line:
SUBSYSTEMS=="usb", ATTRS{idProduct}=="2ff4", ATTRS{idVendor}=="03eb", MODE="0666", SYMLINK+="m2"
  • Reload the udev rules: sudo udevadm control --reload-rules
  • When you reconnect your micro, it should show up as /dev/m2, and you shouldn't need to use sudo when running dfu-programmer or make flash anymore


Troubleshooting

"Device or resource busy" when trying to connect to the M2 via a serial terminal

This usually happens on Ubuntu, and is caused by the modem manager seeing the new serial connection and trying to determine if it's a modem (tying up the connection in the process). Uninstalling the modem manager is the easiest fix: sudo apt-get remove --purge modemmanager

\\