The Windows way of doing that is just using ATMEL Studio but we don't have it in Linux. As a customization freak, I'll just write the steps of how to compile and flash your program to an AVR microcontroller and leave the rest for you. So integrating this steps into your favorite IDE, if you are using one, is your job.
These are the tools that we need to install, just pull them from your package manager (These package names exists in Arch Linux repos, they might differ in other distros repositories): - avr-gcc GNU C compiler for AVR architecture - avr-libc AVR libraries - avr-binutils Some AVR tools, we need it to create hex files from compiled programs, because avrdude needs a hex file instead of a binary to flash. - avrdude A dude that is required to perform flashing
Compile it.
avr-gcc main.c -Os -Wall -mmcu=atmega32 -o main_bin
Convert your program to hex from binary.
avr-objcopy -j .text -j .data -O ihex main_bin "main.hex"
Flash it.
avrdude -c usbasp -p m32 -U flash:w:"main.hex"
avrdude
When you do the last step, you will get an error that says you don't have permissions. You can just run avrdude with sudo and it will work this time. But of course this is not the preferred way to do it. What you need to do is write an udev rule so we can access programmer without root privileges.
/etc/udev/rules.d/55-avr-programmer.rules
Write this into file:
# USB-ASPcable ATTR{idVendor}=="16c0", ATTR{idProduct}=="05dc", GROUP="plugdev", MODE="0666"~
Again, as you can see this configuration is for my programmer, usbasp
. You need to change idVendor
and idProduct
according to your device. To find these values, just run lsusb
(If you are using usb extender cord or something like that, it is possible that lsusb might not display your device. Just connect your programmer directly to your PC if that is the case):
> lsusb ... Bus 003 Device 010: ID 16c0:05dc Van Ooijen Technische Informatica shared ID for use with libu ...
VENDOR_ID:PRODUCT_ID
. So edit your file according to this information.You may restart your computer or just use these commands to reload udev rules:
$ sudo udevadm control --reload-rules $ sudo udevadm trigger=