Friday, 1 June 2018

linux - Error while uploading hex file to AVR uC


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?



Answer



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.


No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...