Programming an AVR using the official AVR ICSP on linux  - Page 1
Forum section: electronics / beginners

author: Kdog44
author_rank: Contributor
timestamp: July 26, 2014, 09:06:52 am
content: I want to program using the ICSP from AVR on linux using the terminal. I have installed the AVR tool chain. My target is an ATMEGA328 chip. I made the assumption that the AVR tool chain comes with drivers for the ICSP. I went through the cd that came with the programmer and did not find any driver software. The circuit I was using was basic. Just a capacitor to smooth out the input voltage, an LED indicating there is power, and the ATMEGA328 chip (with power and ground connections) connected to the ICSP header. Nothing much at all, just a standard test circuit. The command that I ran in the terminal was:Code:sudo avrdude -p m328 -c avrispmkIIThe message I got back was:Code:avrdude: stk500v2_command(): command failedavrdude: stk500v2_program_enable(): bad AVRISPmkII connection status: Target not detectedavrdude: initialization failed, rc=-1Double check connections and try again, or use -F to overridethis check.The status LED on the programmer was green when power was connected to board, so I believe it identified the target. Do i need some special driver software for the programmer? What is the next step?

author: Bored@Work
author_rank: Super Contributor
timestamp: July 26, 2014, 10:48:40 am
content: There is no such thing as ICSP for AVRs (the Arduino people get that constantly wrong). So in reality, what is that "official AVR ICSP" hardware thingy you are using?

author: firewalker
author_rank: Super Contributor
timestamp: July 26, 2014, 11:56:56 am
content: I guess you are using a cheap usb ISP. The most common error is bad wiring. From the header to MISO, MOSI, SCK, RESET pins.Alexander.

author: mikerj
author_rank: Super Contributor
timestamp: July 26, 2014, 01:17:41 pm
content: Quote from: Bored@Work on July 26, 2014, 10:48:40 amIf you can't perform In Circuit Serial Programming on AVR's then I have apparently been performing the impossible for many years. Or are you trying to point out that Atmel's own name for this method is "In System Programming"?The 'official tool' for AVRs that support the ISP interface would be theAVRISP.

author: Bored@Work
author_rank: Super Contributor
timestamp: July 26, 2014, 01:28:45 pm
content: Quote from: mikerj on July 26, 2014, 01:17:41 pmNo, you have decided to adapt Arduino idiot-speak, that's all.

author: zapta
author_rank: Super Contributor
timestamp: July 26, 2014, 02:17:26 pm
content: This is the script I used to program boards with blank atmega328p using AVRICSP MKII. This is for Mac OS but should be similar for Linux.https://github.com/zapta/power-monitors/blob/master/pmon_3v8/firmware/icsp_program_all.shNotice the -B 4 flag, it reduce the bit rate of the programmer. The blank atmega328p comes stock configured for 1Mhz clock and the ICSP speed should not be faster than 0.25% of that.The avrdude on my machine was installed as part of the Arduino IDE. I am not sure if it also installed any AVRICSP MKII specific drivers.As others said earlier, verify your wiring and also make sure you don't overload those signals with LEDs etc (if you have an oscilloscope, look at the signals and verify that they are clean).

author: Kdog44
author_rank: Contributor
timestamp: July 26, 2014, 07:17:29 pm
content: I am using the AVRICSP MKII.

author: radioFlash
author_rank: Regular Contributor
timestamp: July 26, 2014, 10:10:38 pm
content: Quote from: Kdog44 on July 26, 2014, 07:17:29 pmTo be precise, it's the "AVRISP MKII" and should look like this :http://www.atmel.com/tools/avrispmkii.aspx.One thing about this programmer: it doesn't provide power to the device being programmed, so you need to provide that separately. I was getting nowhere, until I watched Dave's video in which he talks about a mod that provides power from the USB pin. You need to either provide power to the device you're programming, or you could mod the programmer as Dave describes:http://www.eevblog.com/2011/03/25/eevblog-158-avr-isp-mk2-lm317-regulator-tutorial/