How-to add a user space application to uClinux

From Klaus' wiki
Revision as of 14:58, 13 February 2011 by Klaus (Talk | contribs)

Jump to: navigation, search

First as root user goto the uClinux-dist directory.

The examples below are all for an hellowworld applications. Replace helloworld with the wanted application name.

Edit user/Makefile and add the line with "helloworld" exactly as shown below.

dir_  =
dir_$(CONFIG_JFFS_FS)                       += mtd-utils
dir_$(CONFIG_JFFS2_FS)                      += mtd-utils

Create a directory for the application

$ mkdir user/helloworld

Next add support in the config help file. Edit config/ and add the helloworld part as shown below. NOTE: there must be two spaces before text in the comments, which cannot be more than seventy characters long.

  Build AppWeb with the ability to dynamically load AppWeb modules.
  AppWeb modules are a convenient way to add your application code
  to AppWeb.
  A user space application saying hello to the world.
  Install "agetty" in /bin
  Approx. binary size: 19k

Edit the fine config/ Add a line as shown below:

mainmenu_option next_comment
comment 'Miscellaneous Applications'
bool 'helloworld'               CONFIG_USER_HELLOWORLD_HELLOWORLD
bool '7za'                      CONFIG_USER_P7ZIP_7ZA

The application can now be found in top of the Miscellaneous Application menu If the directory contains several binaries another line can be added, where the last "HELLOWORLD" is the name of the binary file to be included.

Next a proper Makefile must be established in user/helloworld.

   EXEC = helloworld
   OBJS = helloworld.o
   all: $(EXEC)
   $(EXEC): $(OBJS)
        $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)
        $(ROMFSINST)    /bin/$(EXEC)
        -rm -f $(EXEC) *.elf *.gdb *.o

If there are more binaries to be produced use the skeleton to create a Makefile

   EXECS = helloworld goodbyeworld
   OBJS =  helloworld.o goodbyeworld.o
   all: $(EXECS)
   $(EXECS): $(OBJS)
        $(CC) $(LDFLAGS) -o $@ $@.o $(LDLIBS)
        $(ROMFSINST) -e CONFIG_USER_HELLOWORLD_HELLOWORLD             /bin/helloworld
        $(ROMFSINST) -e CONFIG_USER_HELLOWORLD_GOODBYEWORLD           /bin/goodbyeworld

NOTE: Remember not to copy directly from this page. All indentations are done with tab's not spaces!

Finally create the program.


Now when all this are in place run

$ make menuconfig

After checking the application build a new kernel and filesystem image. Check that helloworld are in romfs/bin !

Happy hacking on your own applications from here.