Forum Discussion

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

buildroot to build toolchain on Linux

TO_BE_DONE

107 Replies

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

    hi hippo:

    I have compiled the kernel successed ,then got the vmlinux in /linux-2.6.15.1.

    But when I exec "made ARCH=nios2nommu CROSS_COMPILE=nios2-linux-uclibc- INSTALL_MOD_PATH=/home/alex/rootfs modules_install".I meet a erro.

    [root@localhost linux-2.6.15.1]# make ARCH=nios2nommu CROSS_COMPILE=nios2-linux-uclibc- INSTALL_MOD_PATH=/home/alex/rootfs modules_install

    no emulation specific options.

    The present kernel configuration has modules disabled.

    Type 'make config' and enable loadable module support.

    Then build a kernel with module support enabled.

    So I ececed "make ARCH=nios2nommu CROSS_COMPILE=nios2-linux-uclibc- menuconfig"

    In "modules support" , I seleced "enable modules...."

    After save, I execed "make ARCH=nios2nommu CROSS_COMPILE=nios2-linux-uclibc-"

    but make failed. I got following erro information:

    .

    .

    .

    arch/nios2nommu/kernel/setup.c:101:33: warning: "CONFIG_SMC91111" is not definedarch/nios2nommu/kernel/setup.c:101:54: warning: "CONFIG_OPEN_ETH" is not definedarch/nios2nommu/kernel/setup.c:101:75: warning: "CONFIG_MTIP1000_ETH" is not defined

    arch/nios2nommu/kernel/setup.c:101:100: warning: "CONFIG_DM9000_ETH" is not defined

    arch/nios2nommu/kernel/setup.c:200:33: warning: "CONFIG_SMC91111" is not definedarch/nios2nommu/kernel/setup.c:200:54: warning: "CONFIG_OPEN_ETH" is not definedarch/nios2nommu/kernel/setup.c:200:75: warning: "CONFIG_MTIP1000_ETH" is not defined

    arch/nios2nommu/kernel/setup.c:200:100: warning: "CONFIG_DM9000_ETH" is not defined

    .

    .

    .

    kernel/intermodule.c:178: warning: `inter_module_register' is deprecated (declared at kernel/intermodule.c:38)

    kernel/intermodule.c:179: warning: `inter_module_unregister' is deprecated (declared at kernel/intermodule.c:78)

    kernel/intermodule.c:181: warning: `inter_module_put' is deprecated (declared at kernel/intermodule.c:159)

    CC kernel/extable.o

    CC kernel/params.o

    CC kernel/posix-timers.o

    CC kernel/kthread.o

    CC kernel/wait.o

    CC kernel/kfifo.o

    CC kernel/posix-cpu-timers.o

    CC kernel/futex.o

    CC kernel/uid16.o

    CC kernel/module.o

    kernel/module.c: In function `load_module':

    kernel/module.c:1534: error: `EM_ALTERA_NIOS2' undeclared (first use in this function)

    kernel/module.c:1534: error: (Each undeclared identifier is reported only once

    kernel/module.c:1534: error: for each function it appears in.)

    make[1]: *** [kernel/module.o] 错误 1

    make: *** [kernel] 错误 2

    [root@localhost linux-2.6.15.1]#

    How can I solve the question?

    Do I must copy modules fills from MX_1.4 source code to ~/rootfs?

    Thank you very much! http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/smile.gif
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    You can use "free" to find out the memory usage.

    You can try the following to reduce the memory usage.

    1. The default busybox use more options than you will need.

    You can reduce the commands or features supported by busybox, only keep those you will use.

    cd ~/buildroot/build_nios2/busybox

    make menuconfig

    make

    cd ~/buildroot

    make

    2. reduce the kernel, reduce unused driver and file system.

    cd ~/linux-2.6.x

    make ...... menuconfig

    make

    3. remove unused files and nodes in rootfs/etc and rootfs/dev

    in file ~/buildroot/target/generic/device_table.txt

    in dir ~/buildroot/target/generic/target_skeleton

    4. you can delete files at run time when they are no longer in use.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    It is easy to compile a simple program, as pointed out by leonqin and tschmelcher.

    nios2-linux-uclibc-gcc hello.c -o hello -elf2flt

    The copy hello to ~/rootfs/bin, and rebuild kernel image for initramfs.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi hippo!

    I created a patch for the 2.6.11 kernel to include support for a timer called watchdog configured as a watchdog in SOPC-builder. I think it&#39;s not specific to 2.6.11 so you could include this in the patch-set if you like.

    The more drivers standard available (or in one patch) the more attractive the Nios2 platform gets!

    Respect for the work you&#39;ve done so far!

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

    This guide worked for me. Thanks hippo! initramfs cuts down on my flash memory requirements a lot. http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/smile.gif

    To others planning to use the above guide, here are some things I ran into:

    - Before starting, make sure you have bison, flex, and dos2unix. Bison and flex are probably available as packages for your Linux distribution. dos2unix is a common tool, but amazingly I didn&#39;t have it and my Linux distribution didn&#39;t have a package for it! If it&#39;s the same with you, then the simplest thing to do is to use the two-line perl script for dos2unix that they give here: http://soft.zoneo.net/linux/dos_to_unix.php (http://soft.zoneo.net/linux/dos_to_unix.php). Name the script "dos2unix" (without any extension), make it executable, and put it in your path. (Note: don&#39;t get the fancy dos2unix that converts between DOS, UNIX, and Mac in any direction. It&#39;ll break the build.)

    - The build process for elf2flt tries to use a static libc library, which you might not have. If the build for it fails with an error like "ld: cannot find -lc", then that&#39;s probably your problem. However, you can just change the elf2flt build process to use shared libraries. After the build fails due to the error, edit buildroot/toolchain_build_nios2/elf2flt/Makefile and remove the "-static" flag in LDFLAGS. Then run "make" and "make install" in the elf2flt directory to finish it, and then continue the rest of the build process by running "make" in the buildroot directory.

    - The build process automatically downloads additional source code from predetermined locations on the web. However, I found that some of the sites it tries to access don&#39;t exist anymore (or at least they were down when I was doing this). If a program called "wget" keeps trying to download from some URL, that&#39;s probably what&#39;s wrong. To fix this, google for the last part of the URL that it&#39;s trying to access (e.g. "gcc-3.4.3.tar.gz"). You should find a working link to that file somewhere on the first page of results. Use your browser&#39;s "Copy Link Location" feature to get the URL of the file. Next, grep the buildroot tree for the URL that wget is using (e.g. grep -R "mirrors\.rcn\.net" ~/buildroot). One of the results should be a line like GCC_SITE=http://mirrors.rcn.net/.../gcc-3.4.3.tar.gz in some makefile or something. Edit that file and change that line to use the URL that you found instead. Then resume the build process by running "make" in the buildroot directory. The wget step should then work.

    - If you configured your kernel to not support loadable modules, or if you just don&#39;t need any on your system, then you can skip the two steps labeled "copy module files to rootfs and generate modules.dep" and "rebuild image for initramfs".

    As a note, I built buildroot using gcc version 3.4.5.