PDA

Просмотр полной версии : avrdude в linux



v4567
06.04.2013, 23:16
Есть микроконтроллер ATtiny85 и программа - под виндой для прошивки пользуюсь унипроф (программатор Громова - http://easyelectronics.ru/avr-shag-pervyj-programmator.html) флэш нормально стирается и программируется, соответственно программа в микроконтроллере работает как надо.

В линукс для прошивки пользуюсь avrdude делаю всё под рутом. Винда и линукс на одном и том же компьютере.

Вот строки в конфиге avrdude.conf для программатора Громова


programmer
id = "gromov";
baudrate = 9600;
desc = "serial port banging, reset=dtr sck=rts mosi=txd miso=cts";
type = serbb;
reset = 4;
sck = 7;
mosi = 3;
miso = 8;
;

Сразу скажу что комментирование строки baudrate = 9600; результата не принесло.

В начале стираю командой:

avrdude -P /dev/ttyS0 -p t85 -c gromov -e -v

выдаёт:

avrdude: Version 5.11, compiled on Nov 22 2012 at 22:51:08
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2009 Joerg Wunsch

System wide configuration file is "/usr/local/etc/avrdude.conf"
User configuration file is "/root/.avrduderc"
User configuration file does not exist or is not a regular file, skipping

Using Port : /dev/ttyS0
Using Programmer : gromov
AVR Part : ATtiny85
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 512 4 0 4000 4500 0xff 0xff
flash 65 6 32 0 yes 8192 64 128 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 9000 9000 0x00 0x00
lfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
efuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
calibration 0 0 0 0 no 2 0 0 0 0 0x00 0x00

Programmer Type : SERBB
Description : serial port banging, reset=dtr sck=rts mosi=txd miso=cts

avrdude: AVR device initialized and ready to accept instructions

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

avrdude: Device signature = 0x1e930b
avrdude: safemode: lfuse reads as E2
avrdude: safemode: hfuse reads as DF
avrdude: safemode: efuse reads as FF
avrdude: erasing chip

avrdude: safemode: lfuse reads as E2
avrdude: safemode: hfuse reads as DF
avrdude: safemode: efuse reads as FF
avrdude: safemode: Fuses OK

avrdude done. Thank you.

далее записываю командой:

avrdude -P /dev/ttyS0 -p t85 -c gromov -U flash:w:begogni85.he x:i -v

выдаёт:

avrdude: Version 5.11, compiled on Nov 22 2012 at 22:51:08
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2009 Joerg Wunsch

System wide configuration file is "/usr/local/etc/avrdude.conf"
User configuration file is "/root/.avrduderc"
User configuration file does not exist or is not a regular file, skipping

Using Port : /dev/ttyS0
Using Programmer : gromov
AVR Part : ATtiny85
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 512 4 0 4000 4500 0xff 0xff
flash 65 6 32 0 yes 8192 64 128 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 9000 9000 0x00 0x00
lfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
efuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
calibration 0 0 0 0 no 2 0 0 0 0 0x00 0x00

Programmer Type : SERBB
Description : serial port banging, reset=dtr sck=rts mosi=txd miso=cts

avrdude: AVR device initialized and ready to accept instructions

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

avrdude: Device signature = 0x1e930b
avrdude: safemode: lfuse reads as E2
avrdude: safemode: hfuse reads as DF
avrdude: safemode: efuse reads as FF
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 "begogni85.hex"
avrdude: writing flash (54 bytes):

Writing | #################### #################### ########## | 100% 0.19s

avrdude: 54 bytes of flash written
avrdude: verifying flash memory against begogni85.hex:
avrdude: load data flash data from input file begogni85.hex:
avrdude: input file begogni85.hex contains 54 bytes
avrdude: reading on-chip flash data:

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

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
0x0e != 0x00
avrdude: verification error; content mismatch

avrdude: safemode: lfuse reads as E2
avrdude: safemode: hfuse reads as DF
avrdude: safemode: efuse reads as FF
avrdude: safemode: Fuses OK

avrdude done. Thank you.

Как видно вылезла ошибка:

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
0x0e != 0x00
avrdude: verification error; content mismatch

Вроде как кристалл не стёрся, но стирание вроде прошло нормально.
Естественно программа на микроконтроллере работает не так, причём иногда бывает так что записывается без этой ошибки, соответственно тогда всё работает нормально.

Подскажите пожалуйста в чём может быть проблема!!
За помощь заранее благодарен!!!!

v4567
07.04.2013, 18:55
Всё проблему решил!!!!!!!!!

Не хватает каких то флагов для /dev/ttyS0

Вот ссылка:
http://radiokot.ru/forum/viewtopic.php?f=20&t=41093&sid=614ab729b563f6c0 b9faf269057ad55f&start=20

Кстати детали я так и не понял.

Теперь я расскажу как я делаю.

У меня по команде:



stty < /dev/ttyS0


Выдавало:



speed 9600 baud; line = 0;
-brkint -imaxbel


Флагов всего два -brkint -imaxbel как говорят их не достаточно.

Поэтому выполняю команду:



stty 9600 ignbrk -brkint -icrnl -imaxbel -opost -isig -icanon -iexten -echo noflsh </dev/ttyS0


Её надо в автозагрузку поместить или выполнять один раз после перезагрузки компа перед прошитием микроконтроллера.

Теперь по команде:



stty < /dev/ttyS0


Выдаёт:



speed 9600 baud; line = 0;
min = 1; time = 0;
ignbrk -brkint -icrnl -imaxbel
-opost
-isig -icanon -iexten -echo noflsh


После этого всё начинает работать. Вначале стираю командой:



avrdude -P /dev/ttyS0 -p t85 -c gromov -b 9600 -B 48 -e
или
avrdude -P /dev/ttyS0 -p t85 -c gromov -b 9600 -e
или
avrdude -P /dev/ttyS0 -p t85 -c gromov -e


Далее программирую:



avrdude -P /dev/ttyS0 -p t85 -c gromov -b 9600 -B 48 -D -U flash:w:begogni85.he x:i
или
avrdude -P /dev/ttyS0 -p t85 -c gromov -b 9600 -B 48 -U flash:w:begogni85.he x:i
или
avrdude -P /dev/ttyS0 -p t85 -c gromov -b 9600 -U flash:w:begogni85.he x:i
или
avrdude -P /dev/ttyS0 -p t85 -c gromov -U flash:w:begogni85.he x:i


Со всеми командами работает нормально.