Porting Apps to uClinux-dist

Showing results for 
Search instead for 
Did you mean: 

Porting Apps to uClinux-dist

Porting Apps to uClinux-dist



Before you do the porting, you should check if if the apps/libs are already ported in uClinux-dist (uclinux.org) or Blackfin uclinux-dist.

If none exist, you can add the apps/libs into uClinux-dist. The uClinux-dist uses the build system from Linux kernel, with Kconfig and Makefile. You will need to add an config entry in Kconfig, and a rule in Makefile. Please read about Kconfig in the file nios2-linux/linux-2.6/Documentation/kbuild/kconfig-language.txt.

Add hello apps to uClinux-dist


Take the hello apps example,


1. edit file user/Kconfig, add an entry after the line of menu "Miscellaneous Applications",


   bool "hello"


    The hello example


2. add a line to user/Makefile , dir_$(CONFIG_USER_HELLO_HELLO) += hello


3. mkdir ~/uClinux-dist/user/hello

   put hello.c in user/hello dir,


4. create Makefile in user/hello dir,


EXEC = hello


OBJS = hello.o


all: $(EXEC)


$(EXEC): $(OBJS)

$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)






-rm -f $(EXEC) *.elf *.gdb *.o



Staging dir structure

In nios2 uclinux, a staging dir is created at built time, and libs/apps are installed to this dir. Then "make romfs" will copy them to "romfs" dir.

This is very similar to the staging dir of "buildroot".

You may take exmples from user/net-snmp, lib/libgmp.

In user/net-snmp, there are

Makefile net-snmp-5.2.1

In lib/libgmp, there are

gmp-4.2.2 Makefile

The sources are located in a subdir, and a Makefile is added to build and install. You should take a look at the Makefile.

all: build-$(VER)/Makefile

   $(MAKE) -C build-$(VER) install DESTDIR=$(STAGEDIR)




Many packages use to configure or automake/autoconf tools. Please find documents about them from gnu.org or Redhat's. 

GNU Autoconf, Automake, and Libtool (http://sources.redhat.com/autobook/ )

You can find out options with "./configure --help". 


If you got unknow machine type error, add nios2 to config.sub .


--- config.sub~   2003-12-23 20:07:13.000000000 +0800

+++ config.sub   2006-07-12 14:47:00.000000000 +0800

@@ -278,6 +278,11 @@

    m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)



+   nios2 | nios2-* | nios2 | nios2-*)

+      basic_machine=nios2-altera

+      os=-linux

+       ;;


    # We use `pc' rather than `unknown'

    # because (1) that's what they normally are, and

    # (2) the word "unknown" tends to confuse beginning users.


Many packages use autotools to configure. The configure option is defined in uClinux-dist/vendors/Altera/nios2/config.arch,


CONFIGURE_HOST = nios2-linux-uclibc

CONFIGURE_SHARED_ENABLE := --disable-shared

CONFIGURE_SHARED_WITH   := --without-shared

CONFIGURE_BUILD := $(shell sh $(ROOTDIR)/tools/config.guess)

CONFIGURE_OPTS  := \\\\\\\

   --host=$(CONFIGURE_HOST) \\\\\\\

   --build=$(CONFIGURE_BUILD) \\\\\\\

   --prefix=/usr \\\\\\\

   --sysconfdir=/etc \\\\\\\

   --datadir=/usr/share \\\\\\\

   --mandir=/usr/share/man \\\\\\\

   --infodir=/usr/share/info \\\\\\\

   --localstatedir=/var/lib \\\\\\\



   --disable-dependency-tracking \\\\\\\


ifneq ($(findstring s,$(MAKEFLAGS)),)




You may use the uClinux-dist/tools/autotools.mk to port packages. Please look at the Makefile of,


lib/flex/Makefile:include $(ROOTDIR)/tools/autotools.mk

lib/ncurses/Makefile:include $(ROOTDIR)/tools/autotools.mk

lib/libpng/Makefile:include $(ROOTDIR)/tools/autotools.mk

lib/lzo/Makefile:include $(ROOTDIR)/tools/autotools.mk


fork() is not supported for nommu, so you should use vfork() instead.

  1. if EMBED
  2.  pid = vfork();
  3. #else
  4.  pid = fork();
  5. #endif


bcopy/bzero/index/rindex macro

These func are marked legacy. They should not be used. You can replace them with memmove/memset/strchr/strrchr.


Version history
Last update:
‎12-19-2022 11:59 AM
Updated by: