- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
UPDATE : This post is out of date. Please follow the new one,
http://forum.niosforum.com/forum/ind...showtopic=3174
This is a mini howto about building toolchains ,uClinux and initramfs for NIOS2 on Linux platform.
It is for those unable to access marc's site, or want to do it from scratch.
Please help to improve it. And give feed back to me. I will move this to a project when ready.
Why build the tools when you have the IDE on Windows?
The IDE on Windows are just not good for kernel development.
The tools run much faster and less trouble on Linux.
Why use Initramfs? It is common in major Linux distributions with 2.6 kernel.
It replaces romfs. It is compressed. The rootfs (initrd) image can be linked into the kernel, and make the booting easier.
You don't need other devices, such as MTD,CF/IDE,NFS to bring up your root fs.
As they are not yet available for a new custom board.
You can mount other devices or filesystem later, in user space.
Jdhar and I had worked on another thread,
"uClinux without Flash (again)"
There were what we had tried with IDE on Windows, but failed.
It was successed then, based on marc's site to build the tools on Linux.
You may follow it to learn more about Initramfs and the booting process.
If you are new to uClinux, it is very helpful to read the FAQ on the www.ucdot.org.
You should start with a mininal system with only nios2 cpu core,dram,timer,jtag/serial console and a cfi flash, (which can be dummy and removed later).
Here we go!
First get the sources file from your Windows platform.
You should enable "gnutools source" package selection when installing nios2 distribution CD (not available in eval CD).
The compiler sources are located in the dir altera/kits/nios2/bin/nios-gnutools/src.
Downloaded and install the uClinux 2.6 release 1.4 of microtronic from this forum.
Find the sources in altera/kits/nios2/examples/software/linux and the kernel linux-2.6.x .
Sample config files and Rules.mak for apps are included at the end of this post.
We will do all the works with command line on Linux. No IDE except when you want to download.
Convert the CRLF in the source trees with zip -r and unzip -a.
Place converted source trees in /usr/local/src/nios2/ , including binutils,gcc,elf2flt,linux-2.6.x,uClibc,apps and busybox.
Make build dirs in /usr/local/src/nios2/build/ binutils,gcc,elf2flt, kernel,rootfs.
The exec,lib files will be in /usr/local/bin /usr/local/nios2-elf.
### create the root file system
mkdir /usr/local/src/nios2/build/rootfs
cd /usr/local/src/nios2/build/rootfs
mkdir bin sbin usr usr/bin usr/sbin etc var var/log dev proc sys tmp mnt
# create a simple etc/inittab
echo "::askfirst:/bin/sh" >etc/inittab
# prepare for user space init
ln -s /sbin/init init
# make some basic devices
# Look at linux-2.6.x/Documents/devices.txt for the list of devices numbers.
cd dev
mknod console c 5 1
mknod null c 1 3
mknod zero c 1 5
mknod hda b 3 0
mknod hda1 b 3 1
### prepare the compiler
cd /usr/local/src/nios2/build/binutils
../../binutils/configure --target=nios2-elf
make
make install
cd /usr/local/src/nios2/build/gcc
../../gcc/configure --target=nios2-elf --enable-languages=c
make
make install
cd /usr/local/src/nios2/build/elf2flt
../../elf2flt/configure --target=nios2-elf --with-bfd-include-dir=../binutils/bfd --with-libbfd=../binutils/bfd/libbfd.a --with-libiberty=../binutils/libiberty/libiberty.a
make
make install
### compile the kernel
cd /usr/local/src/nios2/linux-2.6.x
# remove the lines contain "dos2unix" in Makefile, scripts/Makefile.build, scripts/Makefile.lib.
make ARCH=nios2nommu O=/usr/local/src/nios2/build/kernel CROSS_COMPILE=nios2-elf- hwselect SYSPTF=/usr/local/src/nios2/build/yoursystem.ptf
make ARCH=nios2nommu O=/usr/local/src/nios2/build/kernel CROSS_COMPILE=nios2-elf- menuconfig
#### .config must have
# Miscellaneous Options
CONFIG_CMDLINE=""
# Block devices
CONFIG_INITRAMFS_SOURCE="/usr/local/src/nios2/build/rootfs"
# Kernel hacking
# CONFIG_FULLDEBUG is not set
make ARCH=nios2nommu O=/usr/local/src/nios2/build/kernel CROSS_COMPILE=nios2-elf-
### compile the uClibc
ln -s /usr/bin/install /bin/install
cd /usr/local/src/nios2/uClibc
make CROSS=nios2-elf- menuconfig
#### .config must have
# Target Architecture Features and Options
KERNEL_SOURCE="/usr/local/src/nios2/linux-2.6.x"
KERNEL_AUTOCONF="/usr/local/src/nios2/build/kernel"
# Library Installation Options
RUNTIME_PREFIX="/usr/local/nios2-elf/"
DEVEL_PREFIX="/usr/local/nios2-elf/"
make CROSS=nios2-elf-
make CROSS=nios2-elf- install
### compile the buysbox
ln -s /usr/local/nios2-elf/lib /usr/local/nios2-elf/scripts
cd /usr/local/src/nios2/busybox
make UCLIBC_PLUGIN=/usr/local/nios2-elf APP_PLUGIN=/usr/local/nios2-elf menuconfig
#### .config must have
# Build Options
CONFIG_STATIC=y
USING_CROSS_COMPILER=y
CROSS_COMPILER_PREFIX="nios2-elf-"
KERNEL_BUILD_DIRECTORY="/usr/local/src/nios2/build/kernel"
# Installation Options
PREFIX="/usr/local/src/nios2/build/rootfs"
make UCLIBC_PLUGIN=/usr/local/nios2-elf APP_PLUGIN=/usr/local/nios2-elf
make UCLIBC_PLUGIN=/usr/local/nios2-elf APP_PLUGIN=/usr/local/nios2-elf install
### update the rootfs with busybox added
### you should rebuild the kernel whenever the rootfs is updated
cd /usr/local/src/nios2/linux-2.6.x
make ARCH=nios2nommu O=/usr/local/src/nios2/build/kernel CROSS_COMPILE=nios2-elf-
cd /usr/local/src/nios2/build/kernel
nios2-elf-objcopy -O binary vmlinux vmlinux.bin
Then you can download and get the busybox shell prompt.
Enjoy!!
The minimal kernel config to be placed in /usr/local/src/nios2/build/kernel/.config
Code:
<1>
The sample config for uClibc ot be placed in /usr/local/src/nios2/uClibc/.config
Code:
<2>
The sample config file for busybox to be placed in /usr/local/src/nios2/busybox/.config
Code:
<3>
The file to help make apps in /usr/local/src/nios2/apps/Rules.mak
eg,
cd /usr/local/src/nios2/apps/samples
ln -s ../Rules.mak .
make KERNELBUILDDIR=/usr/local/src/nios2/build/kernel install
Then the apps will be installed into /usr/local/src/nios2/build/rootfs/bin.
Code:
<4>
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I got some errors when build the cross tool chain
1. ==================================================== src is from linux2nios CD->GUNSRC.TGZ binutils->OK gcc->error elf2flt->OK here is the gcc error: rule to make target `../../../gcc/gcc/config/nios2/lib2-divmod.c', needed by
`libgcc.mk'. Stop.
make: Leaving directory `/usr/local/src/nios2/build/gcc/gcc'
make: *** Error 2
2. ================================================== windows_src: binutils->error gcc->ok elf2flt->ok here is the gcc error ...
checking whether ANSI C string concatenation works ... yes
*** ld does not support target nios2-elf
*** see ld/configure.tgt for supported targets
make: *** Error 1
3. ================================================== I fount the size of nios2-elf-gcc ar ld ... form inux2nios CD->GUNBIN.TGZ is larger than the ones that I built out. i.e. GUNBIN.TGZ->nios2-elf-gcc 409,858 byte /usr/local/bin/nios2-elf-gcc 269,679 byte( which is I built out) but I tested both of them could worke well. Why? Is it the static-library and dynamic-library? 4. ================================================== I cannot built out /usr/local/nios2-elf/lib (there are libm.a libc.a ...) and /usr/local/nios2-elf/include (some *.h files used for C) In which step are they during building cross tool chain?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wow, great work hippo.. we shoudl all be thankful you put that time in to summarize it. Our thread does a great job IMO of walking someone through the process, but it's good you summarized it here. Unfortunately, I will be unavailable to add much until the new year... but once I'm back, I will add as much info as I can.
J- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi J, Happy new year.
More information about Initramfs can be found on LWN, "Initramfs arrives" and "Patch: Documentation for ramfs, rootfs, initramfs."- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Mountain8848,
Which linux distribution do you use? I have built on Slackware 10.2 and Fedora core4. You should use gcc 3.xx to build the tools. There are problems when using gcc 4.xx. On Redhat/Fedora , there were compat-gcc packages. cd /usr/bin mv gcc gcc4 ln -s gcc32 gcc I didn't use the source from linux nios2 cd. You maybe right about the exec binary size differeces between them, static/dynamic. About the libs/includes, there are two sets. The newlib is used by altera IDE as default. And uClibc is used by busybox/uclinux. You don't need newlib if most of your works on uclinux. The uClibc build refers to kernel build include. You must follow the steps, build kernel before build uCLibc. The uClibc build in my first post, make install will place the includes and libs into /usr/local/nios2-elf/ include and lib. I did build both, and install into different dirs. You can select with -nostdinc and -nostdlib flags. 1. newlib place the source in /usr/local/src/nios2/ newlib. after you build the nios2-elf-gcc. cd /usr/local/src/nios2/newlib/newlib cp configure.host.smallc configure.host mkdir /usr/local/src/nios2/build/newlib cd /usr/local/src/nios2/build/newlib ../../newlib/configure --target=nios2-elf make make install Then the include and lib will be placed in /usr/local/nios2-elf . 2. uClibc if you install both lib set, follow the steps, as in the first post. but set the RUNTIME/DEVEL install dirs to another place. change the UCLIBC_PLUGIN when building busybox, and apps.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is about modules. We will install the modules tree and update the busybox to use "modprobe".
The busybox in release1.4 from microtronic can not support modules in trees. Download the latest update from http://busybox.net/downloads/snapshots/bus...napshot.tar.bz2 (http://busybox.net/downloads/snapshots/busybox-snapshot.tar.bz2). Newer update has more features and fixs. I used the one built on 20051220. Place it in /usr/local/src/nios2. # rename the old busybox, so you can still use it when you need cd /usr/local/src/nios2 mv busybox busybox-1.00-pre8 tar jxf busybox-snapshot.tar.bz2 cd busybox Update the Makefile and Rules.mak in busybox.*** Makefile 2005/12/27 13:07:23 1.1
--- Makefile 2005/12/28 00:46:02
***************
*** 211,219 ****
endif# ifneq ($(strip $(HAVE_DOT_CONFIG)),y)
! busybox: .depend $(libraries-y)
$(CC) $(EXTRA_CFLAGS) $(LDFLAGS) -o $@ -Wl,--start-group $(libraries-y) $(LIBRARIES) -Wl,--end-group
! $(STRIPCMD) $@
busybox.links: $(top_srcdir)/applets/busybox.mkll include/bb_config.h $(top_srcdir)/include/applets.h
- $(SHELL) $^ >$@
--- 211,228 ----
endif# ifneq ($(strip $(HAVE_DOT_CONFIG)),y)
! busybox: busybox.elf
! nios2-elf-elf2flt -s 16000 -o $@ $<
!
!#
!# Make a relocatable ELF file.
!#
! %.elf : %.bin
! $(LD) -T /usr/local/nios2-elf/scripts/elf2flt.ld -Ur -o $@ $<
!
! busybox.bin: .depend $(libraries-y)
$(CC) $(EXTRA_CFLAGS) $(LDFLAGS) -o $@ -Wl,--start-group $(libraries-y) $(LIBRARIES) -Wl,--end-group
!# $(STRIPCMD) $@
busybox.links: $(top_srcdir)/applets/busybox.mkll include/bb_config.h $(top_srcdir)/include/applets.h
- $(SHELL) $^ >$@
***************
*** 328,334 ****
docs/busybox pod2htm* *.gdb *.elf *~ core .*config.log
docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
docs/busybox.net/BusyBox.html busybox.links libbb/loop.h
! .config.old busybox
- rm -rf _install testsuite/links
- find . -name .\*.flags -exec rm -f {} \;
- find . -name \*.o -exec rm -f {} \;
--- 337,343 ----
docs/busybox pod2htm* *.gdb *.elf *~ core .*config.log
docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
docs/busybox.net/BusyBox.html busybox.links libbb/loop.h
! .config.old busybox *.bin
- rm -rf _install testsuite/links
- find . -name .\*.flags -exec rm -f {} \;
- find . -name \*.o -exec rm -f {} \;
*** Rules.mak 2005/12/27 12:56:02 1.1
--- Rules.mak 2005/12/28 00:55:09
***************
*** 72,83 ****
# If you are using Red Hat 6.x with the compatible RPMs (for developing under
# Red Hat 5.x and glibc 2.0) uncomment the following. Be sure to read about
# using the compatible RPMs (compat-*) at http://www.redhat.com !
!# LIBCDIR:=/usr/i386-glibc20-linux
#
# For other libraries, you are on your own. But these may (or may not) help...
!# LDFLAGS+=-nostdlib
!# LIBRARIES:=$(LIBCDIR)/lib/libc.a -lgcc
!# CROSS_CFLAGS+=-nostdinc -I$(LIBCDIR)/include -I$(GCCINCDIR) -funsigned-char
# GCCINCDIR:=$(shell gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
WARNINGS=-Wall -Wstrict-prototypes -Wshadow
--- 72,83 ----
# If you are using Red Hat 6.x with the compatible RPMs (for developing under
# Red Hat 5.x and glibc 2.0) uncomment the following. Be sure to read about
# using the compatible RPMs (compat-*) at http://www.redhat.com !
! LIBCDIR:=/usr/local/nios2-elf
#
# For other libraries, you are on your own. But these may (or may not) help...
! LDFLAGS+=-nostdlib -Wl,-r -Wl,-d -L$(LIBCDIR)/lib $(LIBCDIR)/lib/crt0.o
! LIBRARIES:=-lc -lm -lgcc
! CROSS_CFLAGS+=-nostdinc -I$(LIBCDIR)/include -I/usr/local/src/nios2/build/kernel/include -funsigned-char -iwithprefix include -D__uClinux__
# GCCINCDIR:=$(shell gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
WARNINGS=-Wall -Wstrict-prototypes -Wshadow
***************
*** 103,108 ****
--- 103,109 ----
-e 's/sh/sh/'
-e 's/mips-.*/mips/'
-e 's/mipsel-.*/mipsel/'
+ -e 's/nios2-.*/nios2nommu/'
-e 's/cris.*/cris/'
)
endif
make menuconfig make make install The .config of busybox must have, ## Build Options#
CONFIG_STATIC=y
CONFIG_LFS=y
USING_CROSS_COMPILER=y
CROSS_COMPILER_PREFIX="nios2-elf-"
EXTRA_CFLAGS_OPTIONS="-Dfork=vfork"
CONFIG_FEATURE_SUSv2=y
CONFIG_FEATURE_SUSv2_OBSOLETE=y
# # Installation Options# # CONFIG_INSTALL_NO_USR is not set
CONFIG_INSTALL_APPLET_SYMLINKS=y# CONFIG_INSTALL_APPLET_HARDLINKS is not set# CONFIG_INSTALL_APPLET_DONT is not set
PREFIX="/usr/local/src/nios2/build/rootfs"
If your nios2 does not have hw mul, add "-mno-hw-mul" to extra cflags above. If your nios2 does have hw mulx, add "-mhw-mulx" to extra cflags above. "-mhw-mul" is the default. Next, we will update the kernel Makefile, and install modules into rootfs. cd /usr/local/src/nios2/linux-2.6.x Update Makefile ,as it should be in newer kernels. *** Makefile~ 2005-12-16 11:19:34.000000000 +0800
--- Makefile 2005-12-27 13:34:02.000000000 +0800
***************
*** 894,900 ****
ifeq "$(strip $(INSTALL_MOD_PATH))" ""
depmod_opts :=
else
! depmod_opts := -b $(INSTALL_MOD_PATH)/lib/modules -r
endif
.PHONY: _modinst_post
_modinst_post: _modinst_
--- 894,900 ----
ifeq "$(strip $(INSTALL_MOD_PATH))" ""
depmod_opts :=
else
! depmod_opts := -b $(INSTALL_MOD_PATH) -r
endif
.PHONY: _modinst_post
_modinst_post: _modinst_
make ARCH=nios2nommu O=/usr/local/src/nios2/build/kernel CROSS_COMPILE=nios2-elf- INSTALL_MOD_PATH=/usr/local/src/nios2/build/rootfs# ## update the rootfs with modules added make ARCH=nios2nommu O=/usr/local/src/nios2/build/kernel CROSS_COMPILE=nios2-elf- You should enable modules support in kernel, and module utilities (insmod,rmmod,lsmod,modprobe) in busybox. The kerenl modules tree will be installed into the INSTALL_MOD_PATH/lib/modules/2.6.11-uc0/kernel/... and modules.dep will be generated. Then the "modprobe" command will work now. eg modprobe vfat will load fs/fat/fat.ko and fs/vfat/vfat.ko. If you have CF/Microdrive/IDE or other block devices, you can use it to store the modules. Either, 1. Mount it as root, without initramfs. Flash devices are not recommand for root, because of the limited write life. Config the kernel command line to "root=/dev/hda1", and disable initramfs. You should have the device driver and file system compiled in, instead of modules. The FAT/VFAT does not support symlink, and can not be used as root if you want busybox. Consider minix if the root part size <64MB, or ext2 for larger disk. Mount and copy the rootfs to your device, with cp -a. 2. Mount it as /lib, over the initramfs, and keep the initramfs small. Change the modules install path to another dir, then cd lib of this and cp -a to the devices. The ext3 and reiserfs still have some problem in kernel compilation. I am checking. Patch to support minix for /usr/local/src/nios2/linux-2.6.x/include/asm-nios2nommu/bitops.h *** bitops.h 2005/11/10 06:55:12 1.1
--- bitops.h 2005/11/10 06:56:58
***************
*** 469,472 ****
--- 469,479 ----
# define ext2_find_first_zero_bit find_first_zero_bit
# define ext2_find_next_zero_bit find_next_zero_bit
+ /* Bitmap functions for the minix filesystem. */
+# define minix_test_and_set_bit(nr,addr) test_and_set_bit(nr,addr)
+# define minix_set_bit(nr,addr) set_bit(nr,addr)
+# define minix_test_and_clear_bit(nr,addr) test_and_clear_bit(nr,addr)
+# define minix_test_bit(nr,addr) test_bit(nr,addr)
+# define minix_find_first_zero_bit(addr,size) find_first_zero_bit(addr,size)
+
# endif /* _ASM_NIOS_BITOPS_H */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Could you provide unified patches for this? Maybe it's time to refresh the patches for buildroot; though I most of the changes seem already available.
I think it would be really nice if we could unify these efforts to have a native GNU/Linux toolchain, since commercially noone seems to be interested in this (resulting IMHO in less good systems: it simply does not make sense developing Linux on a Windows machine, it's like trying to join the traffic on a highway with a bicycle).- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi marc,
I'd like to thank you for the great help from your site. I would join with you to work out a better tools/apps building on Linux. Let me know what I can help. I will make unified diff. The Emacs is default to context diff. I just set it to unified mode. Do you have progress to build busybox and apps inside buildroot yet?- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- originally posted by hippo@Dec 28 2005, 03:06 PM do you have progress to build busybox and apps inside buildroot yet? --- Quote End --- As for busybox, that should not be much of a problem; but since we have a perl build environment for other platforms that builds busybox seperately; I kept busybox out of buildroot. As long as the applets are supported by the arch of course; the same goes (basically) for the other apps in buildroot. Some will work with or without modifications others will not. I haven't done much work there; since we shifted back to MMU archs (decisions above my head).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I could only agree that MMU makes the different.
Again the patch to support minx in unified diff. linux-2.6.x/include/asm-nios2nommu/bitops.h--- bitops.h 2005/11/10 06:55:12 1.1
+++ bitops.h 2005/11/10 06:56:58
@@ -469,4 +469,11 @@
# define ext2_find_first_zero_bit find_first_zero_bit
# define ext2_find_next_zero_bit find_next_zero_bit
+/* Bitmap functions for the minix filesystem. */
+#define minix_test_and_set_bit(nr,addr) test_and_set_bit(nr,addr)
+#define minix_set_bit(nr,addr) set_bit(nr,addr)
+#define minix_test_and_clear_bit(nr,addr) test_and_clear_bit(nr,addr)
+#define minix_test_bit(nr,addr) test_bit(nr,addr)
+#define minix_find_first_zero_bit(addr,size) find_first_zero_bit(addr,size)
+
# endif /* _ASM_NIOS_BITOPS_H */
About the busybox, you can also use the stable release 1.01. http://busybox.net/downloads/busybox-1.01.tar.bz2 (http://busybox.net/downloads/busybox-1.01.tar.bz2) With the patch. --- modutils/insmod.c 2005/12/28 11:32:46 1.1
+++ modutils/insmod.c 2005/12/28 11:33:20
@@ -4022,7 +4022,7 @@
fstat(fd, &st);
len = st.st_size;
- map = mmap(NULL, len, PROT_READ, MAP_SHARED, fd, 0);
+ map = mmap(NULL, len, PROT_READ, MAP_PRIVATE, fd, 0);
if (map == MAP_FAILED) {
bb_perror_msg_and_die("cannot mmap `%s'", filename);
}
--- Makefile 2005/12/28 09:14:17 1.1
+++ Makefile 2005/12/28 13:16:09
@@ -123,9 +123,18 @@
include $(patsubst %,%/Makefile.in, $(SRC_DIRS))
-include $(top_builddir)/.depend
-busybox: $(ALL_MAKEFILES) .depend include/config.h $(libraries-y)
+busybox: busybox.elf
+ $(APP_PLUGIN)/bin/elf2flt -s 16000 -o $@ $<
+
+#
+# Make a relocatable ELF file.
+#
+%.elf : %.bin
+ $(LD) -T $(APP_PLUGIN)/scripts/elf2flt.ld -Ur -o $@ $<
+
+busybox.bin: $(ALL_MAKEFILES) .depend include/config.h $(libraries-y)
$(CC) $(LDFLAGS) -o $@ -Wl,--start-group $(libraries-y) $(LIBRARIES) -Wl,--end-group
- $(STRIPCMD) $@
+# $(STRIPCMD) $@
busybox.links: $(top_srcdir)/applets/busybox.mkll include/config.h $(top_srcdir)/include/applets.h
- $(SHELL) $^ >$@
@@ -272,7 +281,7 @@
docs/busybox pod2htm* *.gdb *.elf *~ core .*config.log
docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
docs/busybox.net/BusyBox.html busybox.links libbb/loop.h
- .config.old .hdepend busybox
+ .config.old .hdepend busybox *.bin
- rm -rf _install
- find . -name .\*.flags -exec rm -f {} \;
- find . -name \*.o -exec rm -f {} \;
--- Rules.mak 2005/12/28 09:17:00 1.1
+++ Rules.mak 2005/12/28 13:34:54
@@ -71,12 +71,13 @@
# If you are using Red Hat 6.x with the compatible RPMs (for developing under
# Red Hat 5.x and glibc 2.0) uncomment the following. Be sure to read about
# using the compatible RPMs (compat-*) at http://www.redhat.com !
-#LIBCDIR:=/usr/i386-glibc20-linux
+LIBCDIR?=$(UCLIBC_PLUGIN)
+KERNEL_INCLUDE=$(shell echo $(KERNEL_BUILD_DIRECTORY))/include
#
# For other libraries, you are on your own. But these may (or may not) help...
-#LDFLAGS+=-nostdlib
-#LIBRARIES:=$(LIBCDIR)/lib/libc.a -lgcc
-#CROSS_CFLAGS+=-nostdinc -I$(LIBCDIR)/include -I$(GCCINCDIR)
+LDFLAGS+=-nostdlib -Wl,-r -Wl,-d -L$(LIBCDIR)/lib $(LIBCDIR)/lib/crt0.o
+LIBRARIES:=$(LIBCDIR)/lib/libc.a -lgcc
+CROSS_CFLAGS+=-nostdinc -I$(LIBCDIR)/include -I$(KERNEL_INCLUDE) -funsigned-char -iwithprefix include -D__uClinux__
# GCCINCDIR:=$(shell gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
WARNINGS=-Wall -Wstrict-prototypes -Wshadow
@@ -96,6 +97,7 @@
-e 's/sh/sh/'
-e 's/mips-.*/mips/'
-e 's/mipsel-.*/mipsel/'
+ -e 's/nios2-.*/nios2nommu/'
-e 's/cris.*/cris/'
)
endif
Or use the snapshot. http://busybox.net/downloads/busybox-snapshot.tar.bz2 (http://busybox.net/downloads/busybox-snapshot.tar.bz2) With the patch. --- Makefile 2005/12/27 13:07:23 1.1
+++ Makefile 2005/12/28 14:52:08
@@ -211,9 +211,18 @@
endif# ifneq ($(strip $(HAVE_DOT_CONFIG)),y)
-busybox: .depend $(libraries-y)
+busybox: busybox.elf
+ $(APP_PLUGIN)/bin/elf2flt -s 16000 -o $@ $<
+
+#
+# Make a relocatable ELF file.
+#
+%.elf : %.bin
+ $(LD) -T $(APP_PLUGIN)/scripts/elf2flt.ld -Ur -o $@ $<
+
+busybox.bin: .depend $(libraries-y)
$(CC) $(EXTRA_CFLAGS) $(LDFLAGS) -o $@ -Wl,--start-group $(libraries-y) $(LIBRARIES) -Wl,--end-group
- $(STRIPCMD) $@
+# $(STRIPCMD) $@
busybox.links: $(top_srcdir)/applets/busybox.mkll include/bb_config.h $(top_srcdir)/include/applets.h
- $(SHELL) $^ >$@
@@ -328,7 +337,7 @@
docs/busybox pod2htm* *.gdb *.elf *~ core .*config.log
docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
docs/busybox.net/BusyBox.html busybox.links libbb/loop.h
- .config.old busybox
+ .config.old busybox *.bin
- rm -rf _install testsuite/links
- find . -name .\*.flags -exec rm -f {} \;
- find . -name \*.o -exec rm -f {} \;
--- Rules.mak 2005/12/27 12:56:02 1.1
+++ Rules.mak 2005/12/28 14:53:39
@@ -72,12 +72,13 @@
# If you are using Red Hat 6.x with the compatible RPMs (for developing under
# Red Hat 5.x and glibc 2.0) uncomment the following. Be sure to read about
# using the compatible RPMs (compat-*) at http://www.redhat.com !
-#LIBCDIR:=/usr/i386-glibc20-linux
+LIBCDIR?=$(UCLIBC_PLUGIN)
+KERNEL_INCLUDE=$(shell echo $(KERNEL_BUILD_DIRECTORY))/include
#
# For other libraries, you are on your own. But these may (or may not) help...
-#LDFLAGS+=-nostdlib
-#LIBRARIES:=$(LIBCDIR)/lib/libc.a -lgcc
-#CROSS_CFLAGS+=-nostdinc -I$(LIBCDIR)/include -I$(GCCINCDIR) -funsigned-char
+LDFLAGS+=-nostdlib -Wl,-r -Wl,-d -L$(LIBCDIR)/lib $(LIBCDIR)/lib/crt0.o
+LIBRARIES:=$(LIBCDIR)/lib/libc.a -lgcc
+CROSS_CFLAGS+=-nostdinc -I$(LIBCDIR)/include -I$(KERNEL_INCLUDE) -funsigned-char -iwithprefix include -D__uClinux__
# GCCINCDIR:=$(shell gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
WARNINGS=-Wall -Wstrict-prototypes -Wshadow
@@ -103,6 +104,7 @@
-e 's/sh/sh/'
-e 's/mips-.*/mips/'
-e 's/mipsel-.*/mipsel/'
+ -e 's/nios2-.*/nios2nommu/'
-e 's/cris.*/cris/'
)
endif
The .config must has, ## Build Options#
CONFIG_STATIC=y
CONFIG_LFS=y
USING_CROSS_COMPILER=y
CROSS_COMPILER_PREFIX="nios2-elf-"
EXTRA_CFLAGS_OPTIONS="-Dfork=vfork"
# # Installation Options# # CONFIG_INSTALL_NO_USR is not set
PREFIX="/usr/local/src/nios2/build/rootfs"
Then build, make UCLIBC_PLUGIN=/usr/local/nios2-elf APP_PLUGIN=/usr/local/nios2-elf KERNEL_BUILD_DIRECTORY=/usr/local/src/nios2/build/kernel menuconfig
make UCLIBC_PLUGIN=/usr/local/nios2-elf APP_PLUGIN=/usr/local/nios2-elf KERNEL_BUILD_DIRECTORY=/usr/local/src/nios2/build/kernel
make UCLIBC_PLUGIN=/usr/local/nios2-elf APP_PLUGIN=/usr/local/nios2-elf KERNEL_BUILD_DIRECTORY=/usr/local/src/nios2/build/kernel install
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is about how to update uClibc to 0.9.28 stable release.
http://www.uclibc.org/downloads/uclibc-0.9.28.tar.bz2 (http://www.uclibc.org/downloads/uclibc-0.9.28.tar.bz2) You should config the lib install dir to a new place. And change the UCLIBC_PLUGIN for busybox and apps to this new place. You should turn on "wide char support" in "string and stdio support" for busybox to work. After installed the new uclibc, make clean and rebuild busybox and apps. Then update kernel image with initramfs. The daily snapshot of uClibc is still broken for nios2. Patch,--- Rules.mak 2005/12/29 07:20:49 1.1
+++ Rules.mak 2005/12/30 01:43:32
@@ -266,7 +266,9 @@
# If -msoft-float isn't supported, we want an error anyway.
# Hmm... might need to revisit this for arm since it has 2 different
# soft float encodings.
+ifneq ($(strip $(TARGET_ARCH)),nios2)
CPU_CFLAGS += -msoft-float
+endif
ifeq ($(strip $(TARGET_ARCH)),arm)
# No longer needed with current toolchains, but leave it here for now.
# If anyone is actually still using gcc 2.95 (say), they can uncomment it.
--- libc/sysdeps/linux/nios2/crt0.S 2005/12/29 07:03:01 1.1
+++ libc/sysdeps/linux/nios2/crt0.S 2005/12/30 03:07:54
@@ -6,7 +6,8 @@
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License. See the file COPYING.LIB in the main
* directory of this archive for more details.
*
* Written by Wentao Xu <wentao@microtronix.com>
+ * udpated by hippo for uClibc 0.9.28 and newer
*
*/
@@ -18,7 +19,8 @@
.type __start,@function
.weak _init
.weak _fini
- .type __uClibc_start_main,@function
+ .type main,@function
+ .type __uClibc_main,@function
.type __h_errno_location, @function
.type _stdio_init, @function
.type _stdio_term, @function
@@ -36,9 +38,10 @@
addi gp, gp, %lo(_gp)
/* load argc, argv, envp from stack */
- ldw r4, 0(sp)
- ldw r5, 4(sp)
- ldw r6, 8(sp)
+ movhi r4, %hi(main)
+ ori r4, r4, %lo(main) /* main */
+ ldw r5, 0(sp) /* argc */
+ ldw r6, 4(sp) /* argv */
/* load the 4th arg */
movhi r7, %hi(_init)
@@ -48,17 +51,19 @@
movhi r8, %hi(_fini)
ori r8, r8, %lo(_fini)
stw r8, 0(sp)
-
+ stw r2, 4(sp) /* rtld_fini */
+ stw sp, 8(sp) /* stack_end */
+
/* call uClibc_main, shouldn't return */
# ifdef __PIC__
/* just pray 16 bit offset is enough */
- br __uClibc_start_main
+ br __uClibc_main
# else
- call __uClibc_start_main
+ call __uClibc_main
# endif
/* crash in the event of return */
__exit:
movui r2, TRAP_ID_SYSCALL
movui r3, __NR_exit
- trap
+ trap
Run, #fix for autoconf.h
make ARCH_CFLAGS="-I(your kernel build/include)" menuconfig
make ARCH_CFLAGS="-I(your kernel build/include)"
make ARCH_CFLAGS="-I(your kernel build/include)" install
The .config must have, ## Target Architecture Features and Options#
KERNEL_SOURCE="your kernel source linux-2.6.x"# # uClibc development/debugging options#
CROSS_COMPILER_PREFIX="nios2-elf-"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
TO_BE_DONE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
frist, make sure you have the compiler build,
$ nios2-elf-gcc -v
Reading specs from /usr/local/lib/gcc/nios2-elf/3.4.1/specs
Configured with: ../../gcc/configure --target=nios2-elf --enable-languages=c
Thread model: single
gcc version 3.4.1 (Altera Nios II 5.1 b73)
then, the hardware include header generation. note, this is a signle line command. make ARCH=nios2nommu O=/usr/local/src/nios2/build/kernel CROSS_COMPILE=nios2-elf- hwselect SYSPTF=/usr/local/src/nios2/build/yoursystem.ptf
next the config, note, this is a signle line command. make ARCH=nios2nommu O=/usr/local/src/nios2/build/kernel CROSS_COMPILE=nios2-elf- menuconfig
next, the compile, note, this is a signle line command. make ARCH=nios2nommu O=/usr/local/src/nios2/build/kernel CROSS_COMPILE=nios2-elf-
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Another helpful info from uclibc mailing list,
<div class='quotetop'>QUOTE </div> --- Quote Start --- basic Buildroot from scratch tutorial found David Smoot davidsmoot at gmail.com Thu Dec 1 09:11:32 PST 2005 * Previous message: [gmail] NFS and Buildroot ...again. * Next message: basic Buildroot from scratch tutorial found * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] For the 90% of listers that are relatively fluent in busybox /uclibc, ignore this email, this is for the small percentage like me who joined this list because they lack understanding of busybox. I'm still a relative newbie on busybox but have been working in my spare time to pull myself up the learning curve. I stumbled across some pretty good reference material by accident this morning that has greatly helped me understand busybox and uclibc. Thought I would share: http://free-electrons.com/articles/elfs/en (http://free-electrons.com/articles/elfs/en) A tutorial on a quick embedded system buildup using buildroot. http://free-electrons.com/articles/optimizations/en (http://free-electrons.com/articles/optimizations/en) A longer more general embedded linux presentation. Anyway, it helped me so maybe someone else on the list can benefit. David Smoot[/b] --- Quote End ---- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have met the same problem like mountain8848.so unlucky!
slackware 9.0,gcc 3.2.2 --- Quote Start --- I got some errors when build the cross tool chain 2. ================================================== windows_src: binutils->error gcc->ok elf2flt->ok here is the gcc error...
checking whether ANSI C string concatenation works ... yes
*** ld does not support target nios2-elf
*** see ld/configure.tgt for supported targets
make: *** Error 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have setup a "fresh and clean" slackware 9.0 with only A+D+glibc.
It builds and there is no such problem. Try "unset CC".- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You should try out the new buildroot.
Just set arch to "nios2" in "make menuconfig". http://forum.niosforum.com/forum/index.php?showtopic=3129 (http://forum.niosforum.com/forum/index.php?showtopic=3129)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page