<div dir="ltr"><br><br><div class="gmail_quote">On Mon, Aug 23, 2010 at 10:44 AM, Shachar Shemesh <span dir="ltr"><<a href="mailto:shachar@shemesh.biz">shachar@shemesh.biz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div dir="ltr" bgcolor="#ffffff" text="#000000">
Erez D wrote:
<blockquote type="cite">
<div dir="ltr"><br>
<br>
<div class="gmail_quote"><div class="im">
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div dir="ltr" bgcolor="#ffffff" text="#000000">Is that before or
instead of the usual initializations?<br>
</div>
</blockquote>
<div>before. <br>
</div>
</div><div class="im"><div>i just want to run a hardware registers initialization function.<br>
</div>
</div></div>
</div>
</blockquote>
<br>
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.)<br></div></blockquote><div>correct <br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div dir="ltr" bgcolor="#ffffff" text="#000000">
<br>
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. </div></blockquote><div>nope<br><br>i compile with:<br>avr32-g++ -O0 -g3 -Wall -c -fmessage-length=0 -mpart=uc3l064 -ffunction-sections -masm-addr-pseudos -oDebug\main.o main.cpp<br>
avr32-g++ -O0 -g3 -Wall -c -fmessage-length=0 -mpart=uc3l064 -ffunction-sections -masm-addr-pseudos -oDebug\uart.o uart.cpp<br>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 <br>
<br><br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div dir="ltr" bgcolor="#ffffff" text="#000000">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:<br>
1. Supply your hardware initialization code, preferably written in
assembly, mapped into a custom section.<br>
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).<br>
<br>
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.<br>
<br>
Good luck. Also, there are consultants (ahem) that would be happy to
charge you in order to work out the details for you.<div class="im"><br></div></div></blockquote><div>thanks,<br><br>I saw on the internet that i should modify the crt0.S file to call my initialization function<br>however i can not find the crt0.S file it uses. probably already compiled. <br>
</div><div><br>thanks,<br>erez. <br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div dir="ltr" bgcolor="#ffffff" text="#000000"><div class="im">
Shachar<br>
<pre cols="72">--
Shachar Shemesh
Lingnu Open Source Consulting Ltd.
<a href="http://www.lingnu.com" target="_blank">http://www.lingnu.com</a>
</pre>
</div></div>
</blockquote></div><br></div>