ATNEL tech-forum https://forum.atnel.pl/ |
|
Atmega3228p nie działa poprawnie po wgraniu bootloadera https://forum.atnel.pl/topic18435.html |
Strona 1 z 1 |
Autor: | proqix [ 18 maja 2017, o 22:39 ] |
Tytuł: | Atmega3228p nie działa poprawnie po wgraniu bootloadera |
Witam. Dopiero zaczynam grubszą zabawę z atmegą 328p i natknąłem się na trudny problem. Wgrałem program z błędem, który uniemożliwił mi komunikacje po TTL z prockiem i programowania go. By to naprawić wgrałem od nowa bootloader za pomocą USBasp. Dzięki temu udało mi się w części odzyskać kontrole, ale z nieznanych mi przyczyn już nie jestem w stanie wgrywać programów bezpośrednio na procesor. Znaczy się jeżeli wezmę przykład "blink" i rozpocznę jego wgrywanie to otrzymuje że nie może się połączyć: Kod: avrdude: Version 6.3, compiled on Dec 16 2016 at 13:33:19 Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/ Copyright (c) 2007-2014 Joerg Wunsch System wide configuration file is "C:\Users\THX\Desktop\arduino-1.8.1\hardware\tools\avr/etc/avrdude.conf" Using Port : COM3 Using Programmer : arduino Overriding Baud Rate : 57600 avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x49 Ale gdy w tym momencie jeszcze kliknę opcje "Wypal bootloader" to od nowa zostaje wgrany bootloader wraz z programem blink Kod: C:\Users\THX\Desktop\arduino-1.8.1\hardware\tools\avr/bin/avrdude -CC:\Users\THX\Desktop\arduino-1.8.1\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -cusbasp -Pusb -e -Ulock:w:0x3F:m -Uefuse:w:0x05:m -Uhfuse:w:0xDA:m -Ulfuse:w:0xFF:m avrdude: Version 6.3, compiled on Dec 16 2016 at 13:33:19 Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/ Copyright (c) 2007-2014 Joerg Wunsch System wide configuration file is "C:\Users\THX\Desktop\arduino-1.8.1\hardware\tools\avr/etc/avrdude.conf" Using Port : usb Using Programmer : usbasp AVR Part : ATmega328P Chip Erase delay : 9000 us PAGEL : PD7 BS2 : PC2 RESET disposition : dedicated 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 20 4 0 no 1024 4 0 3600 3600 0xff 0xff flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00 hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00 efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00 lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00 calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00 signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00 Programmer Type : usbasp Description : USBasp, http://www.fischl.de/usbasp/ avrdude: auto set sck period (because given equals null) avrdude: warning: cannot set sck period. please check for usbasp firmware update. avrdude: AVR device initialized and ready to accept instructions Reading | ################################################## | 100% 0.01s avrdude: Device signature = 0x1e950f (probably m328p) avrdude: erasing chip avrdude: auto set sck period (because given equals null) avrdude: warning: cannot set sck period. please check for usbasp firmware update. avrdude: reading input file "0x3F" avrdude: writing lock (1 bytes): C:\Users\THX\Desktop\arduino-1.8.1\hardware\tools\avr/bin/avrdude -CC:\Users\THX\Desktop\arduino-1.8.1\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -cusbasp -Pusb -Uflash:w:C:\Users\THX\Desktop\arduino-1.8.1\hardware\arduino\avr/bootloaders/atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex:i -Ulock:w:0x0F:m avrdude: Version 6.3, compiled on Dec 16 2016 at 13:33:19 Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/ Copyright (c) 2007-2014 Joerg Wunsch System wide configuration file is "C:\Users\THX\Desktop\arduino-1.8.1\hardware\tools\avr/etc/avrdude.conf" Writing | ################################################## | 100% 0.00s avrdude: 1 bytes of lock written avrdude: verifying lock memory against 0x3F: avrdude: load data lock data from input file 0x3F: avrdude: input file 0x3F contains 1 bytes avrdude: reading on-chip lock data: Reading | ################################################## | 100% 0.00s avrdude: verifying ... avrdude: 1 bytes of lock verified avrdude: reading input file "0x05" avrdude: writing efuse (1 bytes): Writing | ***failed; ################################################## | 100% 0.04s avrdude: 1 bytes of efuse written avrdude: verifying efuse memory against 0x05: avrdude: load data efuse data from input file 0x05: avrdude: input file 0x05 contains 1 bytes avrdude: reading on-chip efuse data: Reading | ################################################## | 100% 0.00s avrdude: verifying ... avrdude: WARNING: invalid value for unused bits in fuse "efuse", should be set to 1 according to datasheet This behaviour is deprecated and will result in an error in future version You probably want to use 0xfd instead of 0x05 (double check with your datasheet first). avrdude: 1 bytes of efuse verified avrdude: reading input file "0xDA" Using Port : usb avrdude: writing hfuse (1 bytes): Using Programmer : usbasp Writing | ################################################## | 100% 0.00s avrdude: 1 bytes of hfuse written avrdude: verifying hfuse memory against 0xDA: avrdude: load data hfuse data from input file 0xDA: avrdude: input file 0xDA contains 1 bytes avrdude: reading on-chip hfuse data: Reading | ################################################## | 100% 0.00s avrdude: verifying ... avrdude: 1 bytes of hfuse verified avrdude: reading input file "0xFF" avrdude: writing lfuse (1 bytes): Writing | ################################################## | 100% 0.00s avrdude: 1 bytes of lfuse written avrdude: verifying lfuse memory against 0xFF: avrdude: load data lfuse data from input file 0xFF: avrdude: input file 0xFF contains 1 bytes avrdude: reading on-chip lfuse data: Reading | ################################################## | 100% 0.00s avrdude: verifying ... avrdude: 1 bytes of lfuse verified avrdude done. Thank you. AVR Part : ATmega328P Chip Erase delay : 9000 us PAGEL : PD7 BS2 : PC2 RESET disposition : dedicated 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 20 4 0 no 1024 4 0 3600 3600 0xff 0xff flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00 hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00 efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00 lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00 calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00 signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00 Programmer Type : usbasp Description : USBasp, http://www.fischl.de/usbasp/ avrdude: auto set sck period (because given equals null) avrdude: warning: cannot set sck period. please check for usbasp firmware update. avrdude: AVR device initialized and ready to accept instructions Reading | ################################################## | 100% 0.01s avrdude: Device signature = 0x1e950f (probably m328p) 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: auto set sck period (because given equals null) avrdude: warning: cannot set sck period. please check for usbasp firmware update. avrdude: reading input file "C:\Users\THX\Desktop\arduino-1.8.1\hardware\arduino\avr/bootloaders/atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex" avrdude: writing flash (32652 bytes): Writing | ################################################## | 100% 0.00s avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x49 avrdude: 32652 bytes of flash written avrdude: verifying flash memory against C:\Users\THX\Desktop\arduino-1.8.1\hardware\arduino\avr/bootloaders/atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex: avrdude: load data flash data from input file C:\Users\THX\Desktop\arduino-1.8.1\hardware\arduino\avr/bootloaders/atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex: avrdude: input file C:\Users\THX\Desktop\arduino-1.8.1\hardware\arduino\avr/bootloaders/atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex contains 32652 bytes avrdude: reading on-chip flash data: Reading | ################################################## | 100% 0.00s avrdude: verifying ... avrdude: 32652 bytes of flash verified avrdude: reading input file "0x0F" avrdude: writing lock (1 bytes): Writing | ################################################## | 100% 0.02s avrdude: 1 bytes of lock written avrdude: verifying lock memory against 0x0F: avrdude: load data lock data from input file 0x0F: avrdude: input file 0x0F contains 1 bytes avrdude: reading on-chip lock data: Reading | ################################################## | 100% 0.00s avrdude: verifying ... avrdude: 1 bytes of lock verified avrdude done. Thank you. avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x49 AVR Part : ATmega328P Chip Erase delay : 9000 us PAGEL : PD7 BS2 : PC2 RESET disposition : dedicated 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 20 4 0 no 1024 4 0 3600 3600 0xff 0xff flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00 hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00 efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00 lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00 calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00 signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00 Programmer Type : Arduino Description : Arduino Hardware Version: 2 Firmware Version: 1.16 Vtarget : 0.0 V Varef : 0.0 V Oscillator : Off SCK period : 0.1 us avrdude: AVR device initialized and ready to accept instructions Reading | ################################################## | 100% 0.00s avrdude: Device signature = 0x1e950f (probably m328p) avrdude: reading input file "C:\Users\THX\AppData\Local\Temp\arduino_build_771485/DigitalReadSerial.ino.hex" avrdude: writing flash (2068 bytes): Writing | ################################################## | 100% 0.63s avrdude: 2068 bytes of flash written avrdude: verifying flash memory against C:\Users\THX\AppData\Local\Temp\arduino_build_771485/DigitalReadSerial.ino.hex: avrdude: load data flash data from input file C:\Users\THX\AppData\Local\Temp\arduino_build_771485/DigitalReadSerial.ino.hex: avrdude: input file C:\Users\THX\AppData\Local\Temp\arduino_build_771485/DigitalReadSerial.ino.hex contains 2068 bytes avrdude: reading on-chip flash data: Reading | ################################################## | 100% 0.48s avrdude: verifying ... avrdude: 2068 bytes of flash verified avrdude done. Thank you. I wgrany program działa, ku mojemu zdumieniu działają też inne programy wgrane w ten sposób, aczkolwiek nie sądzę by to było dobre rozwiązanie problemu i może popełniłem jakiś błąd? Dodatkowo żeby ta metoda zadziałała to musi zostać spełniona konfiguracja Płytka: "Arduino Mini or Pro Mini" Procesor: "ATmega328 3.3V 8Mhz" Port COM3 (w moim przypadku) Programator: USBasp Pod piny 11 12 13 oraz RES podpięty odpowiednio USBasp oraz pod TX i RX USB to TTL + zasilanie, inaczej nie przejdzie. Kożystam z Arduino IDE 1.8.1 Już tydzień szukam rozwiązania i brakuje mi pomysłów. Zastanawiam się czy przypadkiem nie uszkodziłem nieodwracalnie układu, ale programy w użyciem TTL działają poprawnie więc sam już nie wiem i proszę o pomoc. |
Autor: | xentis [ 19 maja 2017, o 06:24 ] |
Tytuł: | Re: Atmega3228p nie działa poprawnie po wgraniu bootloadera |
Musisz trochę dokładniej opisać na jakim sprzęcie działasz i jak to masz wszystko podpięte (najlepiej zrób i wrzuć jakieś zdjęcie - tylko tak by było wszystko dobrze widać). Piszesz o procku atmega328p - ale masz sam procek na stykówce czy masz płytkę arduino mini czy arduino pro mini? Do wgrywania "skeczy" w arduino używany jest uart więc programator jest nie potrzebny (potrzebny jest tylko do wgrania bootloadera) Przy podpinaniu przejściówki uart (czyli twojego USB to TTL) musisz pamiętać że podpinać należy na krzyż czyli RX TTL z TX arduino, TX TTL z RX arduino). |
Autor: | proqix [ 20 maja 2017, o 18:39 ] |
Tytuł: | Re: Atmega3228p nie działa poprawnie po wgraniu bootloadera |
Mam Windows 10 i do ISP pobrałem sterowniki z http://www.fischl.de ale nie Arduino IDE nie mogło znaleźć tego urządzenia więc użyłem programu z http://zadig.akeo.ie/ i po zainstalowaniu sterowników WinUSB (v6.1.7600.16385) zaczęło działać. Ten programator z aliexpresu zamówiłem Zgodnie z opisem pinów na ISP, który znalazłem i pinów na atmedze Połączyłem według tego schematu ISP | Atmega MOSI do Pin 11 MISO do Pin 12 SCK do Pin 13 RES do RES GND do GND VCC do VCC na ISP ustawiłem zworkę na 5V Na USB2TTL też ustawiłem zworkę na 5V i podłączyłem RX do TX i TX do RX. Piny są ładnie opisane na obu płytkach więc się nie pomyliłem na pewno Całość wygląda tak Na początku zabawy programy wgrywałem po TTL'u. Teraz jest tak, jak pisałem, do wgrania mszą być podpięte oba. Najpierw kliknąć by wgrał program a później kliknąć wypalanie bootloadera. Inaczej wypluje stk500_getsync() attempt 10 of 10: not in sync: resp=0x49 i że się nie udało wgrać programu. Bo z portu COM3 nic nie odpowiada. Myślałem też, że USB2TTL jest uszkodzony ale podpiąłem do niego GPRS Neoway M590 i gadałem z nim i żadnych problemów nie było. W załączniku jest program, który to wszystko spowodował. Choć nie rozumiem czemu bo testowałem go wcześniej na Arduino Nano i działało to poprawnie. |
Autor: | xentis [ 20 maja 2017, o 20:39 ] |
Tytuł: | Re: Atmega3228p nie działa poprawnie po wgraniu bootloadera |
Twoja przejściówka USB2TTL do tego arduino się nie za bardzo nadaje! Widzisz arduino mini ma jeszcze pin DTR który musi być podłączony do takiego samego pinu w przejściówce USB2TTL. Wejście to jest odpowiedzialne za zresetowanie arduino celem uruchomienia bootloader przed wgraniem programu. Widzisz samo arduino (zarówno to mini które nie posiada wbudowanego portu USB czyli układu USB2TTL, jak i pozostałe które posiadają już na pokładzie zintegrowany układ USB2UART) korzysta z bootloadera do wgrywania skeczy. Sam bootloader (który jest w pewnym sensie programatorem) to program który jest umieszczony w wydzielonej pamięci uC z arduino. Ten bootloader działa tak że po uruchomieniu arduino (czyli po podaniu zasilania lub po resecie) bootloader przez krótką chwilę czeka na dane z UARTA. Jeżeli nic nie nadleci bootloader przekazuje wykonywanie do głównego programu wgranego do arduino i w czasie działania tego programu nie ma jak ponownie uruchomić bootloadera. Gdy piszesz program w Arduino IDE i chcesz go wgrać to po skompilowaniu programu Arduino IDE na pinie DTR wystawia sygnał który powoduje zresetowanie płytki arduino przez co uruchamia się bootloader i następuje komunikacja poprzez USB2TTL. W twoim przypadku brak jest wymuszenia resetu. Jedyne co mogę Ci poradzić to możesz spróbować naciskać przycisk reset na płytce w momencie gdy Arduino IDE próbuje wgrać program do uC zaraz po kompilacji ale musisz to robić umiejętnie - obserwując diody na USB2TTL jak zaczną mrugać sygnalizując przesył danych to już nie możesz nacisnąć resetu bo przerwiesz proces programowania. Ewentualnie jak już masz programator to możesz wgrywać program poprzez opcje z menu szkic -> "Wgraj używając programatora" wtedy program jest wgrywany z pominięciem bootloadera poprzez szynę danych SPI. Albo możesz poszukać przejściówki USB2TTL która będzie posiadać wyprowadzony pin DTR np taką na bogato https://www.sklep.atnel.pl/pl/p/ATB-USB-RS232/85 sam taką posiadam i działa wyśmienicie, w dodatku nasza polska, jak się już upierasz przy chińszczyźnie to szukaj przejściówki z dopiskiem "pro mini" i upewnij się że ma pin DTR. proqix napisał(a): Na początku zabawy programy wgrywałem po TTL'u. W momencie gdy w arduino nie ma żadnego programu tylko bootloader to uda Ci się wgrać program z jednej prostej przyczyny: skoro nie ma programu to bootloader nie może przekazać działania do programu głównego bo go nie ma! Dla tego bootloader jest stale aktywny. Tak więc jak robisz wypal bootloader to cała pamięć uC jest czyszczona i wgrywany jest sam bootloader - stąd udaje się wgrać pierwszy program a następnego już nie. |
Autor: | proqix [ 21 maja 2017, o 13:54 ] |
Tytuł: | Re: Atmega3228p nie działa poprawnie po wgraniu bootloadera |
Dzięki za odpowiedź i wyjaśnienie problemu. |
Strona 1 z 1 | Strefa czasowa: UTC + 1 |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |