Author Topic: RfDuino reboots when I attempt to write to Flash...  (Read 3083 times)

equarles2

  • RFduino Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
RfDuino reboots when I attempt to write to Flash...
« on: March 08, 2015, 10:11:03 PM »
Hello,

The application that I am building needs to be able to store a few values in Flash for persistence.  I have found several stand alone examples that work fine; like this one:

https://github.com/RFduino/RFduino/blob/master/libraries/RFduinoNonBLE/examples/Flash/FlashStructure/FlashStructure.ino

However, when I add this code into my sketch, as soon as it reaches the Flash Erase function, the processor reboots itself and ends up in a funky state, that only powering it down and back up again can resolve.  My Sketch is not that big. See output from the linker:

Sketch uses 33,496 bytes (25%) of program storage space. Maximum is 131,072 bytes. 

and therefore I don't think that my sketch is actually residing at Page 251 (the one I'm trying to write to), so I'm perplexed and cannot move forward.

Can someone shed some light on what may be going on?

Thank you!

tolson

  • Global Moderator
  • *****
  • Posts: 866
  • Karma: +20/-0
    • View Profile
    • Thomas Olson Consulting
Re: RfDuino reboots when I attempt to write to Flash...
« Reply #1 on: March 09, 2015, 09:56:42 AM »
I don't know if that Flash Page is available or not with any particular library version or application. I prefer to just get the next available page instead of using a particular page. The FlashButtonUpdate2 example shows how.

lopesjeronimo

  • RFduino Newbie
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
    • DPTR
Re: RfDuino reboots when I attempt to write to Flash...
« Reply #2 on: July 03, 2015, 05:55:45 AM »
equarles2, I'm facing very similar problem. Also using page 251

My application:
 - receive data, and store at a temporary buffer
 - at loop(), process the buffer: includes reading from flash, and very occasionally, writing to it
 - a also have a timer (TIMER 2) to blink a led, and control a relay

The application is crashing at flash erase function. But now is the weird part of it, the application worked for some days, and then this problem appeared.

Did you find out anything since then?

wookie1

  • RFduino Jr. Member
  • **
  • Posts: 25
  • Karma: +0/-0
    • View Profile
Re: RfDuino reboots when I attempt to write to Flash...
« Reply #3 on: October 11, 2015, 04:04:38 PM »
I'm having this issue also, everything works great and then it just starts resetting one day continually. I can get the device to work again if I change the flash page I'm writing to, but I'm sure it's a matter of time until it happens again. I turn off the radio and wait 20ms before I erase or write, then turn the radio on.

tolson

  • Global Moderator
  • *****
  • Posts: 866
  • Karma: +20/-0
    • View Profile
    • Thomas Olson Consulting
Re: RfDuino reboots when I attempt to write to Flash...
« Reply #4 on: October 11, 2015, 06:44:42 PM »
Sounds like you may be writing to a particular Flash location more than 20,000 times.

wookie1

  • RFduino Jr. Member
  • **
  • Posts: 25
  • Karma: +0/-0
    • View Profile
Re: RfDuino reboots when I attempt to write to Flash...
« Reply #5 on: October 12, 2015, 07:22:12 AM »
No, less than 100 times for sure. Maybe there was some power interruption right at the moment of reading or erasing and writing, but it's happened to me on two different units so I'm wondering if it's similar to these other 2 posters.

Tim

  • RFduino Sr. Member
  • ****
  • Posts: 126
  • Karma: +2/-0
    • View Profile
Re: RfDuino reboots when I attempt to write to Flash...
« Reply #6 on: September 27, 2016, 06:08:39 PM »
Hi  ...

This is from a long time ago, so perhaps resolved.

I had the same issue, now using Simblee, and resolved by examining the first few bytes of each flash page to see where my sketch and the Simblee OTA boot loader is stored.

Code: [Select]
void write_flash_contents() {
  Serial.begin(9600);
  for (i=124;i<252;i++) {
    char *p = (char*)ADDRESS_OF_PAGE(i);
    Serial.print(i);
    Serial.print(" ");
    int j;
    for (j=0;j<9;j++) {
      Serial.print(p[j],DEC);
      Serial.print(" ");
    }
    Serial.println(p[9],DEC);
  }
 }
}

You need to run this code before you write any data to flash. Then choose a page that's not used. I use page 203 and all works fine.

Tim

lovelyboy

  • RFduino Newbie
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Re: RfDuino reboots when I attempt to write to Flash...
« Reply #7 on: October 03, 2016, 07:11:25 PM »
dear all, especially user karma.  how many data of integers we can save on single page.? need your valuable help. thanks. 

lovelyboy

  • RFduino Newbie
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Re: RfDuino reboots when I attempt to write to Flash...
« Reply #8 on: October 03, 2016, 07:26:47 PM »
I mean to say capacity of one page to store integer(2 bytes). I heard one page is of 1Kbits.? is it right?

 

anything