Version 20 (modified by 15 years ago) (diff) | ,
---|
MutekH quick start guide for SoCLib platform
This quickstart guide only present 2 target plaforms among those supported by MutekH. These platforms are linux/darwin user process and the SoCLib hardware simulator. Other supported platforms are multiprocessors IBMPC/x86 and some micro-controllers.
MutekH can be compiled for Mips, Arm, PowerPC, x86 and Avr porcessors.
MutekH configurations
The MutekH kernel source code is fully configurable and can be tweaked to adapt hardware platform and application needs. Configuration is handled by a dedicated tool which check dependencies and other relationships between the large set of available configuration tokens.
This document present two source code configurations:
- A first MutekH build designed to run embedded in a unix process.
This is the simplest way to have MutekH running as it does not need extra hardware or simulator. It enables running MutekH natively on the host processor. This configuration suffer from several limitations regarding available peripheral, but it is usefull to test and debug algorithms.
The first example below show how to run MutekH using this configuration.
- The second example below explain how to setup a SoCLib hardware simulator with 4 RISC processor (Mips, Arm or PowerPC).
Part 1 : Running MutekH in a UNIX process
This first example only require to get the MutekH source code.
Getting the sources
svn co -r 1024 https://www-asim.lip6.fr/svn/mutekh/trunk/mutekh
Source tree is organized this way:
mutekh |-- arch contains hardware platforms modules for hexo |-- cpu contains processors modules for hexo |-- doc documentation |-- drivers device and filesystem drivers |-- examples Test and example programs |-- gpct container library, available as a separate project |-- hexo Hexo hardware abstraction layer |-- libc standard C library |-- libm standard math library |-- libnetwork netwotk stack |-- libpthread posix thread library |-- libvfs virtual File System |-- mutek hardware independant kernel code |-- scripts build system scripts `-- tools some usefull tools
More directories are actually available with other libraries and features.
Writing the example source code
Note: This example is available directly from examples/hello
in source tree.
- Creating a new modules directory
mkdir hello cd hello
- Writing the source code in
hello.c
#include <pthread.h> pthread_mutex_t m; pthread_t a, b; void *f(void *param) { while (1) { pthread_mutex_lock(&m); printf("(%i) %s", cpu_id(), param); pthread_mutex_unlock(&m); pthread_yield(); } } int main() { pthread_mutex_init(&m, NULL); pthread_create(&a, NULL, f, "Hello "); pthread_create(&b, NULL, f, "World\n"); }
- Writing the
Makefile
objs = hello.o
Writing the MutekH configuration file
Our configuration file is named hello/config_emu
.
Details about configuration file is explained later.
This configuration file describe the following things:
- The application license, used to check license consistency for modules in use,
- The target hardware platform and processor
- Use of the POSIX threads library
- Use of terminal output
- Declaration of a new "hello" modules
The MutekH source code is split in modules. We now have to declare our new module to have it compiled along with the kernel by the build system. As modules may be located out of the source tree, we have to specify the module directory.
# Application license CONFIG_LICENSE_APP_LGPL # Platform types CONFIG_ARCH_EMU # Processor types CONFIG_CPU_X86_EMU # Mutek features CONFIG_PTHREAD CONFIG_MUTEK_CONSOLE # Device drivers CONFIG_DRIVER_CHAR_EMUTTY # Code compilation options CONFIG_COMPILE_DEBUG # New source code module to be compiled CONFIG_MODULES hello:%CONFIGPATH
Compiling the application along with MutekH
Simply type:
make CONF=hello/config_emu
Once the compilation process has finished, the executable binary is available:
kernel-emu-x86-emu.out
Execution
Simply execute the program as a normal unix executable:
$ ./kernel-emu-x86-emu.out (0) Hello (0) World (0) Hello (0) World (0) Hello (0) World (0) Hello (0) World ...
Part2 : Running MutekH in a multiprocessor SoCLib simulator
Getting SoCLib
We now need to have a working SoCLib install. SoCLib installation is explained here: https://www.soclib.fr/trac/dev/wiki/InstallationNotes
SoCLib platform description
The SoCLib source tree contains a platform dedicated to this tutorial:
soclib/soclib/platform/topcells/caba-vgmn-mutekh_tutorial/
.
Getting the cross-compilers
You can rely on the tools/crossgen.mk
script which comes along with MutekH to build some GNU cross-toolchains:
$ tools/crossgen.mk $ tools/crossgen.mk all TARGET=mipsel-unknown-elf
MutekH Configuration
Note: This example is readily available in the examples/hello
directory in the MutekH source tree.
The MutekH configuration for the 4 Mips processors platform is in the trunk/mutekh/examples/hello/config_soclib_mipsel file.
You may have noticed the processor definition change: we are now building for a 4 little-endian Mips processors platform.
Have a look to the BuildSystem page for more information about configuration system and configuration file format. The MutekH API reference manual describes all available configuration tokens.
Platform description
This hardware platform uses now hardware enumeration (plug and play), so the CONFIG_ARCH_DEVICE_TREE
token is defined in the configuration file. It will let the kernel get the platform layout description from a FlattenedDeviceTree which will be built-in.
Therefore, we have to provide the platform description FlattenedDeviceTree and add it to the Makefile to have it compiled in.
The hello/Makefile
file must contain:
objs = hello.o platform-mips.o
The current FlattenedDeviceTree source file is trunk/mutekh/examples/hello/platform-mips.dts.
Compiling the application along with MutekH
The MutekH kernel and the application may be built out of the source tree.
Change to the SoCLib platform directory and apply the following steps to experiment with out of tree compilation. You have to setup the following variables:
MUTEKH_DIR
- Path to MutekH source tree
APP
- Path to application source
CONFIG
- MutekH configuration file name
$ cd soclib/soclib/platform/topcells/caba-vgmn-mutekh_tutorial $ make MUTEKH_DIR=~/mutekh/ APP=~/mutekh/examples/hello CONFIG=config_soclib_mipsel all
This will build the MutekH kernel along with the application. You can still build MutekH separately as explained in the first part. The simulator can then be built using:
$ cd soclib/soclib/platform/topcells/caba-vgmn-mutekh_tutorial $ make system.x
Execution
The simulator needs the MutekH executable file name and the processor type and the number of processors of this type:
$ ./system.x mutekh/kernel-soclib-mips.out:mips32:4
You may want to refer to other articles and documents available from the main page to go further with MutekH.
The SoCLib home page provides a livecd image with more advanced examples ready to compile and run. These examples are using older MutekH revisions though.
Attachments (4)
- mutekh_overview.gif (2.8 KB) - added by 17 years ago.
- arch_emu.gif (1.3 KB) - added by 17 years ago.
- arch_4proc.gif (4.9 KB) - added by 17 years ago.
- mutekh_overview_emu.gif (2.7 KB) - added by 17 years ago.
Download all attachments as: .zip