Extended Weak Reference support - Netduino Plus 2 (and Netduino Plus 1) - Netduino Forums
   
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

Extended Weak Reference support


  • Please log in to reply
13 replies to this topic

#1 Paolo Patierno

Paolo Patierno

    Advanced Member

  • Members
  • PipPipPip
  • 169 posts
  • LocationItaly

Posted 01 February 2013 - 09:18 PM

Hello,

what about Extended Weak Reference on Netduino/Netduino Plus ?

It seems that it isn't supported in the current firmware. Is it right ?

 

Thanks,

Paolo.


Paolo Patierno

Microsoft MVP on Windows Embedded & IoT

Azure Advisor

Twitter : @ppatierno
Linkedin : paolopatierno
Blog : DevExperience

Blog : Embedded101
?


#2 Paolo Patierno

Paolo Patierno

    Advanced Member

  • Members
  • PipPipPip
  • 169 posts
  • LocationItaly

Posted 02 February 2013 - 02:58 PM

I have seen that in 4.1 firmware version, the file Sam7x_Bl_config.cpp contains BLOCKTYPE_STORAGE_A and BLOCKTYPE_STORAGE_B definition. These definitions aren't in the 4.2 firmware version.

Have you removed extended weak reference support in 4.2 version ?


Paolo Patierno

Microsoft MVP on Windows Embedded & IoT

Azure Advisor

Twitter : @ppatierno
Linkedin : paolopatierno
Blog : DevExperience

Blog : Embedded101
?


#3 Paolo Patierno

Paolo Patierno

    Advanced Member

  • Members
  • PipPipPip
  • 169 posts
  • LocationItaly

Posted 03 February 2013 - 08:14 AM

I have modified the Sam7x_Bl_config.cpp in this way :

 

const BlockRange g_SAM7X_BS_BlockRange[] = {   //   { BlockRange::BLOCKTYPE_BOOTSTRAP ,  0,  5 },   { BlockRange::BLOCKTYPE_CODE   ,  6, 46 },   //{ BlockRange::BLOCKTYPE_DEPLOYMENT   , 47, 62 },  { BlockRange::BLOCKTYPE_DEPLOYMENT   , 47, 60 },  { BlockRange::BLOCKTYPE_STORAGE_A , 61, 61 },   { BlockRange::BLOCKTYPE_STORAGE_B , 62, 62 },   { BlockRange::BLOCKTYPE_CONFIG   , 63, 63 } };

 

but nothing...the following example doesn't work...

 

public static void Main()

 

{

 

// Reads data from FLASH memory.

 

// If no entry with AppSettings/0 identifier exists in memory, a new one is created.

 

settingsReference = ExtendedWeakReference.RecoverOrCreate(typeof(AppSettings), 0, ExtendedWeakReference.c_SurvivePowerdown);

 

// If the entry was just created, its value is set to null.

 

if (settingsReference.Target == null)

 

Settings = new AppSettings();

 

else

 

Settings = (AppSettings)settingsReference.Target; // EWR.Target is of type object

 

Settings.RunCount++; // Change a settings value.

 

settingsReference.Target = Settings; // This call writes the updated data into FLASH.

 

Debug.Print(Settings.WelcomeMessage);

 

Debug.Print("Number of starts: " + Settings.RunCount.ToString());

 

Thread.Sleep(5000);

 

 

 

}


Paolo Patierno

Microsoft MVP on Windows Embedded & IoT

Azure Advisor

Twitter : @ppatierno
Linkedin : paolopatierno
Blog : DevExperience

Blog : Embedded101
?


#4 Paolo Patierno

Paolo Patierno

    Advanced Member

  • Members
  • PipPipPip
  • 169 posts
  • LocationItaly

Posted 04 February 2013 - 07:56 AM

no one can answer that question? no one from SecretLabs ??


Paolo Patierno

Microsoft MVP on Windows Embedded & IoT

Azure Advisor

Twitter : @ppatierno
Linkedin : paolopatierno
Blog : DevExperience

Blog : Embedded101
?


#5 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 04 February 2013 - 04:43 PM

Hi Paolo, Extended Weak References are not supported on Netduino. There is a tradeoff between complete garbage collection and EWR support. Also the latest NETMF firmware releases don't leave enough room on Netduino Plus for EWR sectors. So we recommend using MicroSD for storage. With the gen2 boards, there's enough extra room that we can look at possibly storing some data onboard using a simpler mechanism than EWR. EWR was really great for the original SPOT watches...but there are other ways to support on-chip storage now. Chris

#6 Paolo Patierno

Paolo Patierno

    Advanced Member

  • Members
  • PipPipPip
  • 169 posts
  • LocationItaly

Posted 04 February 2013 - 05:03 PM

Yes Chris...but I have recompiled the firmware enabling 2 flash blocks (8 KB for each block) for extended weak references so that I have reduced flash space for my application (128 KB - 2 * 8 KB = 112 KB).

Is there anything else to do to enable EWR ?


Paolo Patierno

Microsoft MVP on Windows Embedded & IoT

Azure Advisor

Twitter : @ppatierno
Linkedin : paolopatierno
Blog : DevExperience

Blog : Embedded101
?


#7 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 04 February 2013 - 05:31 PM

Is there anything else to do to enable EWR ?

 
IMHO changing flash memory layout in block range definition structure is not enough, you'd have to do also the following:


    [*]Update scatterfile to match the changes in block range,
    [*]Actually add the extended weak feature ("DataStorage") using the SolutionWizard.
    [/list]

    And, you'd want to flash the updated TinyBooterDecompressor.bin to make sure it uses correct flash memory layout.



#8 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 04 February 2013 - 05:34 PM

Hi Paolo, You'll want to adjust these values in the Netduino.settings file.
    <TinyCLR_Defines Include="PLATFORM_DEPENDENT_HEAP_SIZE_THRESHOLD=10240" />    <TinyCLR_Defines Include="PLATFORM_DEPENDENT_HEAP_SIZE_THRESHOLD_UPPER=131072" />
EWRs are saved to flash based on "memory pressure". But for the garbage collector to clean everything up all the time we've needed to push the upper threshold all the way to 128KB. If you want to enable EWRs you'll need to reduce the upper threshold. There may be additional steps needed. Chris

#9 Paolo Patierno

Paolo Patierno

    Advanced Member

  • Members
  • PipPipPip
  • 169 posts
  • LocationItaly

Posted 04 February 2013 - 06:40 PM

 
IMHO changing flash memory layout in block range definition structure is not enough, you'd have to do also the following:


    [*]Update scatterfile to match the changes in block range,
    [*]Actually add the extended weak feature ("DataStorage") using the SolutionWizard.
    [/list]

    And, you'd want to flash the updated TinyBooterDecompressor.bin to make sure it uses correct flash memory layout.

 

I haven't modified scatterfile because the "DataStorage" area is inside deployment area code. The two data storage blocks use 16 KB from 128 KB deployment area code so that the latter becomes 112 KB. According to you how can I modify the scatter file ?

I have already flashed TinyBooterDecompressor.

The only missing thing is to add EWK using the SolutionWizard.


Paolo Patierno

Microsoft MVP on Windows Embedded & IoT

Azure Advisor

Twitter : @ppatierno
Linkedin : paolopatierno
Blog : DevExperience

Blog : Embedded101
?


#10 Paolo Patierno

Paolo Patierno

    Advanced Member

  • Members
  • PipPipPip
  • 169 posts
  • LocationItaly

Posted 04 February 2013 - 06:41 PM

Hi Paolo, You'll want to adjust these values in the Netduino.settings file.

    <TinyCLR_Defines Include="PLATFORM_DEPENDENT_HEAP_SIZE_THRESHOLD=10240" />    <TinyCLR_Defines Include="PLATFORM_DEPENDENT_HEAP_SIZE_THRESHOLD_UPPER=131072" />
EWRs are saved to flash based on "memory pressure". But for the garbage collector to clean everything up all the time we've needed to push the upper threshold all the way to 128KB. If you want to enable EWRs you'll need to reduce the upper threshold. There may be additional steps needed. Chris

 

There isn't a way to force GC to write EWR objects into flash ?


Paolo Patierno

Microsoft MVP on Windows Embedded & IoT

Azure Advisor

Twitter : @ppatierno
Linkedin : paolopatierno
Blog : DevExperience

Blog : Embedded101
?


#11 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 04 February 2013 - 06:52 PM

There isn't a way to force GC to write EWR objects into flash ?

I believe that NETMF 4.3 has a new "Flush" feature for EWRs. We don't use or support EWR with Netduino so I haven't tested it...but I saw it while browsing through the firmware source. Chris

#12 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 04 February 2013 - 07:02 PM

I haven't modified scatterfile because the "DataStorage" area is inside deployment area code.

 

Well, then it is not necessary to update the scatterfile...



#13 Paolo Patierno

Paolo Patierno

    Advanced Member

  • Members
  • PipPipPip
  • 169 posts
  • LocationItaly

Posted 04 February 2013 - 07:03 PM

Well, then it is not necessary to update the scatterfile...

 

So do you think that I only need to enable EWK feature with Solution Wizard ...

And about Chris suggestion on heap threshold ?


Paolo Patierno

Microsoft MVP on Windows Embedded & IoT

Azure Advisor

Twitter : @ppatierno
Linkedin : paolopatierno
Blog : DevExperience

Blog : Embedded101
?


#14 Emilio Pastore

Emilio Pastore

    Member

  • Members
  • PipPip
  • 12 posts
  • LocationSão Paulo, Brasil

Posted 19 January 2015 - 01:26 PM

Hey Paolo !

 

I'm very much interested in making EWR work on the Netduino. Have you managed to make it happen ?

 

Thanks, Emilio






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.