Hi Santosh,

I don't think I'm going to be much help here, because I haven't used BlockStorage in a long time. Are you mounting to the volume correctly? Both your read and write interfaces need to be mounted to the same volume, or you won't be reading back from the same place you wrote.

If you're interested in simply reading/writing to the flash in TinyOS 1.x, check out the FlashBridge library located in tinyos-1.x/contrib/rincon/tos/lib/FlashBridge. There's an example application in tinyos-1.x\contrib\rincon\tos\lib\FlashBridge\apps\FlashBridgeViewer

Make sure you include the stm25p media directory inside FlashBridge/media when you try to compile. You'll need to use rincon's FlashBridgeViewer java app to get the FlashBridgeViewer working properly. But you can use the FlashBridge interface without the viewer in your own application.

Below is an excerpt from the readme in tinyos-1.x\contrib\rincon\tos\lib\FlashBridge\apps\FlashBridgeViewer

Goodluck,
-David


I always alias "flashbridge" to "java com.rincon.flashbridgeviewer.FlashViewer"
just so you know what's going on...


First let's take a look at what commands we have available from the FlashBridge. Compile FlashBridgeViewerTest or BlackbookConnect or something to the mote and connect to the mote with your serial forwarder. Then...


$ flashbridge
No arguments found
Usage: java com.rincon.flashviewer [mote] [command]
  COMMANDS
    -read [start address] [range]
    -write [start address] [22 characters]
    -erase [sector]
    -flush
    -crc [start address] [range]
    -ping


Let's ping the mote to see if we have FlashBridgeViewer installed:
$ flashbridge -ping
Pong! The mote has FlashViewer installed.


Great, now let's read a page of data:
$ flashbridge -read 0 0x100
0x0 to 0x100
_________________________________________________
FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF   |
FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF   |
FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF   |
FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF   |
FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF   |
FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF   |
FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF   |
FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF   |
FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF   |
FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF   |
FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF   |
FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF   |
FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF   |
FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF   |
FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF   |
FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF   |


Let's write some data.  The FlashBridge itself lets you
write as much data at a time as you want, but our TOS_Msg's being passed back and forth over UART only hold so much. And there's not much you can specify on the command line anyway, so here's what
happens:

$ flashbridge -write 0x0 hello_flashbridge!
Writing data
0x68 0x65 0x6c 0x6c 0x6f 0x5f 0x66 0x6c 0x61 0x73 0x68 0x62 0x72 0x69 0x64 0x67
0x65 0x21
SUCCESS: 18 bytes written to 0x0


We'll read 0x20 bytes back from 0x0 to make sure what we wrote exists:
$ flashbridge -read 0 0x20
0x0 to 0x20
_________________________________________________
68 65 6C 6C 6F 5F 66 6C 61 73 68 62 72 69 64 67 | hello_fl ashbridge
65 21 FF FF FF FF FF FF   FF FF FF FF FF FF FF FF   |   !

Keep in mind that the AT45DB flash doesn't necessarily put what you wrote onto the physical flash until you flush it out, so here's how you flush:

$ flashbridge -flush
SUCCESS: Flush complete


We can take the CRC of the data we just wrote:
$ flashbridge -crc 0x0 18
SUCCESS: CRC is 0x6D3F


And we can erase the entire sector. FlashBridge was designed for sector erases, which you can actually go in and edit if you want - but it's not entirely recommended. The ST M25P80 flash erases in sector-lengths, which is 64kB at a time. Atmel's AT45DB flash chip erases in page-lengths, which is 256B at a time. To maintain compatibility between the two chips, FlashBridge erases the full 64kB at a time on both the AT45DB and the STM25P chips. It can probably be done faster on the AT45DB implementation than it is right now, but I haven't programmed any of the block erase
stuff that the chip actually supports.

Another option would be to go in and edit the FlashSettings.h file for the AT45DB and define smaller sector sizes and readjust all those flash parameters, and that should maintain compatibility as well.

So let's erase. It takes about 1 second/sector - which is 1 second per erase.
$ flashbridge -erase 0
SUCCESS: Sector 0 erase complete

And for that AT45DB you'll want to flush after that as well to make sure
changes are commmited to flash.



Now let's read back address 0x0:
$ flashbridge -read 0 0x100
0x0 to 0x100
_________________________________________________
FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF   |
FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF   |
FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF   |
FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF   |
FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF   |
FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF   |
FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF   |
FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF   |
FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF   |
FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF   |
FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF   |
FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF   |
FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF   |
FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF   |
FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF   |
FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF   |





On Wed, 7 Feb 2007 22:59:20 -0600 (CST)
 "SANTOSH KUMAR" <[EMAIL PROTECTED]> wrote:
Hi David,

I use blockstorage interface and I use BlockWrite and BlockRead to write and read respectively on telosb. I am able to read the data but the data is not the same as the one written. I am not sure whether the write is happening correctly. I suspect this because I called some Leds in the writeDone and that call is not
being executed.

This is my write call.

return_val = call BlockWrite.write(0,Data,6);
if(!return_val)
       call Leds.yellowOn();

The Data is initially set to
    memset((void *)Data,10,6)


In my writeDone

       call Leds.yellowOn();

In another program I have written the read structure where I read from the flash
using the following call

return_val = call FlashRead.read(0,Data,6);
if(!return_val)
       call Leds.redOn();

In the readDone I do a memcmp of the 2; the data read with the written data. It says they are not the same.
Please let me know where I have made a mistake.

Is there a way I can check the exact content of the flash?
Thanks in advance.

Regards,
Santosh.



_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to