UPGRADE YOUR BROWSER
We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!
03-10-2009 03:28 AM
Hello everyone!
I am trying to call a C function writen by me before the main program is called and executed in a Microblaze system. I found the main function call in crtinit.s (Default C run-time initialization for MicroBlaze) file "brlid r15, main" and just inserted my function call before it "brlid r15, myfunction", so it looks like this
brlid r15, myfunction /* call myfunction before executing the main program
brlid r15, main /* Execute the program */
However main() program is called and executed but my function is never called before it. Could someone please tell me what is going on and what I am doing wrong.
Thanks in advance.
03-11-2009 12:18 PM
Davit:
The brlid branch instruction has a delay slot, meaning that the next instruction after the branch is executed as the branch target address is calculated. In this case, this means that the branch to the main function may begin execution. The proper way to call your function before main is:
*****************************************************
// Call function and fill delay slot with a No-op
brlid r15, myFunction
nop
// Call main
brlid r15, main
// instruction located here will be executed "during" the branch
*****************************************************
Give this a try to see if it solves your problem.
-Jason
03-12-2009 07:32 AM
03-12-2009 10:05 AM
Which assembly files are you changing? Are they located within your XPS project directory or are they in the $XILINX_EDK installation path?
I believe that the software/lib files in $XILINX_EDK are just for show, and the actual files used are in .o format in the compiler directory for mb-gcc.
$XILINX_EDK/gnu/microblaze/lin64/microblaze-xilinx-elf/lib
(NOTE: lin64 should be changed depending on your type of system)
Also, I would make a backup of the old .o file just to make sure it doesn't become corrupted.
03-16-2009 04:18 AM - edited 03-16-2009 04:37 AM
I found the object files in the "EDK\gnu\microblaze\nt\microblaze-xilinx-elf\lib" directory but I don't actually know how to modify them. My guess is I should complile the modified assembly files into those object files using a make file. Is there any guidance on how to do it?
I don't know how those object files are added to my project. If I could find out that I could exclude them from my project and include my own initialization files.
05-11-2009 01:56 PM
Page 138 of the edk10_est_rm.pdf guide says...
"Modifying Startup Files:
The initialization files are distributed in both pre-compiled and source form with EDK. The
pre-compiled object files are found in the compiler library directory. Sources for the
initialization files for the MicroBlaze GNU compiler can be found in the
<XILINX_EDK>/sw/lib/microblaze/src directory, where <XILINX_EDK> is the
EDK installation area.
To fulfill a custom startup file requirement, you can take the files from the source area and
include them as a part of your application sources. Alternatively, you can assemble the files
into .o files and place them in a common area. To refer to the newly created object files
instead of the standard files, use the -B directory-name command-line option while
invoking mb-gcc. To prevent the default startup files from being used, use -
nostartfiles on final compile line. Note that the miscellaneous compiler standard CRT
files, such as crti.o, and crtbegin.o, are not provided with source code. They are
available in the installation to be used as is. You may need to bring them in on your final
link command."