Forum Discussion

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

Building net-snmp for uClinux in FLT format

Hi all. I'm trying to build net-snmp for Nios II uClinux (specifically its agent, snmpd). I found an account of how to do this from forum member "temex" at http://forum.niosforum.com/forum/index.php?showtopic=2955 (http://forum.niosforum.com/forum/index.php?showtopic=2955) (see post# 5 in that topic)), but I seem to be missing the final step and I'm hoping someone here can help.

I downloaded the same version of net-snmp mentioned by temex (5.2.2), but I don't have the (expensive) Microtronix Nios II Linux CDK, so I downloaded what appears to be a very similar thing from http://scorpius.homelinux.org/~marc/nios2.html (http://scorpius.homelinux.org/~marc/nios2.html) (see "binary snapshot of the toolchain", near the bottom of that page). I installed that on a Linux PC and then followed the instructions from temex to build net-snmp for Nios II Linux, which went fine. However, the binaries that it produced were in the ELF format, and uClinux only accepts FLT.

So, my problem is: "what do I have to do to get FLT binaries?"

I&#39;ve already tried one approach. I&#39;ve got the Microtronix Nios II Linux Distribution 1.4 on a Windows PC (which has Quartus II 5.1 and the Nios II Development Kit 5.0), so I tried looking at what its tools do to make FLT binaries. In the Rules.mak for a Nios II Linux Application Project, it uses a program called elf2flt to do this, but when I tried to use that program on the ELF binary that I&#39;d made for snmpd, it died complaining that "Input file contains no relocation info". I noticed that the Rules.mak file used some linker options that might be needed to make elf2flt work on the resulting ELF file (it uses -r, -d, -Ur, and -T <a particular linker script>), so I tried making the net-snmp build process use those options by giving --with-ldflags="..." to ./configure. (I had to leave out -d because, when I supplied it, ./configure complained that nios2-linux-gcc couldn&#39;t make executables and wouldn&#39;t proceed.) However, when I built with these extra flags and tried to convert the ELFs, elf2flt still died with the same complaint. This seems odd to me, because the -r flag means to make a relocatable file, which is what elf2flt was demanding. I think the resulting ELF files might have been the same size as before, too ...

So ... does anyone know what I&#39;ve done wrong? http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/smile.gif

Thanks in advance.

5 Replies

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

    It is a problem of gcc check in configure.

    You could add a short dummy --with-ldflag for configure only, eg, "-Wl,-v".

    After it build Makefile, edit the LDFLAGS in Makefile to include -elf2flt.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Awesome. After doing that, the binaries that the build made were in the FLT format. Thanks very much!

    To anyone else looking to get net-snmp&#39;s snmpd to work, I also needed to configure my kernel to support large mem allocations (Processor type and features -> Allow allocating large blocks of memory), and I need to run snmpd with -f. After that just set up the environment on your uClinux system like how snmpd needs it (i.e. with the .conf and the MIBs) and it runs fine.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Thanks hippo, I&#39;m going to try out the buildroot toolchain. I&#39;ll let you know how it goes.

    About net-snmp, if anyone needs to port 5.3.0.1, you can use the same procedure as for 5.2.2, except I also needed to comment out the definitions of getutent, endutent, and setutent in agent/mibgroup/host/hr_system.c (they&#39;re already defined in uClibc and the linker complains about having two sets of them). Also, if you use the same toolchain binaries as I did, then gcc&#39;s optimizer will introduce a bug when compiling agent/mibgroup/hardware/cpu/cpu.c. Either add &#39;asm("nop");&#39; after the call to _cpu_update_stats on line 34, or compile with -O1 instead of -O2.

    Incidentally, I&#39;ve also found that it&#39;s not necessary to use --with-ldflags="-Wl,-v" and then edit the Makefiles to add -elf2flt. You can just use --with-ldflags="-elf2flt" when running ./configure.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    tschmelcher,

    how big did your executable get?

    When I build it , the snmpd has 1636952 Bytes.

    Is this approx right ?

    Is there a way to make it leaner?