Arduino IDE sketch upload via AVRSPMKII

Hi,
there is a similar thread but I don't want to borrow it, so i make my new and own one:

My Problem:
Upload a sketch to a raw ATMEGA328P
I tried several hints I found in diverse threads and forums.
My board is Arduino UNO ATMEGA 328P
My Programmer is a clone AVRISPmkII "mySmartUSB light" uses stk500v2
My system is ubuntu 11.04
Arduino IDE 1.0

I want to use Arduino IDE to flash the sketch onto the raw device without changing the fuses (keep the internal oscillator alive) and thus use no bootloader

"avrdude" which i installed to linux using "apt-get install avrdude" connects to both
my raw 328P and the one on the UNO board at least reading, so I can download
the fuse settings and flash content and the like.

But using the IDE I get the well known ".... programmer does not respond" error

in this thread http://arduino.cc/forum/index.php/topic,96715.0.html an answer was:

There is no need to modify anything in IDE 1.0. Just

  • connect your AVRISP mkII six-pin header to Uno,
  • set Tools - Board - Uno,
  • set Tools - Programmer - AVRISP mkII,
  • make sure Uno has power.
    You must upload using File - Upload using programmer instead of File - Upload.

So I did and here is what i get
Setting the correct serial port : /dev/ttyUSB0
Setting the correct board : UNO
Setting the programmer to : avrispmkII
Verifing the sketch OK

Upload via button or File->Upload returns
sometimes 'avrdude: stk500_getsync(): not in sync: resp=0x1b'
mostly 'avrdude: stk500_recv(): programmer is not responding'

Upload via File->"Upload using programmer" returns
'avrdude: usbdev_open(): did not find any USB device "usb" '

Assumptions:
In the installation directory of arduino /arduino-1.0/hardware/tools is an avrdude located which is used by the arduino ide 1.0 and may be different from the linux installed avrdude.

Possible solutions:
1)
Make the bitstream from the sketch (and find it on the harddisk)
and upload it using the linux installed avrdude
To do(try) this I need to know where the bitstream (hex file) ist located.
So where ist the hex file of the sketch located so I could try 1)

Replace the arduino avrdude by the linux avrdue (litterally) (I did not try this)
Was this done by someone , any experience?

with the arduino avrdude came a avrdude.conf which might need some tweaking
but I don't know what would make the difference in there
Too much possibilities to tweak at?
Did anybody tweak the /arduino-1.0/hardware/tools/avrdude.conf
What was done to get the programmer responding, if this is the reason??

Upload via File->"Upload using programmer" returns
'avrdude: usbdev_open(): did not find any USB device "usb" '
Why is this, when the correct settings in the tools menu are all done?
Where does ardunio get the avrdude -P parameter (which seems to be wrong)?

thanks a ton for your reading and possible replies

Martin

1) So where ist the hex file of the sketch located so I could try 1)
In preferences turn on verbose compile messages to see where binaries are being built.
In preferences.txt set preproc.save_build_files=true to keep the IDE from deleting the files after upload.

4) Why is this, when the correct settings in the tools menu are all done? Where does ardunio get the avrdude -P parameter (which seems to be wrong)?
Here is somebody that fixed the problem by tweaking Ubuntu:
http://steve.kargs.net/bacnet/avr-isp-mkii-on-ubuntu-hardy/

Avrdude can't see the AVRISP MKII without having an extra driver installed. Here's the link:

http://www.libusb.org/wiki/libusb-win32

After doing the install I can now use the AVRISP MKII from within the Arduino IDE.

Martyn.

Hi John,
thx for your reply.

  1. So where ist the hex file of the sketch located so I could try 1)
    In preferences turn on verbose compile messages to see where binaries are being built.
    In preferences.txt set preproc.save_build_files=true to keep the IDE from deleting the files after upload.

I did so and was able to retrieve the bitstream (intel hex file)
I was able to flash the file to the ATMEGA using avrdude from the commandline.
Still I am not able to flash the ATMEGA from within the Arduino IDE because of 4)

  1. Why is this, when the correct settings in the tools menu are all done? Where does ardunio get the avrdude -P parameter (which seems to be wrong)?
    Here is somebody that fixed the problem by tweaking Ubuntu:
    AVR ISP mkII on Ubuntu Hardy | Steve’s Software Trek

So I did. As described in 3) I was able to use the linux commandline version of avrdude but still get the error message from within arduino ide

@Ringz

Avrdude can't see the AVRISP MKII without having an extra driver installed. Here's the link:
http://www.libusb.org/wiki/libusb-win32

that's true for a windows environment but not für linux. (note your posted link "....-win32")
Thanks for your efforts

As I am able to retrieve the hex code (bitstream) from the temp directory (one has to copy it right away, the directory will be deleted later on somehow) and can use avrdude from the commandline, this thread is solved.
In terms of using ardunio ide it's not.

rgds
Martin

@Ringz - thanks! That worked perfectly for my windows system...