3
\$\begingroup\$

I am trying to upload a hex file to an ATtiny85 from Ubuntu by running these commands:

avr-gcc -mmcu=attiny85 -Wall -Os -o src.elf main.cpp
avr-objcopy -j .text -j .data -O ihex src.elf src.hex
avrdude -p t85 -c avrispmkII -e -U flash:w:src.hex

I get this error:

avrdude: ser_open(): can't set attributes for device "/dev/ttyS0": Inappropriate ioctl for device

I tried to use different USB ports, but that didn't help. How can I resolve this issue?

\$\endgroup\$
  • \$\begingroup\$ Try using 'sudo' before the avrdude command, you might have your usb permissions a little whacky. Also you may need to make sure you're using the right port which you can override with the -P flag to avrdude. \$\endgroup\$ – NickHalden Apr 29 '13 at 17:44
  • \$\begingroup\$ Nope, 'sudo' did not work... \$\endgroup\$ – user151324 Apr 29 '13 at 17:47
  • \$\begingroup\$ You might see stackoverflow.com/questions/9929587/… Can't really help you with the AVRISP beyond that so removed my answer which applied more to stk500 style USB serial programmers/Arduino ISP sketches. \$\endgroup\$ – Chris Stratton Apr 29 '13 at 17:59
  • \$\begingroup\$ ) Unplug your programmer; 2) On the command line enter sudo dmesg -c; 3) Plug in your programmer; 4) On the command line enter `sudo dmesg -c again and copy its output into your question. \$\endgroup\$ – jippie Apr 29 '13 at 22:40
  • \$\begingroup\$ This is pretty easy to solve once you know what to look for. Consider joining us in chat: chat.stackexchange.com/rooms/15/electrical-engineering I can talk you through it. \$\endgroup\$ – jippie Apr 29 '13 at 22:42
3
\$\begingroup\$

A short write-up from chat.

First make sure the driver module is loaded, apparently this does not happen automatically:

Option 1: On the fly: modprobe cdc-acm

Option 2: To load the module at boot time:

  • sudo bash -c 'echo hoi >> /etc/modules Notice the double >> is important.
  • reboot
  • check if the module is loaded: lsmod | grep cdc-acm && echo success || echo failed

You should be able to program the device using:

sudo avrdude -v -p t85 -c avrispmkII -P usb -U flash:w:src.hex

Check this question for more information: https://stackoverflow.com/questions/5412727/avrisp-mkii-doesnt-work-with-avrdude-in-linux

Not sure what the reason is for the error message you reported at this point:

avrdude: stk500v2_command(): command failed
avrdude: stk500v2_program_enable(): bad AVRISPmkII connection status: Target not detected
avrdude: initialization failed, rc=-1 

Your to do list:

  1. Automatically load the cdc-acm module => Described above.
  2. Figure out what is wrong with your udev rules, so you do not have to use sudo for programming => check https://askubuntu.com/ for that.
  3. Figure out why the programmer doesn't respond. https://electronics.stackexchange.com/ is the right place. A picture of your setup will help. As it is a different error than you started with, I think a new question is justified.
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.