Klone on uclinux

stewy edited this page Oct 9, 2013 · 3 revisions

uClinux Installation

Install uClinux as detailed in http://www.uclinux.org/get_started/uClinuxbeginner.html doing the basic steps detailed in the following paragraphs:

  • download the tools
  • m68k-elf toolchain
  • uClinux distribution
  • compiling the basics

You should end up having the m68k-elf toolchain in /usr/local/bin - which shall be in your shell’s PATH - while the uClinux tree at /opt/uClinux-dist.

Custom Toolchain

Next, since KLone has no builtin default for uClinux, you need to create a custom MaKL toolchain with needed C and LD flags:

UCLIBC_INCS = /opt/uClinux-dist/uClibc/include

CC = m68k-elf-gcc
CFLAGS = -I${UCLIBC_INCS} -m5200 -msep-data -D__UCLINUX__
LDFLAGS = -Wl,-elf2flt -lc 
CXX = m68k-elf-g++
CXXFLAGS = ${CFLAGS}
AR = m68k-elf-ar
RANLIB = m68k-elf-ranlib
LD = m68k-elf-ld
NM = m68k-elf-nm
STRIP = m68k-elf-strip

This file will be saved as m68k-elf.tc in your KLone application top-level directory.

KLone Makefile

Now it’s time for the top-level KLone Makefile:

KLONE_VERSION = 3.1.0
KLONE_CUSTOM_TC = $(CURDIR)/m68k-elf.tc
WEBAPP_DIR = $(CURDIR)/webapp
include klapp.mk

klapp.mk: ; wget -O $@ http://koanlogic.com/klone/klapp.mk

Cross Compilation

Ready to compile:

$ make

If the kloned link is broken, the server has been built and you can find it at: klone-${KLONE_VERSION}/build/target/klone-core-${KLONE_VERSION}/src/kloned/kloned.

Configuration and Running

Since uClinux has no fork(2) system call, the iterative server model is the only available choice - i.e. client requests are served sequentially. The kloned.conf file shall be something like the following:

server_list main

main.model  iterative
main.type   http
main.addr   tcp4://*:8080

Also you may want to use the -F command line argument to tell kloned not to detach from the controlling terminal via daemon(3) which in turn would call fork(2):

$ ./kloned -F