Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
21 years ago

Trouble Linking N2 Legacy Port

I'm getting a linking error on a ~20 module project. I got everything to compile fine, but this is stumping me. I saw in search that someone else had posted the same exact link errors so maybe this has been solved?

I started with the example Makefile in the Peripherals_Test example and replaced the modules with my own. Do I need to add a lib or something? I searched the entire Nios2 tree for any file (.a or .o) that contained the missing symbols to no avail. TIA, Ken

# 2004.09.27.16:57:13 --- Linking obj/scan.out

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

-lib/nios2-elf/3.3.3/../../../../nios2-elf/lib/mno-hw-mul/libc.a(closer.o): In f

unction `_close_r':

closer.o(.text+0x20): warning: _close is not implemented and will always fail

...

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

-lib/nios2-elf/3.3.3/../../../../nios2-elf/lib/mno-hw-mul/libc.a(readr.o): In fu

nction `_read_r':

readr.o(.text+0x2c): warning: _read is not implemented and will always fail

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

-lib/nios2-elf/3.3.3/../../../../nios2-elf/lib/mno-hw-mul/libc.a(writer.o): In f

unction `_write_r':

writer.o(.text+0x2c): warning: _write is not implemented and will always fail

collect2: ld returned 1 exit status

7 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    OK, I'm about to go home, but here's a guess that might get you on the right track.

    Peripheral test is made for legacy SDK. So, you may have to change some things to make it work in the IDE.

    I would get Peripheral test working in the IDE first, then modify it for your modules.

    Does that help?

    I don't know if the IDE uses makefiles? None of the examples (software) seem to have them.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hey Kerri,

    This is a Legacy port. Now I did add a few macros to turn on and off interrupts. Would this trigger IDE linking requirements?

    If so, how do I turn interrupts on and off in Legacy mode? (The porting guide indicated to use the NiosII macros)

    The two macros are NIOS2_READ_STATUS(status) and NIOS2_WRITE_STATUS().

    But even if I remove or comment them out I get the same link error.

    Thanks,

    Ken
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I'll see what I can find.

    I was in a hurry yesterday, The IDE does use makefiles. There is more information in the software developers handbook. But since you're not going the IDE route, it's moot.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi Ken,

    Can you post the complete command line and output from the failure? The parts of the output you have included only contain warnings which shouldn't prevent the linker from creating the executable.

    Jonah
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Jonah,

    You're right! These are just warnings. Any idea what's causing them. I removed all of my fprintf's thinking that was the cause, but they are still there.

    Kind of waiting for a service release, thinking that a lot of this is just first release stuff. A v1.0.1 was mentioned as close with v1.1 (?) later this year.

    Ken
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi Ken,

    This is highlighting something that has never been complete in the legacy SDK: certain C "stub" routines that are usually provided separate from the GNU tool & newlib library distribution. In Nios I, we did not include code for these routines either, just empty subroutine declarations to avoid linker warnings (CYA statement: the Nios I s/w development literature called these out and mentioned what wasn't implemented). This was done because, in Nios I, the routines just weren't needed. We had implemented our own 'custom' printf/sprintf/fprintf etc (which was easy without a filesystem).

    Going forward into Nios II, it was decided to do things 'right' in terms of C support and thus the HAL library was born - HAL includes things like open/close/fstat, etc., and file-IO type operation is supported. This is used in device access, printf(), etc., but more importantly, the support is there for future OS and filesystem support.

    Now the legacy SDK, on the other hand, was designed to carry over s/w support from Nios I, nothing more: this means that the open/close/fstat routines, etc., are still not supported. The difference: in Nios I we had a C file, nios_cstubs.c, which had the empty subroutines for these.. in the Nios II legacy SDK, these "stubs" don't exist, and hence the link warnings.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Thanks Jesse,

    Maybe I'll do the same thing and create some stubs.

    Please don't give up on the Legacy Mode of NiosII. It's (relative) simplicity and learning curve and footprint are going to appeal to a lot of engineer types.

    The subtle improvements to gdb/Insight like remembering breakpoints, putting the code browser on the main toolbar, and better support for stdio while debugging are great.

    Thinking back, I probably could have sent printf's to the serial port while debugging through the JTAG, but the N2 setup makes it easy and natural to do so. I like it very much.

    I do get an occasional JTAG hiccup that I'm hoping the new USB Blaster will solve, but overall I'd say I'm quite pleased with the improvements.

    Regards,

    Ken