Forum: Mikrocontroller und Digitale Elektronik Tiny25 programmieren mit winAVR


von Jens R. (tecdroid)


Lesenswert?

Also nachdem meine Frau ihren alten Laptop nicht mehr braucht, hab ich 
endlich einen mit LPT.
Jetzt wollte ich ein einfaches Programm in meinen Tiny25 laden, für den 
ich eigens nen kleinen Programmer gebastelt hab (stk200)

#include <avr/io.h>

int main (int argc, char **argv) {
  int i = 0;
  while (1) {
    i ++;
  }
  return 0;
}


mein Makefile sieht so aus:

TARGET = main
MCU    = attiny25
CC     = avr-gcc
OBJCOPY=avr-objcopy
CFLAGS =-g -mmcu=$(MCU) -Wall -Wstrict-prototypes -Os -mcall-prologues 
-save-temps -fno-common

all: $(TARGET).hex

$(TARGET).hex : $(TARGET).o
  $(OBJCOPY) -j .data -j .text -O ihex $^ $@

$(TARGET).elf: $(TARGET).o
  $(CC) $(CFLAGS) -o $@ -Wl,-Map,$(TARGET).map $^

$(TARGET).o : $(TARGET).c
  $(CC) $(CFLAGS) -c $^ -o $@

program: $(TARGET).hex
  install_giveio.bat
  avrdude -p t25 -c stk200 -U flash:w:$(TARGET).hex -v
  uninstall_giveio.bat

clean:
  rm -f *.o *.map *.elf *.hex *.s *.i

ist mehr oder weniger abgetippt aus der Roboternetz-Wiki. Allerdings war 
da ein Werwechlser der Parameter $^ $@  in der Zeile ${OBJCOPY}

Beim Programmieren hab ich jetzt folgendes Protokoll..

install_giveio.bat
Copying the driver to the windows directory
target file: C:\WINDOWS\giveio.sys
Das System kann die angegebene Datei nicht finden.
Remove a running service if needed...
Installing Windows NT/2k/XP driver: giveio
installing giveio from C:\WINDOWS\giveio.sys... ok.
starting giveio... ok.
set start type of giveio to auto... ok.
Success
avrdude -p t25 -c stk200 -U flash:w:main.hex -v

avrdude: Version 5.1
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

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

         Using Port            : lpt1
         Using Programmer      : stk200
         AVR Part              : ATtiny25
         Chip Erase delay      : 4500 us
         PAGEL                 : P00
         BS2                   : P00
         RESET disposition     : possible i/o
         RETRY pulse           : SCK
         serial program mode   : yes
         parallel program mode : yes
         Timeout               : 200
         StabDelay             : 100
         CmdexeDelay           : 25
         SyncLoops             : 32
         ByteDelay             : 0
         PollIndex             : 3
         PollValue             : 0x53
         Memory Detail         :

                                  Block Poll               Page 
Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages 
MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ 
----- ----- ---------
           eeprom        65     6     4    0 no        128    0      0 
4000  4500 0xff 0xff
           flash         65     6    32    0 yes      2048   32     64 
4500  4500 0xff 0xff
           signature      0     0     0    0 no          3    0      0 
0     0 0x00 0x00
           lock           0     0     0    0 no          1    0      0 
0     0 0x00 0x00
           lfuse          0     0     0    0 no          1    0      0 
0     0 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0 
0     0 0x00 0x00
           efuse          0     0     0    0 no          1    0      0 
0     0 0x00 0x00
           calibration    0     0     0    0 no          1    0      0 
0     0 0x00 0x00

         Programmer Type : PPI
         Description     : STK200
           VCC     = 0x00 (not used)
           BUFF    = 0x0c = pins 4,5
           RESET   = 9
           SCK     = 6
           MOSI    = 7
           MISO    = 10
           ERR LED = 0
           RDY LED = 0
           PGM LED = 0
           VFY LED = 0

avrdude: AVR device initialized and ready to accept instructions

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

avrdude: Device signature = 0x1e9108
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 (2 bytes):

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

avrdude: 2 bytes of flash written
avrdude: verifying flash memory against main.hex:
avrdude: load data flash data from input file main.hex:
avrdude: input file main.hex auto detected as Intel Hex
avrdude: input file main.hex contains 2 bytes
avrdude: reading on-chip flash data:

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

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0001
         0xc0 != 0x31
avrdude: verification error; content mismatch

avrdude done.  Thank you.

make.exe: *** [program] Error 1

> Process Exit Code: 2

kann mir wer erklären, was da falsch läuft?

von Uwe N. (ulegan)


Angehängte Dateien:

Lesenswert?

Das MAKEFILE geht bei mir nicht... Es läuft zwar ohne Fehlermeldung, das 
erzeugte HEX-File ist allerdings leer. Das scheint bei dir auch so zu 
sein, denn AVRDUDE sagt was von "avrdude: writing flash (2 bytes):".
Erzeuge mal ein MAKEFILE mit mfile oder nimm das aus dem Anhang, das 
funktioniert. Allerdings hat es das Programm komplett wegoptimiert...
Das ist auch richtig so, denn es macht icht wirklich etwas. Die Variable 
i wird nicht weiterverwendet, also braucht sie auch nicht hochgezählt 
werden. Das ganze erzeugte Programm besteht aus Initialisierung und 
einer leeren Endlosschleife.
Zweitens hat AVRDUDE beim verify einen Fehler entdeckt: An Adresse 0x001 
steht 0x31 statt 0xc0. Das könnte allerdings eine Folge des leeren 
HEX-Files sein.

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.