[Tinyos-help] BlockWrite.write writing to the wrong address

David Moss dmm at rincon.com
Wed Sep 28 16:02:47 PDT 2005

On some calls to BlockStorage's BlockWrite.write, the data seems to be
written to the wrong address in flash.  For example, I tell it to write to
0x0, I see that it's writing to 0x0, I get the event back that says it wrote
to 0x0, and on the flash it shows I wrote to 0x70000 or some address like
that that is a multiple of 0x10000.  The flash is partitioned into a volume
per sector, so sector 0 is volume 0, sector 1 is volume 1, etc.  No mounting
is taking place anywhere between when I write the data and when I read it
back from flash.  I understand that mounting to a different volume will
shift that volume's address in flash to 0x0, and it would make sense that if
I mounted to a different volume and wrote to 0x0 and then mounted back to
sector 0, I would see the data I wrote appear in a different sector.  Again,
that's not the case - I do not explicitly call Mount.mount anytime between
reading and writing. 
Here's some code with comments and output to demonstrate the problem:
 * Example function showing how the variables are being setup and how I'm
calling BlockWrite.write
result_t example {
  uint32_t currentAddress;  // the address we'll be writing to.
  some_struct data;  // struct data we're writing to flash
  // Set the address to write to:
  currentAddress = 0x0;
  // Setup the data we're writing:
  call JDebug.jdbg("Address to write data to = %xl", currentAddress);  //
Custom java debugging function to debug output to the screen.
  /** Output on the screen here reads "Address to write data to = 0x0" */
  if(!call BlockWrite.write(currentAddress, &data, sizeof(some_struct))) {
    call JDebug.jdbg("BlockWrite.write failed");
    return FAIL;
  return SUCCESS;
 * Returned event from BlockWrite after the flash has been written
event void BlockWrite.writeDone(storage_result_t result, block_addr_t raddr,
void *buf, block_addr_t len) {
  call JDebug.jdbg("BlockWrite finished writing to address %xl with result
%s", raddr, result);  // Custom java debugging function to debug output to
the screen
 /** Output on the screen here reads "BlockWrite finished writing to address
0x0 with result 0 (storage_ok)" */
Of course, there are a lot of other things going on in my actual program,
but this shows the code with all the extra stuff stripped out.  Has anybody
used the BlockStorage interface enough to understand what can be happening
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.millennium.berkeley.edu/pipermail/tinyos-help/attachments/20050928/2fc46383/attachment.htm

More information about the Tinyos-help mailing list