Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

An error during compiling

Altera_Forum
Honored Contributor II
1,161 Views

hi, 

i'm a freshman in embedded.my target board is cyclone2 ep2c35(with 48k total ram bits on chip,105 M4k memory blocks). the components i added into my design as follows: 

a processor,on chip memory(16kbytes ram) ,lcd_display,jtag uart,pio 

my program :# include "alt_types.h"# include <stdio.h># include <unistd.h># include "system.h"# include "sys/alt_irq.h"# include "altera_avalon_pio_regs.h" 

... 

FILE * lcd; 

lcd = fopen("/dev/lcd_display", "w"); 

....... 

 

i select "small C library" and "reduced device drivers" options 

i encounter two questions while compiling 

1)i can&#39;t use the fopen function,the error msg during compiling: 

 

obj/count_binary.o(.text+0x98): In function `main&#39;: 

../count_binary.c:22: undefined reference to `fopen 

collect2: ld returned 1 exit status 

make: *** [count_binary_3.elf] Error 1 

Build completed 

 

finally i use printf instead.and the program can run on the "nios/s" core; 

when i run it on my core descibed above, i came across another problem  

2) 

Linking count_binary_3.elf... 

/cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/ 

gcc/nios2-elf/3.4.1/../../../../nios2-elf/bin/ld: region onchip_memory_0 is 

full (count_binary_3.elf section .text). Region needs to be 42168 bytes 

larger. 

/cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/ 

gcc/nios2-elf/3.4.1/../../../../nios2-elf/bin/ld: region onchip_memory_0 is 

full (count_binary_3.elf section .rwdata). Region needs to be 652 bytes 

larger. 

/cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/ 

gcc/nios2-elf/3.4.1/../../../../nios2-elf/bin/ld: section .rodata [00000020 

-> 00000737] overlaps section .exceptions [00000020 -> 000001c7] 

/cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/ 

gcc/nios2-elf/3.4.1/../../../../nios2-elf/bin/ld: section .rwdata [00000738 

-> 0000228b] overlaps section .text [000001c8 -> 0000c4b7] 

/cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/ 

gcc/nios2-elf/3.4.1/../../../../nios2-elf/bin/ld: section .bss [00000020 -> 

00000257] overlaps section .exceptions [00000020 -> 000001c7] 

obj/count_binary.o(.text+0xc8): In function `count_lcd&#39;: 

../count_binary.c:60: Unable to reach (at 0x00000034) from the global 

pointer (at 0x0000a210) because the offset (-41436) is out of the allowed 

range, -32678 to 32767. 

 

is it necessary to add an extern memory? 

if yes,how can i do it?because i looked through the nios2 sw&hw dev handbook but can&#39;t find the introduction of steps to add a extern ram 

 

can anyone help me? 

thank u for your attention
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
455 Views

I think you ran out of onchip memory... (it&#39;s one of the first error messages) 

 

There are many examples distributed by Altera that shows how external RAMs can be used... just start from them! 

 

bye 

 

Paolo
0 Kudos
Altera_Forum
Honored Contributor II
455 Views

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

i select "small C library" and "reduced device drivers" options 

i encounter two questions while compiling 

1)i can&#39;t use the fopen function,the error msg during compiling: 

 

obj/count_binary.o(.text+0x98): In function `main&#39;: 

../count_binary.c:22: undefined reference to `fopen 

collect2: ld returned 1 exit status 

make: *** [count_binary_3.elf] Error 1 

Build completed[/b] 

--- Quote End ---  

 

 

I guess you shouldn&#39;t enable small C library property if you want to use &#39;fopen&#39;. 

 

FYI. 

 

regards, 

David
0 Kudos
Reply