Forum: Mikrocontroller und Digitale Elektronik CAN-Bootloader Arduino


von PeterP (Gast)


Lesenswert?

Hallo,

ich möchte meinen Arduino Nano mit angeflanschtem MCP2515 Modul ganz 
gerne über den CAN-Bus flashen.
Mit einem USBtin (fischl.de) mit Hilfe von SocketCAN kommuniziert der 
Arduino mit einem Linux-PC über Shellbefehle 
(http://www.fischl.de/usbtin/linux_can_socketcan/).

Bei der Suche im Web bin Ich auf ein interessantes Projekt gestossen 
(http://www.kreatives-chaos.com/artikel/can-bootloader).
Dort wird zum Upload aber Python benutzt und ein USB2CAN Interface.
Kenne mich nicht wirklich aus mit Python und suche eine Möglichkeit die 
Firmware mit dem USBtin und SocketCAN zu bewerkstelligen.

Wäre für jede Hilfe sehr dankbar.

von PeterP (Gast)


Lesenswert?

Sorry, hatte mich am Ende meines Beitrages verschrieben. Nochmal:

Suche eine Möglichkeit das Firmwareupdate des Arduino Nano mit 
CAN-Bootloader mit dem USBtin und SocketCAN zu bewerkstelligen.

von PeterP (Gast)


Lesenswert?

OK, habe mir das ganze nochmal genauer angeschaut und hatte überlesen, 
das oben genannter Bootloader ATMega8/88/168, ATMega16/32 und ATMega644 
unterstützt.
Stellt sich also erstmal die Frage, ob und wie Ich was ändern muss, um 
diesen Bootloader auf einen ATmega328, wie er im Arduino Nano verbaut 
ist, zum laufen zu bekommen. Und wie Ich die Fuses setzen muss.
Wäre klasse, wenn mir jemand dazu Hilfestellung/Anregungen geben kann.

von public (Gast)


Lesenswert?

ATMega328 ist das nicht der ATMega8 mit erweitertem Speicher, oder gibt 
es da noch ne Änderung?

Ich schätze wir können auch bloß im Datenblatt lesen. Also vorkauen will 
dir hier keiner was, zumal es ja diese tollen Tutorials gibt ;)

Andernfalls würde ich sagen flash das ding einfach drauf, dat teil geht 
schon nicht kaputt :D

beste grüße
public

von PeterP (Gast)


Lesenswert?

Danke , habe Ich schon gemacht. Den Bootloader flashen funktioniert ohne 
weiteres durch leichte Anpassungen im Makefile.

Bleibt noch das Problem, das Pythonscript anzupassen, so daß es mit dem 
USBtin läuft.
Mir soll hier auch keiner was vorkauen, muß mich dann wohl selber etwas 
in Python reinlesen.

von PeterP (Gast)


Lesenswert?

Der 328p und das MCP2515 Board sind mit 16MHz getaktet.
CAN-Bus Speed 125 Kbps.

Ein flashen ist leider nicht erfolgreich:

./bootloader.py -i 0xfd  -f Blink.hex -p /dev/ttyACM0
CAN Bootloader

Port      : /dev/ttyACM0
Board Id  : 253 (0xfd)
File      : test.hex
Size      : 1030 Bytes
Interface : CAN2USB

connecting ...  Warning: Wrong message number detected (board says 5, I 
have 0)
ok
board id 0xfd (T0) v2.0, 224 pages [128 Byte]
write 9 pages

Warning: Wrong message number detected (board says 9, I have 26)
Warning: Wrong message number detected (board says a, I have 26)
Exception: No response after 2 attempts and timeout 0 while sending 
'DATA.request id 0xfd [26] 0 > 01 02 04 08'
16
Warning: Wrong message number detected (board says a, I have 26)
Warning: Wrong message number detected (board says a, I have 26)
Exception: No response after 2 attempts and timeout 0 while sending 
'SET_ADDRESS.request id 0xfd [26] 128 > 00 00 00 00'
8
Warning: Wrong message number detected (board says a, I have 26)
Warning: Wrong message number detected (board says a, I have 26)
Exception: No response after 2 attempts and timeout 0 while sending 
'SET_ADDRESS.request id 0xfd [26] 128 > 00 00 00 00'
4
Warning: Wrong message number detected (board says a, I have 26)
Warning: Wrong message number detected (board says a, I have 26)
Exception: No response after 2 attempts and timeout 0 while sending 
'SET_ADDRESS.request id 0xfd [26] 128 > 00 00 00 00'
2
Warning: Wrong message number detected (board says a, I have 26)
Warning: Wrong message number detected (board says a, I have 26)
Exception: No response after 2 attempts and timeout 0 while sending 
'SET_ADDRESS.request id 0xfd [26] 128 > 00 00 00 00'
1
Warning: Wrong message number detected (board says a, I have 26)
Warning: Wrong message number detected (board says a, I have 26)
Exception: No response after 2 attempts and timeout 0 while sending 
'SET_ADDRESS.request id 0xfd [26] 128 > 00 00 00 00'
Error: No response after 2 attempts and timeout 0 while sending 
'SET_ADDRESS.request id 0xfd [26] 128 > 00 00 00 00'



Hat jemand eine Idee?

von PeterP (Gast)


Lesenswert?

Anscheinend ist das Interesse nicht so groß hier, aber für die, die es 
interessiert:
Ein time.sleep(.001) in der SerialInterface class (can.py) hat das 
Problem der verschluckten Messages gelöst.

Danke an F.Greif für die gute Arbeit

von Christian G. (Firma: privat) (dotti)


Lesenswert?

Habe hier ein ähnliches Problem. Ich benutze den Greifschen 
CAN-Debugger, um einen CAN-Node zu flashen. Output des bootloader.py 
zeigt immerhin Progress, bricht dann aber bei zu langen Dateien 
irgendwann ab (immer unterschiedlich, wie weit er kommt - hier etwa nach 
1kB).

$ python bootloader.py -i 0xff -p /dev/ttyUSB0 -f /tmp/CAN_node_v1.hex 
-d

CAN Bootloader

Port      : /dev/ttyUSB0
Board Id  : 255 (0xff)
debug mode active!
File      : /tmp/CAN_node_v1.hex
Size      : 1930 Bytes
Interface : CAN2USB

connecting ...  < id: 18ffff01 dlc: 0 >
< id:      7ff dlc: 4 > ff 01 00 80
< id:      7ff dlc: 4 > ff 01 00 80
< id:      7ff dlc: 4 > ff 01 00 80
< id:      7ff dlc: 4 > ff 01 00 80
< id:      7ff dlc: 4 > ff 01 00 80
< id: 18ffff01 dlc: 0 >
< id:      7ff dlc: 4 > ff 01 00 80
< id:      7ff dlc: 4 > ff 01 00 80
> id:      7fe dlc: 8 > ff 41 00 80 02 02 00 e0
ok
board id 0xff (T0) v2.0, 224 pages [128 Byte]
write 16 pages

< id:      7ff dlc: 8 > ff 02 01 80 00 00 00 00
> id:      7fe dlc: 8 > ff 42 01 80 00 00 00 00
< id:      7ff dlc: 8 > ff 03 02 9f 0c 94 34 00
< id:      7ff dlc: 8 > ff 03 03 1e 0c 94 51 00
< id:      7ff dlc: 8 > ff 03 04 1d 0c 94 51 00
< id:      7ff dlc: 8 > ff 03 05 1c 0c 94 51 00


[...]


< id:      7ff dlc: 8 > ff 03 3f 02 8f ef 8e bd
< id:      7ff dlc: 8 > ff 03 40 01 95 e0 22 0f
< id:      7ff dlc: 8 > ff 03 41 00 33 1f 9a 95
< id:      7ff dlc: 8 > ff 03 41 00 33 1f 9a 95
Exception: No response after 2 attempts and timeout 0 while sending 
'DATA.request id 0xff [41] 0 > 33 1f 9a 95'
16
< id:      7ff dlc: 8 > ff 02 41 80 00 09 00 00
< id:      7ff dlc: 8 > ff 02 41 80 00 09 00 00
Exception: No response after 2 attempts and timeout 0 while sending 
'SET_ADDRESS.request id 0xff [41] 128 > 00 09 00 00'
8
< id:      7ff dlc: 8 > ff 02 41 80 00 09 00 00
< id:      7ff dlc: 8 > ff 02 41 80 00 09 00 00
Exception: No response after 2 attempts and timeout 0 while sending 
'SET_ADDRESS.request id 0xff [41] 128 > 00 09 00 00'
4
< id:      7ff dlc: 8 > ff 02 41 80 00 09 00 00
< id:      7ff dlc: 8 > ff 02 41 80 00 09 00 00
Exception: No response after 2 attempts and timeout 0 while sending 
'SET_ADDRESS.request id 0xff [41] 128 > 00 09 00 00'
2
< id:      7ff dlc: 8 > ff 02 41 80 00 09 00 00
< id:      7ff dlc: 8 > ff 02 41 80 00 09 00 00
Abort!


Kleineres Programm flashen (togglende LED) ging ohne Abbrüche 
erfolgreich.
Vielleicht könnte hier ein time.sleep(.001) wie bei dir helfen. Wo hast 
du es denn genau hingebaut?

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.