Pages: [1]   Go Down
Author Topic: Problem with uploading sketches  (Read 1204 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

i have a microcontroller board with a atmega168 on it.
To prgramm it flashes the bootloader over isp and now want to use it with arduino.
The problem is that when i write a programm to the board, the first time it works. the second time i get this error:

avrdude: stk500_getsync(): not in sync: resp=0x7e

where the hexnumber in the end changes from time to time.
To flash a new programm i now always have to first flash the bootloader again, and then upload the programm from arduino again.

in my boards.txt i added the board

Code:
##############################################################

emcreprap.name=EMC2RepRap

emcreprap.upload.protocol=arduino
emcreprap.upload.maximum_size=14336
emcreprap.upload.speed=19200

emcreprap.bootloader.low_fuses=0xff
emcreprap.bootloader.high_fuses=0xdd
emcreprap.bootloader.extended_fuses=0x00
emcreprap.bootloader.path=atmega
emcreprap.bootloader.file=ATmegaBOOT_168_ng.hex
emcreprap.bootloader.unlock_bits=0x3F
emcreprap.bootloader.lock_bits=0x0F

emcreprap.build.mcu=atmega168
emcreprap.build.f_cpu=16000000L
emcreprap.build.core=arduino

and i flashed the ATmega_168_ng bootloader using avrdude (from the arduino ide my programmer wont work correctly)

so any ideas why it only works once everytime. looks to me like the boatloader somehow overwrites parts of itself ?? 
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 209
Posts: 13015
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Are you changing the lock-bits before and after uploading the bootloader?

Have you ensured the fuses are set correctly?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

where should i change the lockbits?
the fuse bit should be ok, didnt change here anything,
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 209
Posts: 13015
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
the fuse bit should be ok, didnt change here anything,

How did you come into possession of the processor?  Did you purchase it new?
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 209
Posts: 13015
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
where should i change the lockbits?

Using AVRDUDE, before uploading the bootloader, you "unlock" the processor.  Using AVRDUDE, after uploading the bootloader, you "lock" the processor.

I do not know the details.  I suspect you can find the details by searching the forum.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

i bought the chip from digikey and etched a little board which has some FETs, some pots and a max232 for the serial connection.
I did this before may times. normaly i just programmed the controller in c compiled it with avrgcc and flashed it with avrdude.
now i want to try the arduino ide because it is a nice thing to have a ide where the editor the compiler and the programmer are all in one.
Logged

Scotland
Offline Offline
Edison Member
*
Karma: 26
Posts: 1338
Have you had your Arduino fix today?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Try this :

avrdude -p m168 -c diecimila -B 4800 -P ft0 -e -U lock:w:0x3f:m -U lfuse:w:0xff:m -U hfuse:w:0xdd:m -U efuse:w:0x00:m

avrdude -p m168 -c diecimila -P ft0 -D -U flash:w:168boot.hex:i

avrdude -p m168 -c diecimila -P ft0 -U lock:w:0x0f:m

replace diecimila with your programmer
and168boot.hex with your boot hex file

unplug power from chip, plug in
upload with IDE.


Drew.
Logged

Drew.
http://www.uk-pcb.co.uk - My UK Based PCB Fab & Assembly Company
Design work undertaken
SMD & Thru-Hole assembly

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 212
Posts: 8934
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

My guess is that your board does not implement auto-reset.  You have to hold down the reset, click on the upload button in the IDE, and release the reset when you see the "Binary sketch size:" message in the IDE.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Pages: [1]   Go Up
Jump to: