Programmare file .hex, mission impossible............

E rieccomi ancora a chiedere qualche dritta.
Dopo giorni giorni e giorni di prove senza risultati soddisfacenti, ma solo con qualche piccolo segno di avanzamento, sono arrivato ancora qui per vedere se riesco ad uscire da questa situazione ingarbugliata.
Il discorso è questo, dovrei scrivere un file in formato .hex dentro ad un atmega328.
Dopo aver provato svariate combinazioni, sono approdato a questo link: http://www.gioblu.com/tutorials/programmazione/216-usare-larduino-uno-come-programmatore-isp e seguendo questa guida, sono riuscito a scrivere il bootloader su un atmega vergine.

Quindi fin qui sono arrivato, ora stavo tentando di scrivere questo benedetto file .hex tramite avrdude.
Per la documentazione ho seguito questo sito: AVRDUDE: 2.2 Programmers accepting extended parameters

E alla fine ho provato con questo comando:

avrdude -c arduino -p m328p -P /dev/ttyACM0 -b 115200 -U flash:w:/home/stefano/Scrivania/servo2ppm_v4_3_for_release/servo2ppm_v4_3_16Mhz/ppm_encoder_v4_3.hex

Ovviamente il valore del parametro -c l'ho cambiato con tutti i valori che mi sembravano più congrui alla situazione.
Le risposte di avrdude sono variabili in base al tipo di parametro usato e sono:

stk500_getsync(): not in sync: resp=0xe0
avrdude: stk500_2_ReceiveMessage(): timeout
avrdude: stk500_recv(): programmer is not responding

Insomma, non riesco a venire fuori da questa situazione disperata che mi sta tenendo bloccato tutto un progetto abbastanza importante :frowning:

Mi sembra impossibile che nessuno in questo forum abbia avuto la necessità di scrivere su un atmega un file .hex senza dover passare obbligatoriamente per l'IDE :frowning:
Helpppppppppppp!!!
Grazie.
Ciao.

prova con:
tieni premuto il tasto reset, lascialo e subito dipo lancia il comando:
avrdude -F -v -p m328p -cstk500v1 -P /dev/ttyACM0 -b 115200 -D -U flash:w:"file.hex":i

:astonished:
Qualcosa di diverso l'ha fatto, ora devo preparare il circuito sulla breadboard per vedere se effettivamente il programma gira a dovere.

avrdude -F -v -p m328p -cstk500v1 -P /dev/ttyACM0 -b 115200 -D -U flash:w:/home/stefano/Scrivania/servo2ppm_v4_3_for_release/servo2ppm_v4_3_16Mhz/ppm_encoder_v4_3.hex:i 

avrdude: Version 5.10, compiled on Jun 29 2010 at 21:09:48
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/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/ttyACM0
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 115200
         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     5     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 : STK500
         Description     : Atmel STK500 Version 1.x firmware
         Hardware Version: 3
         Firmware Version: 3.3
         Vtarget         : 0.3 V
         Varef           : 0.3 V
         Oscillator      : 28.800 kHz
         SCK period      : 3.3 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.03s

avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.
avrdude: Expected signature for ATMEGA328P is 1E 95 0F
avrdude: safemode: lfuse reads as 0
avrdude: safemode: hfuse reads as 0
avrdude: safemode: efuse reads as 0
avrdude: reading input file "/home/stefano/Scrivania/servo2ppm_v4_3_for_release/servo2ppm_v4_3_16Mhz/ppm_encoder_v4_3.hex"
avrdude: writing flash (3252 bytes):

Writing | ################################################## | 100% 0.88s

avrdude: 3252 bytes of flash written
avrdude: verifying flash memory against /home/stefano/Scrivania/servo2ppm_v4_3_for_release/servo2ppm_v4_3_16Mhz/ppm_encoder_v4_3.hex:
avrdude: load data flash data from input file /home/stefano/Scrivania/servo2ppm_v4_3_for_release/servo2ppm_v4_3_16Mhz/ppm_encoder_v4_3.hex:
avrdude: input file /home/stefano/Scrivania/servo2ppm_v4_3_for_release/servo2ppm_v4_3_16Mhz/ppm_encoder_v4_3.hex contains 3252 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.79s

avrdude: verifying ...
avrdude: 3252 bytes of flash verified

avrdude: safemode: lfuse reads as 0
avrdude: safemode: hfuse reads as 0
avrdude: safemode: efuse reads as 0
avrdude: safemode: Fuses OK

avrdude done.  Thank you.

Speriamo bene :slight_smile:
Grazie.

Domanda.............
ma se piuttosto di preparare il circuito sulla breadboard, inserisco quell'atmega sullo zoccolo del mio arduino uno, non dovrei riuscire lo stesso a testare il tutto?
Tanto a me non interessa dialogare tramite usb, devo solo collegarmi alle varie porte per vedere se il programma mi risponde correttamente e la scheda arduino uno dovrebbe anche in mancanza di bootloader alimentarmi correttamente l'atmega.
Sto dicendo una fesseria?

dovrebbe funzionare, salvo che il chip di bordo usb/seriale non sfasi

Ci provo.
Grazie.