avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Modifying compiler output to suit Tiny13 bootloader


From: David Carr
Subject: Re: [avr-gcc-list] Modifying compiler output to suit Tiny13 bootloader
Date: Sun, 25 Oct 2009 18:45:36 -0400
User-agent: Thunderbird 2.0.0.23 (X11/20090817)

Hope everyone is enjoying this thread as much as I am ;)

For posterity and confirmation of my understanding:

It looks like the rjmp at address 0 is generated by the file /usr/avr/lib/crttnXX.o. This file seems to be generated during the avr-libc build process from a file called gcrt1.S in the avr-libc distribution. To override this behavior it seems that I'd have to make a custom start up assembly file and use it for my bootloader-C projects. That sounds messy.

After perusing this page [http://www.nongnu.org/avr-libc/user-manual/mem_sections.html], it appears that a better solution might be to override the weak .init0/__init() section. The new .init0/__init() would rjmp to my bootloader. My bootloader could then rjmp back to .init1 or .init2 so long as those were placed at a fixed location. Linker script to do that?

Lastly, the avr-libc startup code seems to zero r1, zero the status register, and load the stack pointer. I'm not sure if there are any other pieces of state I should be concerned about.

-DC

David Carr wrote:
Hi all,

I've been writing a bootloader for the Tiny13 for the past few days. At this point, the bootloader can download, program, and execute simple programs written in assembly. Now I'd like to add support for programs compiled with avr-gcc.

I wrote a very simple C program and looked at the assembly output produced by avr-gcc. The first line is:

00000000 <__vectors>:
  0:   10 c0           rjmp    .+32            ; 0x22 <__ctors_end>

My bootloader lives in the last 192 bytes of flash, so I'd like to replace this instruction (at address 0) with an rjmp to that location. Where/how does this line get generated? I assume its deep in the architecture specific start up code somewhere.

Secondly, what assumptions does the compiler make about the state of the machine/registers on boot? It seems there is some initialization going on in the __ctors_end section, such as zeroing r1.

Lastly, where do the linker scripts live now?
The avr-libc webpage mentions /usr/avr/lib, but I only have a bunch files ending in .o there. No files ending in .x. Am I doing something silly?

I really appreciate any help you can give me. Understanding the internals of gcc is a formidable challenge for me.
-David Carr


_______________________________________________
AVR-GCC-list mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list





reply via email to

[Prev in Thread] Current Thread [Next in Thread]