Hi!
Ich versuche gerade einen Bootloader... Aber Es funktioniert nicht! Hab
alles bis aufs Grundgerüst runtergebrochen! der inhnat des bin.-files,
das letztendlich geflasht werden soll steht im Array test[] . Ist der
Bootloader fertig mit schreiben und startet er immer wieder neu, obwohl
er ja zum Application-Teil also Adresse 0 springen soll. hat jemand ne
Ahnung?
Lineroptions :+= -Wl,-section-start=.text=0x7000
Fuses: bootloadersize auf 4096
bootrst ist auf 0 (häkchen in avrstudion)
Wenn dein HAuptprogramm ISRs enthält würde ich Dir vorshclagen, dass Du
das IVSEL Bit im MCUCR setzen/löschen (siehe Datenblatt).
Wenn man die Reset-Fuse setzt (start im Bootloader, dann werden auch die
IRQ VEktoren umgebogen auf den Bootloaderbereich!9 Das muss man dann
wieder
selber hinbiegen, bevor man die Applikation startet...
probier mal das für den Sprung in die Applikation
void (* start_application) (void); // Definition Variable als
Funktionszeiger
start_application = 0x0000; // Adresse fuer Einsprung
start_application(); // und aufrufen
..nur der Vollständigkeit halber: Was ∗genau∗ soll das..
> MCUSR= 0;
erreichen? (JTAG aktivieren? IVSEL auf 0 setzen funktioniert so nicht!)
Normalerweise(tm) lässt man sich für einen sauberen Reset vom Watchdog
beissen, dabei werden auch die Port-Konfiguartionen/.. auf die
Standardwerte gesetzt, nicht potentiell auf einen Mischmasch.
Und noch was:
Florian H. schrieb:> Lineroptions :+= -Wl,-section-start=.text=0x7000
--------------------------------------------^^^^^^
Adressen beim avr-gcc sind *Byte*adressen. Ich nehme mal an, dass
deshalb 0xf000 gemeint ist (außer Dein Bootloader belegt mehr als die
Hälfte des Flash).
Hi so hab das mit IVSEL ausprobiert. Laut Datenblatt:
>to change the IVSEL bit:>a. Write the Interrupt Vector Change Enable (IVCE) bit to one.>b. Within four cycles, write the desired value to IVSEL while writing a >zero to
IVCE.
also Funktion zum Jumpen ist nun:
1
void(*start_application)(void);
2
voidapp_start(void)
3
{
4
start_application=0x0000;
5
MCUCR|=(1<<IVCE);
6
asmvolatile("nop");
7
asmvolatile("nop");
8
asmvolatile("nop");
9
asmvolatile("nop");
10
MCUCR&=~(1<<IVSEL);
11
//asm volatile("jmp 0x0000");
12
start_application();
13
}
@ Natthias: hab es mit
1
asmvolatile("jmp 0x0000");
und
1
start_application();
wie du gemaint hast probiert! keine Änderung
Fazit: Selbes Verhalten wie vorher!
Gruß Flo
@Hc Zimmerer
Das ist mir auch schon aufgefallen. Eigentlich dürfte der Bootloader gar
nicht starten. Florian H. schreibt aber, dass der Bootloader sehr wohl
losläuft, er kommt nur nicht in die Application Section.
Florian H. schrieb:>>to change the IVSEL bit:>>a. Write the Interrupt Vector Change Enable (IVCE) bit to one.>>b. Within four cycles, write the desired value to IVSEL while writing a >zero to> IVCE.>> also Funktion zum Jumpen ist nun:void (* start_application) (void);
1
>voidapp_start(void)
2
>{
3
>start_application=0x0000;
4
>MCUCR|=(1<<IVCE);
5
>asmvolatile("nop");
6
>asmvolatile("nop");
7
>asmvolatile("nop");
8
>asmvolatile("nop");
9
>MCUCR&=~(1<<IVSEL);
Das ist genau falsch herum verstanden. Lies Dir b) nochmal durch. Du
musst nicht 4 Zyklen warten, sondern innerhalb von 4 Zyklen schreiben.
Übrigens: die Byte-Entsprechung zur Wortadresse 0x7000 ist 0xE000 (um
meinen Flüchtigkeitsfehler zu korrigieren).