Changes between Initial Version and Version 1 of Arch/Soclib/Tutorial


Ignore:
Timestamp:
Dec 3, 2009, 12:57:49 PM (14 years ago)
Author:
Nicolas Pouillon
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Arch/Soclib/Tutorial

    v1 v1  
     1= MutekH tutorial for SoCLib platform =
     2
     3This guide explain how to run MutekH on a [wiki:Arch/Soclib SoCLib] hardware simulator.
     4This is allow easy experimentation with advanced multi-processor programming.
     5
     6You are '''highly encouraged''' to first follow the [wiki:QuickStartUnix MutekH as Unix process quick start guide]
     7which introduces more basic concepts.
     8
     9MutekH for SoCLib can be compiled for Mips, Arm, PowerPC processors.
     10Other processors are available with different platforms.
     11
     12== The SoCLib platform ==
     13
     14The MutekH kernel source code is fully configurable and can be tweaked to adapt hardware platform
     15and application needs. Configuration is handled by a dedicated tool which check dependencies and
     16other relationships between the large set of available configuration tokens.
     17
     18The example below explains how to setup a SoCLib hardware simulator with 4 RISC processor (Mips, Arm or PowerPC).
     19
     20[[BR]][[BR]][[Image(arch.png,nolink)]][[BR]][[BR]]
     21
     22=== Getting SoCLib ===
     23
     24We now need to have a working SoCLib install. SoCLib installation is explained here: https://www.soclib.fr/trac/dev/wiki/InstallationNotes
     25
     26=== SoCLib platform description ===
     27
     28The SoCLib source tree contains a platform dedicated to this tutorial:
     29{{{soclib/soclib/platform/topcells/caba-vgmn-mutekh_soclib_tutorial/}}}
     30
     31=== Getting the cross-compilers ===
     32
     33SoCLib installation nodes already provides a way to get cross-compiler, if you don't already have them, MutekH holds a tool
     34to build a complete cross-compilation toolchain:
     35
     36The script is in [source:trunk/mutekh/tools/crossgen.mk@1183 tools/crossgen.mk]:
     37{{{
     38 $ tools/crossgen.mk
     39[prints some help]
     40 $ tools/crossgen.mk all TARGET=mipsel-unknown-elf
     41}}}
     42
     43== The MutekH part ==
     44
     45=== Getting the sources ===
     46
     47{{{
     48svn co -r 1183 https://www-asim.lip6.fr/svn/mutekh/trunk/mutekh
     49}}}
     50
     51=== Writing the example source code ===
     52
     53Note: This example is available directly from [source:trunk/mutekh/examples/hello@1183 examples/hello] directory in source tree.
     54
     55 * Writing the source code in `hello.c`
     56{{{
     57#include <pthread.h>
     58
     59pthread_mutex_t m;
     60pthread_t a, b;
     61
     62void *f(void *param)
     63{
     64  while (1)
     65    {
     66      pthread_mutex_lock(&m);
     67      printf("(%i) %s", cpu_id(), param);
     68      pthread_mutex_unlock(&m);
     69      pthread_yield();
     70    }
     71}
     72int main()
     73{
     74  pthread_mutex_init(&m, NULL);
     75  pthread_create(&a, NULL, f, "Hello ");
     76  pthread_create(&b, NULL, f, "World\n");
     77}
     78}}}
     79
     80 * Writing the `Makefile`
     81{{{
     82objs = hello.o
     83}}}
     84
     85
     86=== Writing the MutekH configuration ===
     87
     88The MutekH configuration for the 4 Mips processors platform is in the [source:trunk/mutekh/examples/hello/config examples/hello/config] file.
     89
     90This file only holds information about the application (here a simple pthread application) and relies upon files in the [source:trunk/mutekh/examples/common@1183 examples/common] directory for the platform definitions.
     91
     92Have a look to the BuildSystem page for more information about configuration system and configuration file format.
     93
     94The [http://www.mutek.fr/www/mutekh_api/ MutekH API reference manual] describes all available configuration tokens.
     95
     96=== Platform description ===
     97
     98The MutekH software uses hardware enumeration to get details about available hardware in the platform, so the `CONFIG_ARCH_DEVICE_TREE` token is defined in the [source:trunk/mutekh/examples/common/platforms-soclib.conf@1183 examples/common/platforms-soclib.conf] configuration file. It will let the kernel get the platform layout description from a FlattenedDeviceTree which will be built into the kernel.
     99
     100Therefore, the build also compiles the correct FlattenedDeviceTree from the platform name.
     101
     102The current FlattenedDeviceTree source file is
     103[source:trunk/mutekh/examples/common/pf_soclib_tutorial_ppc.dts examples/common/pf_soclib_tutorial_ppc.dts],
     104[source:trunk/mutekh/examples/common/pf_soclib_tutorial_arm.dts (for arm)],
     105[source:trunk/mutekh/examples/common/pf_soclib_tutorial_mips.dts (for mips)].
     106
     107=== Compiling the application along with MutekH ===
     108
     109The MutekH kernel and the application may be built out of the source tree.
     110
     111Change to the SoCLib platform directory and apply the following steps to experiment
     112with out of tree compilation. You have to setup the following variables:
     113
     114 `MUTEKH_DIR`::
     115   Path to MutekH source tree
     116 `APP`::
     117   Path to application source
     118 `CONFIG`::
     119   MutekH configuration file name
     120 `BUILD`::
     121   MutekH build option list (target architecture, cpu type, …)
     122
     123See the `config.mk` file in the tutorial platform directory for more information.
     124
     125{{{
     126$ cd soclib/soclib/platform/topcells/caba-vgmn-mutekh_soclib_tutorial
     127$ make MUTEKH_DIR=/path/to/mutekh
     128}}}
     129
     130This will build the MutekH kernel along with the application.
     131You can still build MutekH separately as explained in the first part. The simulator can then be built using:
     132
     133{{{
     134$ cd soclib/soclib/platform/topcells/caba-vgmn-mutekh_tutorial
     135$ make system.x
     136}}}
     137
     138== Execution ==
     139
     140You can optionally pass an alternative kernel to the simulator, but this defaults to the correct kernel name if you followed the tutorial until here.
     141{{{
     142$ ./system.x mutekh/kernel-soclib-ppc.out
     143}}}
     144
     145You may want to refer to other articles and documents available from the main page to go further with MutekH.
     146
     147The [soclib:wiki: SoCLib] home page provides a livecd image with more advanced examples ready to compile and run. These examples are using older MutekH revisions though.
     148
     149Other more advanced topics and guides are available from the [wiki: Main page].