Upload Sketch su Arduino Mega 2560 da rete o via SD

Buongiorno a tutti!
Ho una decina di Arduino Mega 2560 dislocati in un ambiente produttivo, che rilevano impulsi digitali ed accendono delle lampade di segnalazione. Tutti gli Arduino Mega hanno la Ethernet Shield, e inviano-ricevono dati con dei Pc client(un pc ogni 4 Arduino), attraverso messaggi Socket.
La mia necessità è quella di poter caricare lo sketch da remoto da un singolo pc, attraverso la rete, in modo da poter apportare modifiche al programma da remoto, senza recarmi necessariamente dal cliente.
Ho fatto diverse ricerche in internet, ma in nessun caso si utilizzavano Arduino Mega per lo scopo, ma solo Uno o 2009, con bootloader modificati, e forse per questo motivo sono riuscito a briccare una scheda.

Spero di aver dato tutte le informazioni necessarie per capire la mia esigenza.
Grazie mille

Questo bootloader (che non ho mai usato!) supporta anche la Mega
--> GitHub - codebndr/Ariadne-Bootloader: A little less unfinished TFTP bootloader for Arduino Ethernet or Arduino with Ethernet Shield

Per sloccare la Mega brikkata usa la programmazione ISP. :wink:

Naturalmente ti puoi anche iscrivere a Codebender, link in firma, e flashare le board tramite la rete via Web. :wink:
Codecender a volte è un po skizzinoso con alcuni codici per cui non è possibile compilare e inviate la totalità degli sketch.

Ciao Paolo P. ,
grazie per la risposta, credo che quella indicata da te con Ariadne Bootloader sia la strada giusta.
Sono due giorni però che provo a caricare il bootloader, ma senza risultati.
Anche caricando il bootloader originale, riscontro degli errori.
Per la programmazione dell' Arduino Mega(MEGA2) utilizzo un Arduino Mega con Sketch Arduino ISP(MEGA1), con il seguente collegamento:
-Pin 53 MEGA1 --> Reset MEGA2
-Pin 51 MEGA1 --> Pin 51 MEGA2
-Pin 52 MEGA1 --> Pin 52 MEGA2
-Pin 50 MEGA1 --> Pin 50 MEGA2
-Pin GND MEGA1 --> Pin GND MEGA2
-Pin +5V MEGA1 --> Pin +5V MEGA2

Appena parte, i led TX-RX del MEGA1 cominciano a lampeggiare velocemente, con il LED del pin 13 Fisso, mentre sull'Arduino da programmare, rimane il LED del pin 13 fisso.
Dopo circa 3 minuti e mezzo si fermano e sull'Ide compare il seguente messaggio di errore:

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x1e000
0xff != 0x0d
avrdude: verification error; content mismatch
avrdude: Send: Q [51] [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]

avrdude done. Thank you.

Per la programmazione del bootloader segui la guida di Michele Menniti --> http://michelemenniti.it/arduino_burn_bootloader.php
Pagina 17 e 25.

Nel caso chiedi a lui o spera che passi di qui. :wink:

E' proprio quella che ho seguito!!! :~
Ora provo con la programmazione via Parallela, e se non funzionerà nemmeno quella, sarà un bel problema.

Grazie

Ho riprovato seguendo la Guida del Prof. Menniti, ma nulla. Testato con programmazione da porta parallela con Adattatore Autocostruito come da indicazioni sul sito ufficiale Arduino, ma nulla.

Lascia perdere la programmazione parellela. Usa quella ISP.
Con un WatchDog settato a 30millisecondi hai poco spazio di manovra per la programmazione.
--> Problemi con watchdog: impossibile caricare nuovi sketch - Generale - Arduino Forum

Ciao,
l'unica cosa che riesco a dirti al volo, poi ci sentiamo con calma in serata, se non risolvi, è sul messaggio d'errore:

0xff != 0x0d

Nella board che hai selezionato al momenti di caricare il bootloader dovresti trovare l'extended fuse settato a ff o 0d, cambialo con l'altro valore e vedi cosa succede.
Scusa ma in questo momento non faccio in tempo a leggere il Topic. Più tardi riuscirò e leggere l'esito di questa prova.
Confermo il consiglio di lasciar perdere altri tipi di programmazione, arriviamo prima a fare tutte le prove ISP :slight_smile:

Grazie per la risposta velocissima :slight_smile:
Ho provato a scrivere l' efuse, ma in entrambi i casi il caricamento del bootloader è fallito
Scrittura efuse FF

c:\Program Files (x86)\Arduino\hardware\tools\avr\bin>avrdude.exe -CC:\avrdude.c
onf -patmega2560 -cstk500v1 -P\\.\COM8 -b19200 -Uefuse:w:0xFF:m

avrdude.exe: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.06s

avrdude.exe: Device signature = 0x1e9801
avrdude.exe: reading input file "0xFF"
avrdude.exe: writing efuse (1 bytes):

Writing | ################################################## | 100% 0.06s

avrdude.exe: 1 bytes of efuse written
avrdude.exe: verifying efuse memory against 0xFF:
avrdude.exe: load data efuse data from input file 0xFF:
avrdude.exe: input file 0xFF contains 1 bytes
avrdude.exe: reading on-chip efuse data:

Reading | ################################################## | 100% 0.01s

avrdude.exe: verifying ...
avrdude.exe: 1 bytes of efuse verified

avrdude.exe: safemode: Fuses OK

avrdude.exe done.  Thank you.

Prova Scrittura Bootloader

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x1e000
         0xff != 0x8e
avrdude: verification error; content mismatch
avrdude: Send: Q [51]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [10] 

avrdude done.  Thank you.

Scrittura efuse 0D

c:\Program Files (x86)\Arduino\hardware\tools\avr\bin>avrdude.exe -CC:\avrdude.c
onf -patmega2560 -cstk500v1 -P\\.\COM8 -b19200 -Uefuse:w:0x0d:m

avrdude.exe: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.07s

avrdude.exe: Device signature = 0x1e9801
avrdude.exe: reading input file "0x0d"
avrdude.exe: writing efuse (1 bytes):

Writing |                                                    | 0% 0.00s ***faile
d;
Writing | ################################################## | 100% 0.16s

avrdude.exe: 1 bytes of efuse written
avrdude.exe: verifying efuse memory against 0x0d:
avrdude.exe: load data efuse data from input file 0x0d:
avrdude.exe: input file 0x0d contains 1 bytes
avrdude.exe: reading on-chip efuse data:

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

avrdude.exe: verifying ...
avrdude.exe: verification error, first mismatch at byte 0x0000
             0x0d != 0xfd
avrdude.exe: verification error; content mismatch

avrdude.exe: safemode: efuse changed! Was d, and is now fd
Would you like this fuse to be changed back? [y/n] n
avrdude.exe: safemode: Fuses OK

avrdude.exe done.  Thank you.

Prova Scrittura Bootloader

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x1e000
         0xff != 0x8e
avrdude: verification error; content mismatch
avrdude: Send: Q [51]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [10] 

avrdude done.  Thank you.

Ora se provo a caricare uno sketch qualsiasi non riesco e va in errore

avrdude: Version 5.11, compiled on Sep  2 2011 at 19:38:36
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\Arduino\hardware/tools/avr/etc/avrdude.conf"

         Using Port                    : \\.\COM9
         Using Programmer              : stk500v2
         Overriding Baud Rate          : 115200
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14] 
avrdude: Recv: 
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14] 
avrdude: Recv: 
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14] 
avrdude: Recv: 
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14] 
avrdude: Recv: 
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14] 
avrdude: Recv: 
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14] 
avrdude: Recv: 
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
         AVR Part                      : ATMEGA2560
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         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    10     8    0 no       4096    8      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           flash         65    10   256    0 yes    262144  256   1024  4500  4500 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : STK500V2
         Description     : Atmel STK500 Version 2.x firmware
         Programmer Model: Unknown
avrdude: Send: . [1b] . [01] . [00] . [02] . [0e] . [03] . [90] . [85] 
avrdude: Recv: 
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14]

Figurati :slight_smile:
quindi stai usando AVRDUDE.....A me pare che non stia scrivendo nemmeno i fuse, visto che escono failed di qua e di là.
Ho letto ora tutto il Topic, se il micro è bricked non c'è niente da fare, è possibile applicare solo la programmazione HV, ma nel caso di quel micro è un lavoro da squilibrati, in quando dovresti dissaldarlo dalla mega, risaldarlo su una scheda appositamente creata per la programmaziome HV, quindi la domanda di conferma è:
una delle due schede non funziona più correttamente con l'IDE? Perché ritieni di averla brickata, hai fatto in precedenza prove ISP con fuse sballati?

Ho usato AVRDUDE solo per provare a scrivere i fuse (non sapendo come fare altrimenti).
La scrittura del efuse a FF va a buon fine, ma non quella a 0D.
Se adesso provo a scrivere il bootloader originale , quando termina in errore(byte 0x1e000 0xff != 0x0d), ho il led del pin 13 che lampeggia a intermittenza.
Nonostante questo errore, se lo collego via usb e invio lo sketch del blink, lo upload e funziona( per essere sicuro ho impostato il blink a 100 ms invece di 1000).

Quindi in teoria non dovrebbe essere brikkato.

Il tutto è nato quando ho provato a caricare il bootloader Adriadne.

$0D può non essere accettato perché passi al chip il valore di fuse che non esistono. Secondo il sito Fuse Calculator:
http://www.engbedded.com/fusecalc

con $0D potresti avere problemi, prova con $05.

Sì, è come dice Leo, allora puoi provare 0x05 o 0x07, tanto incidono solo sul BOD level.
Però il blink come prova non è idoneo, quel cavolo di LED lampeggia per la qualsiasi; impostalo su un pin diverso e aggiungi una R + led al volo, oppure carica uno sketch che mostri qualcosa sul serial monitor, insomma una prova più seria, ok?
Se risponde all'IDE non c'è ragione per la quale non funzioni l'ISP....

Provato a cambiare i fuse:

Fuse-->05:

c:\Program Files (x86)\Arduino\hardware\tools\avr\bin>avrdude.exe -CC:\avrdude.c
onf -patmega2560 -cstk500v1 -P\\.\COM8 -b19200 -Uefuse:w:0x05:m

avrdude.exe: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.07s

avrdude.exe: Device signature = 0x1e9801
avrdude.exe: reading input file "0x05"
avrdude.exe: writing efuse (1 bytes):

Writing |                                                    | 0% 0.00s ***faile
d;
Writing | ################################################## | 100% 0.16s

avrdude.exe: 1 bytes of efuse written
avrdude.exe: verifying efuse memory against 0x05:
avrdude.exe: load data efuse data from input file 0x05:
avrdude.exe: input file 0x05 contains 1 bytes
avrdude.exe: reading on-chip efuse data:

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

avrdude.exe: verifying ...
avrdude.exe: verification error, first mismatch at byte 0x0000
             0x05 != 0xfd
avrdude.exe: verification error; content mismatch

avrdude.exe: safemode: efuse changed! Was 5, and is now fd
Would you like this fuse to be changed back? [y/n] n
avrdude.exe: safemode: Fuses OK

avrdude.exe done.  Thank you.

Provato a caricare Bootloader:

avrdude: Recv: . [10] 
# | 100% 170.56s

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x1e000
         0xff != 0x8e
avrdude: verification error; content mismatch
avrdude: Send: Q [51]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [10] 

avrdude done.  Thank you.

Fuse -->07

avrdude: Recv: . [10] 
# | 100% 170.56s

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x1e000
         0xff != 0x8e
avrdude: verification error; content mismatch
avrdude: Send: Q [51]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [10] 

avrdude done.  Thank you.

Caricamento Bootloader:

# | 100% 170.10s

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x1e000
         0xff != 0x8e
avrdude: verification error; content mismatch
avrdude: Send: Q [51]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [10] 

avrdude done.  Thank you.

Fatte queste prove caricato sketch che scrive su Seriale -->la scheda funziona e sul monitor seriale leggo ciò che scrivo.

E' proprio un comportamento strano, che IDE stai usando?

L'ultima versione stabile-->1.0.5

Non riesce a riprogrammare fuse e bootloader ma quello che c'è carica gli sketch correttamente? :roll_eyes:

Se provo a mettere il fuse -->FF

c:\Program Files (x86)\Arduino\hardware\tools\avr\bin>avrdude.exe -CC:\avrdude.c
onf -patmega2560 -cstk500v1 -P\\.\COM8 -b19200 -Uefuse:w:0xFF:m

avrdude.exe: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.06s

avrdude.exe: Device signature = 0x1e9801
avrdude.exe: reading input file "0xFF"
avrdude.exe: writing efuse (1 bytes):

Writing | ################################################## | 100% 0.06s

avrdude.exe: 1 bytes of efuse written
avrdude.exe: verifying efuse memory against 0xFF:
avrdude.exe: load data efuse data from input file 0xFF:
avrdude.exe: input file 0xFF contains 1 bytes
avrdude.exe: reading on-chip efuse data:

Reading | ################################################## | 100% 0.01s

avrdude.exe: verifying ...
avrdude.exe: 1 bytes of efuse verified

avrdude.exe: safemode: Fuses OK

avrdude.exe done.  Thank you.

Così non sembra vada in errore, però poi andato a caricare il bootloader, ricevo ancora errori.

Ne stò uscendo pazzo :cold_sweat: :cold_sweat:

ambro7:
Il tutto è nato quando ho provato a caricare il bootloader Adriadne.

La board per caricare il bootloade di Codebender è questa:

##############################################################

ariadne2560M.name=Arduino Mega 2560 (Ariadne Bootloader)

ariadne2560M.upload.protocol=stk500v2
ariadne2560M.upload.maximum_size=258048
ariadne2560M.upload.speed=115200

ariadne2560M.bootloader.low_fuses=0xFF
ariadne2560M.bootloader.high_fuses=0xD8
ariadne2560M.bootloader.extended_fuses=0xFD
ariadne2560M.bootloader.path=ariadne
ariadne2560M.bootloader.file=ariadne_atmega2560.hex
ariadne2560M.bootloader.unlock_bits=0x3F
ariadne2560M.bootloader.lock_bits=0x0F

ariadne2560M.build.mcu=atmega2560
ariadne2560M.build.f_cpu=16000000L
ariadne2560M.build.core=arduino:arduino
ariadne2560M.build.variant=arduino:mega

##############################################################

I fuse sono: FF D8 FD
SPI enable
Boot Size 0
Boot Size 1
Boot Reset
BoD level 1

--> -U lfuse:w:0xff:m -U hfuse:w:0xd8:m -U efuse:w:0xfd:m

Trovi il file board.txt completo qui --> https://github.com/codebendercc/Ariadne-Bootloader/tree/mega/hardware/ariadne

ma i fuse sono identici alla board originale!!!
Fai una cosa, con avrdude leggi tutti e tre i fuse e cerchiamo di capire cosa dobbiamo sistemare, certamente l'extended che è FD e non FF, ma vediamo gli altri due