Forum Index > General > Ask an Evil Mad Scientist!
 AVR programming methods
 |  Printable Version
By: FIFTEEN54 (offline) on Thursday, February 17 2011 @ 02:11 AM PST (Read 6455 times)  
FIFTEEN54

I have been using an Arduino Uno to prototype various projects, breadboard style, then building barebones boards to program and implement. I have recently decided to start using blank ATmega328 with the EMSL target boards. This opened up a can of worms because now I find my self playing with AVRdude and Xcode. AVRdude is fine however, Xcode seems to be overcomplicated for what I am trying to achieve. Like using a laser chain-saw that harnesses the power of 3 stars to toast half a bagel. This leads me to my question, what is the easiest way to program via ISP? Should I just burn the Arduino bootloader onto the blank ATmega and modify one of my USB-BUBs with some pico-hook ends to get to pins 2 and 3? Is there a way to just keep with the easy to use Arduino environment and use USBtinyISP and call it a day?


Forum Apprentice
Apprentice


Status: offline

Registered: 02/17/11
Posts: 8

Profile Email    
   
By: Windell (offline) on Thursday, February 17 2011 @ 12:13 PM PST  
Windell

>This opened up a can of worms because now I find my self playing with AVRdude and Xcode.
>AVRdude is fine however, Xcode seems to be overcomplicated for what I am trying to achieve.

I also use Xcode, but *just* as a text editor. Just save the file (command-s), and then in the terminal, use a makefile to compile and program the chips. ("make all<return>make install<return>" ) This is definitely the fastest, most efficient way to work with AVR chips.

(There *is* an Xcode extension for use with avr-gcc/avrdude, but I found it to be just too darn slow to execute the menu items to compile and program.)


>Should I just burn the Arduino bootloader onto the blank ATmega and modify one of my USB-BUBs with some pico-hook ends to get to pins 2 and 3?

You can, but I generally prefer *not* to use the bootloader when I have an ISP programmer handy.


>Is there a way to just keep with the easy to use Arduino environment and use USBtinyISP and call it a day?

Yes, that too. http://www.arduino.cc/en/Hacking/Programmer


Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/

Forum Evil Scientist
Evil Scientist

Status: offline

Registered: 06/15/06
Posts: 1932
Sunnyvale, CA

Profile Email Website  
   
By: FIFTEEN54 (offline) on Thursday, February 17 2011 @ 12:21 PM PST  
FIFTEEN54

Thanks, that cleared that right up.


Forum Apprentice
Apprentice


Status: offline

Registered: 02/17/11
Posts: 8

Profile Email    
   
By: FIFTEEN54 (offline) on Sunday, February 20 2011 @ 01:42 AM PST  
FIFTEEN54

Hey, another problem has reared its head, I edited the preferences.txt file to use the usbtinyisp to flash sketches directly to the micros and I receive this error:

USB write error: expected 128, got -1
avrdude: verification error, first mismatch at byte 0x00ef
0x92 != 0xa9
avrdude: verification error; content mismatch



I get the very same error when I try to burn the bootloader back on. I have tried this on another chip just to confirm that its not my Arduino failing.

Incidentally AVRDUDE erases the chip fine with no errors. I haven't tried to upload using AVRDUDE because as said before setting everything up to develop and compile hex files seems like a nightmare and there are no clear tutorials to efficiently do this as far as I know, everything is outdated for the most part. However I do have crosspack and all the tools that come with it, I am sort of lost though when it comes to using them...


Forum Apprentice
Apprentice

Status: offline

Registered: 02/17/11
Posts: 8

Profile Email    
   
By: Windell (offline) on Sunday, February 20 2011 @ 03:50 PM PST  
Windell

I'm afraid that I'm not familiar with this problem or resolution; I suggest that you try searching the Arduino forums for the solution.


Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/

Forum Evil Scientist
Evil Scientist

Status: offline

Registered: 06/15/06
Posts: 1932
Sunnyvale, CA

Profile Email Website  
   
By: Windell (offline) on Sunday, February 20 2011 @ 03:50 PM PST  
Windell

Actually, one thing to check: You *do* have a crystal on these boards, right?


Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/

Forum Evil Scientist
Evil Scientist

Status: offline

Registered: 06/15/06
Posts: 1932
Sunnyvale, CA

Profile Email Website  
   
By: FIFTEEN54 (offline) on Sunday, February 20 2011 @ 04:20 PM PST  
FIFTEEN54

Yes, one has a legit crystal and the other one has a resonator. I have also found the temp .hex file created by the Arduino IDE and tried to upload using AVRDUDE directly but no dice. I have been scouring the internet tirelessly and that error seems to be a device permissions problem. I am now trying to find that configuration file and edit it, but alas mac only similar to linux so I have no idea what file that is... So really this is turning in to a mac configuration issue...


Forum Apprentice
Apprentice

Status: offline

Registered: 02/17/11
Posts: 8

Profile Email    
   
By: Windell (offline) on Sunday, February 20 2011 @ 04:25 PM PST  
Windell

>I have been scouring the internet tirelessly and that error seems to be a device permissions problem

You might try, from the command line, "sudo avrdude ..."



Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/

Forum Evil Scientist
Evil Scientist

Status: offline

Registered: 06/15/06
Posts: 1932
Sunnyvale, CA

Profile Email Website  
   
By: FIFTEEN54 (offline) on Sunday, February 20 2011 @ 04:32 PM PST  
FIFTEEN54

Yes, I tried that, not so much. Every function fails for the same reason... not only on my imac but on my macbook as-well... I am beginning to think this could be my programmer....


Forum Apprentice
Apprentice

Status: offline

Registered: 02/17/11
Posts: 8

Profile Email    
   
By: Windell (offline) on Sunday, February 20 2011 @ 04:36 PM PST  
Windell

> I am beginning to think this could be my programmer....

You might try something easier before jumping to that conclusion.

Also, see if changing the bit rate helps. See:
http://code.google.com/p/arduino/issues/detail?id=69


Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/

Forum Evil Scientist
Evil Scientist

Status: offline

Registered: 06/15/06
Posts: 1932
Sunnyvale, CA

Profile Email Website  
   
By: FIFTEEN54 (offline) on Sunday, February 20 2011 @ 05:01 PM PST  
FIFTEEN54

Results:

$ avrdude -c usbtiny -p m328p -B 5 -V -e -U lock:w:0x3F:m -U hfuse:w:0xDF:m -U lfuse:w:0xFF:m -U efuse:w:0xF8:m

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e950f
avrdude: erasing chip
avrdude: reading input file "0x3F"
avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of lock written
avrdude: reading input file "0xDF"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of hfuse written
avrdude: reading input file "0xFF"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of lfuse written
avrdude: reading input file "0xF8"
avrdude: writing efuse (1 bytes):

Writing | | 0% 0.00s ***failed;
Writing | ################################################## | 100% 0.04s

avrdude: 1 bytes of efuse written

avrdude: safemode: efuse changed! Was f8, and is now 0
Would you like this fuse to be changed back? [y/n] n
avrdude: safemode: Fuses OK

avrdude done. Thank you.




$ avrdude -c usbtiny -p m328p -B 1 -V -D -U flash:w:/applications/arduino.app/contents/resources/java/hardware/arduino/bootloaders/optiboot/optiboot_atmega328.hex:i

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f
avrdude: reading input file "/applications/arduino.app/contents/resources/java/hardware/arduino/bootloaders/optiboot/optiboot_atmega328.hex"
avrdude: writing flash (32748 bytes):

Writing | | 0% 0.00s
avrdude: error: usbtiny_send: usb_control_msg(DeviceRequestTO): unknown error (expected 128, got -1)
Writing | ################################################## | 100% 0.07s

avrdude: failed to write flash memory, rc=-1

avrdude: safemode: Fuses OK

avrdude done. Thank you.



Forum Apprentice
Apprentice

Status: offline

Registered: 02/17/11
Posts: 8

Profile Email    
   
By: Windell (offline) on Sunday, February 20 2011 @ 05:13 PM PST  
Windell

set the extended fuse to 0x00.


Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/

Forum Evil Scientist
Evil Scientist

Status: offline

Registered: 06/15/06
Posts: 1932
Sunnyvale, CA

Profile Email Website  
   
By: FIFTEEN54 (offline) on Sunday, February 20 2011 @ 05:19 PM PST  
FIFTEEN54

There is no error now when I write to the fuse blocks but I still get the same error when burning the bootloader...


Forum Apprentice
Apprentice

Status: offline

Registered: 02/17/11
Posts: 8

Profile Email    
   
By: Windell (offline) on Sunday, February 20 2011 @ 06:52 PM PST  
Windell

>There is no error now when I write to the fuse blocks but I still get the same error when burning the bootloader...

Try changing just one thing at a time. You're also trying (for example) a faster write speed there.


Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/

Forum Evil Scientist
Evil Scientist

Status: offline

Registered: 06/15/06
Posts: 1932
Sunnyvale, CA

Profile Email Website  
   
By: FIFTEEN54 (offline) on Monday, February 21 2011 @ 12:13 AM PST  
FIFTEEN54

Just as an update, it was indeed a clocking issue. "-B 155 " seems to be the sweet spot. I am now successfully writing to flash but sketches don't seem to work. Still tinkering with it... Thanks for all the help Windell.


Forum Apprentice
Apprentice

Status: offline

Registered: 02/17/11
Posts: 8

Profile Email    
   



 All times are PDT. The time is now 06:27 AM.
Normal Topic Normal Topic
Locked Topic Locked Topic
Sticky Topic Sticky Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Able to Post 
Filtered HTML Allowed 
Censored Content 

Evil Mad Scientist Forum Archives — Read only!

Please visit our new forums for new discussions.


DIY Hardware for Electronic Art


The Original Egg-Bot Kit


Octolively
Interactive LED kits


Meggy Jr RGB
LED matrix game
development kit.


Business-card sized
AVR target boards


Peggy 2
LED Pegboard kits

My Account






Lost your password?