Forum: Mikrocontroller und Digitale Elektronik AVR Bootloader lock/fuse bits


von Dietmar B. (theq)


Lesenswert?

Hallo,

ich will den Bootloader meines Arduino Nano clone (ATmega328p) neu 
schreiben.
Als ISP nutze ich einen anderen Nano.

Als settings nutze ich die Standardeinstellungen des avrdude
lock 0x3F
efuse 0xFD
hfuse 0xDA
lfuse 0xFF

scheitere aber beim Schreiben der lock/fuse bits.
Bin für jeden Hinweis dankbar!
1
D:\Apps\arduino-1.8.7\hardware\tools\avr/bin/avrdude -CD:\Apps\arduino-1.8.7\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -e -carduino -PCOM6 -b57600 -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xDA:m -Ulfuse:w:0xFF:m
2
3
avrdude: Version 6.3-20171130
4
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
5
         Copyright (c) 2007-2014 Joerg Wunsch
6
7
         System wide configuration file is "D:\Apps\arduino-1.8.7\hardware\tools\avr/etc/avrdude.conf"
8
9
         Using Port                    : COM6
10
         Using Programmer              : arduino
11
         Overriding Baud Rate          : 57600
12
         AVR Part                      : ATmega328P
13
         Chip Erase delay              : 9000 us
14
         PAGEL                         : PD7
15
         BS2                           : PC2
16
         RESET disposition             : dedicated
17
         RETRY pulse                   : SCK
18
         serial program mode           : yes
19
         parallel program mode         : yes
20
         Timeout                       : 200
21
         StabDelay                     : 100
22
         CmdexeDelay                   : 25
23
         SyncLoops                     : 32
24
         ByteDelay                     : 0
25
         PollIndex                     : 3
26
         PollValue                     : 0x53
27
         Memory Detail                 :
28
29
                                  Block Poll               Page                       Polled
30
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
31
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
32
           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
33
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
34
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
35
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
36
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
37
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
38
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
39
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
40
41
         Programmer Type : Arduino
42
         Description     : Arduino
43
         Hardware Version: 2
44
         Firmware Version: 1.16
45
         Vtarget         : 0.0 V
46
         Varef           : 0.0 V
47
         Oscillator      : Off
48
         SCK period      : 0.1 us
49
50
avrdude: AVR device initialized and ready to accept instructions
51
52
Reading | ################################################## | 100% 0.01s
53
54
avrdude: Device signature = 0x1e950f (probably m328p)
55
avrdude: safemode: lfuse reads as 0
56
avrdude: safemode: hfuse reads as 0
57
avrdude: safemode: efuse reads as 0
58
avrdude: erasing chip
59
avrdude: reading input file "0x3F"
60
avrdude: writing lock (1 bytes):
61
62
Writing |                                                    | 0% 0.00s ***failed;
63
Writing | ################################################## | 100% 0.08s
64
65
avrdude: 1 bytes of lock written
66
avrdude: verifying lock memory against 0x3F:
67
avrdude: load data lock data from input file 0x3F:
68
avrdude: input file 0x3F contains 1 bytes
69
avrdude: reading on-chip lock data:
70
71
Reading | ################################################## | 100% 0.01s
72
73
avrdude: verifying ...
74
avrdude: verification error, first mismatch at byte 0x0000
75
         0x00 != 0x3f
76
avrdude: verification error; content mismatch
77
78
avrdude: safemode: lfuse reads as 0
79
avrdude: safemode: hfuse reads as 0
80
avrdude: safemode: efuse reads as 0
81
avrdude: safemode: Fuses OK (E:00, H:00, L:00)
82
83
avrdude done.  Thank you.

: Bearbeitet durch User
von Karl M. (Gast)


Lesenswert?

Hallo,

Du musst den Chip  erst komplett löschen.

Siehe AVRDude man - page.

von Dietmar B. (theq)


Lesenswert?

Karl M. schrieb:
> Du musst den Chip  erst komplett löschen.

aber ich dachte das macht "-e" schon ... ?!

von Einer K. (Gast)


Angehängte Dateien:

Lesenswert?

Dietmar B. schrieb:
> D:\Apps\arduino-1.8.7\hardware\tools\avr/bin/avrdude
> -CD:\Apps\arduino-1.8.7\hardware\tools\avr/etc/avrdude.conf -v
> -patmega328p -e -carduino -PCOM6 -b57600 -Ulock:w:0x3F:m
> -Uefuse:w:0xFD:m -Uhfuse:w:0xDA:m -Ulfuse:w:0xFF:m

Sieht fast ok aus!
Bis auf die Baudrate.
Arduino as ISP erwartet da eigentlich 19200 Baud.

Im Anhang ein Log vom Bootloader brennen
Target: Nano.
Bootloader: Der neue Nano Bootloader
Programmer: Arduino as ISP auf einem UNO

von Dietmar B. (theq)


Lesenswert?

Die Baud Rate musste ich (nach einigem rumprobieren) umstellen ... 
vermutlich weil ich auf beiden Nanos den alten Bootloder habe oder weil 
das Klone sind.

von Einer K. (Gast)


Lesenswert?

Dietmar B. schrieb:
> Die Baud Rate musste ich (nach einigem rumprobieren) umstellen ...
> vermutlich weil ich auf beiden Nanos den alten Bootloder habe oder weil
> das Klone sind.

Die Baudrate wird zwischen Programmer und PC genutzt.
Deine Analyse ist also (recht) falsch!

Die Baudrate hat NICHTS mit irgendeinem Bootloader oder den Klonen zu 
tun.
Zumindest sollte es nicht.


Ich möchte dafür wetten, dass du vergessen hast den DTR-Reset des 
Programmers zu unterbinden.
10µF zwischen Reset und GND erledigen das.

von Dietmar B. (theq)


Lesenswert?

Die 10µF bringen leider keine Veränderung.

Die 57600 Baud ist halt die einzige die funktioniert. Alle anderen Baud 
Raten führen zu Kommunikationsfehlern.

Im übrigen scheine ich den Bootloader prinzipiell flashen zu können wenn 
ich das Setzen der lock/fuse bits weglasse. Das führt dann aber zu einem 
anderen Fehler (verification error ... adresse 0x7f00).

Vieleicht wandert das Ding einfach in die Tonne ... trotzdem vielen Dank 
für eure Hilfe!

1
D:\Apps\arduino-1.8.7\hardware\tools\avr/bin/avrdude -CD:\Apps\arduino-1.8.7\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM6 -b57600 -Uflash:w:D:\Apps\arduino-1.8.7\hardware\arduino\avr\bootloaders/atmega/ATmegaBOOT_168_atmega328.hex:i -Ulock:w:0x0F:m
2
3
avrdude: Version 6.3-20171130
4
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
5
         Copyright (c) 2007-2014 Joerg Wunsch
6
7
         System wide configuration file is "D:\Apps\arduino-1.8.7\hardware\tools\avr/etc/avrdude.conf"
8
9
         Using Port                    : COM6
10
         Using Programmer              : arduino
11
         Overriding Baud Rate          : 57600
12
         AVR Part                      : ATmega328P
13
         Chip Erase delay              : 9000 us
14
         PAGEL                         : PD7
15
         BS2                           : PC2
16
         RESET disposition             : dedicated
17
         RETRY pulse                   : SCK
18
         serial program mode           : yes
19
         parallel program mode         : yes
20
         Timeout                       : 200
21
         StabDelay                     : 100
22
         CmdexeDelay                   : 25
23
         SyncLoops                     : 32
24
         ByteDelay                     : 0
25
         PollIndex                     : 3
26
         PollValue                     : 0x53
27
         Memory Detail                 :
28
29
                                  Block Poll               Page                       Polled
30
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
31
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
32
           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
33
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
34
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
35
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
36
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
37
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
38
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
39
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
40
41
         Programmer Type : Arduino
42
         Description     : Arduino
43
         Hardware Version: 2
44
         Firmware Version: 1.16
45
         Vtarget         : 0.0 V
46
         Varef           : 0.0 V
47
         Oscillator      : Off
48
         SCK period      : 0.1 us
49
50
avrdude: AVR device initialized and ready to accept instructions
51
52
Reading | ################################################## | 100% 0.01s
53
54
avrdude: Device signature = 0x1e950f (probably m328p)
55
avrdude: safemode: lfuse reads as 0
56
avrdude: safemode: hfuse reads as 0
57
avrdude: safemode: efuse reads as 0
58
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
59
         To disable this feature, specify the -D option.
60
avrdude: erasing chip
61
avrdude: reading input file "D:\Apps\arduino-1.8.7\hardware\arduino\avr\bootloaders/atmega/ATmegaBOOT_168_atmega328.hex"
62
avrdude: writing flash (32670 bytes):
63
64
Writing | ################################################## | 100% 0.07s
65
66
avrdude: 32670 bytes of flash written
67
avrdude: verifying flash memory against D:\Apps\arduino-1.8.7\hardware\arduino\avr\bootloaders/atmega/ATmegaBOOT_168_atmega328.hex:
68
avrdude: load data flash data from input file D:\Apps\arduino-1.8.7\hardware\arduino\avr\bootloaders/atmega/ATmegaBOOT_168_atmega328.hex:
69
avrdude: input file D:\Apps\arduino-1.8.7\hardware\arduino\avr\bootloaders/atmega/ATmegaBOOT_168_atmega328.hex contains 32670 bytes
70
avrdude: reading on-chip flash data:
71
72
Reading | ################################################## | 100% 0.06s
73
74
avrdude: verifying ...
75
avrdude: verification error, first mismatch at byte 0x7f00
76
         0xff != 0x09
77
avrdude: verification error; content mismatch
78
79
avrdude: safemode: lfuse reads as 0
80
avrdude: safemode: hfuse reads as 0
81
avrdude: safemode: efuse reads as 0
82
avrdude: safemode: Fuses OK (E:00, H:00, L:00)
83
84
avrdude done.  Thank you.

von Einer K. (Gast)


Lesenswert?

Dietmar B. schrieb:
> Die 57600 Baud ist halt die einzige die funktioniert. Alle anderen Baud
> Raten führen zu Kommunikationsfehlern.
In dem Punkt verarscht du dich selber.

Schaue in den Arduino as ISP Sketch.
Da steht eindeutig 19200 Baud.
Also müssen deine 57600 Baud falsch sein.

Siehe dazu: 
https://github.com/arduino/Arduino/blob/ee1967cd530ceb9a1d638875e385157e90d532e8/build/shared/examples/11.ArduinoISP/ArduinoISP/ArduinoISP.ino
Zeile 142

Thema durch.

von Dietmar B. (theq)


Lesenswert?

schon klar. die hab ich natürlich auch abgeändert

von Einer K. (Gast)


Lesenswert?

Dietmar B. schrieb:
> schon klar. die hab ich natürlich auch abgeändert
Is klar... (oh man, oh man)

Dann mach den Unsinn doch bitte wieder rückgängig!

Wie schon gesagt:
> In dem Punkt verarscht du dich selber.

von Einer K. (Gast)


Lesenswert?

Mittlerweile umgestellt?
Der Kondensator noch drin?

Dietmar B. schrieb:
> Die 57600 Baud ist halt die einzige die funktioniert. Alle anderen Baud
> Raten führen zu Kommunikationsfehlern.

Genau diese "anderen" Fehlermeldungen sind die "richtigen" und "wahren" 
Fehlermeldungen.
Die hätte ich gerne mal gesehen!
Auf die kommt es an.

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.