Arduino question

Electronics related to CNC

Arduino question

Postby bdring » Thu Jan 31, 2013 1:59 pm

I have a circuit with an ATMega328P. It has no USB or other communications. I am programming it via an AVRISP MKII programmer from the Arduino IDE 1.0.1.

I need to turn off the CLKDIV8 programming fuse on a fresh 328P. I have messed with all the boards.txt type files with no luck. I can get it to work by first installing an existing bootloader with the fuse settings it needs and then overwriting that with my program.

That is no big deal and only takes a few seconds and I only need to do it once per chip, but I eventually need to turn this over to production and that just adds time and confusion.

I have tried using AVR studio, but that requires a USB driver for the programmer that screws up the Arduino IDE programming.
Bart
"If you didn't build it, you will never own it."
bdring
Site Admin
 
Posts: 2966
Joined: Sun Nov 22, 2009 7:33 pm
Location: Chicago, IL, USA

Re: Arduino question

Postby Gadroc » Thu Jan 31, 2013 2:46 pm

You should be able to extract the hex file as "a gold master" for your firmware. You would then just write a batch script that runs and does two actions... 1) Sets fuses as needed, 2) Writes program hex file. You can do this all through avrdude which is included with the Arduino IDE or downloaded separately. I'll look tonight at what the command line switches are to set fuses via avrdude. I wouldn't want an IDE at all in a manufacturing/production process.
Gadroc
 
Posts: 77
Joined: Thu Nov 10, 2011 8:18 pm

Re: Arduino question

Postby Gadroc » Fri Feb 01, 2013 4:53 am

The following command lines will set the fuses and flash in a hex file. You can find your hex files by editing your perferences.txt file and setting build.verbose to true.

Code: Select all
cd {path to arduino install}\hardware\tools\avr\bin
avrdude -C ../etc/avrdude.conf -patmega328p -cstk500v2 -Pusb -e -Ulock:w:0x3F:m -Uefuse:w:0x05:m -Uhfuse:w:0xDA:m -Ulfuse:w:0xFF:m
avrdude -C ../etc/avrdude.conf -patmega328p -cstk500v2 -Pusb -U flash:w:firmware.hex:i -Ulock:w:0x0F:m
Gadroc
 
Posts: 77
Joined: Thu Nov 10, 2011 8:18 pm

Re: Arduino question

Postby bdring » Fri Feb 01, 2013 1:24 pm

Thanks,

I have used avrdude in the past. I just got fixated on trying to get the IDE to do what I wanted. You are right about production not using the IDE. I'll setup a batch file.
Bart
"If you didn't build it, you will never own it."
bdring
Site Admin
 
Posts: 2966
Joined: Sun Nov 22, 2009 7:33 pm
Location: Chicago, IL, USA

Re: Arduino question

Postby Gadroc » Fri Feb 01, 2013 1:39 pm

BTW - You can make Atmel Studio work on the same machine as avrdude. You need to install the filter version of libusb you can get from here.

1) Install Atmel Studio (which will install the Jungo driver for Atmel programers).
2) Download the libusb-win32-devel-filter-1.2.6.0.exe files and install it. At the end it will run a wizard and select your programmer from the list of USB devices and install a filter on it.

Now avrdude will use the libusb driver correctly and Atmel studio will use the jungo driver. One thing I noticed when using my dragon is it reads unused locks and fuse bits as 1. This causes a problem with the arduino IDE cause it's configured to send them as 0. This causes flash errors as the written value doesn't match the read value. If you get the same problem use the following lines instead of the above.

Code: Select all
cd {path to arduino install}\hardware\tools\avr\bin
avrdude -C ../etc/avrdude.conf -patmega328p -cstk500v2 -Pusb -e -Ulock:w:0xFF:m -Uefuse:w:0xFD:m -Uhfuse:w:0xDA:m -Ulfuse:w:0xFF:m
avrdude -C ../etc/avrdude.conf -patmega328p -cstk500v2 -Pusb -U flash:w:firmware.hex:i -Ulock:w:0xCF:m
Gadroc
 
Posts: 77
Joined: Thu Nov 10, 2011 8:18 pm


Return to Electronics

Who is online

Users browsing this forum: No registered users and 7 guests