gcc q
Erez D
erez0001 at gmail.com
Mon Aug 23 12:59:39 IDT 2010
On Mon, Aug 23, 2010 at 10:44 AM, Shachar Shemesh <shachar at shemesh.biz>wrote:
> Erez D wrote:
>
>
>
> Is that before or instead of the usual initializations?
>>
> before.
> i just want to run a hardware registers initialization function.
>
>
> Okay. I'm going to assume that you are writing code that is meant to run
> directly on the hardware, no external OS. Also, I'm assuming you have a
> means to actually load that code into the CPU's address space (nor flash,
> loader, etc.)
>
correct
>
> If those assumptions are true, and you are working with a GNU toolchain (or
> derivative), then you, most likely, have a linker control file (also known
> as a "linker script"). If you are not sure, search for an invocation of the
> linker phase with the -T or --script options.
>
nope
i compile with:
avr32-g++ -O0 -g3 -Wall -c -fmessage-length=0 -mpart=uc3l064
-ffunction-sections -masm-addr-pseudos -oDebug\main.o main.cpp
avr32-g++ -O0 -g3 -Wall -c -fmessage-length=0 -mpart=uc3l064
-ffunction-sections -masm-addr-pseudos -oDebug\uart.o uart.cpp
avr32-g++ -mpart=uc3l064 -Wl,--gc-sections -Wl,--direct-data
--rodata-writable -Wl,-Map,Debug\main.map -oDebug\proj3.elf Debug\main.o
Debug\uart.o
This file will explicitly know where to place code so that it is executed
> first thing on startup, and will probably be placing the compiler's startup
> code there. You will need to do two things:
> 1. Supply your hardware initialization code, preferably written in
> assembly, mapped into a custom section.
> 2. Modify the linker script to load that section into the CPU's startup
> point, and only load your compiler's output after it (or elsewhere - details
> depend on your precise hardware).
>
> If your "hardware registers initialization function" is written in C, you
> will need to figure out what your ABI is, and set it up from your assembly
> stub. Also, check your hardware docs to see whether the hardware has any
> guarantees it makes about register values etc., and check whether the
> compiler's startup code relies on those. If so, you might need to make sure
> your stub's exit code does the right thing.
>
> Good luck. Also, there are consultants (ahem) that would be happy to charge
> you in order to work out the details for you.
>
> thanks,
I saw on the internet that i should modify the crt0.S file to call my
initialization function
however i can not find the crt0.S file it uses. probably already compiled.
thanks,
erez.
> Shachar
>
> --
> Shachar Shemesh
> Lingnu Open Source Consulting Ltd.http://www.lingnu.com
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.cs.huji.ac.il/pipermail/linux-il/attachments/20100823/1e084f37/attachment-0001.html>
More information about the Linux-il
mailing list