📄 platforms - tinyos documentation wiki.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- saved from url=(0042)http://docs.tinyos.net/index.php/Platforms -->
<HTML lang=en dir=ltr xml:lang="en"
xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>Platforms - TinyOS Documentation Wiki</TITLE>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<META content=Platforms,TOSSIM,Concurrency name=keywords><LINK
href="/favicon.ico" rel="shortcut icon"><LINK
title="TinyOS Documentation Wiki (English)" href="/opensearch_desc.php"
type=application/opensearchdescription+xml rel=search>
<STYLE type=text/css media="screen, projection">@import url( /skins/common/shared.css?97 );
@import url( /skins/monobook/main.css?97 );
</STYLE>
<LINK media=print
href="Platforms - TinyOS Documentation Wiki.files/commonPrint.css" type=text/css
rel=stylesheet><!--[if lt IE 5.5000]><style type="text/css">@import "/skins/monobook/IE50Fixes.css?97";</style><![endif]--><!--[if IE 5.5000]><style type="text/css">@import "/skins/monobook/IE55Fixes.css?97";</style><![endif]--><!--[if IE 6]>
<STYLE type=text/css>@import url( /skins/monobook/IE60Fixes.css?97 );
</STYLE>
<![endif]--><!--[if IE 7]><style type="text/css">@import "/skins/monobook/IE70Fixes.css?97";</style><![endif]--><!--[if lt IE 7]>
<SCRIPT src="Platforms - TinyOS Documentation Wiki.files/IEFixes.js"
type=text/javascript></SCRIPT>
<META http-equiv=imagetoolbar content=no><![endif]-->
<SCRIPT type=text/javascript>/*<![CDATA[*/var skin = "monobook";var stylepath = "/skins";var wgArticlePath = "/index.php/$1";var wgScriptPath = "";var wgScript = "/index.php";var wgServer = "http://docs.tinyos.net";var wgCanonicalNamespace = "";var wgCanonicalSpecialPageName = false;var wgNamespaceNumber = 0;var wgPageName = "Platforms";var wgTitle = "Platforms";var wgAction = "view";var wgRestrictionEdit = [];var wgRestrictionMove = [];var wgArticleId = "15";var wgIsArticle = true;var wgUserName = null;var wgUserGroups = null;var wgUserLanguage = "en";var wgContentLanguage = "en";var wgBreakFrames = false;var wgCurRevisionId = "290";/*]]>*/</SCRIPT>
<SCRIPT src="Platforms - TinyOS Documentation Wiki.files/wikibits.js"
type=text/javascript><!-- wikibits js --></SCRIPT>
<SCRIPT src="Platforms - TinyOS Documentation Wiki.files/index.php"
type=text/javascript><!-- site js --></SCRIPT>
<STYLE type=text/css>@import url( /index.php?title=MediaWiki:Common.css&usemsgcache=yes&action=raw&ctype=text/css&smaxage=18000 );
@import url( /index.php?title=MediaWiki:Monobook.css&usemsgcache=yes&action=raw&ctype=text/css&smaxage=18000 );
@import url( /index.php?title=-&action=raw&gen=css&maxage=18000 );
</STYLE>
<!-- Head Scripts -->
<SCRIPT src="Platforms - TinyOS Documentation Wiki.files/ajax.js"
type=text/javascript></SCRIPT>
<META content="MSHTML 6.00.2900.3268" name=GENERATOR></HEAD>
<BODY class="mediawiki ns-0 ltr page-Platforms">
<DIV id=globalWrapper>
<DIV id=column-content>
<DIV id=content><A id=top name=top></A>
<H1 class=firstHeading>Platforms</H1>
<DIV id=bodyContent>
<H3 id=siteSub>From TinyOS Documentation Wiki</H3>
<DIV id=contentSub></DIV>
<DIV id=jump-to-nav>Jump to: <A
href="http://docs.tinyos.net/index.php/Platforms#column-one">navigation</A>, <A
href="http://docs.tinyos.net/index.php/Platforms#searchInput">search</A></DIV><!-- start content -->
<TABLE class=toc id=toc summary=Contents>
<TBODY>
<TR>
<TD>
<DIV id=toctitle>
<H2>Contents</H2></DIV>
<UL>
<LI class=toclevel-1><A
href="http://docs.tinyos.net/index.php/Platforms#Introduction"><SPAN
class=tocnumber>1</SPAN> <SPAN class=toctext>Introduction</SPAN></A>
<LI class=toclevel-1><A
href="http://docs.tinyos.net/index.php/Platforms#Chips_vs_Platforms"><SPAN
class=tocnumber>2</SPAN> <SPAN class=toctext>Chips vs
Platforms</SPAN></A>
<LI class=toclevel-1><A
href="http://docs.tinyos.net/index.php/Platforms#Initial_platform_bring-up"><SPAN
class=tocnumber>3</SPAN> <SPAN class=toctext>Initial platform
bring-up</SPAN></A>
<UL>
<LI class=toclevel-2><A
href="http://docs.tinyos.net/index.php/Platforms#The_.platform_file"><SPAN
class=tocnumber>3.1</SPAN> <SPAN class=toctext>The .platform
file</SPAN></A>
<LI class=toclevel-2><A
href="http://docs.tinyos.net/index.php/Platforms#The_hardware.h_file"><SPAN
class=tocnumber>3.2</SPAN> <SPAN class=toctext>The hardware.h
file</SPAN></A> </LI></UL>
<LI class=toclevel-1><A
href="http://docs.tinyos.net/index.php/Platforms#Setting_up_the_build_environment_and_building_the_.22null.22_app"><SPAN
class=tocnumber>4</SPAN> <SPAN class=toctext>Setting up the build
environment and building the "null" app</SPAN></A>
<UL>
<LI class=toclevel-2><A
href="http://docs.tinyos.net/index.php/Platforms#Defining_a_make_target"><SPAN
class=tocnumber>4.1</SPAN> <SPAN class=toctext>Defining a make
target</SPAN></A> </LI></UL>
<LI class=toclevel-1><A
href="http://docs.tinyos.net/index.php/Platforms#Getting_Blink_to_work"><SPAN
class=tocnumber>5</SPAN> <SPAN class=toctext>Getting Blink to
work</SPAN></A>
<LI class=toclevel-1><A
href="http://docs.tinyos.net/index.php/Platforms#Conclusion"><SPAN
class=tocnumber>6</SPAN> <SPAN class=toctext>Conclusion</SPAN></A>
<LI class=toclevel-1><A
href="http://docs.tinyos.net/index.php/Platforms#Related_Documentation"><SPAN
class=tocnumber>7</SPAN> <SPAN class=toctext>Related
Documentation</SPAN></A> </LI></UL></TD></TR></TBODY></TABLE>
<SCRIPT type=text/javascript> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </SCRIPT>
<A name=Introduction></A>
<H1><SPAN class=mw-headline>Introduction</SPAN></H1>
<P>Many different hardware platforms (e.g micaZ, telos, eyesIFX) can be used
with TinyOS. This lesson shows you what a platform port consists of, and how
TinyOS reuses as much code as possible between different platforms. The lesson
will proceed by showing how to do the port for an imaginary mote called "yamp",
which has a MSP430 microcontroller and a CC2420 radio transceiver. </P>
<P>The <B>target audience</B> of this lesson consists of those people that want
to better understand what the difference between e.g "make micaz" and "make
telosb" is, and how these differences concretely map into the underlying files,
definitions, etc. </P>
<P>Note that the material covered in this tutorial is <B>not</B> strictly
necessary for regular tinyos developpers, and you can safely skip it if you have
no intention of working down to the lowest level or developping new platforms.
</P><A name=Chips_vs_Platforms></A>
<H1><SPAN class=mw-headline>Chips vs Platforms</SPAN></H1>
<P>Two key building blocks for any mote are the microcontroller and radio
transceiver. Of course, both a microcontroller and a radio can be used on more
than one platform. This is indeed the case for the MSP430 and CC2420 that our
yamp mote uses (telos, eyes, and tinynode use the MSP430; telos and micaz use
the CC2420). </P>
<P>Given this multiplicity of platforms, it would be vasly redundant if each
platform developper had to rewrite the software support for each chip from
scratch. While a chip may be physically wired in a different way on different
platforms (e.g., a radio is connected to a different digital pins on the
microcontroller), by far the largest part of the logic to deal with a chip is
platform-independent. </P>
<P>Thus, platform-independent code to support a chip is placed in a
chip-specific directory. Writing a platform port for a platform is then
(essentially) a matter of <B>pulling in the code for each of the platform's
chips, and "gluing" things together</B>. For example, the modules and components
that support the CC2420 are in tos/chips/cc2420. This radio is used on both the
telos and micaZ motes; the "gluing" is done by the modules in the
tos/platforms/telosa/chips/cc2420 and tos/platforms/micaz/chips/cc2420/
directories. </P>
<P>Note that in general there may be more to a platform port than pulling in
existing code for different chips, in particular when a new platform uses a chip
that is not yet supported. Developping drivers for a new chip can be a
non-trivial undertaking (especially for radios and microcontrollers); these
aspects are not covered here. </P><A name=Initial_platform_bring-up></A>
<H1><SPAN class=mw-headline>Initial platform bring-up</SPAN></H1>
<P>As a first step to bring up the platform, we will stick to the bare minimum
in order to compile and install the Null application on our yamp mote. </P>
<P>All platform-specific code goes in tos/platforms/. For example, we have
tos/platforms/micaz or tos/platforms/tinynode. Our first step is to create a
directory for the yamp platform: </P><PRE> $ cd tinyos-2.x/tos/platforms
$ mkdir yamp
</PRE><A name=The_.platform_file></A>
<H2><SPAN class=mw-headline>The .platform file</SPAN></H2>
<P>Each platform directory (such as tos/platforms/yamp) should contain a file
named ".platform", that contains basic compiler parameters information for each
platform. So, create the file "tos/platforms/yamp/.platform" (note the <B>.</B>
in "<B>.</B>platform" !!!), that contains the following: </P><PRE> push( @includes, qw(
%T/chips/cc2420
%T/chips/msp430
%T/chips/msp430/adc12
%T/chips/msp430/dma
%T/chips/msp430/pins
%T/chips/msp430/timer
%T/chips/msp430/usart
%T/chips/msp430/sensors
%T/lib/timer
%T/lib/serial
%T/lib/power
) );
@opts = qw(
-gcc=msp430-gcc
-mmcu=msp430x1611
-fnesc-target=msp430
-fnesc-no-debug
-fnesc-scheduler=TinySchedulerC,TinySchedulerC.TaskBasic,TaskBasic,TaskBasic,runTask,postTask
);
</PRE>
<P>This file contains perl snippets that are intepreted by the ncc compiler. The
first statement simply adds some directories to the include path that is used
when compiling an application for the yamp platform (the %T gets expanded
to the full location of tinyos-2.x/tos, using the TOS2DIR environment variable).
Note that we have included the CC2420 and MSP430 directories, as well as some
libraries. </P>
<P>The second statement defines the @opts list, that contains various parameters
passed to nesc. Please consult the nesc documentation for information on the
meaning of these parameters. </P><A name=The_hardware.h_file></A>
<H2><SPAN class=mw-headline>The hardware.h file</SPAN></H2>
<P>Each platform directory also has a file named "hardware.h" that is included
by default when compiling an application for that platform. This can define
platform-specific constants, pin names, or also include other "external" header
files (e.g. msp430hardware.h in our case, or atm128hardware.h for platforms
using the atm128 MCU).<BR>So, create the file "tos/platforms/yamp/hardware.h"
with the following contents: </P><PRE> #ifndef _H_hardware_h
#define _H_hardware_h
#include "msp430hardware.h"
// LEDs
TOSH_ASSIGN_PIN(RED_LED, 5, 4);
TOSH_ASSIGN_PIN(GREEN_LED, 5, 5);
TOSH_ASSIGN_PIN(YELLOW_LED, 5, 6);
// UART pins
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -