ELEKTRO FORUM

Elektroforum
It is currently January 9, 2009, 5:26 pm

All times are UTC





Post new topic Reply to topic  [ 1 posts ] 
Author Message
PostPosted: 2008-02-03 15:14:04
Online
Registered User

Joined: 2008-02-03 15:14:04
Johannes Bauer schrieb:
...
> Ich will zwei Codeteile zusammenpappen, einen, den ich in Assembler
> geschrieben habe und explizit an eine bestimmte Stelle linke (ganz ans
> Ende, "Bootloader"). Dazu dann das "eigentliche"
Programm, das ganz
> gewöhnlich compiliert wird. Zusammengepappt werden die
Codeschnipsel mit
> etwas avr-objcopy und dd.

Mächtig kompliziert und fehlerträchtig.

> An irgendeiner Stelle im Programm will ich nun
> den unteren Teil anspringen, wenn z.B. eine bestimmte Magic-Sequenz
> kommt. Dazu brauche ich das.
>
> Alternativ: Den Bootloadercode in eine eigene Object-Datei compilieren,
> die in eine eigene Section linken und die Position dieser Section
> explizit definieren - geht das?

Ich mache es gerade so. Im assembler-programm wird beim Booten der UART
initialisiert. Kommt binnen X Sekunden kein bestimmtes Zeichen, wird
nach "0000" gesprungen. Das kann man so machen, daÃź man
zweimal 0 auf
den Stack pusht und dann "ret" ausführt.

Assembler code, "flash.S":
-------------------------
#include <avr/io.h>

.section .bootld
.org 0x0
;Set 9600 Bd
ldi r31,((F CPU)/(9600*16)-1)&0xff

... arbeiten ...
;RESET ins Programm
exitloops:
ldi r31,0
ldi r30,0
ijmp
--------------------------
Im Makefile steht u.a.:
ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
ALL ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
ASRC = flash.S ...
OBJ = $(ASRC:.S=.o) $(SRC:.c=.o) ...
%.o : %.S
$(CC) -c $(ALL ASFLAGS) $< -o $@

Linkt sich alles prima zusammen.

Jetzt muÃź ich den eigentlichen Firmware-Updater noch in asm schreiben,
damit ich nicht auf die Initialisierung für C angewiesen bin,
wenn das
Flashen mal danebenging. Das ist leider recht wahrscheinlich...

Falk


Top
 Profile
 
Post new topic Reply to topic  [ 1 posts ] 

Who is online

Users browsing this forum: Ingolf Pohl <ing.olf@web.de>,"Ralf Bellmann" <rabe@bossmail.de>,Georg Sauthoff <g sauthoff@web.de>,w.beck@niehoff.de (Wolfgang Beck),"M.Kiesel" <m.kiesel@iname.com>, 4 guests, Macau quotes Tłumaczenia angielski Choroby gry online


New posts New posts    No new posts No new posts    Announce Announcement
New posts [ Popular ] New posts [ Popular ]    No new posts [ Popular ] No new posts [ Popular ]    Sticky Sticky
New posts [ Locked ] New posts [ Locked ]    No new posts [ Locked ] No new posts [ Locked ]    Moved topic Moved topic
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group