📄 storage - 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=(0040)http://docs.tinyos.net/index.php/Storage -->
<HTML lang=en dir=ltr xml:lang="en"
xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>Storage - TinyOS Documentation Wiki</TITLE>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<META
content="Storage,Boot Sequence,Getting Started with TinyOS,Resource Arbitration and Power Management"
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="Storage - 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="Storage - 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 = "Storage";var wgTitle = "Storage";var wgAction = "view";var wgRestrictionEdit = [];var wgRestrictionMove = [];var wgArticleId = "13";var wgIsArticle = true;var wgUserName = null;var wgUserGroups = null;var wgUserLanguage = "en";var wgContentLanguage = "en";var wgBreakFrames = false;var wgCurRevisionId = "674";/*]]>*/</SCRIPT>
<SCRIPT src="Storage - TinyOS Documentation Wiki.files/wikibits.js"
type=text/javascript><!-- wikibits js --></SCRIPT>
<SCRIPT src="Storage - 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="Storage - 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-Storage">
<DIV id=globalWrapper>
<DIV id=column-content>
<DIV id=content><A id=top name=top></A>
<H1 class=firstHeading>Storage</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/Storage#column-one">navigation</A>, <A
href="http://docs.tinyos.net/index.php/Storage#searchInput">search</A></DIV><!-- start content -->
<P>This lesson introduces permanent (non-volatile) data storage in TinyOS.
Permanent storage allows a node to persist data even if power is disconnected or
the node is reprogrammed with a new image. You will become familar with
different kinds of data storage including small objects, logs, and large
objects. You will be exposed to the TinyOS interfaces and components that
support permanent data storage on motes and you will learn how to: </P>
<UL>
<LI>Divide the flash chip into volumes, which allows multiple and/or different
type of data to be stored.
<LI>Store configuration data that survives a power cycle.
<LI>Store packets using the logging abstraction and retransmit the overheard
packets after a power cycle. </LI></UL>
<P><BR></P>
<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/Storage#Introduction"><SPAN
class=tocnumber>1</SPAN> <SPAN class=toctext>Introduction</SPAN></A>
<UL>
<LI class=toclevel-2><A
href="http://docs.tinyos.net/index.php/Storage#Interfaces"><SPAN
class=tocnumber>1.1</SPAN> <SPAN class=toctext>Interfaces</SPAN></A>
<LI class=toclevel-2><A
href="http://docs.tinyos.net/index.php/Storage#Components"><SPAN
class=tocnumber>1.2</SPAN> <SPAN class=toctext>Components</SPAN></A>
<LI class=toclevel-2><A
href="http://docs.tinyos.net/index.php/Storage#Implementations"><SPAN
class=tocnumber>1.3</SPAN> <SPAN
class=toctext>Implementations</SPAN></A> </LI></UL>
<LI class=toclevel-1><A
href="http://docs.tinyos.net/index.php/Storage#Volumes"><SPAN
class=tocnumber>2</SPAN> <SPAN class=toctext>Volumes</SPAN></A>
<LI class=toclevel-1><A
href="http://docs.tinyos.net/index.php/Storage#Storing_Configuration_Data"><SPAN
class=tocnumber>3</SPAN> <SPAN class=toctext>Storing Configuration
Data</SPAN></A>
<LI class=toclevel-1><A
href="http://docs.tinyos.net/index.php/Storage#Logging_Data"><SPAN
class=tocnumber>4</SPAN> <SPAN class=toctext>Logging Data</SPAN></A>
<LI class=toclevel-1><A
href="http://docs.tinyos.net/index.php/Storage#Storing_Large_Objects"><SPAN
class=tocnumber>5</SPAN> <SPAN class=toctext>Storing Large
Objects</SPAN></A>
<LI class=toclevel-1><A
href="http://docs.tinyos.net/index.php/Storage#Conclusions"><SPAN
class=tocnumber>6</SPAN> <SPAN class=toctext>Conclusions</SPAN></A>
<LI class=toclevel-1><A
href="http://docs.tinyos.net/index.php/Storage#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>TinyOS 2.x provides three basic storage abstractions: small objects, circular
logs, and large objects. TinyOS 2.x also provides <I>interfaces</I> to abstract
the underlying storage services and <I>components</I> that <I>provide</I>
(implement) these interfaces. </P><A name=Interfaces></A>
<H2><SPAN class=mw-headline>Interfaces</SPAN></H2>
<P>Let's take a look at some of the interfaces that are in the
<CODE>tos/interfaces</CODE> directory and the types defined in the
<CODE>tos/types</CODE> to familiarize ourselves with the general functionality
of the storage system: </P>
<UL>
<LI><CODE><A class="external text"
title=http://www.tinyos.net/tinyos-2.x/tos/interfaces/BlockRead.nc
href="http://www.tinyos.net/tinyos-2.x/tos/interfaces/BlockRead.nc"
rel=nofollow>BlockRead</A></CODE>
<LI><CODE><A class="external text"
title=http://www.tinyos.net/tinyos-2.x/tos/interfaces/BlockWrite.nc
href="http://www.tinyos.net/tinyos-2.x/tos/interfaces/BlockWrite.nc"
rel=nofollow>BlockWrite</A></CODE>
<LI><CODE><A class="external text"
title=http://www.tinyos.net/tinyos-2.x/tos/interfaces/Mount.nc
href="http://www.tinyos.net/tinyos-2.x/tos/interfaces/Mount.nc"
rel=nofollow>Mount</A></CODE>
<LI><CODE><A class="external text"
title=http://www.tinyos.net/tinyos-2.x/tos/interfaces/ConfigStorage.nc
href="http://www.tinyos.net/tinyos-2.x/tos/interfaces/ConfigStorage.nc"
rel=nofollow>ConfigStorage</A></CODE>
<LI><CODE><A class="external text"
title=http://www.tinyos.net/tinyos-2.x/tos/interfaces/LogRead.nc
href="http://www.tinyos.net/tinyos-2.x/tos/interfaces/LogRead.nc"
rel=nofollow>LogRead</A></CODE>
<LI><CODE><A class="external text"
title=http://www.tinyos.net/tinyos-2.x/tos/interfaces/LogWrite.nc
href="http://www.tinyos.net/tinyos-2.x/tos/interfaces/LogWrite.nc"
rel=nofollow>LogWrite</A></CODE>
<LI><CODE><A class="external text"
title=http://www.tinyos.net/tinyos-2.x/tos/types/Storage.h
href="http://www.tinyos.net/tinyos-2.x/tos/types/Storage.h"
rel=nofollow>Storage.h</A></CODE> </LI></UL><A name=Components></A>
<H2><SPAN class=mw-headline>Components</SPAN></H2>
<P>Components provide concrete implementations of the interfaces. You should be
familiar with these components because your code needs to specify both the
<I>interfaces</I> your application <I>uses</I> as well as the <I>components</I>
which <I>provide</I> (implement) these interfaces: </P>
<UL>
<LI><CODE><A class="external text"
title=http://www.tinyos.net/tinyos-2.x/tos/chips/stm25p/ConfigStorageC.nc
href="http://www.tinyos.net/tinyos-2.x/tos/chips/stm25p/ConfigStorageC.nc"
rel=nofollow>ConfigStorageC</A></CODE>
<LI><CODE><A class="external text"
title=http://www.tinyos.net/tinyos-2.x/tos/chips/stm25p/LogStorageC.nc
href="http://www.tinyos.net/tinyos-2.x/tos/chips/stm25p/LogStorageC.nc"
rel=nofollow>LogStorageC</A></CODE>
<LI><CODE><A class="external text"
title=http://www.tinyos.net/tinyos-2.x/tos/chips/stm25p/BlockStorageC.nc
href="http://www.tinyos.net/tinyos-2.x/tos/chips/stm25p/BlockStorageC.nc"
rel=nofollow>BlockStorageC</A></CODE> </LI></UL><A name=Implementations></A>
<H2><SPAN class=mw-headline>Implementations</SPAN></H2>
<P>The preceding components are actually <I>chip-specific implementations</I> of
these abstractions. Since TinyOS supports multiple platforms, each of which
might have its own implementation of the storage drivers, you may need to be
aware of platform-specific constants or other details (e.g. erase size) that can
couple a storage client to the underlying chip-specific implementation. </P>
<P>For example, the preceding links are all specific to the ST Microelectronics
M25Pxx family of flash memories used in the Telos and Tmote Sky motes. You <I>do
not</I> need to worry about the details of where these files reside because
TinyOS's make system includes the correct drivers automatically. However, you
<I>do</I> need to know what these components are called because your code must
list them in a <CODE>components</CODE> declaration. </P>
<P>If you are curious, the following links will let you browse the
implementations of the Atmel AT45DB family of flash memories used in the
Mica2/MicaZ motes: </P>
<UL>
<LI><CODE><A class="external text"
title=http://www.tinyos.net/tinyos-2.x/tos/chips/at45db/ConfigStorageC.nc
href="http://www.tinyos.net/tinyos-2.x/tos/chips/at45db/ConfigStorageC.nc"
rel=nofollow>ConfigStorageC</A></CODE>
<LI><CODE><A class="external text"
title=http://www.tinyos.net/tinyos-2.x/tos/chips/at45db/LogStorageC.nc
href="http://www.tinyos.net/tinyos-2.x/tos/chips/at45db/LogStorageC.nc"
rel=nofollow>LogStorageC</A></CODE>
<LI><CODE><A class="external text"
title=http://www.tinyos.net/tinyos-2.x/tos/chips/at45db/BlockStorageC.nc
href="http://www.tinyos.net/tinyos-2.x/tos/chips/at45db/BlockStorageC.nc"
rel=nofollow>BlockStorageC</A></CODE> </LI></UL>
<P>Finally, the following links will let you browse the implementation for the
Intel imote2 flash memory: </P>
<UL>
<LI><CODE><A class="external text"
title=http://www.tinyos.net/tinyos-2.x/tos/platforms/intelmote2/ConfigStorageC.nc
href="http://www.tinyos.net/tinyos-2.x/tos/platforms/intelmote2/ConfigStorageC.nc"
rel=nofollow>ConfigStorageC</A></CODE>
<LI><CODE><A class="external text"
title=http://www.tinyos.net/tinyos-2.x/tos/platforms/intelmote2/LogStorageC.nc
href="http://www.tinyos.net/tinyos-2.x/tos/platforms/intelmote2/LogStorageC.nc"
rel=nofollow>LogStorageC</A></CODE>
<LI><CODE><A class="external text"
title=http://www.tinyos.net/tinyos-2.x/tos/platforms/intelmote2/BlockStorageC.nc
href="http://www.tinyos.net/tinyos-2.x/tos/platforms/intelmote2/BlockStorageC.nc"
rel=nofollow>BlockStorageC</A></CODE> </LI></UL><A name=Volumes></A>
<H1><SPAN class=mw-headline>Volumes</SPAN></H1>
<P>TinyOS 2.x divides a flash chip into one or more fixed-sized <I>volume</I>s
that are specified at compile-time using an XML file. This file, called the
volume table, allows the application developer to specify the name, size, and
(optionally) the base address of each volume in the flash. Each volume provides
a single type of storage abstraction (e.g. configuration, log, or block
storage). The abstraction type defines the physical layout of data on the flash
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -