Skip to content

Not all SAMD devices use external eeprom #1322

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
pbolduc opened this issue Jul 25, 2019 · 1 comment
Open

Not all SAMD devices use external eeprom #1322

pbolduc opened this issue Jul 25, 2019 · 1 comment

Comments

@pbolduc
Copy link

pbolduc commented Jul 25, 2019

Moved from #1066.

I am using a Moteino M0. A Moteino M0 uses a ATSAMD21G18 processor. When I try to run a simple serial gateway, I found during initialization when MySensors tries to write the parent node id to eeprom, the process hanges. I put debug statements before and after each line to isolate the place it hung. According to the SAM D21 datasheet, the eeprom is emulated. Here is the line where it hangs,

hwWriteConfig(EEPROM_PARENT_NODE_ID_ADDRESS, MY_PARENT_NODE_ID);

A note from Moteino M0 guide, https://lowpowerlab.com/guide/moteino/moteinom0/

The booloader is located in the first 8KB of internal flash memory and is protected by the NVM user byte fuse.
There is no dedicated EEPROM on the SAMD21 microcontroller but EEPROM can be emulated up to 16kb and the Arduino EEPROM library can be used to access this emulated EEPROM.

I also found this arduino issue related to the eeprom on SAMD.

I think the current SAMD configuration was developed around the Sensebender-Gateway. Based on the BOM, the Sensebender-Gateway has an extra "32Kb (4096x8) Serial EEPROM with Unique Serial Number"

In my local copy of MySensors, I #ifdef wrapped the calls to hwRead/hwWrite and the gateway runs as expected. In the MyHwSAMD.h, there is currently no way to opt out of the external EEPROM,

#define MY_EXT_EEPROM_I2C_ADDRESS (0x50u)
#define MY_EXT_EEPROM_SIZE (kbits_512)
#define MY_EXT_EEPROM_PAGE_SIZE (32u)

In my case, I can think of the following options for persisting the configuration,

  1. Use the emulated eeprom
  2. Use external flash memory (Moteino M0 has an optional
  3. Do not persist the configuration

I would like some help coming up with a proposed solution that can be merged into the main MySensors. The very first thing that comes to mind is adding a new defines to define what kind of storage to use (eeprom, external eeprom, i2c / spi flash, none).

@tbowmo
Copy link
Contributor

tbowmo commented Jul 29, 2019

Yes, I was only focusing on using the external eeprom when I made the initial samd support, so emulated eeprom was never made.

We should support the emulated part, but as the emulated eeprom is done in flash, which has a reduced re-write count (compared to real eeprom), we should still keep the external eeprom as an option for gateways etc (which stores routing tables, and other "frequently updated" content in eeprom).

Right now coding time on mysensors is almost at zero, due to other projects that has higher WAF score :) but I'll be happy to do code reviews..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants