[[mips_cross_compiler]]

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
mips_cross_compiler [2014/02/16 01:25]
beckmanf [MIPS Cross Compiler build] changed script
mips_cross_compiler [2014/02/16 17:57]
beckmanf [MIPS Cross Compiler build] - used HOME variable
Line 91: Line 91:
  
 # Set the destination # Set the destination
-export MYMIPS=/home/fritz/site+export MYMIPS=${HOME}/site
  
 # Versions # Versions
Line 454: Line 454:
 </​code>​ </​code>​
  
-=== Compile and Run ===+===== Compile and Run an example ===== 
 + 
 +Here is an example mini c code to test the compiler.  
 + 
 +<code c hello.c>​ 
 +/* Hello world */ 
 +#include <​stdio.h>​ 
 + 
 +int myfunc(int a, int b){ 
 +  int k;  
 +  k = a + b;  
 + 
 +  k += 7;  
 +  k *= 6;  
 +  return k;  
 +
 + 
 +int main(){ 
 +  int i,​j,​m; ​  
 +  j = 3; 
 +  m 2; 
 +   
 +  for(i=0;​i<​5;​i++){ 
 +    m +myfunc(i,​j); ​  
 +    printf("​m is %d\n",​m);​ 
 +  } 
 +  return 0; 
 +
 +</​code>​
  
 Compile to Assembler for viewing Compile to Assembler for viewing
  
-mipsel-none-elf-gcc -S fir.c+<​code>​ 
 +mipsel-none-elf-gcc -S hello.c 
 +</​code>​
  
-The output is fir.s which is the assembler code+The output ​assembler code is in hello.s. 
  
 Compile and link ready for simulation with instruction set simulator Compile and link ready for simulation with instruction set simulator
  
-mipsel-none-elf-gcc -o fir -Tidt.ld ​fir.c+<​code>​ 
 +mipsel-none-elf-gcc -o hello -Tidt.ld ​hello.c 
 +</​code>​
  
 Run the code Run the code
  
-mipsel-none-elf-run ​fir+<​code>​ 
 +mipsel-none-elf-run ​hello 
 +</​code>​
  
 === Analyze === === Analyze ===
  
-Produce an annoted source code +Produce an annoted source code showing how often lines are executed. ​
  
-gcc -fprofile-arcs -ftest-coverage -o fir fir.c+<​code>​ 
 +gcc -fprofile-arcs -ftest-coverage -o hello hello.c 
 +./hello 
 +gcov hello.c 
 +</​code>​
  
-./fir+This produces the file hello.c.gcov showing the annotated source file.  ​
  
-gcov fir.c +=== Tracing in instruction set simulator ===
  
 Run with instruction tracing in the simulator Run with instruction tracing in the simulator
  
 <​code>​ <​code>​
-mipsel-none-elf-run --trace-insn=on --trace-file trace fir+mipsel-none-elf-gcc -Tidt.ld -o hello hello.c 
 +mipsel-none-elf-run --trace-insn=on --trace-file trace hello
 </​code>​ </​code>​
  
Line 501: Line 540:
  
 [[dt_openocd]] [[dt_openocd]]
- 
  
  
  
  
  • mips_cross_compiler.txt
  • Last modified: 2014/06/04 17:52
  • by beckmanf