Forum: Compiler & IDEs AVRdude hängt beim flashen


von Arne (Gast)


Lesenswert?

Hi,

ich habe ein Problem mit avrdude.
Hab ein Programm geschrieben und möchte es nun auf den Micokontroller 
flashen. Nun bleibt avrdude aber einfach in der Write-phase hängen.

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 
0.02s

avrdude: Device signature = 0x1e9502
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be 
performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "main.hex"
avrdude: input file main.hex auto detected as Intel Hex
avrdude: writing flash (542 bytes):

Writing | ###########

Flash ich jetzt aber ein anderes Programm drauf, was nur etwa 100Byte 
groß ist, funktioniert alle wunderbar.

Weiß jemand wo das Problem liegen könnte?

von Stefan B. (stefan) Benutzerseite


Lesenswert?

Welchen Aufruf von Avrdude bzw. Kommandozeile benutzt du?

Bekommst du mehr Infos, wenn du die -v oder -vv oder -vvv Optionen 
benutzt und die Ausgabe in eine Datei umleitest, wie im Artikel 
Avrdude erklärt wird?

von Arne (Gast)


Lesenswert?

Hi,

habs eben getestet. Leider bekomme ich durch -v,-vv und -vvv auch keine 
weiteren Infos.

Micokontroller ist übrigens der ATMega32

von Jörg W. (dl8dtl) (Moderator) Benutzerseite


Lesenswert?

Arne schrieb:
> Leider bekomme ich durch -v,-vv und -vvv auch keine
> weiteren Infos.

Das stimmt nicht, da wird auf jeden Fall noch mehr ausgegeben. ;-)
Das erste wäre mal die AVRDUDE-Version, das zweite der Typ des
benutzten Programmieradapters.

Danach noch mit -vvvv laufen lassen und die Logdatei hier bitte
anhängen.

von Egon (Gast)


Lesenswert?

Vielleicht auch mal mit der Programmierfrequenz runtergehen? Hast du 
einen anderen mega32/mega16 probiert? Ist es da ebenso?

von Arne (Gast)


Lesenswert?

Jörg Wunsch schrieb:
> Arne schrieb:
>> Leider bekomme ich durch -v,-vv und -vvv auch keine
>> weiteren Infos.
>
> Das stimmt nicht, da wird auf jeden Fall noch mehr ausgegeben. ;-)
> Das erste wäre mal die AVRDUDE-Version, das zweite der Typ des
> benutzten Programmieradapters.
>
> Danach noch mit -vvvv laufen lassen und die Logdatei hier bitte
> anhängen.

mhh, komisch.
Bei mir hatte der die txt Datei leer gelassen. Aber vielleicht habe ich 
mich einfach nur vertippt.

Den Tipp mit der Programmierfrequenz werde ich morgen mal testen und es 
auchmal mit einem Baugleichen mega32 versuchen.

Schonmal danke für die Tipps.

von Arne (Gast)


Lesenswert?

Hatte mich gestern wohl anscheinend irgendwo in der Console vertippt.
avrdude gibt mir in der txt Datei folgendes aus:

avrdude: Version 5.10, compiled on Jan 19 2010 at 10:45:23
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is 
"C:\WinAVR-20100110\bin\avrdude.conf"

         Using Port                    : usb:xx
         Using Programmer              : avrispmkII
avrdude: usbdev_open(): did not find any (matching) USB device "usb:xx"

Benutzen tu ich WinAVR20100110 der Programmieradapter is ein Diamex 
DX-ISP.
Könnte es daran liegen, dass bei der Treiber installation was falsch 
gelaufen ist? Denn er findet ja anscheinend keinen passenden USB 
Adapter.
Komisch finde ich aber, dass ich die selbe Ausgabe bei einem kleineren 
Programm bekomme, was er aber problemlos auf den Kontroller flasht.

von Stefan B. (stefan) Benutzerseite


Lesenswert?

Arne schrieb:

> Komisch finde ich aber, dass ich die selbe Ausgabe bei einem kleineren
> Programm bekomme, was er aber problemlos auf den Kontroller flasht.

Bist du sicher, dass das kleine Programm dann auch im AVR ist, z.B. 
dadurch dass es eine Aktion ausführt, und nicht nur in einem 
Kommunikationspuffer des PCs versickert ist?

von Stefan B. (stefan) Benutzerseite


Lesenswert?

AVR-Programmer Diamex DX-ISP
http://www.wiesolator.de/index.php?area=AVR&topic=AVR-Progger%20Diamex%20DX-ISP

"Dieses Programmiergerät wird über USB mit dem PC verbunden und 
kommuniziert über das STK500v2 Protokoll mit dem AVR-Studio. Es ist bei 
www.srt-versand.de unter der Artikelnummer 5050112 erhältlich und 
kostete bei der Erstellung des Textes 17,90€. Dieses Programmiergerät 
ist von der Technik und der Funktionalität mit dem mySmartUSB light 
vergleichbar."
http://s-huehn.de/elektronik/avr-prog/avr-prog.htm

"Installation
- Windows eigener Treiber. Einbindung durch einfache *inf Datei"
http://www.srt-versand.de/index.php?sid=&cl=details&anid=8dd49932d00865747.65532223&listtype=search&searchparam=5050112

von Stefan B. (stefan) Benutzerseite


Lesenswert?

Für mich sieht es so aus:

Der Programmer stellt sich dem PC gegenüber als USB-to-RS232 dar, d.h. 
es wird eine COM-Schnittstelle eingetragen.

Die Nummer der COM-Schnittstelle z.B. COM8 musst du herausfinden z.B. 
über den Gerätemanager (Kontrolle vor/nach Einstecken des Programmers) 
oder den Hardware Assistenten 
(http://www.er-forum.de/obd-diag-dl/index.php?action=downloadfile&filename=SW-Installationen.pdf&directory=Bauanleitungen&;) 
und dann in der Avrdude-Kommandozeile angeben.

von Arne (Gast)


Lesenswert?

Hi, schonmal danke Stefan!

Also den Treiber habe ich richtig installiert. Die Com-Schnittstelle 
weiß ich auch (4). Diese hab ich auch richtig in meinem Makefile 
angegeben.

von Stefan B. (stefan) Benutzerseite


Lesenswert?

> weiß ich auch (4). Diese hab ich auch richtig in meinem Makefile
> angegeben.

Dann wundert mich diese Zeile

>>         Using Port                    : usb:xx

Vielleicht mal Makefile und Kommandozeile zeigen, wenn sie nicht geheim 
bleiben müssen.

von Arne (Gast)


Lesenswert?

Also der Makefile sieht so aus:
1
# Hey Emacs, this is a -*- makefile -*-
2
#----------------------------------------------------------------------------
3
# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al.
4
#
5
# Released to the Public Domain
6
#
7
# Additional material for this makefile was written by:
8
# Peter Fleury
9
# Tim Henigan
10
# Colin O'Flynn
11
# Reiner Patommel
12
# Markus Pfaff
13
# Sander Pool
14
# Frederik Rouleau
15
# Carlos Lamas
16
#
17
#----------------------------------------------------------------------------
18
# On command line:
19
#
20
# make all = Make software.
21
#
22
# make clean = Clean out built project files.
23
#
24
# make coff = Convert ELF to AVR COFF.
25
#
26
# make extcoff = Convert ELF to AVR Extended COFF.
27
#
28
# make program = Download the hex file to the device, using avrdude.
29
#                Please customize the avrdude settings below first!
30
#
31
# make debug = Start either simulavr or avarice as specified for debugging, 
32
#              with avr-gdb or avr-insight as the front end for debugging.
33
#
34
# make filename.s = Just compile filename.c into the assembler code only.
35
#
36
# make filename.i = Create a preprocessed source file for use in submitting
37
#                   bug reports to the GCC project.
38
#
39
# To rebuild project do "make clean" then "make all".
40
#----------------------------------------------------------------------------
41
42
43
# MCU name
44
MCU = atmega32
45
46
47
# Processor frequency.
48
#     This will define a symbol, F_CPU, in all source code files equal to the 
49
#     processor frequency. You can then use this symbol in your source code to 
50
#     calculate timings. Do NOT tack on a 'UL' at the end, this will be done
51
#     automatically to create a 32-bit value in your source code.
52
#     Typical values are:
53
#         F_CPU =  1000000
54
#         F_CPU =  1843200
55
#         F_CPU =  2000000
56
#         F_CPU =  3686400
57
#         F_CPU =  4000000
58
#         F_CPU =  7372800
59
#         F_CPU =  8000000
60
#         F_CPU = 11059200
61
#         F_CPU = 14745600
62
#         F_CPU = 16000000
63
#         F_CPU = 18432000
64
#         F_CPU = 20000000
65
F_CPU = 8000000
66
67
68
# Output format. (can be srec, ihex, binary)
69
FORMAT = ihex
70
71
72
# Target file name (without extension).
73
TARGET = main
74
75
76
# Object files directory
77
#     To put object files in current directory, use a dot (.), do NOT make
78
#     this an empty or blank macro!
79
OBJDIR = .
80
81
82
# List C source files here. (C dependencies are automatically generated.)
83
SRC = $(TARGET).c
84
85
86
# List C++ source files here. (C dependencies are automatically generated.)
87
CPPSRC = 
88
89
90
# List Assembler source files here.
91
#     Make them always end in a capital .S.  Files ending in a lowercase .s
92
#     will not be considered source files but generated files (assembler
93
#     output from the compiler), and will be deleted upon "make clean"!
94
#     Even though the DOS/Win* filesystem matches both .s and .S the same,
95
#     it will preserve the spelling of the filenames, and gcc itself does
96
#     care about how the name is spelled on its command-line.
97
ASRC =
98
99
100
# Optimization level, can be [0, 1, 2, 3, s]. 
101
#     0 = turn off optimization. s = optimize for size.
102
#     (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
103
OPT = s
104
105
106
# Debugging format.
107
#     Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs.
108
#     AVR Studio 4.10 requires dwarf-2.
109
#     AVR [Extended] COFF format requires stabs, plus an avr-objcopy run.
110
DEBUG = dwarf-2
111
112
113
# List any extra directories to look for include files here.
114
#     Each directory must be seperated by a space.
115
#     Use forward slashes for directory separators.
116
#     For a directory that has spaces, enclose it in quotes.
117
EXTRAINCDIRS = 
118
119
120
# Compiler flag to set the C Standard level.
121
#     c89   = "ANSI" C
122
#     gnu89 = c89 plus GCC extensions
123
#     c99   = ISO C99 standard (not yet fully implemented)
124
#     gnu99 = c99 plus GCC extensions
125
CSTANDARD = -std=gnu99
126
127
128
# Place -D or -U options here for C sources
129
CDEFS = -DF_CPU=$(F_CPU)UL
130
131
132
# Place -D or -U options here for ASM sources
133
ADEFS = -DF_CPU=$(F_CPU)
134
135
136
# Place -D or -U options here for C++ sources
137
CPPDEFS = -DF_CPU=$(F_CPU)UL
138
#CPPDEFS += -D__STDC_LIMIT_MACROS
139
#CPPDEFS += -D__STDC_CONSTANT_MACROS
140
141
142
143
#---------------- Compiler Options C ----------------
144
#  -g*:          generate debugging information
145
#  -O*:          optimization level
146
#  -f...:        tuning, see GCC manual and avr-libc documentation
147
#  -Wall...:     warning level
148
#  -Wa,...:      tell GCC to pass this to the assembler.
149
#    -adhlns...: create assembler listing
150
CFLAGS = -g$(DEBUG)
151
CFLAGS += $(CDEFS)
152
CFLAGS += -O$(OPT)
153
CFLAGS += -funsigned-char
154
CFLAGS += -funsigned-bitfields
155
CFLAGS += -fpack-struct
156
CFLAGS += -fshort-enums
157
CFLAGS += -Wall
158
CFLAGS += -Wstrict-prototypes
159
#CFLAGS += -mshort-calls
160
#CFLAGS += -fno-unit-at-a-time
161
#CFLAGS += -Wundef
162
#CFLAGS += -Wunreachable-code
163
#CFLAGS += -Wsign-compare
164
CFLAGS += -Wa,-adhlns=$(<:%.c=$(OBJDIR)/%.lst)
165
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
166
CFLAGS += $(CSTANDARD)
167
168
169
#---------------- Compiler Options C++ ----------------
170
#  -g*:          generate debugging information
171
#  -O*:          optimization level
172
#  -f...:        tuning, see GCC manual and avr-libc documentation
173
#  -Wall...:     warning level
174
#  -Wa,...:      tell GCC to pass this to the assembler.
175
#    -adhlns...: create assembler listing
176
CPPFLAGS = -g$(DEBUG)
177
CPPFLAGS += $(CPPDEFS)
178
CPPFLAGS += -O$(OPT)
179
CPPFLAGS += -funsigned-char
180
CPPFLAGS += -funsigned-bitfields
181
CPPFLAGS += -fpack-struct
182
CPPFLAGS += -fshort-enums
183
CPPFLAGS += -fno-exceptions
184
CPPFLAGS += -Wall
185
CPPFLAGS += -Wundef
186
#CPPFLAGS += -mshort-calls
187
#CPPFLAGS += -fno-unit-at-a-time
188
#CPPFLAGS += -Wstrict-prototypes
189
#CPPFLAGS += -Wunreachable-code
190
#CPPFLAGS += -Wsign-compare
191
CPPFLAGS += -Wa,-adhlns=$(<:%.cpp=$(OBJDIR)/%.lst)
192
CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
193
#CPPFLAGS += $(CSTANDARD)
194
195
196
#---------------- Assembler Options ----------------
197
#  -Wa,...:   tell GCC to pass this to the assembler.
198
#  -adhlns:   create listing
199
#  -gstabs:   have the assembler create line number information; note that
200
#             for use in COFF files, additional information about filenames
201
#             and function names needs to be present in the assembler source
202
#             files -- see avr-libc docs [FIXME: not yet described there]
203
#  -listing-cont-lines: Sets the maximum number of continuation lines of hex 
204
#       dump that will be displayed for a given single line of source input.
205
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
206
207
208
#---------------- Library Options ----------------
209
# Minimalistic printf version
210
PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
211
212
# Floating point printf version (requires MATH_LIB = -lm below)
213
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
214
215
# If this is left blank, then it will use the Standard printf version.
216
PRINTF_LIB = 
217
#PRINTF_LIB = $(PRINTF_LIB_MIN)
218
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
219
220
221
# Minimalistic scanf version
222
SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
223
224
# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
225
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
226
227
# If this is left blank, then it will use the Standard scanf version.
228
SCANF_LIB = 
229
#SCANF_LIB = $(SCANF_LIB_MIN)
230
#SCANF_LIB = $(SCANF_LIB_FLOAT)
231
232
233
MATH_LIB = -lm
234
235
236
# List any extra directories to look for libraries here.
237
#     Each directory must be seperated by a space.
238
#     Use forward slashes for directory separators.
239
#     For a directory that has spaces, enclose it in quotes.
240
EXTRALIBDIRS = 
241
242
243
244
#---------------- External Memory Options ----------------
245
246
# 64 KB of external RAM, starting after internal RAM (ATmega128!),
247
# used for variables (.data/.bss) and heap (malloc()).
248
#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
249
250
# 64 KB of external RAM, starting after internal RAM (ATmega128!),
251
# only used for heap (malloc()).
252
#EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff
253
254
EXTMEMOPTS =
255
256
257
258
#---------------- Linker Options ----------------
259
#  -Wl,...:     tell GCC to pass this to linker.
260
#    -Map:      create map file
261
#    --cref:    add cross reference to  map file
262
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
263
LDFLAGS += $(EXTMEMOPTS)
264
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
265
LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
266
#LDFLAGS += -T linker_script.x
267
268
269
270
#---------------- Programming Options (avrdude) ----------------
271
272
# Programming hardware
273
# Type: avrdude -c ?
274
# to get a full listing.
275
#
276
AVRDUDE_PROGRAMMER = stk500v2
277
278
# com1 = serial port. Use lpt1 to connect to parallel port.
279
AVRDUDE_PORT = com4
280
281
AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
282
#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
283
284
285
# Uncomment the following if you want avrdude's erase cycle counter.
286
# Note that this counter needs to be initialized first using -Yn,
287
# see avrdude manual.
288
#AVRDUDE_ERASE_COUNTER = -y
289
290
# Uncomment the following if you do /not/ wish a verification to be
291
# performed after programming the device.
292
#AVRDUDE_NO_VERIFY = -V
293
294
# Increase verbosity level.  Please use this when submitting bug
295
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> 
296
# to submit bug reports.
297
#AVRDUDE_VERBOSE = -v -v
298
299
AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
300
AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
301
AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
302
AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
303
304
305
306
#---------------- Debugging Options ----------------
307
308
# For simulavr only - target MCU frequency.
309
DEBUG_MFREQ = $(F_CPU)
310
311
# Set the DEBUG_UI to either gdb or insight.
312
# DEBUG_UI = gdb
313
DEBUG_UI = insight
314
315
# Set the debugging back-end to either avarice, simulavr.
316
DEBUG_BACKEND = avarice
317
#DEBUG_BACKEND = simulavr
318
319
# GDB Init Filename.
320
GDBINIT_FILE = __avr_gdbinit
321
322
# When using avarice settings for the JTAG
323
JTAG_DEV = /dev/com1
324
325
# Debugging port used to communicate between GDB / avarice / simulavr.
326
DEBUG_PORT = 4242
327
328
# Debugging host used to communicate between GDB / avarice / simulavr, normally
329
#     just set to localhost unless doing some sort of crazy debugging when 
330
#     avarice is running on a different computer.
331
DEBUG_HOST = localhost
332
333
334
335
#============================================================================
336
337
338
# Define programs and commands.
339
SHELL = sh
340
CC = avr-gcc
341
OBJCOPY = avr-objcopy
342
OBJDUMP = avr-objdump
343
SIZE = avr-size
344
AR = avr-ar rcs
345
NM = avr-nm
346
AVRDUDE = avrdude
347
REMOVE = rm -f
348
REMOVEDIR = rm -rf
349
COPY = cp
350
WINSHELL = cmd
351
352
353
# Define Messages
354
# English
355
MSG_ERRORS_NONE = Errors: none
356
MSG_BEGIN = -------- begin --------
357
MSG_END = --------  end  --------
358
MSG_SIZE_BEFORE = Size before: 
359
MSG_SIZE_AFTER = Size after:
360
MSG_COFF = Converting to AVR COFF:
361
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
362
MSG_FLASH = Creating load file for Flash:
363
MSG_EEPROM = Creating load file for EEPROM:
364
MSG_EXTENDED_LISTING = Creating Extended Listing:
365
MSG_SYMBOL_TABLE = Creating Symbol Table:
366
MSG_LINKING = Linking:
367
MSG_COMPILING = Compiling C:
368
MSG_COMPILING_CPP = Compiling C++:
369
MSG_ASSEMBLING = Assembling:
370
MSG_CLEANING = Cleaning project:
371
MSG_CREATING_LIBRARY = Creating library:
372
373
374
375
376
# Define all object files.
377
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) 
378
379
# Define all listing files.
380
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) 
381
382
383
# Compiler flags to generate dependency files.
384
GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d
385
386
387
# Combine all necessary flags and optional flags.
388
# Add target processor to flags.
389
ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
390
ALL_CPPFLAGS = -mmcu=$(MCU) -I. -x c++ $(CPPFLAGS) $(GENDEPFLAGS)
391
ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
392
393
394
395
396
397
# Default target.
398
all: begin gccversion sizebefore build sizeafter end
399
400
# Change the build target to build a HEX file or a library.
401
build: elf hex eep lss sym
402
#build: lib
403
404
405
elf: $(TARGET).elf
406
hex: $(TARGET).hex
407
eep: $(TARGET).eep
408
lss: $(TARGET).lss
409
sym: $(TARGET).sym
410
LIBNAME=lib$(TARGET).a
411
lib: $(LIBNAME)
412
413
414
415
# Eye candy.
416
# AVR Studio 3.x does not check make's exit code but relies on
417
# the following magic strings to be generated by the compile job.
418
begin:
419
  @echo
420
  @echo $(MSG_BEGIN)
421
422
end:
423
  @echo $(MSG_END)
424
  @echo
425
426
427
# Display size of file.
428
HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
429
ELFSIZE = $(SIZE) --mcu=$(MCU) --format=avr $(TARGET).elf
430
431
sizebefore:
432
  @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \
433
  2>/dev/null; echo; fi
434
435
sizeafter:
436
  @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \
437
  2>/dev/null; echo; fi
438
439
440
441
# Display compiler version information.
442
gccversion : 
443
  @$(CC) --version
444
445
446
447
# Program the device.  
448
program: $(TARGET).hex $(TARGET).eep
449
  $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
450
451
452
# Generate avr-gdb config/init file which does the following:
453
#     define the reset signal, load the target file, connect to target, and set 
454
#     a breakpoint at main().
455
gdb-config: 
456
  @$(REMOVE) $(GDBINIT_FILE)
457
  @echo define reset >> $(GDBINIT_FILE)
458
  @echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
459
  @echo end >> $(GDBINIT_FILE)
460
  @echo file $(TARGET).elf >> $(GDBINIT_FILE)
461
  @echo target remote $(DEBUG_HOST):$(DEBUG_PORT)  >> $(GDBINIT_FILE)
462
ifeq ($(DEBUG_BACKEND),simulavr)
463
  @echo load  >> $(GDBINIT_FILE)
464
endif
465
  @echo break main >> $(GDBINIT_FILE)
466
467
debug: gdb-config $(TARGET).elf
468
ifeq ($(DEBUG_BACKEND), avarice)
469
  @echo Starting AVaRICE - Press enter when "waiting to connect" message displays.
470
  @$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \
471
  $(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT)
472
  @$(WINSHELL) /c pause
473
474
else
475
  @$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \
476
  $(DEBUG_MFREQ) --port $(DEBUG_PORT)
477
endif
478
  @$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE)
479
480
481
482
483
# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
484
COFFCONVERT = $(OBJCOPY) --debugging
485
COFFCONVERT += --change-section-address .data-0x800000
486
COFFCONVERT += --change-section-address .bss-0x800000
487
COFFCONVERT += --change-section-address .noinit-0x800000
488
COFFCONVERT += --change-section-address .eeprom-0x810000
489
490
491
492
coff: $(TARGET).elf
493
  @echo
494
  @echo $(MSG_COFF) $(TARGET).cof
495
  $(COFFCONVERT) -O coff-avr $< $(TARGET).cof
496
497
498
extcoff: $(TARGET).elf
499
  @echo
500
  @echo $(MSG_EXTENDED_COFF) $(TARGET).cof
501
  $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
502
503
504
505
# Create final output files (.hex, .eep) from ELF output file.
506
%.hex: %.elf
507
  @echo
508
  @echo $(MSG_FLASH) $@
509
  $(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock $< $@
510
511
%.eep: %.elf
512
  @echo
513
  @echo $(MSG_EEPROM) $@
514
  -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
515
  --change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) $< $@ || exit 0
516
517
# Create extended listing file from ELF output file.
518
%.lss: %.elf
519
  @echo
520
  @echo $(MSG_EXTENDED_LISTING) $@
521
  $(OBJDUMP) -h -S -z $< > $@
522
523
# Create a symbol table from ELF output file.
524
%.sym: %.elf
525
  @echo
526
  @echo $(MSG_SYMBOL_TABLE) $@
527
  $(NM) -n $< > $@
528
529
530
531
# Create library from object files.
532
.SECONDARY : $(TARGET).a
533
.PRECIOUS : $(OBJ)
534
%.a: $(OBJ)
535
  @echo
536
  @echo $(MSG_CREATING_LIBRARY) $@
537
  $(AR) $@ $(OBJ)
538
539
540
# Link: create ELF output file from object files.
541
.SECONDARY : $(TARGET).elf
542
.PRECIOUS : $(OBJ)
543
%.elf: $(OBJ)
544
  @echo
545
  @echo $(MSG_LINKING) $@
546
  $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)
547
548
549
# Compile: create object files from C source files.
550
$(OBJDIR)/%.o : %.c
551
  @echo
552
  @echo $(MSG_COMPILING) $<
553
  $(CC) -c $(ALL_CFLAGS) $< -o $@ 
554
555
556
# Compile: create object files from C++ source files.
557
$(OBJDIR)/%.o : %.cpp
558
  @echo
559
  @echo $(MSG_COMPILING_CPP) $<
560
  $(CC) -c $(ALL_CPPFLAGS) $< -o $@ 
561
562
563
# Compile: create assembler files from C source files.
564
%.s : %.c
565
  $(CC) -S $(ALL_CFLAGS) $< -o $@
566
567
568
# Compile: create assembler files from C++ source files.
569
%.s : %.cpp
570
  $(CC) -S $(ALL_CPPFLAGS) $< -o $@
571
572
573
# Assemble: create object files from assembler source files.
574
$(OBJDIR)/%.o : %.S
575
  @echo
576
  @echo $(MSG_ASSEMBLING) $<
577
  $(CC) -c $(ALL_ASFLAGS) $< -o $@
578
579
580
# Create preprocessed source for use in sending a bug report.
581
%.i : %.c
582
  $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ 
583
584
585
# Target: clean project.
586
clean: begin clean_list end
587
588
clean_list :
589
  @echo
590
  @echo $(MSG_CLEANING)
591
  $(REMOVE) $(TARGET).hex
592
  $(REMOVE) $(TARGET).eep
593
  $(REMOVE) $(TARGET).cof
594
  $(REMOVE) $(TARGET).elf
595
  $(REMOVE) $(TARGET).map
596
  $(REMOVE) $(TARGET).sym
597
  $(REMOVE) $(TARGET).lss
598
  $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.o)
599
  $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst)
600
  $(REMOVE) $(SRC:.c=.s)
601
  $(REMOVE) $(SRC:.c=.d)
602
  $(REMOVE) $(SRC:.c=.i)
603
  $(REMOVEDIR) .dep
604
605
606
# Create object files directory
607
$(shell mkdir $(OBJDIR) 2>/dev/null)
608
609
610
# Include the dependency files.
611
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
612
613
614
# Listing of phony targets.
615
.PHONY : all begin finish end sizebefore sizeafter gccversion \
616
build elf hex eep lss sym coff extcoff \
617
clean clean_list program debug gdb-config

das Programm selber soll momentan nur eine Header Datei testen, welche 
ich benutzen möchte. Es soll einfach einen String über den RS232 senden. 
Der ist etwas länger, da dort alles für den Header in C definiert wird. 
Den kann ich aber auf auch hier reintun wenns hilft.

von Arne (Gast)


Lesenswert?

Die Kommando Zeile sieht für mich eigentlich auch richtig aus
1
avrdude -p atmega32 -P com4 -c stk500v2    -U flash:w:main.hex

von Stefan B. (stefan) Benutzerseite


Lesenswert?

Arne schrieb:

> Die Kommando Zeile sieht für mich eigentlich auch richtig aus
> avrdude -p atmega32 -P com4 -c stk500v2 -U flash:w:main.hex

Für mich auch und diese Zeile in der Debugausgabe verstehe ich umso 
weniger:

>>         Using Port                    : usb:xx

Eine solche Ausgabe würde ich bei dieser Kommandozeile erwarten:
avrdude -p m32 -c stk500v2 -P usb:xx

von Arne (Gast)


Lesenswert?

Hi,

oh ja, is mir eben auch aufgefallen. Bekomme nun eine txt Datei, in der 
ein wenig mehr drin steht. Leider werde ich aus der nicht wirklich 
schlau.
1
avrdude: Version 5.10, compiled on Jan 19 2010 at 10:45:23
2
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
3
         Copyright (c) 2007-2009 Joerg Wunsch
4
5
         System wide configuration file is "C:\WinAVR-20100110\bin\avrdude.conf"
6
7
         Using Port                    : com4
8
         Using Programmer              : avrispmkII
9
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14] 
10
avrdude: Recv: . [1b] 
11
avrdude: Recv: . [01] 
12
avrdude: Recv: . [00] 
13
avrdude: Recv: . [0b] 
14
avrdude: Recv: . [0e] 
15
avrdude: Recv: . [01] 
16
avrdude: Recv: . [00] 
17
avrdude: Recv: . [08] 
18
avrdude: Recv: A [41] 
19
avrdude: Recv: V [56] 
20
avrdude: Recv: R [52] 
21
avrdude: Recv: I [49] 
22
avrdude: Recv: S [53] 
23
avrdude: Recv: P [50] 
24
avrdude: Recv: _ [5f] 
25
avrdude: Recv: 2 [32] 
26
avrdude: Recv: t [74] 
27
avrdude: stk500v2_getsync(): found AVRISP programmer
28
         AVR Part                      : ATMEGA8
29
         Chip Erase delay              : 10000 us
30
         PAGEL                         : PD7
31
         BS2                           : PC2
32
         RESET disposition             : dedicated
33
         RETRY pulse                   : SCK
34
         serial program mode           : yes
35
         parallel program mode         : yes
36
         Timeout                       : 200
37
         StabDelay                     : 100
38
         CmdexeDelay                   : 25
39
         SyncLoops                     : 32
40
         ByteDelay                     : 0
41
         PollIndex                     : 3
42
         PollValue                     : 0x53
43
         Memory Detail                 :
44
45
                                  Block Poll               Page                       Polled
46
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
47
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
48
           eeprom         4    20   128    0 no        512    4      0  9000  9000 0xff 0xff
49
                                  Block Poll               Page                       Polled
50
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
51
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
52
           flash         33    10    64    0 yes      8192   64    128  4500  4500 0xff 0x00
53
                                  Block Poll               Page                       Polled
54
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
55
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
56
           lfuse          0     0     0    0 no          1    0      0  2000  2000 0x00 0x00
57
                                  Block Poll               Page                       Polled
58
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
59
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
60
           hfuse          0     0     0    0 no          1    0      0  2000  2000 0x00 0x00
61
                                  Block Poll               Page                       Polled
62
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
63
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
64
           lock           0     0     0    0 no          1    0      0  2000  2000 0x00 0x00
65
                                  Block Poll               Page                       Polled
66
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
67
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
68
           calibration    0     0     0    0 no          4    0      0     0     0 0x00 0x00
69
                                  Block Poll               Page                       Polled
70
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
71
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
72
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
73
74
         Programmer Type : STK500V2
75
         Description     : Atmel AVR ISP mkII
76
         Programmer Model: AVRISP
77
avrdude: Send: . [1b] . [02] . [00] . [02] . [0e] . [03] . [90] . [86] 
78
avrdude: Recv: . [1b] 
79
avrdude: Recv: . [02] 
80
avrdude: Recv: . [00] 
81
avrdude: Recv: . [03] 
82
avrdude: Recv: . [0e] 
83
avrdude: Recv: . [03] 
84
avrdude: Recv: . [00] 
85
avrdude: Recv: . [0f] 
86
avrdude: Recv: . [18] 
87
avrdude: Send: . [1b] . [03] . [00] . [02] . [0e] . [03] . [91] . [86]

von Stefan B. (stefan) Benutzerseite


Lesenswert?

Diese Debugausgabe sieht wesentlich besser aus: Keine Probleme mit USB 
und es läuft eine Kommunikation über COM4 mit einem AVR ISP Programmer. 
Gut.

Es wurden viele v bei -v verwendet, deshalb die Ausführlichkeit mit 
jedem übertragenen (Send/Recv) Byte. Schadet im Zweifelsfall aber nicht.

Was dumm gelaufen ist:

1. Die Debugausgabe ist anscheinend mittendrin abgeschnitten. Hattest du 
Angst vor einem zu langen Beitrag? Dann den Tipp: Du kannst die Ausgabe 
prima als Anhang an deine Beiträge anhängen.

2. In der Debugausgabe taucht jetzt als zu programmierender AVR ein 
ATMEGA8 auf aber in deinem Makefile ist als Target ein ATMEGA32 
(siehe auch 1. Beitrag: Device signature = 0x1e9502) eingetragen. Ein 
für Atmega32 übersetztes Programm läuft i.d.R. auf dem Atmega8 nicht :-(

von Arne (Gast)


Lesenswert?

Es wundert mich, dass da ein mega8 auftaucht, obewohl auf dem prozessor 
selber mega32 steht (auf der verpackung ebenfalls).
Wenn ich den Makefile nun auf einen mega8 umstelle, gibt mit avrdude 
einen Fehler wegen der Signatur aus:
1
avrdude -p atmega8 -P com4 -c stk500v2    -U flash:w:main.hex 
2
3
avrdude: AVR device initialized and ready to accept instructions
4
5
Reading | ################################################## | 100% 0.02s
6
7
avrdude: Device signature = 0x1e9502
8
avrdude: Expected signature for ATMEGA8 is 1E 93 07
9
         Double check chip, or use -F to override this check.
10
11
avrdude done.  Thank you.
12
13
make.exe: *** [program] Error 1
14
15
> Process Exit Code: 2
16
> Time Taken: 00:01

von Jörg W. (dl8dtl) (Moderator) Benutzerseite


Lesenswert?

Arne schrieb:
> avrdude: usbdev_open(): did not find any (matching) USB device "usb:xx"

usb:xx benutzt man auch nur für direkt via USB (also ohne "virtual
COM port") angebundene Geräte wie das AVRISPmkII, und das "xx" steht
dabei für die letzten Stellen der Seriennummer.  Wenn man wirklich
xx schreibt, passt es nie auf eine Seriennummer, sodass man in der
Ausgabe von -v nachsehen kann, welche tatsächlichen Geräte am Bus
gefunden worden sind.

Bitte poste mal ein komplettes Logfile als Anhang.  Das Logfile
bekommst du im cmd.exe mit:
1
avrdude <alle Optionen hier> 2> logfile.txt

von Stefan B. (stefan) Benutzerseite


Lesenswert?

Ein Atmega8 hat 28 Beinchen und ein Atmega32 40. Die kann man mit dem 
blossen Auge unterscheiden :-)

> avrdude -p atmega8 -P com4 -c stk500v2    -U flash:w:main.hex

Das ist eine Kommandozeile für den Atmega8 und produziert diese Ausgabe:

> avrdude: Device signature = 0x1e9502
> avrdude: Expected signature for ATMEGA8 is 1E 93 07

Für mich ist das vollkommen OK. Avrdude hat erkannt, dass in der zu 
programmierenden Schaltung ein Atmega32 steckt (Device signature = 
0x1e9502) und du einen Atmega8 programmieren willst (-p atmega8 und 
ATMEGA8 is 1E 93 07), was logischerweise nicht funktioniert und Avrdude 
bricht ab. Make erkennt den Abbruch durch Avrdude und zeigt den 
Fehlercode 1 an. Alles im grünen Bereich.

Interessant wäre nun, wie bei dieser Kommandozeile die Ausgabe aussieht:
avrdude -p atmega32 -P com4 -c stk500v2 -U flash:w:main.hex

von Arne (Gast)


Lesenswert?

Wenn ich die Kommandozeile
avrdude -p atmega32 -P com4 -c stk500v2 -U flash:w:main.hex
kommt es ja zu dem Problem was ich am Anfang meinte, dass er einfach 
beim Write hängen bleibt und ich die Task nurnoch killen kann.

Mein Fehlerausgabe Befehl sieht momentan wie folgt aus:
avrdude -c stk500v2 -p m32 -P com4 -vvvv > "C:\FehlerM32.txt" 2>&1

In der txt Datei steht danach
1
avrdude: Version 5.10, compiled on Jan 19 2010 at 10:45:23
2
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
3
         Copyright (c) 2007-2009 Joerg Wunsch
4
5
         System wide configuration file is "C:\WinAVR-20100110\bin\avrdude.conf"
6
7
         Using Port                    : com4
8
         Using Programmer              : stk500v2
9
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14] 
10
avrdude: Recv: . [1b] 
11
avrdude: Recv: . [01] 
12
avrdude: Recv: . [00] 
13
avrdude: Recv: . [0b] 
14
avrdude: Recv: . [0e] 
15
avrdude: Recv: . [01] 
16
avrdude: Recv: . [00] 
17
avrdude: Recv: . [08] 
18
avrdude: Recv: A [41] 
19
avrdude: Recv: V [56] 
20
avrdude: Recv: R [52] 
21
avrdude: Recv: I [49] 
22
avrdude: Recv: S [53] 
23
avrdude: Recv: P [50] 
24
avrdude: Recv: _ [5f] 
25
avrdude: Recv: 2 [32] 
26
avrdude: Recv: t [74] 
27
avrdude: stk500v2_getsync(): found AVRISP programmer
28
         AVR Part                      : ATMEGA32
29
         Chip Erase delay              : 9000 us
30
         PAGEL                         : PD7
31
         BS2                           : PA0
32
         RESET disposition             : dedicated
33
         RETRY pulse                   : SCK
34
         serial program mode           : yes
35
         parallel program mode         : yes
36
         Timeout                       : 200
37
         StabDelay                     : 100
38
         CmdexeDelay                   : 25
39
         SyncLoops                     : 32
40
         ByteDelay                     : 0
41
         PollIndex                     : 3
42
         PollValue                     : 0x53
43
         Memory Detail                 :
44
45
                                  Block Poll               Page                       Polled
46
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
47
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
48
           eeprom         4    10    64    0 no       1024    4      0  9000  9000 0xff 0xff
49
                                  Block Poll               Page                       Polled
50
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
51
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
52
           flash         33     6    64    0 yes     32768  128    256  4500  4500 0xff 0xff
53
                                  Block Poll               Page                       Polled
54
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
55
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
56
           lfuse          0     0     0    0 no          1    0      0  2000  2000 0x00 0x00
57
                                  Block Poll               Page                       Polled
58
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
59
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
60
           hfuse          0     0     0    0 no          1    0      0  2000  2000 0x00 0x00
61
                                  Block Poll               Page                       Polled
62
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
63
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
64
           lock           0     0     0    0 no          1    0      0  2000  2000 0x00 0x00
65
                                  Block Poll               Page                       Polled
66
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
67
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
68
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
69
                                  Block Poll               Page                       Polled
70
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
71
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
72
           calibration    0     0     0    0 no          4    0      0     0     0 0x00 0x00
73
74
         Programmer Type : STK500V2
75
         Description     : Atmel STK500 Version 2.x firmware
76
         Programmer Model: AVRISP
77
avrdude: Send: . [1b] . [02] . [00] . [02] . [0e] . [03] . [90] . [86] 
78
avrdude: Recv: . [1b] 
79
avrdude: Recv: . [02] 
80
avrdude: Recv: . [00] 
81
avrdude: Recv: . [03] 
82
avrdude: Recv: . [0e] 
83
avrdude: Recv: . [03] 
84
avrdude: Recv: . [00] 
85
avrdude: Recv: . [0f] 
86
avrdude: Recv: . [18] 
87
avrdude: Send: . [1b] . [03] . [00] . [02] . [0e] . [03] . [91] . [86]

Hab dank des Threads hier schon einige dumme Fehler bemerkt die ich 
vorher gemacht habe :)

von Stefan B. (stefan) Benutzerseite


Lesenswert?

Ach so, der Debugtext von oben, der so abgeschnitten aussieht ist der 
vollständige Text. Avrdude hängt nach dem Senden der letzten Zeile

> avrdude: Send: . [1b] . [03] . [00] . [02] . [0e] . [03] . [91] . [86]

Die erwartete Recv Meldung vom Atmega32 wie zur Send Zeile vorher 
kommt einfach nicht.

Brauche ich mehr Zeit, um dem nach zu gehen. Jedenfalls ist für mich die 
Fehlerlage jetzt auch klarer.

von Jörg W. (dl8dtl) (Moderator) Benutzerseite


Lesenswert?

Arne schrieb:
> In der txt Datei steht danach

Mehr nicht?

Dann wäre dein Programmer kaputt.  Die Abfrage nach der Hardware-
Version (Parameter 0x90) klappt noch, und in der nach der Software-
version (0x91) bleibt er hängen?

An dieser Stelle unterscheidet sich ja die Kommandofolge in keiner
Weise zwischen dem ATmega8 und dem ATmega32.

von Arne (Gast)


Lesenswert?

Jo,
ich merk grad, dass meine Console auch hängen bleibt wenn ich den Befehl 
für die txt Ausgabe sende.
Ich werd mal versuchen mir eben einen baugleichen Kontroller zu 
organisieren um zu testen, obs am Kontroller liegt.

von Arne (Gast)


Lesenswert?

Jörg Wunsch schrieb:
> Arne schrieb:
>> In der txt Datei steht danach
>
> Mehr nicht?
>
> Dann wäre dein Programmer kaputt.  Die Abfrage nach der Hardware-
> Version (Parameter 0x90) klappt noch, und in der nach der Software-
> version (0x91) bleibt er hängen?
>
> An dieser Stelle unterscheidet sich ja die Kommandofolge in keiner
> Weise zwischen dem ATmega8 und dem ATmega32.

Ja, er bleibt immer bei der 91 hängen.

von Arne (Gast)


Lesenswert?

Also am ISP Programmierer wirds nicht liegen. Hab das eben mal mit 2 
weiteren getestet.

von Jörg W. (dl8dtl) (Moderator) Benutzerseite


Lesenswert?

Arne schrieb:
> Hab das eben mal mit 2
> weiteren getestet.

Dann probier's mal mit 2 weiteren Computern ...

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.