[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-libc-dev] rjmp across FLASHEND
From: |
Bernhard Kuemel |
Subject: |
Re: [avr-libc-dev] rjmp across FLASHEND |
Date: |
Fri, 07 Oct 2011 12:08:29 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.16) Gecko/20110818 Icedove/3.0.11 |
On 10/07/2011 11:42 AM, Joerg Wunsch wrote:
>> Should the odd case happen, that the application starts beyond the
>> range of rjmp I have to use jmp in the loader. This makes the loader
>> bigger by one word and the reset rjmp changes by one word. So I have 2
>> different rjmps which I have to consider as sync word. I want to
>> minimize the number of sync words to make syncing most reliable.
>
> OK, I see.
>
> The following should be possible to work around the situation:
>
> #include <avr/io.h>
>
> .global main
> main:
> rjmp beyond_vectors
> nop
> /* vectors follow */
> jmp foo
> jmp foo
>
> foo: rjmp foo
>
> beyond_vectors:
> jmp tinyloader
>
>
> .org FLASHEND+1-0x3e
> tinyloader:
> rjmp tinyloader
That's not really an option, because the application code is usually
located at beyond_vectors.
> Btw., .org is a "DONT" in a relocation assembler. Already during the
> days of the venerable Z80, this was avoided. The correct way would be
> to establish a separate section, and then assign the section start
> address to the linker either within the linker script, or from the
> linker commandline.
Hmm, this is my first asm project and I had never used .org or sections
before. I did it with a section, too, but I want to the bootloader as
userfriendly as possible. Is there a good way to get the bootloader
section start address to the linker script or linker command line
automatically? One way I see would be to extract the size of the
bootloader section (it varies by one word, depending on whether jmp or
rjmp is used in it) form the *.lst file, e.g. with perl, calculate the
section start address so that it ends at flashend and call the linker
with the appropriate command line. I don't like this, though. So I used
.org:
.if FLASHEND+1>8*1024
.warning "jmp"
.org FLASHEND+1-0x3e
.else
.warning "rjmp"
.org FLASHEND+1-0x3c
.endif
Easy, simple, automatic. The section variant would have the advantage,
though, that it doesn't program all the unused space skipped by .org
into the uC. Not a big deal, though, because it happens only once when
installing the bootloader.
What's wrong with my usage of .org, btw?
Bernhard