Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Save Custom Settings


  • Please log in to reply
53 replies to this topic

#1 Illishar

Illishar

    Advanced Member

  • Members
  • PipPipPip
  • 146 posts

Posted 15 December 2010 - 10:57 AM

Hello there, Is there a way to save/commit/write your own custom settings on the Netduinos? Eg. if you have a value (set by the user) and you would like to keep it after reboot. I would like to do this, without using a SD card. The deployed app is written to the permanent (internal) flash, so it *is* possible somehow. But how? Theoreticly I could just avoid initializing my variables and the last written value would still be there. Or perhaps that's not the way it works? In the same area: Is there a way to write to the static IP settings etc. on the N+? (Without using the MFDeploy ofc.)

#2 Illishar

Illishar

    Advanced Member

  • Members
  • PipPipPip
  • 146 posts

Posted 15 December 2010 - 11:24 AM

I may have found some of the answer. ExtendedWeakReferences! There's a sample in the SDK. Or what? Anyone got experience in this area?

#3 Fred

Fred

    Advanced Member

  • Members
  • PipPipPip
  • 302 posts
  • LocationUK

Posted 15 December 2010 - 11:31 AM

I've been wondering exactly that. I decided to order a SD breakout board for a Netduino Mini project in case it isn't possible. I'll only be storing a tiny amount of data, but it will need to persist between power cycles. The board is small, cheap and should connect easily enough, but it'd be nice not to need it.

#4 Illishar

Illishar

    Advanced Member

  • Members
  • PipPipPip
  • 146 posts

Posted 15 December 2010 - 12:39 PM

Actually I think that EWR *is* the best answer. (I'll create a new post with the IP question.)

#5 Fred

Fred

    Advanced Member

  • Members
  • PipPipPip
  • 302 posts
  • LocationUK

Posted 15 December 2010 - 12:52 PM

A little bit of digging on this forum and it seems EWR is not supported on the Netduino range as it would take up 16KB of valuable code space. In my case I could probably spare the space, but quite understand that Secret Labs are putting effort into supporting more useful stuff that creating a seperate firmware build that includes EWR.

http://forums.netdui...reference-work/

#6 GDSever

GDSever

    Advanced Member

  • Members
  • PipPipPip
  • 81 posts
  • LocationNewark, DE

Posted 15 December 2010 - 12:59 PM

There are plenty of easy-to-use EEPROMs out there that work with the Netduino. I've got experience with the 24LC16B (if you only need 256 bytes of storage) and 24LC256 (32K?), and up to 8 of those can be used on a single I2C bus. I am sure there are plenty of other EEPROMs that would work as well... Might be worth considering. You're only giving up 2 analog pins, and you could easily add some back using expander chips if that became an issue.

#7 Illishar

Illishar

    Advanced Member

  • Members
  • PipPipPip
  • 146 posts

Posted 15 December 2010 - 03:49 PM

Hm, most likely I only need 2 bytes of storage. (A few extra wouldn't hurt though.) An eeprom seems somewhat overkill when we got 512kb permanent storage. :-/ But fair enough.

#8 Illishar

Illishar

    Advanced Member

  • Members
  • PipPipPip
  • 146 posts

Posted 15 December 2010 - 03:53 PM

Perhaps I could recompile the tinyclr (with a RVDS compiler) and discard some of the unneeded stuff in return for EWR ... Hmmm

#9 Illishar

Illishar

    Advanced Member

  • Members
  • PipPipPip
  • 146 posts

Posted 15 December 2010 - 04:32 PM

This is interesting, if you open the N+ fw source, the DataStorage (EWR) is already included. I think I'll test it ... tomorrow.

#10 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 18 December 2010 - 04:53 AM

Is there a way to write to the static IP settings etc. on the N+? (Without using the MFDeploy ofc.)

Hi Illishar,

Instead of using MFDeploy, you can use the NetworkInterface.EnableStaticIP method to set the static IP settings on a Netduino Plus.

Here's a quick example that shows your current IP address, changes it, and then shows that the change has been made:
// add the following line to the top of your Program.cs file
using Microsoft.SPOT.Net.NetworkInformation;

public static void Main()
{
    // get a reference to our main network interface
    NetworkInterface myNetworkInterface = NetworkInterface.GetAllNetworkInterfaces()[0];

    // print out our current IP address to the Output window
    Debug.Print("ip address (before): " + myNetworkInterface.IPAddress.ToString());

    // set our IP address to a new value; this will be saved in the config sector and will survive reboots
    myNetworkInterface.EnableStaticIP("192.168.5.102", "255.255.255.0", "192.168.5.1");

    // print out our new IP address to the Output windows
    Debug.Print("ip address (after): " + myNetworkInterface.IPAddress.ToString());

    // sleep forever
    Thread.Sleep(Timeout.Infinite);
}
Chris

#11 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 18 December 2010 - 05:04 AM

This is interesting, if you open the N+ fw source, the DataStorage (EWR) is already included. I think I'll test it ... tomorrow.

Hi Illishar,

Full disclosure: we've reserved about 40KB on the chip for expansion. We wanted to "undersell" the product by quoting 128KB of flash (instead of the 168KB+ it really has available) so that we could add more features in the future without taking up any extra space. Savvy users can recompile the firmware to free that all up for their code with the understanding that they might lose some of the extra space with future updates...

Two blocks of flash are marked for EWR storage. We haven't enabled the feature in the Netduino firmware because we may need them for something else...but if you wanted to enable the feature you certainly could.

Chris

#12 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 18 December 2010 - 05:06 AM

Is there a way to save/commit/write your own custom settings on the Netduinos?

Eg. if you have a value (set by the user) and you would like to keep it after reboot. I would like to do this, without using a SD card. The deployed app is written to the permanent (internal) flash, so it *is* possible somehow. But how? Theoreticly I could just avoid initializing my variables and the last written value would still be there. Or perhaps that's not the way it works?


Three options for data storage:

1. SD/EEPROM storage. The Netduino Plus has MicroSD built in, so that's an easy choice. You can also use the v4.1.1 alpha firmware on the Netduino or Netduino Mini to enable SD storage via SPI.
2. EWR: we could enable this on the Netduino/Netduino Mini/Netduino Plus. It's an "old" .NET MF technology, there might be better options available, and it takes up 16KB of flash we've been planning on using for something else...but we could enable it (or you could enable it in your own custom firwmare build).
3. Config block: there is an 8KB "configuration" block on the Netduino. It stores your network settings, USB device name, current debug port, etc. This block of flash is usually only used by the .NET MF firmware itself, but we could create a C# object which would let you write/read a few chunks of data.

Chris

#13 Fred

Fred

    Advanced Member

  • Members
  • PipPipPip
  • 302 posts
  • LocationUK

Posted 18 December 2010 - 08:37 AM

Option 3 sounds good. If you could allocate some of that 8K block to the user and allow easy C# access I'm sure it would be really useful. Anything more than that really should be on an SD card or EEPROM, but when you just need somewhere to stick a few bytes of config that seems like overkill.

#14 Illishar

Illishar

    Advanced Member

  • Members
  • PipPipPip
  • 146 posts

Posted 19 December 2010 - 02:01 PM

Option 3 sounds really interesting. 8k is a lot. Plenty space for both system settings and a few custom settings. And it sounds like it's less costly that EWR. And I didn't knew that the EnableStaticIP would commit to flash. Very nice! (Although one could've wished for a better name perhaps.)

#15 Jim Davies

Jim Davies

    Advanced Member

  • Members
  • PipPipPip
  • 48 posts
  • LocationBrighton & Hove, UK

Posted 20 December 2010 - 09:24 AM

+1 for Option 3 please.

#16 Arron Chapman

Arron Chapman

    Advanced Member

  • Members
  • PipPipPip
  • 289 posts
  • LocationOregon, USA

Posted 20 December 2010 - 06:12 PM

I'll also toss in a vote for Option #3. I've got a few projects (past and planned) that would have benefited from it.

When you talk EE use small words, I'm just a Software Developer :)
My Blog/Site and Everything Else

If my post helped you please consider pressing the "Like This" button in the bottom right-hand corner.

 

Oh my. So many things, so little money!!

 


#17 Fabien Royer

Fabien Royer

    Advanced Member

  • Members
  • PipPipPip
  • 406 posts
  • LocationRedmond, WA

Posted 28 December 2010 - 10:48 PM

+1 for option #3 as well please :)

#18 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 28 December 2010 - 11:06 PM

Okay, option #3 sounds like a possible winner :) We'll dig into it and make sure we're not exposing any nasty "gotchas". The space is very limited, and some of it is already taken (by the USB name, networking, etc.). My biggest worry is what would happen if the data were written only partially before a reset...and then the device might not be able to boot. Since the whole sector might have to be re-written all at once. We'll dig into it. I'll post more when I have some good info... Chris

#19 Charles

Charles

    Advanced Member

  • Members
  • PipPipPip
  • 192 posts

Posted 29 December 2010 - 02:24 AM

And another + for option 3... While I like the external EEPROM option, why add hardware complexity if it isn't necessary??

#20 Fred

Fred

    Advanced Member

  • Members
  • PipPipPip
  • 302 posts
  • LocationUK

Posted 29 December 2010 - 09:18 AM

Instead of using MFDeploy, you can use the NetworkInterface.EnableStaticIP method to set the static IP settings on a Netduino Plus.

Just to save anyone else the bother, I tried flashing the Netduino Plus firmware to a standard Netduino, hoping that I could store a few bytes in the IP settings. I got an error during flashing. It was a pretty big kludge for a few bytes anyway!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.