<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://www.ethernut.de/nutwiki/index.php?action=history&amp;feed=atom&amp;title=Documents%2FNTN-5_Config</id>
		<title>Documents/NTN-5 Config - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://www.ethernut.de/nutwiki/index.php?action=history&amp;feed=atom&amp;title=Documents%2FNTN-5_Config"/>
		<link rel="alternate" type="text/html" href="http://www.ethernut.de/nutwiki/index.php?title=Documents/NTN-5_Config&amp;action=history"/>
		<updated>2026-04-28T22:51:32Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.26.2</generator>

	<entry>
		<id>http://www.ethernut.de/nutwiki/index.php?title=Documents/NTN-5_Config&amp;diff=348&amp;oldid=prev</id>
		<title>Harald: Created page with &quot;&lt;div id=&quot;content&quot;&gt;  = Playing the Nut/OS Configuration Game =  Initially Nut/OS had been written for a fixed hardware, the Ethernut 1 with an ATmega103 MCU and an RTL8019AS Et...&quot;</title>
		<link rel="alternate" type="text/html" href="http://www.ethernut.de/nutwiki/index.php?title=Documents/NTN-5_Config&amp;diff=348&amp;oldid=prev"/>
				<updated>2017-07-13T07:50:14Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;lt;div id=&amp;quot;content&amp;quot;&amp;gt;  = Playing the Nut/OS Configuration Game =  Initially Nut/OS had been written for a fixed hardware, the Ethernut 1 with an ATmega103 MCU and an RTL8019AS Et...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;div id=&amp;quot;content&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Playing the Nut/OS Configuration Game =&lt;br /&gt;
&lt;br /&gt;
Initially Nut/OS had been written for a fixed hardware, the Ethernut 1 with an ATmega103 MCU and an RTL8019AS Ethernet controller. And the only supported development environment had been AVRGCC running on the Windows PC. Good old days.&lt;br /&gt;
&lt;br /&gt;
Today we have to support different targets with different CPUs, Ethernet controllers, memory layouts and I/O hardware as well as different development platforms with different compilers. Thus, system configuration became an important part.&lt;br /&gt;
&lt;br /&gt;
Since Nut/OS 3.9, a GUI became available to simplify the configuration task. The [[../../pdf/enswm28e.pdf|Nut/OS Software Manual]] provides a step by step guide on how to use this tool.&lt;br /&gt;
&lt;br /&gt;
In this paper I will present some more details about the possibilities to configure the system and how the Configurator uses these capabibilities.&lt;br /&gt;
&lt;br /&gt;
== The Make Tool ==&lt;br /&gt;
&lt;br /&gt;
Regardless of which development environment is used to build Nut/OS, [http://www.gnu.org/software/make/ GNU Make] takes over the top level control. Explaining this tool in detail is beyond the scope of this paper and to many developers of embedded systems it looks like C to PASCAL programmers, quite cryptic. But as often, the number of options make a tool look complicated while the main function is quite simple.&lt;br /&gt;
&lt;br /&gt;
When started without any option, Make will look for a file named Makefile, interpret it and perform the related actions. Some Makefiles may contain weird sequencies of characters, but all of them contain something like&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;coding&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;target: dependencies&lt;br /&gt;
        actions&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
This is interpreted by Make in the following way: To produce the &amp;lt;code&amp;gt;target&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;dependencies&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;actions&amp;lt;/code&amp;gt; are required. The three items used here are just placeholders. A real example may look like&lt;br /&gt;
&amp;lt;div class=&amp;quot;coding&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;simple.hex: simple.c simple.h                  &lt;br /&gt;
        avr-gcc -c -mmcu=atmega128 simple.c -o simple.o&lt;br /&gt;
        avr-gcc simple.o -mmcu=atmega128 -lnutdev -lnutos -o simple.elf&lt;br /&gt;
        avr-objcopy -O ihex simple.elf simple.hex&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
Be warned, this may be a real example but for Nut/OS some more steps and options are required. Anyway, it presents a good picture. If simple.c and simple.h exist, then the three given steps are required to create simple.hex. In the first step simple.c is compiled to simple.o. In the second step simple.o is linked with libnutdev.a and libnutos.a to create simple.elf. And in the final step simple.elf is converted to simple.hex.&lt;br /&gt;
You may now argue, that this could be done by a simple batch file or shell script. You are probably right. Now imagine, what a large number of actions would be required to compile all Nut/OS source files for all supported platforms, if we would do it this way. Make simplifies this by allowing us to specify general rules like&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;coding&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;%o : %c&lt;br /&gt;
        avr-gcc -c -mmcu=atmega128 $&amp;amp;lt; -o $@&lt;br /&gt;
%elf: %o&lt;br /&gt;
        avr-gcc $&amp;amp;lt; -mmcu=atmega128 -lnutdev -lnutos -o $@&lt;br /&gt;
%hex: %elf&lt;br /&gt;
        avr-objcopy -O ihex $&amp;amp;lt; $@&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
This already looks too cryptic to many of us, but doesn't really differ from the real world example given above. The big advantage with these rules is, that we just need to write&lt;br /&gt;
&amp;lt;div class=&amp;quot;coding&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;simple.hex: simple.c simple.h&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
and Make knows, which steps are required to create &amp;lt;code&amp;gt;simple.hex&amp;lt;/code&amp;gt; from &amp;lt;code&amp;gt;simple.c&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;simple.h&amp;lt;/code&amp;gt;. That's cool, isn't it?&lt;br /&gt;
Another nice feature of Make is, that it checks automatically, which actions are required after you modified something. In other words, if you edit &amp;lt;code&amp;gt;simple.h&amp;lt;/code&amp;gt;, save your changes and run Make again, it will run all three steps again. If you modified anything else but neither &amp;lt;code&amp;gt;simple.c&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;simple.h&amp;lt;/code&amp;gt;, then Make will keep the already existing &amp;lt;code&amp;gt;simple.hex&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
However, the Nut/OS Makefiles are incomplete here, because they do not list all dependencies. All header files are excluded. Thus, if any header file is changed, you need to run&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;coding&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;make clean&lt;br /&gt;
make&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
in the build tree. The first will remove all files previously created by Make. The option &amp;lt;code&amp;gt;clean&amp;lt;/code&amp;gt; is an explicit target given on the command line. Somewhere in the Makefile there is something found like&lt;br /&gt;
&amp;lt;div class=&amp;quot;coding&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;clean:&lt;br /&gt;
        rm *.o *.hex *.elf&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
For the Windows users: The UNIX command &amp;lt;code&amp;gt;rm&amp;lt;/code&amp;gt; is similar to the DOS command &amp;lt;code&amp;gt;del&amp;lt;/code&amp;gt;. To avoid complete Makefile madness, some basic UNIX commands are included in the Windows distribution of Nut/OS as executables. You can find them in the directory &amp;lt;code&amp;gt;tools/win32&amp;lt;/code&amp;gt;. When running Make in a DOS window, make sure that your PATH points to this directory.&lt;br /&gt;
When the Configurator builds Nut/OS, it will set the correct path and will always run &amp;lt;code&amp;gt;make clean&amp;lt;/code&amp;gt; first. The next chapter will show more details about how the Configurator uses Make.&lt;br /&gt;
&lt;br /&gt;
== Make and the Nut/OS Configurator ==&lt;br /&gt;
&lt;br /&gt;
We assume, that all Configurator settings have been specified by following the Nut/OS Software Manual and that we are ready to create a new Nut/OS build tree.&lt;br /&gt;
&lt;br /&gt;
When selecting &amp;lt;code&amp;gt;Generate Build Tree&amp;lt;/code&amp;gt; from the Configurators &amp;lt;code&amp;gt;Build&amp;lt;/code&amp;gt; menu, then the directory for building Nut/OS will be created with all required subdirectories. In the top level directory of the build tree, the Configurator will additionally create three files, which will be used by the Make tool.&lt;br /&gt;
&lt;br /&gt;
The first of these files is named Makefile. It's a very simple Makefile with three targets: &amp;lt;code&amp;gt;all&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;install&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;clean&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;coding&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;all:&lt;br /&gt;
        $(MAKE) -C arch&lt;br /&gt;
...&lt;br /&gt;
install:&lt;br /&gt;
        $(MAKE) -C arch install&lt;br /&gt;
...&lt;br /&gt;
clean:&lt;br /&gt;
        $(MAKE) -C arch clean&lt;br /&gt;
...&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
Two additional features need to be explained to understand this Makefile. First note the term &amp;lt;code&amp;gt;$(MAKE)&amp;lt;/code&amp;gt;. That's how Make understands definitions similar to C makros. It may be defined somewhere else as &amp;lt;code&amp;gt;MAKE=make&amp;lt;/code&amp;gt;, however, specially &amp;lt;code&amp;gt;$(MAKE)&amp;lt;/code&amp;gt; is internally predefined. The second feature is the command line option &amp;lt;code&amp;gt;-C directory&amp;lt;/code&amp;gt;. This instructs make to change to the specified directory before starting to read the Makefile.&lt;br /&gt;
As you can see, for each target Make is called for each Nut/OS module subdirectory with the same target again. Of course, the Configurator also creates the Makefiles in these subdirectories, which are much more interesting than the top level Makefile.&lt;br /&gt;
&lt;br /&gt;
Let's stay at the top level, where the Configurator created two additional files, &amp;lt;code&amp;gt;NutConf.mk&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;UserConf.mk&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;NutConf.mk&amp;lt;/code&amp;gt; defines several macros, similar to the internally defined &amp;lt;code&amp;gt;$(MAKE)&amp;lt;/code&amp;gt;, which I explained above. When building Nut/OS for the ATmega128 using AVRGCC, this file contains&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;coding&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;MCU_ATMEGA128=atmega128&lt;br /&gt;
MCU_ATMEGA103=atmega103&lt;br /&gt;
MCU=$(MCU_ATMEGA128)&lt;br /&gt;
HWDEF=-D__HARVARD_ARCH__&lt;br /&gt;
CRUROM=crurom&lt;br /&gt;
&lt;br /&gt;
include $(top_blddir)/UserConf.mk&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
Whenever &amp;lt;code&amp;gt;$(MCU)&amp;lt;/code&amp;gt; appears in a Makefile, Make will replace it with &amp;lt;code&amp;gt;$(MCU_ATMEGA128)&amp;lt;/code&amp;gt;, which in turn is replaced by &amp;lt;code&amp;gt;atmega128&amp;lt;/code&amp;gt;.&lt;br /&gt;
The last line of NutConf.mk instructs Make to include &amp;lt;code&amp;gt;UserConf.mk&amp;lt;/code&amp;gt;, which initially contains a single line&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;coding&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;HWDEF += -DETHERNUT2&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
Here's another interesting feature of Make: We can append new string to existing macros. Together with the definition in &amp;lt;code&amp;gt;NutConf.mk&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;$(HWDEF)&amp;lt;/code&amp;gt; will be finally expanded to &amp;lt;code&amp;gt;-D__HARVARD_ARCH__ -DETHERNUT2&amp;lt;/code&amp;gt;. As long as you are using the Ethernut 2 hardware, this is just fine. When building Nut/OS, this compile option is simply ignored. However, the same entry is added by the Configurator when creating the sample directory and should be removed before compiling any of the samples. Hey, wait, we are building Nut/OS. More on the sample applications later.&lt;br /&gt;
Each time, when you re-create the build tree, the Configurator will overwrite existing files in the build tree. Thus, do not edit them, because your changes will get lost. &amp;lt;code&amp;gt;UserConf.mk&amp;lt;/code&amp;gt; is an exception. It is initially created, if it doesn't exists. If it exists, the Configurator will not touch it. You can use it to add additional compile options, for example.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;coding&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;HWDEF += -g3 -gdwarf-2&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
Now let's dive into one of the subdirectories and see, what the Configurator created there. We choose subdirectory os, which mostly contains the Nut/OS kernel code. Wonder! It contains nothing but another Makefile.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;coding&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;PROJ =  libnutos&lt;br /&gt;
&lt;br /&gt;
top_srcdir = c:/ethernut/nut&lt;br /&gt;
top_blddir = c:/ethernut/nutbld&lt;br /&gt;
&lt;br /&gt;
VPATH = $(top_srcdir)/os&lt;br /&gt;
&lt;br /&gt;
SRCS =   heap.c bankmem.c thread.c timer.c event.c devreg.c confos.c version.c \&lt;br /&gt;
         semaphore.c mutex.c msg.c osdebug.c tracer.c&lt;br /&gt;
OBJ1 = nutinit.o&lt;br /&gt;
&lt;br /&gt;
OBJS = $(SRCS:.c=.o)&lt;br /&gt;
include $(top_blddir)/NutConf.mk&lt;br /&gt;
&lt;br /&gt;
include $(top_srcdir)/Makedefs.avr-gcc&lt;br /&gt;
&lt;br /&gt;
INCFIRST=$(INCPRE)$(top_blddir)/include&lt;br /&gt;
&lt;br /&gt;
all: $(PROJ).a $(OBJS) $(OBJ1)&lt;br /&gt;
&lt;br /&gt;
install: $(PROJ).a $(OBJ1)&lt;br /&gt;
        $(CP) $(PROJ).a c:/ethernut/nutbld/lib/$(PROJ).a&lt;br /&gt;
        $(CP) $(OBJ1) c:/ethernut/nutbld/lib/$(notdir $(OBJ1))&lt;br /&gt;
&lt;br /&gt;
include $(top_srcdir)/Makerules.avr-gcc&lt;br /&gt;
&lt;br /&gt;
.PHONY: clean&lt;br /&gt;
clean: cleancc cleanedit&lt;br /&gt;
        -rm -f $(PROJ).a&lt;br /&gt;
        -rm -f $(OBJ1)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
Here is some of the cryptic stuff like &amp;lt;code&amp;gt;OBJS = $(SRCS:.c=.o)&amp;lt;/code&amp;gt;, which is hated so much by Makefile ignorants and which we will not explain here either. Instead we concentrate on those parts, which are relevant to the Nut/OS configuration. Most important is the list of source files&lt;br /&gt;
&amp;lt;div class=&amp;quot;coding&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;SRCS =   heap.c bankmem.c thread.c timer.c event.c devreg.c confos.c version.c \&lt;br /&gt;
         semaphore.c mutex.c msg.c osdebug.c tracer.c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
When using the Configurator, you may have recognized, that some parts in the module tree are disabled. That's because the Configurator keeps track of module dependencies. For example, some drivers like the AVR USART driver do not make sense for the ARM CPU and will be deactivated when selecting this CPU. Now each Nut/OS module displayed in the Configurator's module tree is associated with one or more source files. When creating the build tree, the Configurator will exactly place all source files of all activated modules in the &amp;lt;code&amp;gt;SRCS&amp;lt;/code&amp;gt; line. As a result, the final Nut/OS libraries will contain only those modules, which are available on your target platform.&lt;br /&gt;
Not less important lines in &amp;lt;code&amp;gt;os/Makefile&amp;lt;/code&amp;gt; are&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;coding&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;...                  &lt;br /&gt;
include $(top_blddir)/NutConf.mk&lt;br /&gt;
...&lt;br /&gt;
include $(top_srcdir)/Makedefs.avr-gcc&lt;br /&gt;
...&lt;br /&gt;
include $(top_srcdir)/Makerules.avr-gcc&lt;br /&gt;
...&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
The first one includes &amp;lt;code&amp;gt;NutConf.mk&amp;lt;/code&amp;gt;, which we discussed above. The other two include two files from the Nut/OS source tree. If you look into the top level source directory, you will see a number of files named &amp;lt;code&amp;gt;Makedefs&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Makerules&amp;lt;/code&amp;gt; with different file extensions. When building with AVRGCC, the Configurator will add includes of &amp;lt;code&amp;gt;Makedefs.avr-gcc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Makerules.avr-gcc&amp;lt;/code&amp;gt;. When building with ARMGCC, it will use &amp;lt;code&amp;gt;Makedefs.arm-gcc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Makerules.arm-gcc&amp;lt;/code&amp;gt; instead. Again, newbies may consider the contents of these files weird stuff. That's just fine. Under normal circumstances you will have no reason to deal with these. Simply note, that they contain nothing but special definitions for the compiler you are using. If one of the gurus ever passes you a modified version, for example with JTAG debug options, then copy them into the top level source directory with a different extension. The Configurator automatically scans the source directory for such files. Next time you open the second page in the Configurator's settings dialog, you can select the new extension in the platform drop down box.&lt;br /&gt;
An important final advice: Each time you changed anything in the Configurator settings, you must recreate the build tree.&lt;br /&gt;
&lt;br /&gt;
== Nut/OS Options ==&lt;br /&gt;
&lt;br /&gt;
Up to this point, configurations were mainly related to the compiler and the target CPU. The majority of configurations is related to hardware specifications and various other build options, though. We will now see, how the Configurator uses C header files to pass these setting to the compiler.&lt;br /&gt;
&lt;br /&gt;
Let's assume, we want to enable floating point support for &amp;lt;code&amp;gt;printf&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;scanf&amp;lt;/code&amp;gt;. In the module tree we expand &amp;lt;code&amp;gt;C Runtime (Traget Specific)&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;File Streams&amp;lt;/code&amp;gt; below that. Then we can enable &amp;lt;code&amp;gt;Floating Point&amp;lt;/code&amp;gt; by clicking on the related check box. If we create a new or re-create an existing build tree, then the Configurator adds a new header file named &amp;lt;code&amp;gt;crt.h&amp;lt;/code&amp;gt; in the subdirectory &amp;lt;code&amp;gt;include/cfg&amp;lt;/code&amp;gt; of your build tree, which contains:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;coding&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;#define STDIO_FLOATING_POINT&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
The original &amp;lt;code&amp;gt;include/cfg/crt.h&amp;lt;/code&amp;gt; in the source directory does not contain this entry.&lt;br /&gt;
Here's a snippet form the Nut/OS source code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;coding&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;                  &lt;br /&gt;
#include &lt;br /&gt;
...&lt;br /&gt;
#ifdef STDIO_FLOATING_POINT&lt;br /&gt;
/* This is floating point stuff. */&lt;br /&gt;
....&lt;br /&gt;
#endif&lt;br /&gt;
...&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
As you noticed, the floating point code is added only, if &amp;lt;code&amp;gt;include/cfg/crt.h&amp;lt;/code&amp;gt; defines &amp;lt;code&amp;gt;STDIO_FLOATING_POINT&amp;lt;/code&amp;gt;. The one in the build tree does, the one in the source tree doesn't.&lt;br /&gt;
Now we are back to the Makefiles of the build tree, in our case &amp;lt;code&amp;gt;crt/Makefile&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;coding&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;top_blddir = c:/ethernut/icnutbld&lt;br /&gt;
...                  &lt;br /&gt;
INCFIRST=$(INCPRE)$(top_blddir)/include&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
This is used in the following line of &amp;lt;code&amp;gt;Makerules.avr-gcc&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;div class=&amp;quot;coding&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;%o : %c&lt;br /&gt;
        $(CC) -c $(CPFLAGS) $(INCFIRST) -I$(INCDIR) $(INCLAST) $&amp;amp;lt; -o $@&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
Confused? Don't worry. The result is, that the compiler will search &amp;lt;code&amp;gt;include/cfg/crt.h&amp;lt;/code&amp;gt; in the build tree first. If it couldn't be found there, the search will continue in the source tree. This way the Configurator is able to overwrite existing default header files in the source tree without any modification of the source tree. This is a real advantage, if you want to build Nut/OS for different targets. You can use the same source tree for each target. And if you later upgrade to a new version of Nut/OS, you can replace the source tree whithout losing your specific configurations, because all of them are located in the build tree.&lt;br /&gt;
== The Application Tree ==&lt;br /&gt;
&lt;br /&gt;
Beside the source and the build tree, a third one is used to build Nut/OS applications. It it created by selecting &amp;lt;code&amp;gt;Create Sample Directory&amp;lt;/code&amp;gt; in the Configurator's &amp;lt;code&amp;gt;Build&amp;lt;/code&amp;gt; menu. There's not much mystery in here, but it comes quite handy for creating your own applications.&lt;br /&gt;
&lt;br /&gt;
Users of the ImageCraft IDE are lucky people. They can use the GUI to create new project files in the sample directory. Please follow the steps in the Nut/OS Software Manual.&lt;br /&gt;
&lt;br /&gt;
For using GCC on the command line, just copy one of the subdirectories to a new one with a new name within the sample directory. When adding new or removing existing source files, make sure to update the Makefile accordingly. Even if you don't understand Makefiles, this is quite simple. Be aware, that actions in Makefiles are preceded with a TAB character, spaces won't work. Your text editor should preserve tabs.&lt;br /&gt;
&lt;br /&gt;
Remember &amp;lt;code&amp;gt;UserConf.mk&amp;lt;/code&amp;gt;? When running the compiler on the command line, the default contents created by the Configurator may hurt now, if we do not intend to run the application on Ethernut 2. All samples have been written for Ethernut 1 (including Charon II and other boards using the Realtek Ethernet Controller) and Ethernut 2. All samples with network code contain the following lines:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;coding&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;                  &lt;br /&gt;
#ifdef ETHERNUT2&lt;br /&gt;
#include &amp;amp;lt;dev/lanc111.h&amp;amp;gt;&lt;br /&gt;
#else&lt;br /&gt;
#include &amp;amp;lt;dev/nicrtl.h&amp;amp;gt;&lt;br /&gt;
#endif&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
If ETHERNUT2 is defined in &amp;lt;code&amp;gt;UserConf.mk&amp;lt;/code&amp;gt;, then the application will register the LAN91C111 driver. Otherwise the driver for the RTL8019AS is used. If you want the latter, do not forget to remove the related line in &amp;lt;code&amp;gt;UserConf.mk&amp;lt;/code&amp;gt;. In newer releases &amp;lt;code&amp;gt;WOLF&amp;lt;/code&amp;gt; is another option and uses the AX88796 driver. For this controller simply replace &amp;lt;code&amp;gt;ETHERNUT2&amp;lt;/code&amp;gt; by &amp;lt;code&amp;gt;WOLF&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;UserConf.mk&amp;lt;/code&amp;gt;.&lt;br /&gt;
== Under the Hood ==&lt;br /&gt;
&lt;br /&gt;
As stated above, the GNU Make Tool controls the top level. The bottom level is controlled by Lua, an interpreter language. Mainly because of compatibility problems with Lua libraries on various Linux platforms, the decision to use Lua had been criticized sometimes. But the author is still convinced, that this had been a good decision. The Lua interpreter is extremely small and the language is extremely powerfull. Right now this is hard to believe, because the Configurator uses Lua in a static way. But one day it will shine brighter than everything else...:-)&lt;br /&gt;
&lt;br /&gt;
Neither Lua nor all Nut/OS options will be described here. Just a few details will be discussed.&lt;br /&gt;
&lt;br /&gt;
All Lua scripts are located in the subdirectory &amp;lt;code&amp;gt;conf&amp;lt;/code&amp;gt; within the source tree. When the Configurator starts, it will read &amp;lt;code&amp;gt;repository.nut&amp;lt;/code&amp;gt; first. This file specifies additional scripts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;coding&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;{&lt;br /&gt;
    name = &amp;amp;quot;nutarch&amp;amp;quot;,&lt;br /&gt;
    brief = &amp;amp;quot;Target&amp;amp;quot;,&lt;br /&gt;
    description = &amp;amp;quot;Select one only.&amp;amp;quot;,&lt;br /&gt;
    subdir = &amp;amp;quot;arch&amp;amp;quot;,&lt;br /&gt;
    script = &amp;amp;quot;arch/arch.nut&amp;amp;quot;&lt;br /&gt;
},&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
Here &amp;lt;code&amp;gt;arch/arch.nut&amp;lt;/code&amp;gt; is specified as an additional script to be included, which contains:&lt;br /&gt;
&amp;lt;div class=&amp;quot;coding&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;{&lt;br /&gt;
    macro = &amp;amp;quot;MCU_ATMEGA128&amp;amp;quot;,&lt;br /&gt;
    brief = &amp;amp;quot;Atmel ATmega 128&amp;amp;quot;,&lt;br /&gt;
    description = &amp;amp;quot;8-bit RISC microcontroller with 128K bytes flash, 4K bytes RAM, &amp;amp;quot;..&lt;br /&gt;
                  &amp;amp;quot;4K bytes EEPROM, 64K bytes data memory space, 2 USARTs, 4 timers, &amp;amp;quot;..&lt;br /&gt;
                  &amp;amp;quot;8-channel ADC, SPI and TWI.&amp;amp;quot;,&lt;br /&gt;
    requires = { &amp;amp;quot;TOOL_CC_AVR&amp;amp;quot; },&lt;br /&gt;
    provides = {&lt;br /&gt;
        &amp;amp;quot;HW_TARGET&amp;amp;quot;,&lt;br /&gt;
        &amp;amp;quot;HW_MCU_AVR&amp;amp;quot;,&lt;br /&gt;
        &amp;amp;quot;HW_MCU_AVR_ENHANCED&amp;amp;quot;,&lt;br /&gt;
        &amp;amp;quot;HW_MCU_ATMEGA128&amp;amp;quot;,&lt;br /&gt;
        &amp;amp;quot;HW_NVMEM&amp;amp;quot;,&lt;br /&gt;
        &amp;amp;quot;HW_TIMER_AVR&amp;amp;quot;,&lt;br /&gt;
        &amp;amp;quot;HW_UART_AVR&amp;amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    flavor = &amp;amp;quot;boolean&amp;amp;quot;,&lt;br /&gt;
    file = &amp;amp;quot;include/cfg/arch.h&amp;amp;quot;,&lt;br /&gt;
    makedefs = { &amp;amp;quot;MCU=$(MCU_ATMEGA128)&amp;amp;quot;, &amp;amp;quot;HWDEF=-D__HARVARD_ARCH__&amp;amp;quot; }&lt;br /&gt;
},&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
The last two definitions are the interesting ones. The first one specifies the include file, which will be created by the Configurator when &amp;lt;code&amp;gt;Atmel ATmega 128&amp;lt;/code&amp;gt; is activated. In addition, the Configurator will &amp;lt;code&amp;gt;#define MCU_ATMEGA128&amp;lt;/code&amp;gt; in this file.&lt;br /&gt;
The last definition &amp;lt;code&amp;gt;makedefs =&amp;lt;/code&amp;gt; looks familiar, doesn't it? Indeed it specifies a list of entries, which will be added to &amp;lt;code&amp;gt;NutConf.mk&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
However, before you are able to access the module tree in the Configurator's main window, you will be asked to select a configuration file. These files got the extension &amp;lt;code&amp;gt;.conf&amp;lt;/code&amp;gt; and are also located in the &amp;lt;code&amp;gt;conf&amp;lt;/code&amp;gt; subdirectory of the Nut/OS source tree. They contain simple assignments. Here's the one, which specifies options for running Nut/OS on the STK501 with an ATmega128 and the AVRGCC:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;coding&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;AVR_GCC = &amp;amp;quot;&amp;amp;quot;&lt;br /&gt;
MCU_ATMEGA128 = &amp;amp;quot;&amp;amp;quot;&lt;br /&gt;
NUTMEM_SIZE = &amp;amp;quot;4096&amp;amp;quot;&lt;br /&gt;
NUTMEM_START = &amp;amp;quot;0x100&amp;amp;quot;&lt;br /&gt;
NUTMEM_RESERVED = &amp;amp;quot;64&amp;amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
The entries are related to the same named &amp;lt;code&amp;gt;macro = &amp;lt;/code&amp;gt;entries in the Lua scripts. The first two do not assign any values. The fact, that they appear in this file, sets the related boolean Lua macro definitions to true.&lt;br /&gt;
There are other options handled by Lua, but you should have got the picture. In the current state of the Configurator this is quite helpful, because this tool is far from being perfect. For example, radio boxes are not implemented and the user must take care to enable one CPU or one compiler only and disable all others. One annoying thing is, that the compiler needs to be specified at two places, in the Configurator's setting notebook as well as in the component tree. Furthermore, not all options seem to make their way into the final build. If something seems to go wrong, check the &amp;lt;code&amp;gt;include/cfg&amp;lt;/code&amp;gt; directory in the build tree and further check, wether these files are actually included in the related Nut/OS code. But before panic breaks out: The mainstream works fine, exotic options may fail.&lt;br /&gt;
&lt;br /&gt;
== Changing Environments ==&lt;br /&gt;
&lt;br /&gt;
In the previous chapter we learned, that the configuration of the Configurator's settings notebook isn't always syncronized with the Configurators component tree. That's because they are kept in different places.&lt;br /&gt;
&lt;br /&gt;
All modifications of the component tree are manually stored in platform configuration files with extension &amp;lt;code&amp;gt;.conf&amp;lt;/code&amp;gt;. All modifications of the settings notebook are automatically stored in the Windows registry or in &amp;lt;code&amp;gt;nutconf.ini&amp;lt;/code&amp;gt; when running Linux. This could be quite annoying, when you regularly have to change your environment. The problem isn't finally solved, but for now it helps to call the Configurator with command line option &amp;lt;code&amp;gt;-s&amp;lt;/code&amp;gt; followed by a keyword of your choice. For example, on Windows you can call&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;coding&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;nut\nutconf&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
for projects using ICCAVR and&lt;br /&gt;
&amp;lt;div class=&amp;quot;coding&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;nut\nutconf -s arm&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
for projects with ICCARM. In this case the Configurator will use an alternative registry entry for ICCARM settings. [This example had been transfered to us from the future via PastBeam(tm). ICCARM isn't supported yet.]&lt;br /&gt;
== More Hints ==&lt;br /&gt;
&lt;br /&gt;
'''1.''' After modifying Lua scripts the component tree never appears again. Check for missing commas. The configurator displays the name of the script and the line number of the error.&lt;br /&gt;
&lt;br /&gt;
'''2.''' You can use &amp;lt;code&amp;gt;UserConf.mk&amp;lt;/code&amp;gt; to create a debug enabled binary with AVRGCC by appending&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;HWDEF += -g3 -gdwarf-2&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''3.''' If you need additional include files to be used by several of your applications, then create an include directory in your application tree and add the following line to &amp;lt;code&amp;gt;UserConf.mk&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;INCFIRST += $(INCPRE)../include&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''4.''' Building Nut/OS fails with something like &amp;lt;code&amp;gt;Unsupported target&amp;lt;/code&amp;gt;. Probably the settings in the Configurator's notebook and the component tree specify different compilers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Harald Kipp&amp;lt;br /&amp;gt;&lt;br /&gt;
Herne, May 12th, 2005.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;/div&gt;</summary>
		<author><name>Harald</name></author>	</entry>

	</feed>