--- Quote Start ---
You've got some code reduction options turned on. Only those examples which are tailored specifically for small code size will function with these options enabled. As you've discovered, count_binary is not one of these applications.
Cheers,
- slacker
--- Quote End ---
Hi
I have the same problems the guy above is having. My C code is quite small:
#include <stdio.h>
#include "system.h"
#include <string.h>
#include "altera_avalon_jtag_uart.h"
#include "altera_avalon_jtag_uart_fd.h"
#include "altera_avalon_jtag_uart_regs.h"
int main()
{
char* msg = "Detected the character 't'.\n";
FILE* fp;
char prompt = 0;
fp =
fopen ("/
mnt/host/test.
txt", "r+"); //Open file for reading and writing
if (fp)
{
while (prompt != 'v')
{ // Loop until we receive a 'v'.
prompt =
getc(fp); // Get a character from the JTAG UART.
if (prompt == 't')
{ // Print a message if character is 't'.
fwrite (msg,
strlen (msg), 1, fp);
}
if (ferror(fp))// Check if an error occurred with the file pointer
clearerr(fp);// If so, clear it.
}
fprintf(fp, "Closing the JTAG UART file handle.\n");
fclose (fp);
}
return 0;
}
When I have "small_c_library" disabled I get these build error messages:
nios2-elf-g++ -T'../epuisant_bsp/linker.x' -msys-crt0='../epuisant_bsp/obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../epuisant_bsp -Wl,-Map=epuisant.map -O0 -g -Wall -mno-hw-div -mhw-mul -mno-hw-mulx -o epuisant.elf obj/jtag.o -lm
/cygdrive/c/altera/91/nios2eds/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc/nios2-elf/3.4.6/../../../../nios2-elf/bin/ld: region onchip_memory is full (epuisant.elf section .text). Region needs to be 1696 bytes larger.
/cygdrive/c/altera/91/nios2eds/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc/nios2-elf/3.4.6/../../../../nios2-elf/bin/ld: section .rodata [02210020 -> 0221054b] overlaps section .exceptions [02210020 -> 022101c3]
/cygdrive/c/altera/91/nios2eds/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc/nios2-elf/3.4.6/../../../../nios2-elf/bin/ld: section .rwdata [0221054c -> 02211fe7] overlaps section .text [022101c4 -> 0221c29f]
/cygdrive/c/altera/91/nios2eds/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc/nios2-elf/3.4.6/../../../../nios2-elf/bin/ld: section .bss [02211fe8 -> 022120ef] overlaps section .text [022101c4 -> 0221c29f]
collect2: ld returned 1 exit status
make: *** [epuisant.elf] Error 1
But when I enable the "small_c_library" option I get these ones:
obj/HAL/src/alt_uncached_free.o obj/HAL/src/alt_uncached_malloc.o obj/HAL/src/alt_unlink.o obj/HAL/src/alt_usleep.o obj/HAL/src/alt_wait.o obj/HAL/src/alt_write.o obj/HAL/src/altera_nios2_irq.o obj/HAL/src/crt0.o obj/alt_sys_init.o obj/drivers/src/altera_avalon_jtag_uart_fd.o obj/drivers/src/altera_avalon_jtag_uart_init.o obj/drivers/src/altera_avalon_jtag_uart_ioctl.o obj/drivers/src/altera_avalon_jtag_uart_read.o obj/drivers/src/altera_avalon_jtag_uart_write.o obj/drivers/src/altera_avalon_sysid.o obj/drivers/src/altera_hostfs.o
[BSP build complete]
Info: Compiling jtag.c to obj/jtag.o
nios2-elf-gcc -xc -MP -MMD -c -I../epuisant_bsp -I../epuisant_bsp/drivers/inc -I../epuisant_bsp/HAL/inc -DSYSTEM_BUS_WIDTH=32 -D__hal__ -pipe -DALT_NO_C_PLUS_PLUS -DALT_NO_INSTRUCTION_EMULATION -DALT_SINGLE_THREADED -O0 -g -Wall -mno-hw-div -mhw-mul -mno-hw-mulx -o obj/jtag.o jtag.c
Info: Linking epuisant.elf
nios2-elf-g++ -T'../epuisant_bsp/linker.x' -msys-crt0='../epuisant_bsp/obj/HAL/src/crt0.o' -msys-lib=hal_bsp -L../epuisant_bsp -msmallc -Wl,-Map=epuisant.map -O0 -g -Wall -mno-hw-div -mhw-mul -mno-hw-mulx -o epuisant.elf obj/jtag.o -lm
obj/jtag.o(.text+0x30): In function `main':
/cygdrive/e/epuisant/software/epuisant/jtag.c:20: undefined reference to `fopen'
obj/jtag.o(.text+0x54):/cygdrive/e/epuisant/software/epuisant/jtag.c:25: undefined reference to `getc'
obj/jtag.o(.text+0x80):/cygdrive/e/epuisant/software/epuisant/jtag.c:28: undefined reference to `fwrite'
obj/jtag.o(.text+0xc8):/cygdrive/e/epuisant/software/epuisant/jtag.c:34: undefined reference to `fclose'
collect2: ld returned 1 exit status
Could it be because of a small RAM memory? Should I just use a larger memory? I've followed all the instructions to create a file based system but nothing works....
Please help