Author Topic: Could we use the internal 256kB flash memory for wireless programming ?  (Read 2131 times)

Uncle Buzz

  • Full Member
  • ***
  • Posts: 146
  • Country: fr
Hi,

The title is self explanatory, is it possible to partially rewrite the flash memory where the sketch is located without erasing the emulated EEPROM ? Is there some limitations or dualoptiboot could be upgraded to include this option ?

It implies than sketch should be less than (256 - 8(boot) -16(EEPROM))/2 = 116kB (could be more with less EEPROM memory)

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Sure could, theoretically at least. I haven't tried it, but have considered the possibility. Would take a bunch of coding though on my part. Then *I* would need to address the crowd that wants the 256KB of flash they paid for, not 50% of it  >:(
It we leave the board def as is and allow 240kb (bootloader will surely increase to 16kb because of the more complex extra work dealing with the ARM flash), then OTA would not work if the sketch is larger than 50% (120kb, assuming no eeprom emulated). Would require careful planning for the edge cases where a <50% sketch is updated.

The prospect is interesting. To me personally it is not worth the effort, since the current bootloader already supports the legacy method with the external flash chip, which on the downside uses some board space and ~1uA of current, but on the upside - requires no extra work on my part (or yours the user), and offers the space for general purpose, and offers a unique MAC which can be very useful. The way I look at it, it's a unique feature of the Moteino (clones don't count), if you can live with the above "downsides".

So the question remains - is it worth to put up the work to make use of internal flash space at the cost of halving the usable flash memory when using OTA? What is the real saving, the cost of the FLASH-MEM? For a million units in production, yes this would start to be a very significant saving for your corporate's shareholders. For individual and small count use, does it make sense?
I've already spent a lot of time making this work on M0 which is way different than AVR. I know it will take lots more time to fiddle with the internal vs external FLASH. That's my report on the issue.

What are your thoughts?

Uncle Buzz

  • Full Member
  • ***
  • Posts: 146
  • Country: fr
My first question was about feasability, the second (not asked) is how much work would it cost, and you answered : a lot of work !

About the unique ID, unlike ATMEGA, the M0 has one :
Quote
10.3.3 Serial Number
Each device has a unique 128-bit serial number which is a concatenation of four 32-bit words contained
at the following addresses:
Word 0: 0x0080A00C
Word 1: 0x0080A040
Word 2: 0x0080A044
Word 3: 0x0080A048
The uniqueness of the serial number is guaranteed only when using all 128 bits.

My question was not to ask you to make the work for the few people who might be interested, but if it's possible.

Do you know (at least where I can find them) the couples "power voltage / stable frequency" for the M0 ? I want to try to power it from LifePo4 without 3.3V regulator

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
I did not know about the 128bit MAC, learning something every day!
The Windbond FLASH-MEM has a 64bit unique MAC (ie 8 bytes) - so maybe more friendly for keeping shorter RF packets.

I looked a few times for a voltage vs frequency section/graph/table in the DS and could not find one. I could totally be missing this, but the DS talks about an internal LDO (1.2v) which powers the essential SAMD21 clocks/peripherals, and that external VDD is 1.63 - 3.6V. In my tests I ran M0 from less than 3V with no apparent side effects, still doing some more testing and I will watch for this.

If anyone knows more please fill in!

Uncle Buzz

  • Full Member
  • ***
  • Posts: 146
  • Country: fr
It would be great if we can use the fastest frequency under 2V (I understood from other discussion in the forum than radio is still working until 1.8V)

Since 48MHz is far faster than 16MHz, do you think there something to earn about consumption by decreasing frequency (saving power while the processor is awake, but if he's awake longer, maybe it's not worth it) ?

Do you plan to add the new bootloader of your M0 on your github or this one will stay "closed" ? I wonder if for some more compact development, the 32 pin version could be adapted.

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
The SAMD21 Frequency vs voltage topic has to be explored more.
Decreasing frequency is pretty much always an avenue for lower power. Effort vs returns is another big discussion - the TL;DR for me is that it's usually not very much worth it and improvements are marginal, but others may have a different opinion.

There's a library now to access the flash storage for general purpose storage (ie emulate EEPROM):
https://github.com/cmaglie/FlashStorage

Read the warning section about limited writes (10K cycles) after which the SAMD21 flash can be destroyed. I think the same type of warning was given for AVR and stress testing revealed actual damage occurs at far higher figures - 10 fold or more (missing link but I remember specifically reading about this years ago).