http://www.ethernut.de/nutwiki/index.php?title=Ethernut_3.0_E&feed=atom&action=historyEthernut 3.0 E - Revision history2024-03-28T09:34:57ZRevision history for this page on the wikiMediaWiki 1.26.2http://www.ethernut.de/nutwiki/index.php?title=Ethernut_3.0_E&diff=90&oldid=prevHarald: 1 revision imported2016-10-27T16:02:54Z<p>1 revision imported</p>
<table class='diff diff-contentalign-left'>
<tr style='vertical-align: top;' lang='en'>
<td colspan='1' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='1' style="background-color: white; color:black; text-align: center;">Revision as of 16:02, 27 October 2016</td>
</tr><tr><td colspan='2' style='text-align: center;' lang='en'><div class="mw-diff-empty">(No difference)</div>
</td></tr></table>Haraldhttp://www.ethernut.de/nutwiki/index.php?title=Ethernut_3.0_E&diff=89&oldid=prevDaniel: /* Makefile */2009-03-12T16:39:14Z<p><span dir="auto"><span class="autocomment">Makefile</span></span></p>
<p><b>New page</b></p><div>[[Image:enut30.png|upright|thumb|400px|Ethernut 3.0 E]]<br />
<br />
== Test Environments ==<br />
<br />
{| class="smalldiv"<br />
| style="background-color:#F6F9ED" | Board<br />
| style="background-color:#F6F9ED" | Nut/OS<br />
| style="background-color:#F6F9ED" | YAGARTO<br />
| style="background-color:#F6F9ED" | Tera Term<br />
| style="background-color:#F6F9ED" | TFTP32<br />
|-<br />
| 3.0 E<br />
| 2.6.4<br />
| 20080928<br />
| 4.61<br />
| 3.28<br />
|}<br />
<br />
== Description ==<br />
<br />
On this page you will learn how to setup an Ethernet 3.0 development and testing environment.<br />
<br />
You will learn the '''easiest way''' on how to use the examples from nutwiki and your own applications.<br />
This Guide is not supposed to be a complete manual but as a Quick Start Guide, teaching one of the many methods to get an application running on your Ethernut board.<br />
<br />
Immediatly after working through this document, you have the competence to test the examples featured by nutwiki.<br />
<br />
Screencasts:<br />
<br />
# [[Image:flashvideo.png|16px]] [http://ethernut.de/arc/screencasts/ENUT30CONFIGURATOR.htm Screencast Part 1] The Nut/OS Configurator<br />
# [[Image:flashvideo.png|16px]] [http://ethernut.de/arc/screencasts/ENUT30PREP.htm Screencast Part 2] Preparations<br />
# [[Image:flashvideo.png|16px]] [http://ethernut.de/arc/screencasts/ENUT30COMPILE.htm Screencast Part 3] Compiling the source code<br />
# [[Image:flashvideo.png|16px]] [http://ethernut.de/arc/screencasts/ENUT30BOOTLOADER.htm Screencast Part 4] Utilizing the bootloader<br />
# [[Image:flashvideo.png|16px]] [http://ethernut.de/arc/screencasts/TERATERM.htm Screencast Part 5] Serial Communications / TeraTerm<br />
<br />
== [[Image:winpath.png|24px]] Required Tools for Windows ==<br />
<br />
=== Nut/OS ===<br />
Of course you need the latest version of Nut/OS.<br />
<br />
Visit this page to download the latest version for Win32:<br><br />
Download: [http://ethernut.de/en/download/index.html http://ethernut.de/en/download/index.html]<br />
<br />
Nut/OS for Windows features an installer which will do most of the work for you.<br />
<br />
It is recommended to install the ethernut folder directly on the root directory: <br />
[[Image:winpath.png|24px]] C:/ethernut-4.6.4/ <br />
'''Note:''' All paths in this guide refer to that location!<br />
<br />
=== Tera Term ===<br />
[http://ttssh2.sourceforge.jp/ Tera Term] is a so called terminal emulator. We use it to communicate via COM with the board.<br />
<br />
Download: [http://sourceforge.jp/projects/ttssh2/releases/ http://sourceforge.jp/projects/ttssh2/releases/]<br />
<br />
=== YAGARTO ===<br />
[http://winavr.sourceforge.net/index.html WinAVR] is a very fast, self-contained GCC toolchain for ARM for Windows.<br />
<br />
It includes Binutils, Newlib, GCC compiler, and the Insight debugger.<br />
<br />
An installation guide can be found [http://www.yagarto.de/howto/yagarto1/index.html here]<br />
<br />
Download: [http://sourceforge.net/project/showfiles.php?group_id=211530&package_id=254273 http://sourceforge.net/project/showfiles.php?group_id=211530&package_id=254273]<br />
<br />
<br />
It is recommended to install the YAGARTO folder directly on the root directory:<br />
[[Image:winpath.png|24px]] C:/yagarto/<br />
'''Note:''' All paths in this guide refer to that location!<br />
<br />
=== TFTPD32 ===<br />
<br />
[http://tftpd32.jounin.net/ TFTP32] is an opensource TFTP Server. We will use this protocol, to upload our apllications to the Ethernut 3.0 via Ethernet in just a few seconds.<br />
<br />
Download : [http://tftpd32.jounin.net/tftpd32_download.html http://tftpd32.jounin.net/tftpd32_download.html]<br />
<br />
=== Text Editor ===<br />
You can use any text editor you want.<br />
Some recommended ones include:<br />
* [http://www.eclipse.org/ Eclipse] Open Source<br />
* [http://www.e-texteditor.com/ The e Text Editor] Commercial, Trial<br />
<br />
== [[Image:linuxpath.png|24px]] Required Tools for Linux==<br />
<br />
=== Essential Tools ===<br />
The following GNU tools are required to configure and build a minimal Nut/OS development environment: <br />
* C compiler 4.1 or later<br />
* Binutils 2.18 or later<br />
* Autoconf 2.61<br />
* Automake 1.10<br />
<br />
=== ARM-ELF cross toolchain ===<br />
Furthermore, you need a so called cross toolchain, which allows us to create binaries on a Linux host, which will later run on our target board. When developing for 8-bit AVR, we need <br />
* GNU Compiler Collection for ARM-ELF<br />
* GNU Binary Utilities for ARM-ELF<br />
* newlib C library<br />
<br />
=== WxWidgets ===<br />
[http://www.wxwidgets.org/ wxWidgets] is a cross-platform C++ GUI framework, required for Nut/OS configurator GUI.<br />
<br />
=== Lua ===<br />
[http://www.lua.org/ Lua] is an embeddable scripting language, which is used here to specify the configuration rules. This is also required for Nut/OS configurator to run.<br />
<br />
=== Nut/OS ===<br />
Of course you need the latest version of Nut/OS.<br />
<br />
Visit this page to download the latest source code package for Linux (Debian):<br><br />
Download: [http://ethernut.de/en/download/index.html http://ethernut.de/en/download/index.html]<br />
<br />
It is recommended to install the ethernut folder directly in your home directory: <br />
[[Image:linuxpath.png|24px]] $ ~/ethernut-4.6.4/ <br />
'''Note:''' All paths in this guide refer to that location and will be referred to as "ethernut folder/directory" or "/ethernut-4.6.4"<br />
<br />
=== Minicom ===<br />
[http://alioth.debian.org/projects/minicom/ Minicom] is a so called terminal emulator. We use it to communicate via COM with the board.<br />
<br />
== The Nut/OS Configurator ==<br />
<br />
[[Image:flashvideo.png|64px]] [http://ethernut.de/arc/screencasts/ENUT30CONFIGURATOR.htm Screencast Part 1] <br />
<br />
In order to build an optimized Nut/OS for you needs you have to configure one.<br />
<br />
''In some examples from nutwiki you are asked to setup something in the Nut/OS configurator. This is the time and place to do so.''<br />
<br />
<br />
In general the workflow is as following:<br />
<br />
1. Start the Nut/OS Configurator:<br />
[[Image:winpath.png|24px]] C:\ethernut-4.6.4\nutconf.exe<br />
2. Select and open the configuration file:<br />
[[Image:winpath.png|24px]] C:\ethernut-4.6.4\nut\conf\ethernut30e.conf<br />
3. Click on Menubar: '''Edit > Settings'''<br><br />
* Goto Tab: '''Build'''<br />
** Choose Platform: '''arm-gcc'''<br />
** Choose Build Directory: '''nutbld_30e'''<br />
* Goto Tab: '''Tools'''<br />
** Enter Tool Paths: '''c:\ethernut-4.6.4\nut\tools\win32;c:\yagarto\bin;'''<br>(Do not forget the last semicolon and modify paths if you used other locations as described above.)<br />
* Goto Tab: '''Samples'''<br />
** Choose Application Directory: '''nutapp_30e'''<br />
** Choose Programmer: '''arm-jom'''<br />
* Click '''OK'''<br />
4. In the Nut/OS Components tree (left)<br />
* Expand Tools<br />
** Expand GCC Settings<br />
*** Click on ARM Linker Script<br />
**** Choose 'at91_ram' from the dropdown menu.<br />
By choosing the Linker Script, you specify, in which kind of memory your application will run.<br />
We are using 'at91ram' here, because we are going to upload the<br>application via the Bootloader directly into RAM and run it in there.<br />
<br />
5. Click on Menubar: '''Build > Build Nut/OS'''<br><br />
* Say '''OK''' 2 times.<br />
6. Click on Menubar: '''Build > Create Sample Directory'''<br><br />
* Say '''OK'''<br />
<br />
<br><br />
'''Note:''' You should create a new sample directory every time you build a new system, even if you do not want to use the samples. There are two files named<br />
* Makerules<br />
* Makedefs<br />
in that directory, that are necessary for every application to compile.<br />
<br><br><br />
<br />
Nut/OS Configurator built a customized version for your needs and put it in:<br />
[[Image:winpath.png|24px]] C:\ethernut-4.6.4\nutbld_30e\<br />
<br />
Additionally it created an Sample Application Directory with source codes ready to compile:<br />
[[Image:winpath.png|24px]] C:\ethernut-4.6.4\nutapp_30e\<br />
<br />
== Preparations ==<br />
<br />
[[Image:flashvideo.png|64px]] [http://ethernut.de/arc/screencasts/ENUT30PREP.htm Screencast Part 2]<br />
<br />
=== Application Directory ===<br />
First of all we need a home for our application. <br />
<br />
Create a new directory "'''testcode'''" in<br />
[[Image:winpath.png|24px]] C:\ethernut-4.6.4\nutapp_30e\<br />
<br />
You can, of course, use any names you want.<br />
<br />
=== Editing ===<br />
1. Write your application code, or for testing purposes, paste in an example code from nutwiki in a plain text file.<br />
<br />
2. Save it as <code>testcode.c</code> in:<br />
[[Image:winpath.png|24px]] C:\ethernut-4.6.4\nutapp_30e\testcode\<br />
<br />
'''Note:''' Make sure, that in your Windows folder options, the setting 'Hide file extensions for unknown file types' is deactivated! If not, you will create .txt files instead of .c or Makefiles, when saving in the Editor!<br />
<br />
=== Makefile ===<br />
For our applications to compile, we need a makefile.<br />
<br />
This is used and interpreted by a tool called GNU Make, which we will use later.<br />
<br />
Makefiles may differ from application to application, but the following is a general purpose one, which will work for basic applications.<br><br />
Later, when you are familiar with Nut/OS and makefiles you can create your own ones.<br />
<br />
'''Note''', that in this example makefile, the project name,<br />
<source lang="text"><br />
PROJ = testcode<br />
</source><br />
has to be identical to the name of your application's <code>.c</code> file!<br />
<br />
<source lang="text"><br />
PROJ = testcode<br />
<br />
include ../Makedefs<br />
<br />
SRCS = $(PROJ).c<br />
OBJS = $(SRCS:.c=.o)<br />
LIBS = $(LIBDIR)/nutinit.o -lnutpro -lnutos -lnutarch -lnutdev -lnutarch -lnutnet -lnutfs -lnutcrt<br />
TARG = $(PROJ).hex<br />
PARM = $(PROJ).eep<br />
<br />
all: $(OBJS) $(TARG) $(ITARG) $(DTARG)<br />
<br />
include ../Makerules<br />
<br />
clean:<br />
-rm -f $(OBJS)<br />
-rm -f $(TARG) $(ITARG) $(DTARG)<br />
-rm -f $(PROJ).eep<br />
-rm -f $(PROJ).obj<br />
-rm -f $(PROJ).map<br />
-rm -f $(SRCS:.c=.lst)<br />
-rm -f $(SRCS:.c=.bak)<br />
-rm -f $(SRCS:.c=.i)<br />
</source><br />
'''Note''', when copy and pasting the above Makefile: the spaces before '''-rm...''' have to be '''tabs''' instead of normal spaces!<br />
<br />
<br />
Create a plain text file and paste in the code above. <br />
<br />
Call it <code>Makefile</code> (Without any file extension) and save it to:<br />
[[Image:winpath.png|24px]] C:\ethernut-4.6.4\nutapp_30e\testcode\<br />
<br />
=== Configuration Files ===<br />
The files<br />
* Makedefs<br />
* Makerules<br />
from<br />
[[Image:winpath.png|24px]] C:\ethernut-4.6.4\nutapp_30e\<br />
are essential.<br />
By building a new Nut/OS and a new sample directory (nutapp_30e) these files get updated. <br />
Your application directory (testcode) will remain untouched.<br />
<br />
(If you used different paths, note, that the configuration files have to be located in the top directory of the apllication directory.)<br />
<br />
'''Note:''' You have to build a new sample directory and move 'Makedefs' and 'Makerules' to your application's parent directory (if your app directory is not already a subfolder of "nutapp_30e" as recommended) every time you build a new Nut/OS!<br />
<br />
=== Path environment ===<br />
Every command line session has its own PATH variable. <br />
<br />
Applications like GNU Make look up paths in that variable.<br />
<br />
We need to add to the path variable our tools:<br />
C:/ethernut-4.6.4/nut/tools/win32;c:/yagarto/bin;<br />
<br />
To do so, we could enter in the command line prompt:<br />
SET PATH=c:/ethernut-4.6.4/nut/tools/win32;c:/yagarto/bin;%PATH%<br />
<br />
(The <code>%PATH%</code> at the end appends the original content of the PATH variable to the newly set.<br><br />
By leaving that out the PATH gets overwritten.)<br />
<br />
Because every time you close the command line prompt your PATH variable gets lost,<br><br />
there is a better way to handle it.<br />
<br />
<br />
1. Create a plain text file and enter:<br />
SET PATH=c:/ethernut-4.6.4/nut/tools/win32;c:/yagarto/bin;%PATH%<br />
<br />
2. Name it <code>ARM.bat</code> and save it to:<br />
[[Image:winpath.png|24px]] C:\ethernut-4.6.4\nutapp_30e\testcode\<br />
<br />
This is called a Batch file.<br><br />
Everytime you type in <code>ARM</code> in the <code>testcode</code> directory now, the PATH variable gets set.<br><br />
You have to execute <code>ARM</code> every time after you open a new command line window.<br><br />
If you do not, GNU Make will not find the tools.<br />
<br />
=== Connecting ===<br />
<br />
To connect your Ethernut 3.0<br />
<br />
*Connect Ethernut`s DB-9 RS232 port to an available COM port using the serial cable.<br />
*Use one twisted pair cable to connect Ethernut's RJ-45 connector to the hub / switch / router and the other twisted pair cable to connect the hub / switch / router with the<br />
network adapter in the PC. If you are not using a hub or switch, then directly<br />
connect the Ethernut board with the PC’s network adapter using a twisted pair<br />
cross cable.<br />
*Connect the power supply to the barrel connector on the Ethernut board. The<br />
Ethernut board is equipped with its own rectifier bridge and voltage regulator.<br />
Therefore the polarity of the barrel connector isn't important.<br />
*Apply power to the Ethernut board by connecting the power supply to an<br />
electrical outlet. When the board is powered up, the red power LED should go<br />
on.<br />
<br />
<br />
For further details have a look at the [http://ethernut.de/pdf/ethwm30d.pdf Hardware Manual]<br />
<br />
== Compiling and Using the Bootloader==<br />
<br />
Basically, the workflow is as following.<br />
<br />
# Compiling the source code.<br />
# Setting up a TFTP server, which 'serves' with all files in a certain directory on your computer.<br />
# Utilizing the Bootloader, to connect via LAN to the TFTP Server on your computer and download the binaries from there.<br />
<br />
[[Image:flashvideo.png|64px]] [http://ethernut.de/arc/screencasts/ENUT30COMPILE.htm Screencast Part 3]<br />
[[Image:flashvideo.png|64px]] [http://ethernut.de/arc/screencasts/ENUT30BOOTLOADER.htm Screencast Part 4]<br />
=== Compiling ===<br />
<br />
1. Open a command line window.<br />
<br />
2. Change to<br />
[[Image:winpath.png|24px]] C:\ethernut-4.6.4\nutapp_30e\testcode\<br />
<br />
3. Enter:<br />
[[Image:winpath.png|24px]] SET PATH=c:/ethernut-4.6.4/nut/tools/win32;c:/yagarto/bin;%PATH%<br />
or<br />
[[Image:winpath.png|24px]] ARM<br />
if you are using a batch file.<br />
<br />
4. Enter:<br />
<br />
make clean<br />
<br />
''This tells "Make" to clean up the directory with respect to the rules made in the Makefile''<br />
<br />
You should get something like:<br />
rm -f testcode.o<br />
rm -f testcode.hex testcode.bin testcode.elf<br />
rm -f testcode.eep<br />
rm -f testcode.obj<br />
rm -f testcode.map<br />
rm -f testcode.lst<br />
rm -f testcode.bak<br />
rm -f testcode.i<br />
<br />
If not, you maybe left out step 3.<br />
<br />
5. Enter:<br />
make install<br />
<br />
This should get you something like:<br />
<br />
arm-elf-gcc -c -mcpu=arm7tdmi -Os -mthumb-interwork -fomit-frame-pointer<br />
-Wall -Wstrict-prototypes -fverbose-asm -Wa,-ahlms=testcode.lst <br />
-DETHERNUT3 -I../../nutbld_30e/include -I../../nut/include testcode.c -o testcode.o<br />
testcode.c: In function 'main':<br />
testcode.c:11: warning: implicit declaration of function '_ioctl'<br />
arm-elf-gcc testcode.o -mcpu=arm7tdmi -nostartfiles <br />
-T../../nut/arch/arm/ldscripts/at91_ram.ld -Wl,-Map=testcode.map,--cref,<br />
--no-warn-mismatch -L../../nutbld_30e/lib -Wl,--start-group ../../nutbld_30e/lib/nutinit.o <br />
-lnutpro -lnutos -lnutarch -lnutdev -lnutarch -lnutnet -lnutfs -lnutcrt <br />
-Wl,--end-group -o testcode.elf<br />
arm-elf-objcopy -O ihex testcode.elf testcode.hex<br />
arm-elf-objcopy -O binary testcode.elf testcode.bin<br />
cp testcode.hex ../../nut/bin/arm7tdmi/testcode.hex<br />
cp testcode.bin ../../nut/bin/arm7tdmi/testcode.bin<br />
<br />
This command compiled the source code and generated the binary files beside some other files in<br />
[[Image:winpath.png|24px]] C:\ethernut-4.6.4\nutapp_30e\testcode\<br />
<br />
What it also did is to copy the .hex and .bin files to<br />
[[Image:winpath.png|24px]] C:\ethernut-4.6.4\nut\bin\arm7tdmi<br />
<br />
This is the location from where the bootloader will download the binaries, as you will see in the next step.<br />
<br />
=== Setting up the TFTP Server ===<br />
<br />
1. Launch TFTP32<br />
<br />
2. For the Current Directory browse to<br />
[[Image:winpath.png|24px]] C:\ethernut-4.6.4\nut\bin\arm7tdmi<br />
this is the directory, the TFTP Server will serve with.<br />
<br />
3. The Server interface field is set to your computers network IP.<br />
<br />
4. That was it. Don't close the window.<br />
<br />
=== Using the Bootloader ===<br />
<br />
1. Start '''TeraTerm''' or any other serial communications tool.<br />
<br />
2. Configure TeraTerm with the follwing settings:<br />
*Menubar > Setup > Serial port...<br />
**Baud rate: '''115200'''<br />
**Data: '''8Bit'''<br />
**Parity: '''None'''<br />
**Stop: '''1bit'''<br />
**Flow control: '''none'''<br />
**Transmit delay: '''0''';'''0'''<br />
<br />
3. In the main window: Hold down the space bar -> Push the reset switch on your Ethernut 3.0 -> Release space bar<br />
<br />
4. Now you should see the output of 'BootMon', the Bootloader.<br />
<br />
To be exact, this is the configuration mode of BootMon.<br />
<br />
To configurate BootMon, just type in the information and press Enter to proceed to the next field.<br />
<br />
If you leave a field blank and press Enter, the last setting (displayed in brackets) will be used.<br />
<br />
*MAC Adress: '''Leave blank''' > Enter<br />
*IP Adress: This is the IP adress of the board. Use a free IP of your network, or type in 0.0.0.0 to use DHCP. > Enter<br />
*Net Mask: '''255.255.255.0''' for most cases. Generally the same as your computer's > Enter<br />
*TFTP Adress: Server interface of TFTP (Your computers network IP)<br />
*TFTP Image: This is the binary file we are going to download. In our case, type in '''testcode.bin'''<br />
<br />
<br />
'''''BootMon now downlods your application.'''''<br />
''TFTP should put out some log information.''<br />
<br />
<br />
5. After a few secounds you should see the output of your application!<br />
<br />
[[Image:info.png|16px|center]]<br />
To upload the same file (maybe an updated version of it) again, just push the reset button on your board.<br />
This causes BootMon to use the last settings made again and to download the binaries whithout entering the configuration mode.<br />
<br />
By using<br><code> C:\ethernut-4.6.4\nut\bin\arm7tdmi </code><br><br />
for the TFTP directory to download from, you just have to configure the TFTP file in BootMon, if you want to upload another application, as by using <code>make install</code>, every compiled application's binaries get stored in that directory.<br />
<br />
== Important things to remember ==<br />
In order to not get frustrated remember:<br />
<br />
* When entering the tool paths in the Configurator, do not forget the semicolon at the end of the line!<br />
* Make sure, that the setting 'Hide file extensions for unknown file types' is deactivated in you Windows folder options. Otherwise, 'Editor' won't create proper .c or Makefiles.<br />
* In the Makefile, make sure, that the project name is identical to your <code>.c</code> file's name!<br />
* Update the PATH variable every time you open a new command line prompt! Write a bash file for that.<br />
* You have to build a new sample directory and move 'Makedefs' and 'Makerules' from there to your application's parent directory every time you build a new Nut/OS with the Configurator! <br />
* Use 'at91_ram' as ARM Linker Script (Nut/OS Configurator), when using the Bootloader method.<br />
<br />
== See also ==<br />
* [[Nut/OS Examples]]<br />
* [[Hello World!]] Example<br />
<br />
== External Links ==<br />
<br />
[http://ethernut.de/pdf/ethwm30d.pdf] Ethernut 3.0 Hardware Manual (November 2005)<br />
<br />
[http://ethernut.de/en/hardware/enut3/jtag.html] Document on Ethernut 3 JTAG featuring a guide on how to restore the Bootloader, when destroyed.<br />
<br />
[http://ethernut.de/en/hardware/enut3/appflash.html] This document presents detailed informations about the different possibilities to boot Ethernut 3. <br />
<br />
[http://ethernut.de/pdf/enswm24e.pdf] Ethernut Software Manual (November 2005)<br />
<br />
[http://ethernut.de/en/hardware/enut3/index.html] Ethernut 3.0 section on ethernut.de<br />
<br />
<br><br />
<br />
[[Category:Code Snippets]]<br />
<br />
{{Languages}}</div>Daniel